Added mqtt status topic
This commit is contained in:
parent
1595542d59
commit
6989b1730e
@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
|
|
||||||
//version code in format yymmddb (b = daily build)
|
//version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 1911101
|
#define VERSION 1911102
|
||||||
char versionString[] = "0.8.6";
|
char versionString[] = "0.8.6";
|
||||||
|
|
||||||
|
|
||||||
@ -386,6 +386,7 @@ unsigned long realtimeTimeout = 0;
|
|||||||
long lastMqttReconnectAttempt = 0;
|
long lastMqttReconnectAttempt = 0;
|
||||||
long lastInterfaceUpdate = 0;
|
long lastInterfaceUpdate = 0;
|
||||||
byte interfaceUpdateCallMode = 0;
|
byte interfaceUpdateCallMode = 0;
|
||||||
|
char mqttStatusTopic[40] = ""; //this must be global because of async handlers
|
||||||
|
|
||||||
#if AUXPIN >= 0
|
#if AUXPIN >= 0
|
||||||
//auxiliary debug pin
|
//auxiliary debug pin
|
||||||
|
@ -176,6 +176,7 @@ void handleNotifications()
|
|||||||
{
|
{
|
||||||
//ignore notification if received within a second after sending a notification ourselves
|
//ignore notification if received within a second after sending a notification ourselves
|
||||||
if (millis() - notificationSentTime < 1000) return;
|
if (millis() - notificationSentTime < 1000) return;
|
||||||
|
if (udpIn[1] > 199) return; //do not receive custom versions
|
||||||
|
|
||||||
bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
||||||
//apply colors from notification
|
//apply colors from notification
|
||||||
|
@ -19,7 +19,6 @@ void onMqttConnect(bool sessionPresent)
|
|||||||
{
|
{
|
||||||
//(re)subscribe to required topics
|
//(re)subscribe to required topics
|
||||||
char subuf[38];
|
char subuf[38];
|
||||||
strcpy(subuf, mqttDeviceTopic);
|
|
||||||
|
|
||||||
if (mqttDeviceTopic[0] != 0)
|
if (mqttDeviceTopic[0] != 0)
|
||||||
{
|
{
|
||||||
@ -89,6 +88,10 @@ void publishMqtt()
|
|||||||
strcat(subuf, "/c");
|
strcat(subuf, "/c");
|
||||||
mqtt->publish(subuf, 0, true, s);
|
mqtt->publish(subuf, 0, true, s);
|
||||||
|
|
||||||
|
strcpy(subuf, mqttDeviceTopic);
|
||||||
|
strcat(subuf, "/status");
|
||||||
|
mqtt->publish(subuf, 0, true, "online");
|
||||||
|
|
||||||
char apires[1024];
|
char apires[1024];
|
||||||
XML_response(nullptr, false, apires);
|
XML_response(nullptr, false, apires);
|
||||||
strcpy(subuf, mqttDeviceTopic);
|
strcpy(subuf, mqttDeviceTopic);
|
||||||
@ -243,6 +246,10 @@ bool initMqtt()
|
|||||||
}
|
}
|
||||||
mqtt->setClientId(mqttClientID);
|
mqtt->setClientId(mqttClientID);
|
||||||
if (mqttUser[0] && mqttPass[0]) mqtt->setCredentials(mqttUser, mqttPass);
|
if (mqttUser[0] && mqttPass[0]) mqtt->setCredentials(mqttUser, mqttPass);
|
||||||
|
|
||||||
|
strcpy(mqttStatusTopic, mqttDeviceTopic);
|
||||||
|
strcat(mqttStatusTopic, "/status");
|
||||||
|
mqtt->setWill(mqttStatusTopic, 0, true, "offline");
|
||||||
mqtt->connect();
|
mqtt->connect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void initServer()
|
|||||||
|
|
||||||
server.on("/settings/wifi", HTTP_POST, [](AsyncWebServerRequest *request){
|
server.on("/settings/wifi", HTTP_POST, [](AsyncWebServerRequest *request){
|
||||||
if (!(wifiLock && otaLock)) handleSettingsSet(request, 1);
|
if (!(wifiLock && otaLock)) handleSettingsSet(request, 1);
|
||||||
serveMessage(request, 200,"WiFi settings saved.","Reconnecting now...",255);
|
serveMessage(request, 200,"WiFi settings saved.","Reconnecting now...",129);
|
||||||
forceReconnect = true;
|
forceReconnect = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user