Present locally attached sensors and node when missing radio (#532)
* Present locally attached sensors and node when missing radio Fix #524 * Combining gateway and node presentation.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
extern bool transportSendRoute(MyMessage &message);
|
||||
extern MyMessage _msg;
|
||||
|
||||
|
||||
inline void gatewayTransportProcess() {
|
||||
if (gatewayTransportAvailable()) {
|
||||
_msg = gatewayTransportReceive();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define MyGatewayTransport_h
|
||||
|
||||
#include "MyProtocol.h"
|
||||
#include "MySensorsCore.h"
|
||||
|
||||
// Common gateway functions
|
||||
|
||||
|
||||
@@ -301,8 +301,8 @@ bool gatewayTransportAvailable()
|
||||
inputString[i].idx = 0;
|
||||
debug(PSTR("Client %d connected\n"), i);
|
||||
gatewayTransportSend(buildGw(_msg, I_GATEWAY_READY).set("Gateway startup complete."));
|
||||
if (presentation)
|
||||
presentation();
|
||||
// Send presentation of locally attached sensors (and node if applicable)
|
||||
presentNode();
|
||||
}
|
||||
}
|
||||
bool connected = clients[i].connected();
|
||||
@@ -335,8 +335,7 @@ bool gatewayTransportAvailable()
|
||||
_w5100_spi_en(false);
|
||||
gatewayTransportSend(buildGw(_msg, I_GATEWAY_READY).set("Gateway startup complete."));
|
||||
_w5100_spi_en(true);
|
||||
if (presentation)
|
||||
presentation();
|
||||
presentNode();
|
||||
}
|
||||
}
|
||||
if (client) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
// Topic structure: MY_MQTT_PUBLISH_TOPIC_PREFIX/NODE-ID/SENSOR-ID/CMD-TYPE/ACK-FLAG/SUB-TYPE
|
||||
|
||||
#include "MyGatewayTransport.h"
|
||||
|
||||
#if defined MY_CONTROLLER_IP_ADDRESS
|
||||
IPAddress _brokerIp(MY_CONTROLLER_IP_ADDRESS);
|
||||
@@ -146,8 +147,10 @@ bool reconnectMQTT() {
|
||||
#endif
|
||||
)) {
|
||||
debug(PSTR("MQTT connected\n"));
|
||||
if (presentation)
|
||||
presentation();
|
||||
|
||||
// Send presentation of locally attached sensors (and node if applicable)
|
||||
presentNode();
|
||||
|
||||
// Once connected, publish an announcement...
|
||||
//_MQTT_client.publish("outTopic","hello world");
|
||||
// ... and resubscribe
|
||||
|
||||
@@ -39,6 +39,9 @@ bool gatewayTransportSend(MyMessage &message) {
|
||||
|
||||
bool gatewayTransportInit() {
|
||||
gatewayTransportSend(buildGw(_msg, I_GATEWAY_READY).set("Gateway startup complete."));
|
||||
// Send presentation of locally attached sensors (and node if applicable)
|
||||
presentNode();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ void _begin() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MY_RADIO_FEATURE)
|
||||
#if !defined(MY_GATEWAY_FEATURE)
|
||||
presentNode();
|
||||
#endif
|
||||
|
||||
@@ -325,9 +325,7 @@ bool _processInternalMessages() {
|
||||
}
|
||||
else if (type == I_PRESENTATION) {
|
||||
// Re-send node presentation to controller
|
||||
#if defined(MY_RADIO_FEATURE)
|
||||
presentNode();
|
||||
#endif
|
||||
presentNode();
|
||||
}
|
||||
else if (type == I_HEARTBEAT) {
|
||||
sendHeartbeat();
|
||||
|
||||
Reference in New Issue
Block a user