1
1
/*
2
- * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
2
+ * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
6
6
7
7
#include < string>
8
8
#include < algorithm>
9
9
#include < stdexcept>
10
+ #include < variant>
10
11
11
12
#include " mqtt_client.h"
12
13
#include " esp_log.h"
13
14
14
15
#include " esp_mqtt.hpp"
15
- #include " esp_mqtt_client_config.hpp"
16
16
17
17
namespace {
18
18
@@ -133,6 +133,22 @@ esp_mqtt_client_config_t make_config(BrokerConfiguration const &broker, ClientCr
133
133
esp_mqtt_client_config_t mqtt_client_cfg{};
134
134
config_broker (mqtt_client_cfg, broker);
135
135
config_client_credentials (mqtt_client_cfg, credentials);
136
+ mqtt_client_cfg.session .keepalive = config.session .keepalive ;
137
+ mqtt_client_cfg.session .last_will .msg = config.session .last_will .lwt_msg ;
138
+ mqtt_client_cfg.session .last_will .topic = config.session .last_will .lwt_topic ;
139
+ mqtt_client_cfg.session .last_will .msg_len = config.session .last_will .lwt_msg_len ;
140
+ mqtt_client_cfg.session .last_will .qos = config.session .last_will .lwt_qos ;
141
+ mqtt_client_cfg.session .last_will .retain = config.session .last_will .lwt_retain ;
142
+ mqtt_client_cfg.session .protocol_ver = config.session .protocol_ver ;
143
+ mqtt_client_cfg.session .disable_keepalive = config.session .disable_keepalive ;
144
+ mqtt_client_cfg.network .reconnect_timeout_ms = config.connection .reconnect_timeout_ms ;
145
+ mqtt_client_cfg.network .timeout_ms = config.connection .network_timeout_ms ;
146
+ mqtt_client_cfg.network .disable_auto_reconnect = config.connection .disable_auto_reconnect ;
147
+ mqtt_client_cfg.network .refresh_connection_after_ms = config.connection .refresh_connection_after_ms ;
148
+ mqtt_client_cfg.task .priority = config.task .task_prio ;
149
+ mqtt_client_cfg.task .stack_size = config.task .task_stack ;
150
+ mqtt_client_cfg.buffer .size = config.buffer_size ;
151
+ mqtt_client_cfg.buffer .out_size = config.out_buffer_size ;
136
152
return mqtt_client_cfg;
137
153
}
138
154
}
@@ -150,7 +166,6 @@ Client::Client(esp_mqtt_client_config_t const &config) : handler(esp_mqtt_clien
150
166
CHECK_THROW_SPECIFIC (esp_mqtt_client_start (handler.get ()), mqtt::MQTTException);
151
167
}
152
168
153
-
154
169
void Client::mqtt_event_handler (void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) noexcept
155
170
{
156
171
ESP_LOGD (TAG, " Event dispatched from event loop base=%s, event_id=%" PRIu32, base, event_id);
0 commit comments