Write parentNodeId to eeprom only when differ

This commit is contained in:
Marcelo Aquino
2015-02-11 11:42:07 -02:00
parent 7b99a2ef94
commit 57e8947218
+5 -3
View File
@@ -51,9 +51,11 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
} }
if (_parentNodeId != AUTO) { if (_parentNodeId != AUTO) {
nc.parentNodeId = _parentNodeId; if (_parentNodeId != nc.parentNodeId) {
// Save static parent id in eeprom nc.parentNodeId = _parentNodeId;
eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId); // Save static parent id in eeprom
eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId);
}
autoFindParent = false; autoFindParent = false;
} else { } else {
autoFindParent = true; autoFindParent = true;