Skip to content

Commit 9764190

Browse files
committed
Merge branch 'master' into development
Conflicts: libraries/MySensors/MySensor.cpp
2 parents 83be24d + 08221e6 commit 9764190

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

libraries/MySensors/MySensor.cpp

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

54-
// Read settings from EEPROM
54+
// Read settings from eeprom
5555
eeprom_read_block((void*)&nc, (void*)EEPROM_NODE_ID_ADDRESS, sizeof(NodeConfig));
5656
// Read latest received controller configuration from EEPROM
5757
eeprom_read_block((void*)&cc, (void*)EEPROM_CONTROLLER_CONFIG_ADDRESS, sizeof(ControllerConfig));
@@ -68,7 +68,11 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
6868
autoFindParent = _parentNodeId == AUTO;
6969
if (!autoFindParent) {
7070
nc.parentNodeId = _parentNodeId;
71-
nc.distance = 0;
71+
// Save static parent id in eeprom (used by bootloader)
72+
eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId);
73+
// We don't actually know the distance to gw here. Let's pretend it is 1.
74+
// If the current node is also repeater, be aware of this.
75+
nc.distance = 1;
7276
} else if (!isValidParent(nc.parentNodeId)) {
7377
// Auto find parent, but parent in eeprom is invalid. Force parent search on first transmit.
7478
nc.distance = DISTANCE_INVALID;
@@ -377,6 +381,11 @@ boolean MySensor::process() {
377381
for (uint8_t i=0;i< sizeof(childNodeTable); i++) {
378382
removeChildRoute(i);
379383
}
384+
// Clear parent node id & distance to gw
385+
eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, 0xFF);
386+
eeprom_write_byte((uint8_t*)EEPROM_DISTANCE_ADDRESS, 0xFF);
387+
// Find parent node
388+
findParentNode();
380389
sendRoute(build(msg, nc.nodeId, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_CHILDREN,false).set(""));
381390
}
382391
}

libraries/MySensors/MySensor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class MySensor
249249

250250
private:
251251
#ifdef DEBUG
252-
char convBuf[MAX_PAYLOAD];
252+
char convBuf[MAX_PAYLOAD*2+1];
253253
#endif
254254
uint8_t failedTransmissions;
255255
uint8_t *childNodeTable; // In memory buffer for routing information to other nodes. also stored in EEPROM

0 commit comments

Comments
 (0)