From 0a1ee69a72d8f60d08a9769079e2f969189a29c1 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 12 Jun 2024 12:17:12 -0500 Subject: [PATCH] [SYS] Fix default connection (#1966) --- main/User_config.h | 2 +- main/Zblufi.ino | 3 +++ main/main.ino | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main/User_config.h b/main/User_config.h index 7269422..522d0ba 100644 --- a/main/User_config.h +++ b/main/User_config.h @@ -284,7 +284,7 @@ struct ss_cnt_parameters { #define cnt_parameters_array_size 3 ss_cnt_parameters cnt_parameters_array[cnt_parameters_array_size] = { - {ss_server_cert, ss_client_cert, ss_client_key, OTAserver_cert, MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, true}, + {ss_server_cert, ss_client_cert, ss_client_key, OTAserver_cert, MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, false}, {"", "", "", "", MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, false}, {"", "", "", "", MQTT_SERVER, MQTT_PORT, MQTT_USER, MQTT_PASS, MQTT_SECURE_DEFAULT, MQTT_CERT_VALIDATE_DEFAULT, false}}; diff --git a/main/Zblufi.ino b/main/Zblufi.ino index 4980d4a..4ce93e2 100644 --- a/main/Zblufi.ino +++ b/main/Zblufi.ino @@ -179,6 +179,9 @@ static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_para cnt_index = CNT_DEFAULT_INDEX; } + // We suppose the connection is valid (could be tested before) + cnt_parameters_array[cnt_index].validConnection = true; + saveConfig(); } break; diff --git a/main/main.ino b/main/main.ino index 362df7f..2d8cd06 100644 --- a/main/main.ino +++ b/main/main.ino @@ -1872,6 +1872,9 @@ bool loadConfigFromFlash() { strcat(key, index_suffix); if (json.containsKey(key)) { cnt_parameters_array[i].validConnection = json[key].as(); + } else { + // For backward compatibility, if valid_cnt is not found, we assume the connection is valid + cnt_parameters_array[i].validConnection = true; } } if (json.containsKey("cnt_index")) { @@ -2087,9 +2090,9 @@ void setupwifi(bool reset_settings) { cnt_parameters_array[cnt_index].client_cert = processCert(custom_client_cert.getValue()); cnt_parameters_array[cnt_index].client_key = processCert(custom_client_key.getValue()); # endif +# endif // We suppose the connection is valid (could be tested before) cnt_parameters_array[cnt_index].validConnection = true; -# endif //save the custom parameters to FS saveConfig();