diff --git a/libraries/MySensors/MyConfig.h b/libraries/MySensors/MyConfig.h index 5d7956f..474b705 100644 --- a/libraries/MySensors/MyConfig.h +++ b/libraries/MySensors/MyConfig.h @@ -12,6 +12,6 @@ /*** * Enable/Disable debug logging */ -//#define DEBUG +#define DEBUG #endif diff --git a/libraries/MySensors/MyGateway.cpp b/libraries/MySensors/MyGateway.cpp index 2abed16..843c90e 100644 --- a/libraries/MySensors/MyGateway.cpp +++ b/libraries/MySensors/MyGateway.cpp @@ -11,6 +11,7 @@ #include "MyGateway.h" + MyGateway::MyGateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time) : MySensor(_cepin, _cspin) { ledMode = false; inclusionTime = _inclusion_time; @@ -37,8 +38,8 @@ void MyGateway::begin(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e da useWriteCallback = false; } - s.nodeId = 0; - s.distance = 0; + nc.nodeId = 0; + nc.distance = 0; inclusionMode = 0; buttonTriggeredInclusion = false; countRx = 0; @@ -93,11 +94,6 @@ void MyGateway::checkButtonTriggeredInclusion() { serial(PSTR("0;0;%d;%d;Inclusion started by button.\n"), C_INTERNAL, I_LOG_MESSAGE); buttonTriggeredInclusion = false; setInclusionMode(true); - -#ifdef DEBUG - sendChildren(); -#endif - } } @@ -154,7 +150,13 @@ void MyGateway::parseAndSend(char *commandBuffer) { } } else { txBlink(1); - ok = sendRoute(msg.build(GATEWAY_ADDRESS, destination, sensor, command, type).set(value)); + msg.sender = GATEWAY_ADDRESS; + msg.destination = destination; + msg.sensor = sensor; + msg.type = type; + mSetCommand(msg,command); + msg.set(value); + ok = sendRoute(msg); if (!ok) { errBlink(1); } diff --git a/libraries/MySensors/MySensor.cpp b/libraries/MySensors/MySensor.cpp index 76e2510..55ac350 100644 --- a/libraries/MySensors/MySensor.cpp +++ b/libraries/MySensors/MySensor.cpp @@ -154,7 +154,7 @@ void MySensor::findParentNode() { boolean MySensor::sendRoute(MyMessage message) { // Make sure to process any incoming messages before sending (could this end up in recursive loop?) - process(); + // process(); // If we still don't have any node id, re-request and skip this message. if (nc.nodeId == AUTO && !(mGetCommand(message) == C_INTERNAL && message.type == I_REQUEST_ID)) { diff --git a/libraries/MySensors/MySensor.h b/libraries/MySensors/MySensor.h index f5042d6..c1d43df 100644 --- a/libraries/MySensors/MySensor.h +++ b/libraries/MySensors/MySensor.h @@ -204,6 +204,8 @@ class MySensor : public RF24 NodeConfig nc; // Essential settings for node to work ControllerConfig cc; // Configuration coming from controller boolean relayMode; + MyMessage msg; // Buffer for incoming messages. + MyMessage ack; // Buffer for ack messages. void setupRelayMode(); void setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate); @@ -214,8 +216,6 @@ class MySensor : public RF24 private: uint8_t failedTransmissions; uint8_t *childNodeTable; // In memory buffer for routing information to other nodes. also stored in EEPROM - MyMessage msg; // Buffer for incoming messages. - MyMessage ack; // Buffer for ack messages. void (*timeCallback)(unsigned long); // Callback for requested time messages void (*msgCallback)(MyMessage); // Callback for incoming messages from other nodes and gateway.