A-lurkers changes that attempt to resolve the presentation message sending failures. Creating an experimentation branch for joint investigation.
This commit is contained in:
@@ -226,11 +226,12 @@ boolean Sensor::sendWrite(uint8_t dest, message_s message, int length) {
|
|||||||
// int retry = WRITE_RETRY;
|
// int retry = WRITE_RETRY;
|
||||||
RF24::stopListening();
|
RF24::stopListening();
|
||||||
RF24::openWritingPipe(TO_ADDR(dest));
|
RF24::openWritingPipe(TO_ADDR(dest));
|
||||||
RF24::write(&message, min(MAX_MESSAGE_LENGTH, sizeof(message.header) + length), broadcast);
|
ok = RF24::write(&message, min(MAX_MESSAGE_LENGTH, sizeof(message.header) + length), broadcast);
|
||||||
|
debug(PSTR("Sensor::sendWrite() - return value = %s\n"), ok ? "true" : "false" );
|
||||||
RF24::startListening();
|
RF24::startListening();
|
||||||
RF24::closeReadingPipe(WRITE_PIPE); // Stop listening to write-pipe after transmit
|
RF24::closeReadingPipe(WRITE_PIPE); // Stop listening to write-pipe after transmit
|
||||||
|
|
||||||
if (!broadcast) {
|
if (!broadcast && (radioId == GATEWAY_ADDRESS)) {
|
||||||
// ---------------- WAIT FOR ACK ------------------
|
// ---------------- WAIT FOR ACK ------------------
|
||||||
unsigned long startedWaiting = millis();
|
unsigned long startedWaiting = millis();
|
||||||
bool timeout = false;
|
bool timeout = false;
|
||||||
@@ -238,6 +239,7 @@ boolean Sensor::sendWrite(uint8_t dest, message_s message, int length) {
|
|||||||
while ( !RF24::available() && !timeout ) {
|
while ( !RF24::available() && !timeout ) {
|
||||||
if (millis() - startedWaiting > 100 ) {
|
if (millis() - startedWaiting > 100 ) {
|
||||||
timeout = true;
|
timeout = true;
|
||||||
|
debug(PSTR("Transmit: timeout\n"));
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,10 +248,12 @@ boolean Sensor::sendWrite(uint8_t dest, message_s message, int length) {
|
|||||||
uint8_t idest;
|
uint8_t idest;
|
||||||
RF24::read( &idest, sizeof(uint8_t));
|
RF24::read( &idest, sizeof(uint8_t));
|
||||||
if (dest != idest) {
|
if (dest != idest) {
|
||||||
|
debug(PSTR("Transmit: size problem\n"));
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ok = false;
|
ok = false;
|
||||||
|
debug(PSTR("Transmit: general fail\n"));
|
||||||
}
|
}
|
||||||
//--------------------
|
//--------------------
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-6
@@ -402,7 +402,13 @@ void RF24::begin(void)
|
|||||||
|
|
||||||
void RF24::startListening(void)
|
void RF24::startListening(void)
|
||||||
{
|
{
|
||||||
write_register(CONFIG, read_register(CONFIG) | _BV(PWR_UP) | _BV(PRIM_RX));
|
|
||||||
|
// receiver on, transmitter off
|
||||||
|
write_register(CONFIG, read_register(CONFIG) | _BV(PRIM_RX));
|
||||||
|
|
||||||
|
// if not powered up already, power up the radio
|
||||||
|
powerUp();
|
||||||
|
|
||||||
write_register(STATUS, _BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );
|
write_register(STATUS, _BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );
|
||||||
|
|
||||||
// Restore the pipe0 adddress, if exists
|
// Restore the pipe0 adddress, if exists
|
||||||
@@ -417,9 +423,6 @@ void RF24::startListening(void)
|
|||||||
|
|
||||||
// Go!
|
// Go!
|
||||||
ce(HIGH);
|
ce(HIGH);
|
||||||
|
|
||||||
// wait for the radio to come up (130us actually only needed)
|
|
||||||
delayMicroseconds(130);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
@@ -442,8 +445,15 @@ void RF24::powerDown(void)
|
|||||||
|
|
||||||
void RF24::powerUp(void)
|
void RF24::powerUp(void)
|
||||||
{
|
{
|
||||||
|
uint8_t cfg = read_register(CONFIG);
|
||||||
|
|
||||||
|
// if not powered up then power up and wait for the radio to initialize
|
||||||
|
if (!(cfg & _BV(PWR_UP)))
|
||||||
|
{
|
||||||
|
//printf("RF24::powerUp - powering up radio\n");
|
||||||
write_register(CONFIG,read_register(CONFIG) | _BV(PWR_UP));
|
write_register(CONFIG,read_register(CONFIG) | _BV(PWR_UP));
|
||||||
delayMicroseconds(150);
|
delayMicroseconds(150);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
@@ -509,8 +519,11 @@ bool RF24::write( const void* buf, uint8_t len, const bool multicast )
|
|||||||
|
|
||||||
void RF24::startWrite( const void* buf, uint8_t len, const bool multicast )
|
void RF24::startWrite( const void* buf, uint8_t len, const bool multicast )
|
||||||
{
|
{
|
||||||
// Transmitter power-up
|
// receiver off, transmitter on
|
||||||
write_register(CONFIG, ( read_register(CONFIG) | _BV(PWR_UP) ) & ~_BV(PRIM_RX) );
|
write_register(CONFIG, read_register(CONFIG) & ~_BV(PRIM_RX));
|
||||||
|
|
||||||
|
// if not powered up already, power up the radio
|
||||||
|
powerUp();
|
||||||
|
|
||||||
// Send the payload - Unicast (W_TX_PAYLOAD) or multicast (W_TX_PAYLOAD_NO_ACK)
|
// Send the payload - Unicast (W_TX_PAYLOAD) or multicast (W_TX_PAYLOAD_NO_ACK)
|
||||||
write_payload( buf, len,
|
write_payload( buf, len,
|
||||||
|
|||||||
Reference in New Issue
Block a user