Skip to content

Commit 57e8947

Browse files
author
Marcelo Aquino
committed
Write parentNodeId to eeprom only when differ
1 parent 7b99a2e commit 57e8947

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libraries/MySensors/MySensor.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
5151
}
5252

5353
if (_parentNodeId != AUTO) {
54-
nc.parentNodeId = _parentNodeId;
55-
// Save static parent id in eeprom
56-
eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId);
54+
if (_parentNodeId != nc.parentNodeId) {
55+
nc.parentNodeId = _parentNodeId;
56+
// Save static parent id in eeprom
57+
eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId);
58+
}
5759
autoFindParent = false;
5860
} else {
5961
autoFindParent = true;

0 commit comments

Comments
 (0)