diff --git a/core/MyGatewayTransport.cpp b/core/MyGatewayTransport.cpp index beb16d2..f4e98f4 100644 --- a/core/MyGatewayTransport.cpp +++ b/core/MyGatewayTransport.cpp @@ -20,7 +20,11 @@ #include "MyGatewayTransport.h" extern bool transportSendRoute(MyMessage &message); + +// global variables extern MyMessage _msg; +extern MyMessage _msgTmp; +extern NodeConfig _nc; inline void gatewayTransportProcess() { @@ -41,7 +45,7 @@ inline void gatewayTransportProcess() { if (mGetCommand(_msg) == C_INTERNAL) { if (_msg.type == I_VERSION) { // Request for version. Create the response - gatewayTransportSend(buildGw(_msg, I_VERSION).set(MYSENSORS_LIBRARY_VERSION)); + gatewayTransportSend(buildGw(_msgTmp, I_VERSION).set(MYSENSORS_LIBRARY_VERSION)); #ifdef MY_INCLUSION_MODE_FEATURE } else if (_msg.type == I_INCLUSION_MODE) { // Request to change inclusion mode diff --git a/core/MyGatewayTransportEthernet.cpp b/core/MyGatewayTransportEthernet.cpp index 6c930e7..cef41e7 100644 --- a/core/MyGatewayTransportEthernet.cpp +++ b/core/MyGatewayTransportEthernet.cpp @@ -19,6 +19,10 @@ #include "MyGatewayTransport.h" + // global variables +extern MyMessage _msgTmp; + + #if defined(MY_CONTROLLER_IP_ADDRESS) IPAddress _ethernetControllerIP(MY_CONTROLLER_IP_ADDRESS); #endif @@ -32,8 +36,6 @@ MyMessage _ethernetMsg; #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -// gatewayTransportSend(buildGw(_msg, I_GATEWAY_READY).set("Gateway startup complete.")); - typedef struct { char string[MY_GATEWAY_MAX_RECEIVE_LENGTH]; @@ -113,7 +115,7 @@ bool gatewayTransportInit() { while (WiFi.status() != WL_CONNECTED) { delay(500); - MY_SERIALDEVICE.print("."); + MY_SERIALDEVICE.print(F(".")); yield(); } MY_SERIALDEVICE.print(F("IP: ")); @@ -126,7 +128,7 @@ bool gatewayTransportInit() { #else // Get IP address from DHCP if (!Ethernet.begin(_ethernetGatewayMAC)) { - MY_SERIALDEVICE.print("DHCP FAILURE..."); + MY_SERIALDEVICE.print(F("DHCP FAILURE...")); _w5100_spi_en(false); return false; } @@ -300,7 +302,7 @@ bool gatewayTransportAvailable() clients[i] = _ethernetServer.available(); inputString[i].idx = 0; debug(PSTR("Client %d connected\n"), i); - gatewayTransportSend(buildGw(_msg, I_GATEWAY_READY).set("Gateway startup complete.")); + gatewayTransportSend(buildGw(_msgTmp, I_GATEWAY_READY).set("Gateway startup complete.")); // Send presentation of locally attached sensors (and node if applicable) presentNode(); } @@ -333,7 +335,7 @@ bool gatewayTransportAvailable() client = newclient; debug(PSTR("Eth: connect\n")); _w5100_spi_en(false); - gatewayTransportSend(buildGw(_msg, I_GATEWAY_READY).set("Gateway startup complete.")); + gatewayTransportSend(buildGw(_msgTmp, I_GATEWAY_READY).set("Gateway startup complete.")); _w5100_spi_en(true); presentNode(); } diff --git a/core/MyGatewayTransportSerial.cpp b/core/MyGatewayTransportSerial.cpp index f7c35c8..bbad4b3 100644 --- a/core/MyGatewayTransportSerial.cpp +++ b/core/MyGatewayTransportSerial.cpp @@ -24,6 +24,8 @@ #include "MyMessage.h" #include "MyProtocol.h" + // global variables +extern MyMessage _msgTmp; char _serialInputString[MY_GATEWAY_MAX_RECEIVE_LENGTH]; // A buffer for incoming commands from serial interface int _serialInputPos; @@ -38,7 +40,7 @@ bool gatewayTransportSend(MyMessage &message) { } bool gatewayTransportInit() { - gatewayTransportSend(buildGw(_msg, I_GATEWAY_READY).set("Gateway startup complete.")); + gatewayTransportSend(buildGw(_msgTmp, I_GATEWAY_READY).set("Gateway startup complete.")); // Send presentation of locally attached sensors (and node if applicable) presentNode(); diff --git a/core/MyInclusionMode.cpp b/core/MyInclusionMode.cpp index e55612f..ea2198c 100644 --- a/core/MyInclusionMode.cpp +++ b/core/MyInclusionMode.cpp @@ -19,6 +19,9 @@ #include "MyInclusionMode.h" + // global variables +extern MyMessage _msgTmp; + unsigned long _inclusionStartTime; bool _inclusionMode; @@ -37,7 +40,7 @@ void inclusionModeSet(bool newMode) { if (newMode != _inclusionMode) { _inclusionMode = newMode; // Send back mode change to controller - gatewayTransportSend(buildGw(_msg, I_INCLUSION_MODE).set((uint8_t)(_inclusionMode?1:0))); + gatewayTransportSend(buildGw(_msgTmp, I_INCLUSION_MODE).set((uint8_t)(_inclusionMode?1:0))); if (_inclusionMode) { _inclusionStartTime = hwMillis(); }