Merge branch 'master' into development

Conflicts:
	libraries/MySensors/MyGateway.cpp
	libraries/MySensors/MySensor.cpp
This commit is contained in:
Henrik Ekblad
2015-02-12 22:42:50 +01:00
+5 -1
View File
@@ -67,9 +67,11 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
autoFindParent = _parentNodeId == AUTO; autoFindParent = _parentNodeId == AUTO;
if (!autoFindParent) { if (!autoFindParent) {
if (_parentNodeId != nc.parentNodeId) {
nc.parentNodeId = _parentNodeId; nc.parentNodeId = _parentNodeId;
// Save static parent id in eeprom (used by bootloader) // Save static parent id in eeprom (used by bootloader)
eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId); eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, _parentNodeId);
}
// We don't actually know the distance to gw here. Let's pretend it is 1. // We don't actually know the distance to gw here. Let's pretend it is 1.
// If the current node is also repeater, be aware of this. // If the current node is also repeater, be aware of this.
nc.distance = 1; nc.distance = 1;
@@ -293,7 +295,8 @@ boolean MySensor::process() {
} }
if (command == C_INTERNAL) { if (command == C_INTERNAL) {
if (type == I_FIND_PARENT_RESPONSE && !isGateway) { if (type == I_FIND_PARENT_RESPONSE) {
if (autoFindParent) {
// We've received a reply to a FIND_PARENT message. Check if the distance is // We've received a reply to a FIND_PARENT message. Check if the distance is
// shorter than we already have. // shorter than we already have.
uint8_t distance = msg.getByte(); uint8_t distance = msg.getByte();
@@ -310,6 +313,7 @@ boolean MySensor::process() {
debug(PSTR("new parent=%d, d=%d\n"), nc.parentNodeId, nc.distance); debug(PSTR("new parent=%d, d=%d\n"), nc.parentNodeId, nc.distance);
} }
} }
}
return false; return false;
} else if (sender == GATEWAY_ADDRESS) { } else if (sender == GATEWAY_ADDRESS) {
bool isMetric; bool isMetric;