Skip to content

Commit 64dae74

Browse files
committed
Merge pull request arduino#43 from mapnull/hotfix-1.4
fix a case where parent distance from repeater get stuck at 255
2 parents 4796487 + bf8f5b8 commit 64dae74

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Diff for: libraries/MySensors/MySensor.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,15 @@ boolean MySensor::process() {
285285
uint8_t destination = msg.destination;
286286

287287
if (repeaterMode && command == C_INTERNAL && type == I_FIND_PARENT) {
288-
// Relaying nodes should always answer ping messages
289-
// Wait a random delay of 0-2 seconds to minimize collision
290-
// between ping ack messages from other relaying nodes
291-
delay(millis() & 0x3ff);
292-
sendWrite(sender, build(msg, nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE, false).set(nc.distance), true);
288+
if (nc.distance == 255) {
289+
findParentNode();
290+
} else {
291+
// Relaying nodes should always answer ping messages
292+
// Wait a random delay of 0-2 seconds to minimize collision
293+
// between ping ack messages from other relaying nodes
294+
delay(millis() & 0x3ff);
295+
sendWrite(sender, build(msg, nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE, false).set(nc.distance), true);
296+
}
293297
return false;
294298
} else if (destination == nc.nodeId) {
295299
// Check if sender requests an ack back.

0 commit comments

Comments
 (0)