diff --git a/ChangeLog.txt b/ChangeLog.txt index 175436ae3fa6c331efff8b9316eae6d0eae0a0a1..dc30e4fb4e04b03233dfa096d6862565e5005941 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -4,6 +4,11 @@ # devices BUT not set as globally available for firmware upgrades # (c) neOCampus / F.Thiebolt Université Toulouse3, Laboratoire IRIT + +=== Release 231027 for esp32 only (Arduino Core ESP32 2.0.11) +Added support to save WiFi credentials retrieved from JSON file to get automatically + saved in NVS WiFi credentials area if this later does not already exists + === [jul.23] SDK upgrade === Updated to latest esp32 core Arduino (i.e 2.0.11) diff --git a/neosensor/libraries/boards/neosensor.h b/neosensor/libraries/boards/neosensor.h index 9adaf0bf6787036bfbd3a73296d70279ca07674b..a6357ca7664efebcd238d794210544c9e0a4398a 100644 --- a/neosensor/libraries/boards/neosensor.h +++ b/neosensor/libraries/boards/neosensor.h @@ -44,7 +44,7 @@ */ #define BOARD_NAME "neOSensor" #define BOARD_REVISION 1.2 -#define BOARD_FWREV 230528 // Firmware revision <year><month><day> in 2 digits each +#define BOARD_FWREV 231027 // Firmware revision <year><month><day> in 2 digits each diff --git a/neosensor/libraries/neocampus/wifiParametersMgt.cpp b/neosensor/libraries/neocampus/wifiParametersMgt.cpp index 6a81f885cb9166c97aaf088a826831907d56f8ee..5f0d888799f111e63e803f48b0368ef3250e7bab 100644 --- a/neosensor/libraries/neocampus/wifiParametersMgt.cpp +++ b/neosensor/libraries/neocampus/wifiParametersMgt.cpp @@ -569,18 +569,19 @@ for (JsonObject::iterator it=root.begin(); it!=root.end(); ++it) { * their wifi credentials in the NVS area */ Preferences _nvs; - if( _nvs.begin(WIFI_NVS_NAMESPACE,false) ) { // readwrite mode - if( ! _nvs.isKey(WIFI_NVS_SSID_KEY) and ! _nvs.isKey(WIFI_NVS_PASS_KEY) ) { - log_debug(F("\n[wifiParams] copying SSID credentials to NVS WiFi namespace ..."));log_flush(); + if( ! _nvs.begin(WIFI_NVS_NAMESPACE,true) ) { // read-only to check if it exists + log_debug(F("\n[wifiParams] copying SSID credentials to NVS WiFi namespace ..."));log_flush(); + if( _nvs.begin(WIFI_NVS_NAMESPACE,false) ) { // open NVS WiFi credentials area in RW mode + if( _nvs.putBytes(WIFI_NVS_SSID_KEY,_ssid,strlen(_ssid)+1) != strlen(_ssid)+1 ) { log_error(F("\n[wifiParams] ERROR while saving SSID to NVS ?!?!"));log_flush(); } if( _nvs.putBytes(WIFI_NVS_PASS_KEY,_pass,strlen(_pass)+1) != strlen(_pass)+1 ) { log_error(F("\n[wifiParams] ERROR while saving PASS to NVS ?!?!"));log_flush(); } + // close NVS namespace + _nvs.end(); } - // close NVS namespace - _nvs.end(); } #endif /* ESP32 */ return true;