Merge branch 'development' of https://github.com/mysensors/Arduino.git into development
This commit is contained in:
@@ -299,6 +299,12 @@ void MySensor::setupNode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MySensor::findParentNode() {
|
void MySensor::findParentNode() {
|
||||||
|
static boolean findingParentNode = false;
|
||||||
|
|
||||||
|
if (findingParentNode)
|
||||||
|
return;
|
||||||
|
findingParentNode = true;
|
||||||
|
|
||||||
failedTransmissions = 0;
|
failedTransmissions = 0;
|
||||||
|
|
||||||
// Set distance to max
|
// Set distance to max
|
||||||
@@ -313,6 +319,7 @@ void MySensor::findParentNode() {
|
|||||||
|
|
||||||
// Wait for ping response.
|
// Wait for ping response.
|
||||||
wait(2000);
|
wait(2000);
|
||||||
|
findingParentNode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean MySensor::sendRoute(MyMessage &message) {
|
boolean MySensor::sendRoute(MyMessage &message) {
|
||||||
@@ -786,14 +793,17 @@ boolean MySensor::process() {
|
|||||||
// If this node have an id, relay the message
|
// If this node have an id, relay the message
|
||||||
|
|
||||||
if (command == C_INTERNAL && type == I_FIND_PARENT) {
|
if (command == C_INTERNAL && type == I_FIND_PARENT) {
|
||||||
if (nc.distance == DISTANCE_INVALID) {
|
if (sender != nc.parentNodeId) {
|
||||||
findParentNode();
|
if (nc.distance == DISTANCE_INVALID)
|
||||||
} else if (sender != nc.parentNodeId) {
|
findParentNode();
|
||||||
// Relaying nodes should always answer ping messages
|
|
||||||
// Wait a random delay of 0-2 seconds to minimize collision
|
if (nc.distance != DISTANCE_INVALID) {
|
||||||
// between ping ack messages from other relaying nodes
|
// Relaying nodes should always answer ping messages
|
||||||
wait(hw_millis() & 0x3ff);
|
// Wait a random delay of 0-2 seconds to minimize collision
|
||||||
sendWrite(sender, build(msg, nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE, false).set(nc.distance));
|
// between ping ack messages from other relaying nodes
|
||||||
|
wait(hw_millis() & 0x3ff);
|
||||||
|
sendWrite(sender, build(msg, nc.nodeId, sender, NODE_SENSOR_ID, C_INTERNAL, I_FIND_PARENT_RESPONSE, false).set(nc.distance));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (to == nc.nodeId) {
|
} else if (to == nc.nodeId) {
|
||||||
// We should try to relay this message to another node
|
// We should try to relay this message to another node
|
||||||
|
|||||||
Reference in New Issue
Block a user