From 57e8947218e301be8a229e8746ec25f108d9b4a1 Mon Sep 17 00:00:00 2001 From: Marcelo Aquino Date: Wed, 11 Feb 2015 11:42:07 -0200 Subject: [PATCH] Write parentNodeId to eeprom only when differ --- libraries/MySensors/MySensor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/MySensors/MySensor.cpp b/libraries/MySensors/MySensor.cpp index a2a63b5..1b0cf41 100755 --- a/libraries/MySensors/MySensor.cpp +++ b/libraries/MySensors/MySensor.cpp @@ -51,9 +51,11 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b } if (_parentNodeId != AUTO) { - nc.parentNodeId = _parentNodeId; - // Save static parent id in eeprom - eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId); + if (_parentNodeId != nc.parentNodeId) { + nc.parentNodeId = _parentNodeId; + // Save static parent id in eeprom + eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId); + } autoFindParent = false; } else { autoFindParent = true;