Merge pull request #548 from tekka007/UseMsgTmp
Use _msgTmp to build messages
This commit is contained in:
@@ -20,7 +20,11 @@
|
|||||||
#include "MyGatewayTransport.h"
|
#include "MyGatewayTransport.h"
|
||||||
|
|
||||||
extern bool transportSendRoute(MyMessage &message);
|
extern bool transportSendRoute(MyMessage &message);
|
||||||
|
|
||||||
|
// global variables
|
||||||
extern MyMessage _msg;
|
extern MyMessage _msg;
|
||||||
|
extern MyMessage _msgTmp;
|
||||||
|
extern NodeConfig _nc;
|
||||||
|
|
||||||
|
|
||||||
inline void gatewayTransportProcess() {
|
inline void gatewayTransportProcess() {
|
||||||
@@ -41,7 +45,7 @@ inline void gatewayTransportProcess() {
|
|||||||
if (mGetCommand(_msg) == C_INTERNAL) {
|
if (mGetCommand(_msg) == C_INTERNAL) {
|
||||||
if (_msg.type == I_VERSION) {
|
if (_msg.type == I_VERSION) {
|
||||||
// Request for version. Create the response
|
// 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
|
#ifdef MY_INCLUSION_MODE_FEATURE
|
||||||
} else if (_msg.type == I_INCLUSION_MODE) {
|
} else if (_msg.type == I_INCLUSION_MODE) {
|
||||||
// Request to change inclusion mode
|
// Request to change inclusion mode
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "MyGatewayTransport.h"
|
#include "MyGatewayTransport.h"
|
||||||
|
|
||||||
|
// global variables
|
||||||
|
extern MyMessage _msgTmp;
|
||||||
|
|
||||||
|
|
||||||
#if defined(MY_CONTROLLER_IP_ADDRESS)
|
#if defined(MY_CONTROLLER_IP_ADDRESS)
|
||||||
IPAddress _ethernetControllerIP(MY_CONTROLLER_IP_ADDRESS);
|
IPAddress _ethernetControllerIP(MY_CONTROLLER_IP_ADDRESS);
|
||||||
#endif
|
#endif
|
||||||
@@ -32,8 +36,6 @@ MyMessage _ethernetMsg;
|
|||||||
|
|
||||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||||
|
|
||||||
// gatewayTransportSend(buildGw(_msg, I_GATEWAY_READY).set("Gateway startup complete."));
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char string[MY_GATEWAY_MAX_RECEIVE_LENGTH];
|
char string[MY_GATEWAY_MAX_RECEIVE_LENGTH];
|
||||||
@@ -113,7 +115,7 @@ bool gatewayTransportInit() {
|
|||||||
while (WiFi.status() != WL_CONNECTED)
|
while (WiFi.status() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
delay(500);
|
delay(500);
|
||||||
MY_SERIALDEVICE.print(".");
|
MY_SERIALDEVICE.print(F("."));
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
MY_SERIALDEVICE.print(F("IP: "));
|
MY_SERIALDEVICE.print(F("IP: "));
|
||||||
@@ -126,7 +128,7 @@ bool gatewayTransportInit() {
|
|||||||
#else
|
#else
|
||||||
// Get IP address from DHCP
|
// Get IP address from DHCP
|
||||||
if (!Ethernet.begin(_ethernetGatewayMAC)) {
|
if (!Ethernet.begin(_ethernetGatewayMAC)) {
|
||||||
MY_SERIALDEVICE.print("DHCP FAILURE...");
|
MY_SERIALDEVICE.print(F("DHCP FAILURE..."));
|
||||||
_w5100_spi_en(false);
|
_w5100_spi_en(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -300,7 +302,7 @@ bool gatewayTransportAvailable()
|
|||||||
clients[i] = _ethernetServer.available();
|
clients[i] = _ethernetServer.available();
|
||||||
inputString[i].idx = 0;
|
inputString[i].idx = 0;
|
||||||
debug(PSTR("Client %d connected\n"), i);
|
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)
|
// Send presentation of locally attached sensors (and node if applicable)
|
||||||
presentNode();
|
presentNode();
|
||||||
}
|
}
|
||||||
@@ -333,7 +335,7 @@ bool gatewayTransportAvailable()
|
|||||||
client = newclient;
|
client = newclient;
|
||||||
debug(PSTR("Eth: connect\n"));
|
debug(PSTR("Eth: connect\n"));
|
||||||
_w5100_spi_en(false);
|
_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);
|
_w5100_spi_en(true);
|
||||||
presentNode();
|
presentNode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
#include "MyMessage.h"
|
#include "MyMessage.h"
|
||||||
#include "MyProtocol.h"
|
#include "MyProtocol.h"
|
||||||
|
|
||||||
|
// global variables
|
||||||
|
extern MyMessage _msgTmp;
|
||||||
|
|
||||||
char _serialInputString[MY_GATEWAY_MAX_RECEIVE_LENGTH]; // A buffer for incoming commands from serial interface
|
char _serialInputString[MY_GATEWAY_MAX_RECEIVE_LENGTH]; // A buffer for incoming commands from serial interface
|
||||||
int _serialInputPos;
|
int _serialInputPos;
|
||||||
@@ -38,7 +40,7 @@ bool gatewayTransportSend(MyMessage &message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool gatewayTransportInit() {
|
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)
|
// Send presentation of locally attached sensors (and node if applicable)
|
||||||
presentNode();
|
presentNode();
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
#include "MyInclusionMode.h"
|
#include "MyInclusionMode.h"
|
||||||
|
|
||||||
|
// global variables
|
||||||
|
extern MyMessage _msgTmp;
|
||||||
|
|
||||||
unsigned long _inclusionStartTime;
|
unsigned long _inclusionStartTime;
|
||||||
bool _inclusionMode;
|
bool _inclusionMode;
|
||||||
|
|
||||||
@@ -37,7 +40,7 @@ void inclusionModeSet(bool newMode) {
|
|||||||
if (newMode != _inclusionMode) {
|
if (newMode != _inclusionMode) {
|
||||||
_inclusionMode = newMode;
|
_inclusionMode = newMode;
|
||||||
// Send back mode change to controller
|
// 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) {
|
if (_inclusionMode) {
|
||||||
_inclusionStartTime = hwMillis();
|
_inclusionStartTime = hwMillis();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user