Merge pull request #548 from tekka007/UseMsgTmp

Use _msgTmp to build messages
This commit is contained in:
Henrik Ekblad
2016-08-09 09:12:17 +02:00
committed by GitHub
4 changed files with 20 additions and 9 deletions
+5 -1
View File
@@ -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
+8 -6
View File
@@ -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();
}
+3 -1
View File
@@ -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();
+4 -1
View File
@@ -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();
}