2525 * Copyright Thomas Studwell (2014,2015)
2626 * - MySensors generic radio driver implementation Copyright (C) 2017, 2018 Olivier Mauti <olivier@mysensors.org>
2727 *
28- * Changes by : @tekka, @scalz, @marceloagno
28+ * Changes by : @tekka, @scalz, @marceloagno, @docbender
2929 *
3030 * Definitions for Semtech SX1231/H radios:
3131 * https://www.semtech.com/uploads/documents/sx1231.pdf
@@ -370,7 +370,7 @@ LOCAL bool RFM69_channelFree(void)
370370{
371371 // returns true if channel activity under RFM69_CSMA_LIMIT_DBM
372372 const rfm69_RSSI_t RSSI = RFM69_readRSSI (false );
373- RFM69_DEBUG (PSTR (" RFM69:CSMA:RSSI=%" PRIi16 " \n " ), RFM69_internalToRSSI (RSSI));
373+ // RFM69_DEBUG(PSTR("RFM69:CSMA:RSSI=%" PRIi16 "\n"), RFM69_internalToRSSI(RSSI));
374374 return (RSSI > RFM69_RSSItoInternal (MY_RFM69_CSMA_LIMIT_DBM));
375375}
376376
@@ -500,8 +500,10 @@ LOCAL bool RFM69_setRadioMode(const rfm69_radio_mode_t newRadioMode)
500500
501501 if (newRadioMode == RFM69_RADIO_MODE_STDBY) {
502502 regMode = RFM69_OPMODE_SEQUENCER_ON | RFM69_OPMODE_LISTEN_OFF | RFM69_OPMODE_STANDBY;
503+ RFM69_DEBUG (PSTR (" RFM69:RSB\n " )); // put radio to standby
503504 } else if (newRadioMode == RFM69_RADIO_MODE_SLEEP) {
504505 regMode = RFM69_OPMODE_SEQUENCER_OFF | RFM69_OPMODE_LISTEN_OFF | RFM69_OPMODE_SLEEP;
506+ RFM69_DEBUG (PSTR (" RFM69:RSL\n " )); // put radio to sleep
505507 } else if (newRadioMode == RFM69_RADIO_MODE_RX) {
506508 RFM69.dataReceived = false ;
507509 RFM69.ackReceived = false ;
@@ -511,14 +513,18 @@ LOCAL bool RFM69_setRadioMode(const rfm69_radio_mode_t newRadioMode)
511513 RFM69_setHighPowerRegs (false );
512514 RFM69_writeReg (RFM69_REG_PACKETCONFIG2,
513515 (RFM69_readReg (RFM69_REG_PACKETCONFIG2) & 0xFB ) | RFM69_PACKET2_RXRESTART); // avoid RX deadlocks
516+ RFM69_DEBUG (PSTR (" RFM69:RRX\n " ));
514517 } else if (newRadioMode == RFM69_RADIO_MODE_TX) {
515518 regMode = RFM69_OPMODE_SEQUENCER_ON | RFM69_OPMODE_LISTEN_OFF | RFM69_OPMODE_TRANSMITTER;
516519 RFM69_writeReg (RFM69_REG_DIOMAPPING1, RFM69_DIOMAPPING1_DIO0_00); // Interrupt on PacketSent, DIO0
517520 RFM69_setHighPowerRegs (RFM69.powerLevel >= (rfm69_powerlevel_t )RFM69_HIGH_POWER_DBM);
521+ RFM69_DEBUG (PSTR (" RFM69:RTX\n " ));
518522 } else if (newRadioMode == RFM69_RADIO_MODE_SYNTH) {
519523 regMode = RFM69_OPMODE_SEQUENCER_ON | RFM69_OPMODE_LISTEN_OFF | RFM69_OPMODE_SYNTHESIZER;
524+ RFM69_DEBUG (PSTR (" RFM69:RSY\n " ));
520525 } else {
521526 regMode = RFM69_OPMODE_SEQUENCER_ON | RFM69_OPMODE_LISTEN_OFF | RFM69_OPMODE_STANDBY;
527+ RFM69_DEBUG (PSTR (" RFM69:RSB\n " )); // put radio to standby
522528 }
523529
524530 // set new mode
@@ -553,13 +559,13 @@ LOCAL void RFM69_powerDown(void)
553559
554560LOCAL bool RFM69_sleep (void )
555561{
556- RFM69_DEBUG ( PSTR ( " RFM69:RSL \n " )); // put radio to sleep
562+ // put radio to sleep
557563 return RFM69_setRadioMode (RFM69_RADIO_MODE_SLEEP);
558564}
559565
560566LOCAL bool RFM69_standBy (void )
561567{
562- RFM69_DEBUG ( PSTR ( " RFM69:RSB \n " )); // put radio to standby
568+ // put radio to standby
563569 return RFM69_setRadioMode (RFM69_RADIO_MODE_STDBY);
564570}
565571
@@ -617,7 +623,9 @@ LOCAL bool RFM69_sendWithRetry(const uint8_t recipient, const void *buffer,
617623 rfm69_controlFlags_t flags = 0u ; // reset all flags
618624 RFM69_setACKRequested (flags, !noACK);
619625 RFM69_setACKRSSIReport (flags, RFM69.ATCenabled );
620- (void )RFM69_send (recipient, (uint8_t *)buffer, bufferSize, flags, !retry);
626+ if (!RFM69_send (recipient, (uint8_t *)buffer, bufferSize, flags, !retry)) {
627+ RFM69_DEBUG (PSTR (" RFM69:SWR:SEND,NOIRQ\n " ));
628+ }
621629 if (noACK) {
622630 // no ACK requested
623631 return true ;
0 commit comments