Fix gateway RX indication
Added GW RX indication for MQTT and Serial gateway (PR #585). Only send RX indication when valid message has been received.
This commit is contained in:
@@ -272,19 +272,23 @@ bool gatewayTransportAvailable()
|
|||||||
|
|
||||||
if (packet_size) {
|
if (packet_size) {
|
||||||
//debug(PSTR("UDP packet available. Size:%d\n"), packet_size);
|
//debug(PSTR("UDP packet available. Size:%d\n"), packet_size);
|
||||||
setIndication(INDICATION_GW_RX);
|
|
||||||
#if defined(MY_GATEWAY_ESP8266)
|
#if defined(MY_GATEWAY_ESP8266)
|
||||||
_ethernetServer.read(inputString[0].string, MY_GATEWAY_MAX_RECEIVE_LENGTH);
|
_ethernetServer.read(inputString[0].string, MY_GATEWAY_MAX_RECEIVE_LENGTH);
|
||||||
inputString[0].string[packet_size] = 0;
|
inputString[0].string[packet_size] = 0;
|
||||||
debug(PSTR("UDP packet received: %s\n"), inputString[0].string);
|
debug(PSTR("UDP packet received: %s\n"), inputString[0].string);
|
||||||
return protocolParse(_ethernetMsg, inputString[0].string);
|
const bool ok = protocolParse(_ethernetMsg, inputString[0].string);
|
||||||
#else
|
#else
|
||||||
_ethernetServer.read(inputString.string, MY_GATEWAY_MAX_RECEIVE_LENGTH);
|
_ethernetServer.read(inputString.string, MY_GATEWAY_MAX_RECEIVE_LENGTH);
|
||||||
inputString.string[packet_size] = 0;
|
inputString.string[packet_size] = 0;
|
||||||
debug(PSTR("UDP packet received: %s\n"), inputString.string);
|
debug(PSTR("UDP packet received: %s\n"), inputString.string);
|
||||||
_w5100_spi_en(false);
|
_w5100_spi_en(false);
|
||||||
return protocolParse(_ethernetMsg, inputString.string);
|
const bool ok = protocolParse(_ethernetMsg, inputString.string);
|
||||||
#endif
|
#endif
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
setIndication(INDICATION_GW_RX);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#if defined(MY_GATEWAY_ESP8266)
|
#if defined(MY_GATEWAY_ESP8266)
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ void incomingMQTT(char* topic, byte* payload, unsigned int length) {
|
|||||||
_MQTT_msg.set((const char*)payload);
|
_MQTT_msg.set((const char*)payload);
|
||||||
}
|
}
|
||||||
_MQTT_available = true;
|
_MQTT_available = true;
|
||||||
|
setIndication(INDICATION_GW_RX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ bool gatewayTransportAvailable() {
|
|||||||
if (inChar == '\n') {
|
if (inChar == '\n') {
|
||||||
_serialInputString[_serialInputPos] = 0;
|
_serialInputString[_serialInputPos] = 0;
|
||||||
bool ok = protocolParse(_serialMsg, _serialInputString);
|
bool ok = protocolParse(_serialMsg, _serialInputString);
|
||||||
_serialInputPos = 0;
|
if (ok)
|
||||||
|
{
|
||||||
|
setIndication(INDICATION_GW_RX);
|
||||||
|
}
|
||||||
|
_serialInputPos = 0;
|
||||||
return ok;
|
return ok;
|
||||||
} else {
|
} else {
|
||||||
// add it to the inputString:
|
// add it to the inputString:
|
||||||
|
|||||||
Reference in New Issue
Block a user