фикс переподключения при разрыве соединения
This commit is contained in:
parent
a9e13b78c5
commit
02efa8bf24
20
src/main.cpp
20
src/main.cpp
@ -67,6 +67,7 @@ void reconnect();
|
|||||||
void mqtt_callback(char *topic, byte *payload, unsigned int length);
|
void mqtt_callback(char *topic, byte *payload, unsigned int length);
|
||||||
void mqtt_publish_config();
|
void mqtt_publish_config();
|
||||||
void mqtt_publish_state();
|
void mqtt_publish_state();
|
||||||
|
void mqtt_subscribe_to_commands();
|
||||||
|
|
||||||
float temp;
|
float temp;
|
||||||
float hum;
|
float hum;
|
||||||
@ -81,10 +82,6 @@ void setup()
|
|||||||
setup_wifi();
|
setup_wifi();
|
||||||
setup_time();
|
setup_time();
|
||||||
setup_mqtt();
|
setup_mqtt();
|
||||||
|
|
||||||
mqtt_publish_config();
|
|
||||||
delay(100);
|
|
||||||
mqtt_publish_state();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
@ -171,9 +168,6 @@ void setup_mqtt()
|
|||||||
{
|
{
|
||||||
reconnect();
|
reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
client.subscribe("homeassistant/status");
|
|
||||||
halight.subscribeToCommandTopic();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reconnect()
|
void reconnect()
|
||||||
@ -195,6 +189,13 @@ void reconnect()
|
|||||||
delay(5000);
|
delay(5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.subscribe("homeassistant/status");
|
||||||
|
mqtt_publish_config();
|
||||||
|
delay(100);
|
||||||
|
mqtt_publish_state();
|
||||||
|
delay(100);
|
||||||
|
mqtt_subscribe_to_commands();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mqtt_callback(char *topic, byte *payload, unsigned int length)
|
void mqtt_callback(char *topic, byte *payload, unsigned int length)
|
||||||
@ -225,4 +226,9 @@ void mqtt_publish_config()
|
|||||||
void mqtt_publish_state()
|
void mqtt_publish_state()
|
||||||
{
|
{
|
||||||
halight.sendState();
|
halight.sendState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void mqtt_subscribe_to_commands()
|
||||||
|
{
|
||||||
|
halight.subscribeToCommandTopic();
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user