Fix Client Mode for Ethernet gateway

If MY_GATEWAY_CLIENT_MODE or MY_CONTROLLER_URL_ADDRESS are present, set
MY_GATEWAY_CLIENT_MODE.
MY_USE_UDP requires that MY_GATEWAY_CLIENT_MODE is set.
Add some ifdefs to filter some variables not needed in client mode.
Using global variables to keep the connection to controller open
therefore, no need to reconnect every time we need to send/receive
something.
Add the remaining code to handle incoming messages from controllers.
This commit is contained in:
Marcelo Aquino
2016-09-28 15:18:26 -03:00
parent 8cacb4825b
commit 0c11354a2a
2 changed files with 84 additions and 27 deletions
+8 -4
View File
@@ -141,6 +141,13 @@
#endif
// GATEWAY - TRANSPORT
#if defined(MY_CONTROLLER_IP_ADDRESS) || defined(MY_CONTROLLER_URL_ADDRESS)
#define MY_GATEWAY_CLIENT_MODE
#endif
#if defined(MY_USE_UDP) && !defined(MY_GATEWAY_CLIENT_MODE)
#error You must specify MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS for UDP
#endif
#if defined(MY_GATEWAY_MQTT_CLIENT)
#if defined(MY_RADIO_FEATURE)
// We assume that a gateway having a radio also should act as repeater
@@ -148,7 +155,7 @@
#endif
// GATEWAY - COMMON FUNCTIONS
// We only support MQTT Client using W5100 and ESP8266 at the moment
#if !(defined(MY_CONTROLLER_URL_ADDRESS) || defined(MY_CONTROLLER_IP_ADDRESS))
#if !defined(MY_GATEWAY_CLIENT_MODE)
#error You must specify MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS
#endif
@@ -177,9 +184,6 @@
// We assume that a gateway having a radio also should act as repeater
#define MY_REPEATER_FEATURE
#endif
#if defined(MY_CONTROLLER_IP_ADDRESS)
#define MY_GATEWAY_CLIENT_MODE
#endif
#if !defined(MY_PORT)
#error You must define MY_PORT (controller or gatway port to open)
#endif