check valid parentNodeId before requestNodeId
This commit is contained in:
@@ -87,22 +87,19 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
|
|||||||
findParentNode();
|
findParentNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (_nodeId != AUTO) && (nc.nodeId != _nodeId) ) {
|
if (_nodeId != AUTO) {
|
||||||
// Set static id
|
// Set static id
|
||||||
nc.nodeId = _nodeId;
|
nc.nodeId = _nodeId;
|
||||||
// Save static id in eeprom
|
// Save static id in eeprom
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_NODE_ID_ADDRESS, _nodeId);
|
eeprom_update_byte((uint8_t*)EEPROM_NODE_ID_ADDRESS, _nodeId);
|
||||||
}
|
} else if (isValidParent(nc.parentNodeId)) {
|
||||||
|
// Try to fetch node-id from gateway
|
||||||
// Try to fetch node-id from gateway
|
|
||||||
if (nc.nodeId == AUTO) {
|
|
||||||
requestNodeId();
|
requestNodeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
setupNode();
|
setupNode();
|
||||||
|
|
||||||
debug(PSTR("%s started, id=%d, parent=%d, distance=%d\n"), isGateway?"gateway":(repeaterMode?"repeater":"sensor"), nc.nodeId, nc.parentNodeId, nc.distance);
|
debug(PSTR("%s started, id=%d, parent=%d, distance=%d\n"), isGateway?"gateway":(repeaterMode?"repeater":"sensor"), nc.nodeId, nc.parentNodeId, nc.distance);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MySensor::setupRepeaterMode(){
|
void MySensor::setupRepeaterMode(){
|
||||||
|
|||||||
Reference in New Issue
Block a user