Skip to content

Commit 80bd4df

Browse files
committed
Merge pull request arduino#61 from mapnull/hotfix-parentId_eeprom
Write parentNodeId to eeprom only when differ
2 parents de2bfbf + 57e8947 commit 80bd4df

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)