Accept a new parent only when autoFindParent is 1

In a gateway, I_FIND_PARENT_RESPONSE messages was returning as true by
process(). With this commit it will return as false, is this the right
expected behavior?
This commit is contained in:
Marcelo Aquino
2015-02-11 12:22:27 -02:00
parent 7b99a2ef94
commit d92918c80a
2 changed files with 14 additions and 11 deletions
+1
View File
@@ -37,6 +37,7 @@ void MyGateway::begin(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e da
Serial.begin(BAUD_RATE); Serial.begin(BAUD_RATE);
repeaterMode = true; repeaterMode = true;
isGateway = true; isGateway = true;
autoFindParent = false;
setupRepeaterMode(); setupRepeaterMode();
if (inDataCallback != NULL) { if (inDataCallback != NULL) {
+3 -1
View File
@@ -300,7 +300,8 @@ boolean MySensor::process() {
} }
if (command == C_INTERNAL) { if (command == C_INTERNAL) {
if (type == I_FIND_PARENT_RESPONSE && !isGateway) { if (type == I_FIND_PARENT_RESPONSE) {
if (autoFindParent) {
// We've received a reply to a FIND_PARENT message. Check if the distance is // We've received a reply to a FIND_PARENT message. Check if the distance is
// shorter than we already have. // shorter than we already have.
uint8_t distance = msg.getByte(); uint8_t distance = msg.getByte();
@@ -312,6 +313,7 @@ boolean MySensor::process() {
eeprom_write_byte((uint8_t*)EEPROM_DISTANCE_ADDRESS, nc.distance); eeprom_write_byte((uint8_t*)EEPROM_DISTANCE_ADDRESS, nc.distance);
debug(PSTR("new parent=%d, d=%d\n"), nc.parentNodeId, nc.distance); debug(PSTR("new parent=%d, d=%d\n"), nc.parentNodeId, nc.distance);
} }
}
return false; return false;
} else if (sender == GATEWAY_ADDRESS) { } else if (sender == GATEWAY_ADDRESS) {
bool isMetric; bool isMetric;