mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 12:36:52 +03:00
Improve MQTT (#2091)
* moved functions * use hostname as default MQTT maintopic if parameter is not set * use hostname as default MQTT client ID * Only send Homassistant Discovery and Static Topics on the first connect. Retry in next round if any topic failed * . * add missing return code usage * send maintopic/connection on every round like the system topics --------- Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
@@ -326,8 +326,7 @@ bool mqtt_handler_flow_start(std::string _topic, char* _data, int _data_len) {
|
||||
void MQTTconnected(){
|
||||
if (mqtt_connected) {
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Connected to broker");
|
||||
MQTTPublish(lwt_topic, lwt_connected, true); // Publish "connected" to maintopic/connection
|
||||
|
||||
|
||||
if (connectFunktionMap != NULL) {
|
||||
for(std::map<std::string, std::function<void()>>::iterator it = connectFunktionMap->begin(); it != connectFunktionMap->end(); ++it) {
|
||||
it->second();
|
||||
|
||||
Reference in New Issue
Block a user