Fix another problem related to config from controller (reading wrong position at startup!). Bugfix. Only strip carriage return on serial data from controller (at gateway)
This commit is contained in:
@@ -46,7 +46,7 @@ void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, b
|
||||
// Read settings from EEPROM
|
||||
eeprom_read_block((void*)&nc, (void*)EEPROM_NODE_ID_ADDRESS, sizeof(NodeConfig));
|
||||
// Read latest received controller configuration from EEPROM
|
||||
eeprom_read_block((void*)&cc, (void*)EEPROM_LOCAL_CONFIG_ADDRESS, sizeof(ControllerConfig));
|
||||
eeprom_read_block((void*)&cc, (void*)EEPROM_CONTROLLER_CONFIG_ADDRESS, sizeof(ControllerConfig));
|
||||
if (cc.isMetric == 0xff) {
|
||||
// Eeprom empty, set default to metric
|
||||
cc.isMetric = 0x01;
|
||||
@@ -328,11 +328,12 @@ boolean MySensor::process() {
|
||||
bool isMetric;
|
||||
|
||||
if (type == I_REBOOT) {
|
||||
// Requires MySensors or other bootloader with watchdogs enabled
|
||||
wdt_enable(WDTO_15MS);
|
||||
for (;;);
|
||||
} else if (type == I_ID_RESPONSE) {
|
||||
if (nc.nodeId == AUTO) {
|
||||
nc.nodeId = msg.getInt();
|
||||
nc.nodeId = msg.getByte();
|
||||
// Write id to EEPROM
|
||||
if (nc.nodeId == AUTO) {
|
||||
// sensor net gateway will return max id if all sensor id are taken
|
||||
@@ -347,14 +348,13 @@ boolean MySensor::process() {
|
||||
} else if (type == I_CONFIG) {
|
||||
// Pick up configuration from controller (currently only metric/imperial)
|
||||
// and store it in eeprom if changed
|
||||
isMetric = msg.getByte() == 'M' ;
|
||||
isMetric = msg.getString()[0] == 'M' ;
|
||||
if (cc.isMetric != isMetric) {
|
||||
cc.isMetric = isMetric;
|
||||
eeprom_write_byte((uint8_t*)EEPROM_CONTROLLER_CONFIG_ADDRESS, isMetric);
|
||||
//eeprom_write_block((const void*)&cc, (uint8_t*)EEPROM_CONTROLLER_CONFIG_ADDRESS, sizeof(ControllerConfig));
|
||||
}
|
||||
} else if (type == I_CHILDREN) {
|
||||
if (repeaterMode && msg.getByte() == 'C') {
|
||||
if (repeaterMode && msg.getString()[0] == 'C') {
|
||||
// Clears child relay data for this node
|
||||
debug(PSTR("rd=clear\n"));
|
||||
for (uint8_t i=0;i< sizeof(childNodeTable); i++) {
|
||||
|
||||
Reference in New Issue
Block a user