|
@@ -64,10 +64,19 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
|
|
mqtt_event_handler_cb((esp_mqtt_event_handle_t) event_data);
|
|
mqtt_event_handler_cb((esp_mqtt_event_handle_t) event_data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password){
|
|
|
|
|
|
|
+void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password, std::string _LWTContext, int _keepalive){
|
|
|
|
|
+ std::string _zwmessage = "connection lost";
|
|
|
|
|
+
|
|
|
|
|
+ int _lzw = _LWTContext.length();
|
|
|
|
|
+
|
|
|
esp_mqtt_client_config_t mqtt_cfg = {
|
|
esp_mqtt_client_config_t mqtt_cfg = {
|
|
|
.uri = _mqttURI.c_str(),
|
|
.uri = _mqttURI.c_str(),
|
|
|
.client_id = _clientid.c_str(),
|
|
.client_id = _clientid.c_str(),
|
|
|
|
|
+// .lwt_topic = _LWTContext.c_str(),
|
|
|
|
|
+ .lwt_topic = "wasserzaehler/connection",
|
|
|
|
|
+ .lwt_msg = _zwmessage.c_str(),
|
|
|
|
|
+ .lwt_msg_len = _lzw,
|
|
|
|
|
+ .keepalive = _keepalive
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
if (_user.length() && _password.length()){
|
|
if (_user.length() && _password.length()){
|