@@ -303,17 +303,19 @@ boolean MySensor::process() {
303
303
}
304
304
305
305
if (command == C_INTERNAL) {
306
- if (type == I_FIND_PARENT_RESPONSE && !isGateway) {
307
- // We've received a reply to a FIND_PARENT message. Check if the distance is
308
- // shorter than we already have.
309
- uint8_t distance = msg.getByte ();
310
- if (distance<nc.distance -1 ) {
311
- // Found a neighbor closer to GW than previously found
312
- nc.distance = distance + 1 ;
313
- nc.parentNodeId = msg.sender ;
314
- eeprom_write_byte ((uint8_t *)EEPROM_PARENT_NODE_ID_ADDRESS, nc.parentNodeId );
315
- eeprom_write_byte ((uint8_t *)EEPROM_DISTANCE_ADDRESS, nc.distance );
316
- debug (PSTR (" new parent=%d, d=%d\n " ), nc.parentNodeId , nc.distance );
306
+ if (type == I_FIND_PARENT_RESPONSE) {
307
+ if (autoFindParent) {
308
+ // We've received a reply to a FIND_PARENT message. Check if the distance is
309
+ // shorter than we already have.
310
+ uint8_t distance = msg.getByte ();
311
+ if (distance<nc.distance -1 ) {
312
+ // Found a neighbor closer to GW than previously found
313
+ nc.distance = distance + 1 ;
314
+ nc.parentNodeId = msg.sender ;
315
+ eeprom_write_byte ((uint8_t *)EEPROM_PARENT_NODE_ID_ADDRESS, nc.parentNodeId );
316
+ eeprom_write_byte ((uint8_t *)EEPROM_DISTANCE_ADDRESS, nc.distance );
317
+ debug (PSTR (" new parent=%d, d=%d\n " ), nc.parentNodeId , nc.distance );
318
+ }
317
319
}
318
320
return false ;
319
321
} else if (sender == GATEWAY_ADDRESS) {
0 commit comments