From 1ed7489088bb64dad7d0600eb329935257e5100a Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Wed, 17 Jan 2024 23:16:07 +0100 Subject: [PATCH] Don't store ssid when encryption failed --- components/tactility/src/services/wifi/wifi_credentials.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/tactility/src/services/wifi/wifi_credentials.c b/components/tactility/src/services/wifi/wifi_credentials.c index 35ee5a8e..d23dc752 100644 --- a/components/tactility/src/services/wifi/wifi_credentials.c +++ b/components/tactility/src/services/wifi/wifi_credentials.c @@ -205,9 +205,11 @@ bool tt_wifi_credentials_set(const char* ssid, char password[TT_WIFI_CREDENTIALS TT_LOG_E(TAG, "Failed to encrypt credentials for \"%s\": %d", ssid, encrypt_result); } - result = nvs_set_blob(handle, ssid, password_encrypted, TT_WIFI_CREDENTIALS_PASSWORD_LIMIT); - if (result != ESP_OK) { - TT_LOG_E(TAG, "Failed to get credentials for \"%s\": %s", ssid, esp_err_to_name(result)); + if (result == ESP_OK) { + result = nvs_set_blob(handle, ssid, password_encrypted, TT_WIFI_CREDENTIALS_PASSWORD_LIMIT); + if (result != ESP_OK) { + TT_LOG_E(TAG, "Failed to get credentials for \"%s\": %s", ssid, esp_err_to_name(result)); + } } tt_wifi_credentials_nvs_close(handle);