From b40c06db5646d1a27a23686b8914a53eb539dd87 Mon Sep 17 00:00:00 2001
From: francois <francois@clever.amilab.irit.fr>
Date: Tue, 30 May 2023 16:34:19 +0200
Subject: [PATCH] update

---
 neosensor/libraries/neocampus/sensocampus.cpp | 21 +++++++++----------
 neosensor/libraries/neocampus/sensocampus.h   |  4 +++-
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/neosensor/libraries/neocampus/sensocampus.cpp b/neosensor/libraries/neocampus/sensocampus.cpp
index 4035268e..a503f647 100644
--- a/neosensor/libraries/neocampus/sensocampus.cpp
+++ b/neosensor/libraries/neocampus/sensocampus.cpp
@@ -536,22 +536,21 @@ bool senso::_parseCredentials( char *json ) {
     log_info(F("\n[senso] found 'password' = "));log_info(_mqtt_passwd); log_flush();
     _updated = true;
   }
-  else {
-    // no password provided
-
-
-si NVS ==> _updated = true to force saving file + save senso credentials to NVS
-
   // no password provided --> does login match ?
-  else if( strncmp(_mqtt_login,(const char *)(root[F("login")]),sizeof(_mqtt_login))!=0 ) {
+  else if( strncmp(_mqtt_login,(const char *)(root[F("login")]),sizeof(_mqtt_login))==0 ) {
+    // no password provided but login matches ours ==> we also have the right password :)
+    log_info(F("\n[senso] found SAME 'login' = "));log_info(_mqtt_login); log_flush();
+  }
+  // no password provided and login does not match ... but will it match login from NVS ?
+  else if( ) {
+    to be continued
+    _updated = true;  // to save config
+  }
+  else {
     // mqtt_login does not match and no password provided ... you're dead!
     log_error(F("\n[senso] no password provided and logins do not match ... dead :(")); log_flush();
     return false;
   }
-  else {
-    // no password provided but login matches ours ==> we also have the right password :)
-    log_info(F("\n[senso] found SAME 'login' = "));log_info(_mqtt_login); log_flush();
-  }
 
   // success :)
   return true;
diff --git a/neosensor/libraries/neocampus/sensocampus.h b/neosensor/libraries/neocampus/sensocampus.h
index 4471673a..914a9a1d 100644
--- a/neosensor/libraries/neocampus/sensocampus.h
+++ b/neosensor/libraries/neocampus/sensocampus.h
@@ -78,12 +78,14 @@ private:
     bool _parseConfig( const char * );    // VERY IMPORTANT 'const' as it force ArduinoJson to create a copy
     bool _loadConfig( JsonObject );       // interprets JSON buffer from config file
     bool _saveConfig( JsonObject );       // fill JSON buffer with things to save to config file
+    bool _NVSgetLogin( & );               // [NVS] retrieve sensOCampus mqtt_login from NonVolatileStorage
+    bool _NVSgetPasswd( & );              // [NVS] retrieve sensOCampus mqtt_passwd from NonVolatileStorage
 
     /*
      * private attributes
      */
     bool _initialized;                    // check if structure is valid
-    bool _updated;                        // any change in current parameters ?
+    bool _updated;                        // any change in current parameters ? yes ==> save it
     bool _defaults;                       // default parameters, hence no need to save
     
     wifiParametersMgt *_wp;               // global wifiParametersMgt
-- 
GitLab