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