mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2026-01-27 12:50:39 +03:00
Quick Fix for MQTT Init Problem
This commit is contained in:
@@ -17,6 +17,8 @@ std::map<std::string, std::function<bool(std::string, char*, int)>>* subscribeFu
|
||||
|
||||
|
||||
int failedOnRound = -1;
|
||||
|
||||
bool MQTT_Enabled = true;
|
||||
|
||||
esp_mqtt_event_id_t esp_mmqtt_ID = MQTT_EVENT_ANY;
|
||||
// ESP_EVENT_ANY_ID
|
||||
@@ -29,6 +31,11 @@ int keepalive, SetRetainFlag;
|
||||
void (*callbackOnConnected)(std::string, int) = NULL;
|
||||
|
||||
|
||||
void MQTTdisable()
|
||||
{
|
||||
MQTT_Enabled = false;
|
||||
}
|
||||
|
||||
bool MQTTPublish(std::string _key, std::string _content, int retained_flag) {
|
||||
int msg_id;
|
||||
std::string zw;
|
||||
@@ -163,6 +170,16 @@ void MQTT_Configure(std::string _mqttURI, std::string _clientid, std::string _us
|
||||
}
|
||||
|
||||
bool MQTT_Init() {
|
||||
|
||||
if (MQTT_Enabled == false)
|
||||
return false;
|
||||
|
||||
if ((client_id.length() == 0) || (lwt_topic.length() == 0))
|
||||
{
|
||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, std::string("Init with no Client_ID or Topic. Abort Init!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_err_t ret;
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, std::string("Init"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user