mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 12:36:52 +03:00
rolling 20221010
This commit is contained in:
@@ -52,6 +52,7 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event)
|
||||
break;
|
||||
case MQTT_EVENT_DISCONNECTED:
|
||||
ESP_LOGI(TAG_INTERFACEMQTT, "MQTT_EVENT_DISCONNECTED");
|
||||
esp_mqtt_client_reconnect(client);
|
||||
break;
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG_INTERFACEMQTT, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id);
|
||||
@@ -99,17 +100,6 @@ bool MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st
|
||||
|
||||
int _lzw = _zwmessage.length();
|
||||
|
||||
/* LWTContext = _LWTContext;
|
||||
|
||||
mqtt_cfg.uri = _mqttURI.c_str();
|
||||
mqtt_cfg.client_id = _clientid.c_str();
|
||||
mqtt_cfg.lwt_topic = _LWTContext.c_str();
|
||||
mqtt_cfg.lwt_msg = _zwmessage.c_str();
|
||||
mqtt_cfg.lwt_retain = 1;
|
||||
mqtt_cfg.lwt_msg_len = _lzw;
|
||||
mqtt_cfg.keepalive = _keepalive;
|
||||
*/
|
||||
|
||||
esp_mqtt_client_config_t mqtt_cfg = {
|
||||
.uri = _mqttURI.c_str(),
|
||||
.client_id = _clientid.c_str(),
|
||||
@@ -164,39 +154,6 @@ bool MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void MQTTReConnect(){
|
||||
std::string _zwmessage = "connection lost";
|
||||
int _lzw = _zwmessage.length();
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
client = esp_mqtt_client_init(&mqtt_cfg);
|
||||
if (client)
|
||||
{
|
||||
if (esp_mqtt_client_register_event(client, esp_mmqtt_ID, mqtt_event_handler, client) != ESP_OK)
|
||||
LogFile.WriteToFile("MQTT - Could not register event!");
|
||||
if (esp_mqtt_client_start(client) != ESP_OK)
|
||||
LogFile.WriteToFile("MQTT - Could not start client!");
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
if(MQTTPublish(_LWTContext, "", 1)) {
|
||||
LogFile.WriteToFile("MQTT - Client init successful");
|
||||
}
|
||||
=======
|
||||
if (mqtt_connected)
|
||||
MQTTPublish(LWTContext, "", 1);
|
||||
else
|
||||
LogFile.WriteToFile("Problem with (Re)Connection not successful!");
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFile.WriteToFile("MQTT - Could not Init client!");
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void MQTTdestroy() {
|
||||
if (client != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user