@@ -109,12 +109,12 @@ bool ESBMesh<network_t, radio_t>::write(const void* data, uint8_t msg_type, size
109109 if (mesh_address == MESH_DEFAULT_ADDRESS ) return 0 ;
110110
111111 int16_t toNode = 0 ;
112- uint32_t lookupTimeout = millis () + MESH_WRITE_TIMEOUT ;
112+ uint32_t lookupStart = millis ();
113113 uint32_t retryDelay = 5 ;
114114
115115 if (nodeID) {
116116 while ((toNode = getAddress (nodeID)) < 0 ) {
117- if (millis () > lookupTimeout || toNode == -2 ) {
117+ if (millis () - lookupStart > MESH_WRITE_TIMEOUT || toNode == -2 ) {
118118 return 0 ;
119119 }
120120 retryDelay += 10 ;
@@ -349,12 +349,12 @@ bool ESBMesh<network_t, radio_t>::requestAddress(uint8_t level)
349349 IF_RF24MESH_DEBUG (printf_P (PSTR (" MSH Poll Level %d\n " ), level));
350350 network.multicast (header, 0 , 0 , level);
351351
352- uint32_t timeout = millis () + 55 ;
352+ const uint32_t pollStart = millis ();
353353#define MESH_MAXPOLLS 4
354354 uint16_t contactNode[MESH_MAXPOLLS ];
355355 uint8_t pollCount = 0 ;
356356
357- while (millis () < timeout && pollCount < MESH_MAXPOLLS ) {
357+ while (millis () - pollStart < 55 && pollCount < MESH_MAXPOLLS ) {
358358#if defined(RF24MESH_DEBUG)
359359 bool goodSignal = radio.testRPD ();
360360#endif
@@ -399,9 +399,9 @@ bool ESBMesh<network_t, radio_t>::requestAddress(uint8_t level)
399399
400400 IF_RF24MESH_DEBUG (printf_P (PSTR (" MSH Request address from: 0%o\n " ), contactNode[i]));
401401
402- timeout = millis () + 225 ;
402+ const uint32_t responseStart = millis ();
403403
404- while (millis () < timeout ) {
404+ while (millis () - responseStart < 225 ) {
405405 if (network.update () == NETWORK_ADDR_RESPONSE ) {
406406 if (network.frame_buffer [7 ] == _nodeID) {
407407 uint16_t newAddy = 0 ;
0 commit comments