@@ -196,15 +196,25 @@ void MQTTClient::setup(void) {
196196
197197 // ESP-IDF v5.5
198198 esp_mqtt_client_config_t mqtt_cfg = {};
199+
200+ // Broker configuration
199201 mqtt_cfg.broker .address .uri = broker_url.c_str ();
200- mqtt_cfg.credentials_t .set_null_client_id = false ;
201- mqtt_cfg.verification_t .use_global_ca_store = this ->enable_certificates ;
202- mqtt_cfg.credentials_t .client_id = id_name.c_str ();
203- mqtt_cfg.credentials_t .authentication_t .username = this ->enable_user_and_pass ? user_name.c_str () : NULL ;
204- mqtt_cfg.credentials_t .authentication_t .password = this ->enable_user_and_pass ? user_password.c_str () : NULL ;
205- mqtt_cfg.credentials_t .authentication_t .certificate = this ->enable_certificates ? (const char *)client_cert_pem : NULL ;
206- mqtt_cfg.credentials_t .authentication_t .client_key_pem = this ->enable_certificates ? (const char *)client_key_pem : NULL ;
207- mqtt_cfg.task_t .stack_size = task_stack_size;
202+
203+ // Credentials configuration
204+ mqtt_cfg.credentials .set_null_client_id = false ;
205+ mqtt_cfg.credentials .client_id = id_name.c_str ();
206+ mqtt_cfg.credentials .username = this ->enable_user_and_pass ? user_name.c_str () : NULL ;
207+ mqtt_cfg.credentials .authentication .password = this ->enable_user_and_pass ? user_password.c_str () : NULL ;
208+
209+ // Certificate configuration (updated paths)
210+ if (this ->enable_certificates ) {
211+ mqtt_cfg.broker .verification .use_global_ca_store = true ;
212+ mqtt_cfg.credentials .authentication .certificate = (const char *)client_cert_pem;
213+ mqtt_cfg.credentials .authentication .key = (const char *)client_key_pem;
214+ }
215+
216+ // Task configuration
217+ mqtt_cfg.task .stack_size = task_stack_size;
208218
209219 ESP_LOGW (TAG, " [APP] Free memory: %d bytes" , esp_get_free_heap_size ());
210220 client = esp_mqtt_client_init (&mqtt_cfg);
0 commit comments