Merge pull request #62 from mapnull/hotfix-autoFindParent_response

Accept a new parent only when autoFindParent is 1
This commit is contained in:
Henrik Ekblad
2015-02-12 22:23:13 +01:00
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
@@ -303,7 +303,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();
@@ -315,6 +316,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;