Skip to content

[RFC] Mysensors HAL retry hack #1477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions MyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,15 @@
#define MY_TRANSPORT_DISCOVERY_INTERVAL_MS (20*60*1000ul)
#endif

/**
* @def MY_TRANSPORT_SEND_RETRIES
* @brief If defined to a positive number N, the node will try to send the payload to the
* uplink up to N times before actually failing. Useful when working in a noisy environment
* @note Setting this option too high will
*
*/
//#define MY_TRANSPORT_SEND_RETRIES (5)

/**
*@def MY_TRANSPORT_UPLINK_CHECK_DISABLED
*@brief If defined, disables uplink check to GW during transport initialisation
Expand Down
8 changes: 8 additions & 0 deletions hal/transport/MyTransportHAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,15 @@ bool transportHALSend(const uint8_t nextRecipient, const MyMessage *outMsg, cons
const uint8_t finalLength = len;
#endif

#ifdef MY_TRANSPORT_SEND_RETRIES
uint8_t retries = MY_TRANSPORT_SEND_RETRIES;
bool result = false;
while (retries-- && (!result)) {
result = transportSend(nextRecipient, (void *)tx_data, finalLength, noACK);
}
#else
bool result = transportSend(nextRecipient, (void *)tx_data, finalLength, noACK);
#endif
TRANSPORT_HAL_DEBUG(PSTR("THA:SND:MSG LEN=%" PRIu8 ",RES=%" PRIu8 "\n"), finalLength, result);
return result;
}
Expand Down
4 changes: 4 additions & 0 deletions hal/transport/RF24/driver/RF24registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@
#define RF24_CRC_16 (3)

// ARD, auto retry delay
#ifndef RF24_SET_ARD
#define RF24_SET_ARD (5) //=1500us
#endif

// ARD, auto retry count
#ifndef RF24_SET_ARC
#define RF24_SET_ARC (15)
#endif

// nRF24L01(+) register definitions
#define RF24_REG_NRF_CONFIG (0x00)
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ MY_SIGNAL_REPORT_ENABLED LITERAL1
MY_SLEEP_TRANSPORT_RECONNECT_TIMEOUT_MS LITERAL1
MY_SMART_SLEEP_WAIT_DURATION_MS LITERAL1
MY_TRANSPORT_CHKUPL_INTERVAL_MS LITERAL1
MY_TRANSPORT_SEND_RETRIES LITERAL1
MY_TRANSPORT_DISCOVERY_INTERVAL_MS LITERAL1
MY_TRANSPORT_MAX_TSM_FAILURES LITERAL1
MY_TRANSPORT_MAX_TX_FAILURES LITERAL1
Expand Down