Skip to content

Commit fcb9243

Browse files
author
Marcelo Aquino
committed
fix repeater loop for I_FIND_PARENT
A repeater calls findParentNode() inside process() when receives a I_FIND_PARENT and nc.distance is invalid, this could cause a loop
1 parent f6dbdcf commit fcb9243

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libraries/MySensors/MySensor.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ void MySensor::setupNode() {
302302
}
303303

304304
void MySensor::findParentNode() {
305+
static boolean findingParentNode = false;
306+
307+
if (findingParentNode)
308+
return;
309+
findingParentNode = true;
310+
305311
failedTransmissions = 0;
306312

307313
// Set distance to max
@@ -316,6 +322,7 @@ void MySensor::findParentNode() {
316322

317323
// Wait for ping response.
318324
wait(2000);
325+
findingParentNode = false;
319326
}
320327

321328
boolean MySensor::sendRoute(MyMessage &message) {

0 commit comments

Comments
 (0)