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:
Henrik Ekblad
2016-08-01 23:59:31 +02:00
committed by Olivier
parent e475be2980
commit 37119b2a3a
7 changed files with 15 additions and 10 deletions
+1
View File
@@ -22,6 +22,7 @@
extern bool transportSendRoute(MyMessage &message);
extern MyMessage _msg;
inline void gatewayTransportProcess() {
if (gatewayTransportAvailable()) {
_msg = gatewayTransportReceive();
+1
View File
@@ -21,6 +21,7 @@
#define MyGatewayTransport_h
#include "MyProtocol.h"
#include "MySensorsCore.h"
// Common gateway functions
+3 -4
View File
@@ -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) {
+5 -2
View File
@@ -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
+3
View File
@@ -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;
}
+2 -4
View File
@@ -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();