Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
neOCampus-arduino
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GIS-neOCampus
neOSensor
neOCampus-arduino
Commits
f4685cdd
Commit
f4685cdd
authored
1 year ago
by
thiebolt
Browse files
Options
Downloads
Patches
Plain Diff
added WiFi cred backup to NVS if not already set
parent
ac7ec7b9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
neosensor/libraries/neocampus/wifiParametersMgt.cpp
+25
-2
25 additions, 2 deletions
neosensor/libraries/neocampus/wifiParametersMgt.cpp
with
25 additions
and
2 deletions
neosensor/libraries/neocampus/wifiParametersMgt.cpp
+
25
−
2
View file @
f4685cdd
...
@@ -561,8 +561,31 @@ for (JsonObject::iterator it=root.begin(); it!=root.end(); ++it) {
...
@@ -561,8 +561,31 @@ for (JsonObject::iterator it=root.begin(); it!=root.end(); ++it) {
* check if wifi connexion parameters have been read ...
* check if wifi connexion parameters have been read ...
* ... otherwise we'll extract them from struct station
* ... otherwise we'll extract them from struct station
*/
*/
if
(
_wifiSet
)
return
true
;
if
(
_wifiSet
)
{
#ifdef ESP32
/* [oct.23][TEMPORARY] will save credentials retrieved from JSON file to NVS
* Note: only usefull for devices with older firmware that did not already saved
* 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
.
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
();
}
#endif
/* ESP32 */
return
true
;
}
// grab WiFi from previous settings (Wifi global var)
// grab WiFi from previous settings (Wifi global var)
setWIFIsettings
();
setWIFIsettings
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment