Skip to content

Commit 0defe3d

Browse files
committed
MyTransportHal: Implement MY_TRANSPORT_SEND_RETRIES
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
1 parent e536e4b commit 0defe3d

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

MyConfig.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,15 @@
11531153
#define MY_TRANSPORT_DISCOVERY_INTERVAL_MS (20*60*1000ul)
11541154
#endif
11551155

1156+
/**
1157+
* @def MY_TRANSPORT_SEND_RETRIES
1158+
* @brief If defined to a positive number N, the node will try to send the payload to the
1159+
* uplink up to N times before actually failing. Useful when working in a noisy environment
1160+
* @note Setting this option too high will
1161+
*
1162+
*/
1163+
//#define MY_TRANSPORT_SEND_RETRIES (5)
1164+
11561165
/**
11571166
*@def MY_TRANSPORT_UPLINK_CHECK_DISABLED
11581167
*@brief If defined, disables uplink check to GW during transport initialisation

hal/transport/MyTransportHAL.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,15 @@ bool transportHALSend(const uint8_t nextRecipient, const MyMessage *outMsg, cons
173173
const uint8_t finalLength = len;
174174
#endif
175175

176+
#ifdef MY_TRANSPORT_SEND_RETRIES
177+
uint8_t retries = MY_TRANSPORT_RETRIES;
178+
bool result = false;
179+
while (retries-- && (!result)) {
180+
result = transportSend(nextRecipient, (void *)tx_data, finalLength, noACK);
181+
}
182+
#else
176183
bool result = transportSend(nextRecipient, (void *)tx_data, finalLength, noACK);
184+
#endif
177185
TRANSPORT_HAL_DEBUG(PSTR("THA:SND:MSG LEN=%" PRIu8 ",RES=%" PRIu8 "\n"), finalLength, result);
178186
return result;
179187
}

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ MY_SIGNAL_REPORT_ENABLED LITERAL1
6666
MY_SLEEP_TRANSPORT_RECONNECT_TIMEOUT_MS LITERAL1
6767
MY_SMART_SLEEP_WAIT_DURATION_MS LITERAL1
6868
MY_TRANSPORT_CHKUPL_INTERVAL_MS LITERAL1
69+
MY_TRANSPORT_SEND_RETRIES LITERAL1
6970
MY_TRANSPORT_DISCOVERY_INTERVAL_MS LITERAL1
7071
MY_TRANSPORT_MAX_TSM_FAILURES LITERAL1
7172
MY_TRANSPORT_MAX_TX_FAILURES LITERAL1

0 commit comments

Comments
 (0)