A-lurkers changes that attempt to resolve the presentation message sending failures. Creating an experimentation branch for joint investigation.

This commit is contained in:
Bruce Lacey
2014-03-21 22:22:44 -07:00
parent ef5f00e7ef
commit f44098259d
2 changed files with 27 additions and 10 deletions
+6 -2
View File
@@ -226,11 +226,12 @@ boolean Sensor::sendWrite(uint8_t dest, message_s message, int length) {
// int retry = WRITE_RETRY;
RF24::stopListening();
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::closeReadingPipe(WRITE_PIPE); // Stop listening to write-pipe after transmit
if (!broadcast) {
if (!broadcast && (radioId == GATEWAY_ADDRESS)) {
// ---------------- WAIT FOR ACK ------------------
unsigned long startedWaiting = millis();
bool timeout = false;
@@ -238,6 +239,7 @@ boolean Sensor::sendWrite(uint8_t dest, message_s message, int length) {
while ( !RF24::available() && !timeout ) {
if (millis() - startedWaiting > 100 ) {
timeout = true;
debug(PSTR("Transmit: timeout\n"));
ok = false;
}
}
@@ -246,10 +248,12 @@ boolean Sensor::sendWrite(uint8_t dest, message_s message, int length) {
uint8_t idest;
RF24::read( &idest, sizeof(uint8_t));
if (dest != idest) {
debug(PSTR("Transmit: size problem\n"));
ok = false;
}
} else {
ok = false;
debug(PSTR("Transmit: general fail\n"));
}
//--------------------
}
+21 -8
View File
@@ -402,7 +402,13 @@ void RF24::begin(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) );
// Restore the pipe0 adddress, if exists
@@ -417,9 +423,6 @@ void RF24::startListening(void)
// Go!
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)
{
write_register(CONFIG,read_register(CONFIG) | _BV(PWR_UP));
delayMicroseconds(150);
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));
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 )
{
// Transmitter power-up
write_register(CONFIG, ( read_register(CONFIG) | _BV(PWR_UP) ) & ~_BV(PRIM_RX) );
// receiver off, transmitter on
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)
write_payload( buf, len,