Skip to content
Merged
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
12 changes: 6 additions & 6 deletions RF24Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ bool ESBMesh<network_t, radio_t>::write(const void* data, uint8_t msg_type, size
if (mesh_address == MESH_DEFAULT_ADDRESS) return 0;

int16_t toNode = 0;
uint32_t lookupTimeout = millis() + MESH_WRITE_TIMEOUT;
uint32_t lookupStart = millis();
uint32_t retryDelay = 5;

if (nodeID) {
while ((toNode = getAddress(nodeID)) < 0) {
if (millis() > lookupTimeout || toNode == -2) {
if (millis() - lookupStart > MESH_WRITE_TIMEOUT || toNode == -2) {
return 0;
}
retryDelay += 10;
Expand Down Expand Up @@ -349,12 +349,12 @@ bool ESBMesh<network_t, radio_t>::requestAddress(uint8_t level)
IF_RF24MESH_DEBUG(printf_P(PSTR("MSH Poll Level %d\n"), level));
network.multicast(header, 0, 0, level);

uint32_t timeout = millis() + 55;
const uint32_t pollStart = millis();
#define MESH_MAXPOLLS 4
uint16_t contactNode[MESH_MAXPOLLS];
uint8_t pollCount = 0;

while (millis() < timeout && pollCount < MESH_MAXPOLLS) {
while (millis() - pollStart < 55 && pollCount < MESH_MAXPOLLS) {
#if defined(RF24MESH_DEBUG)
bool goodSignal = radio.testRPD();
#endif
Expand Down Expand Up @@ -399,9 +399,9 @@ bool ESBMesh<network_t, radio_t>::requestAddress(uint8_t level)

IF_RF24MESH_DEBUG(printf_P(PSTR("MSH Request address from: 0%o\n"), contactNode[i]));

timeout = millis() + 225;
const uint32_t responseStart = millis();

while (millis() < timeout) {
while (millis() - responseStart < 225) {
if (network.update() == NETWORK_ADDR_RESPONSE) {
if (network.frame_buffer[7] == _nodeID) {
uint16_t newAddy = 0;
Expand Down
Loading