Comments (22)
Awesome, then I will commit this tonight and cut a bug fix version.
from configmanager.
are you adding parameters like the example?
In your setup function start the manager
configManager.setAPName("Demo");
configManager.setAPFilename("/index.html");
configManager.addParameter("name", config.name, 20);
configManager.addParameter("enabled", &config.enabled);
configManager.addParameter("hour", &config.hour);
configManager.addParameter("password", config.password, 20, set);
configManager.addParameter("version", &meta.version, get);
configManager.begin(config);
from configmanager.
@cgmckeever In my haste I didn't add the config initialization to my demo code. I've updated it now to reflect calling addParameter.
Weird thing is, when I add meta.version
it initializes to zero, and stays zero. So it's only affecting my configuration_t
struct.
16:24:27.263 -> Config::begin(): config.calendars = 0
16:24:27.263 -> Config::begin(): meta.version = 0
16:24:28.357 -> Config::begin(): config.calendars = -1
16:24:28.357 -> Config::begin(): meta.version = 0
from configmanager.
FWIW meta
isnt save to the EEPROM, so it not getting clobbered the same way as the config
makes sense -- although why the config
is being set to -1
is baffling me. Im trying to parse back into the code ;)
from configmanager.
meta
isnt save to the EEPROM, so it not getting clobbered the same way as theconfig
makes sense
Agreed. I had the same thought, but I wanted to share the result nonetheless. Thanks for taking a look!
from configmanager.
Have you tried to update the value AFTER you do the begin, and then restart the device to see if the value is preserved - or if it is getting clobbered? I faintly remember something about the initialized value like this, but I may be making this up
from configmanager.
ok, I seem to now think ints are set to -1
... at least that is what my code for setting defaults is telling me
https://github.com/cgmckeever/arduino-sketch/blob/master/esp-alexa-relay/relay-a/v2/main/main.ino#L71 .. see L:80
from configmanager.
If I save the values to eeprom, it reads them fine after a reset. This at least gets me moving forward again.
from configmanager.
I think .. not sure .. its because NULL is treated as -1
.. this is the only hint I have
https://github.com/nrwiersma/ConfigManager#clearsettingsbool-reboot
from configmanager.
I thought NULL
is the same as zero.
from configmanager.
yeah .. Im all confused myself right now .. my code seems to indicate that default ints are -1
and resetting the EEPROM sets things to null
.. but ... I have no conclusive evidence outside of that
from configmanager.
talking more out my butt, BUT .. NULL for the EEPROM may be \xff
https://stackoverflow.com/questions/28737829/whats-the-diffrence-between-xff-and-0xff
from configmanager.
Looking at some EEPROM related discussions, it sounds like -1
(signed char) and 255
(unsigned char) - or 0xFF - is considered unwritten data. So it seems to be part of the EEPROM standard, which is what the emulated EEPROM follows, and your suggestion of checking the values of ints and saving the sane default may be the appropriate approach to handling things. I could be wrong.
At the very least, a warning in the documentation may be warranted.
from configmanager.
One question? When you see the issue, do you have WiFi credentials set in EEPROM? We should never read the config from EEPROM without the magic bytes set, which can only happen once you have actually saved your config before. This can be seen when enabling the debug log, it should print "Reading saved configuration".
Could you perhaps enable the debug logging and post the logs here? This would give us a really good idea of how this is happening.
from configmanager.
When you see the issue, do you have WiFi credentials set in EEPROM?
Yes, I haven't tried this in AP mode.
Could you perhaps enable the debug logging and post the logs here?
MAC: 7C:9E:BD:ED:28:5C
Checking for magic initialization
Reading saved configuration
SSID: "nebakanezer"
Wifi connection attempt 1
Waiting for WiFi to connect
...
Connected to nebakanezer with 192.168.42.12
Station Mode
Webserver enabled on port: 80
Index page registered
Scan page registered
from configmanager.
Ok, i see the issue. When the initial wifi settings are written, the default config should also be written, but it no longer is.
from configmanager.
Can you give this branch a go: https://github.com/nrwiersma/ConfigManager/tree/store-init-config. You will need to start from a clean EEPROM.
from configmanager.
I went through the nuclear option and erased my flash and reuploaded everything. It is doing the Right Thing. It appears the settings are written/read correctly - even in AP mode:
MAC: 7C:9E:BD:ED:28:5C
Checking for magic initialization
MagicBytes mismatch
Starting Access Point
AP Name: Desk Buddy Setup
AP IP address: 192.168.1.1
AP Api Mode
Webserver enabled on port: 80
Index page registered
Scan page registered
Config::begin(): config.calendars = 0 // A debug statement directly after calling ConfigManager::begin()
...
[E][WebServer.cpp:632] _handleRequest(): request handler not found
Unknown URL: captive.apple.com
Index Page: /wifi.html.gz
[E][WebServer.cpp:632] _handleRequest(): request handler not found
Unknown URL: captive.apple.com
Index Page: /wifi.html.gz
[E][WebServer.cpp:632] _handleRequest(): request handler not found
Unknown URL: captive.apple.com
Index Page: /wifi.html.gz
Storing WiFi Settings for SSID: "nebakanezer"
EEPROM committed: true
from configmanager.
What about on second boot, which i think is where you have the initial problem? Is that now fixed as well?
from configmanager.
It comes back up as zero as expected.
MAC: 7C:9E:BD:ED:28:5C
Checking for magic initialization
Reading saved configuration
SSID: "nebakanezer"
Wifi connection attempt 1
Waiting for WiFi to connect
.......
Connected to nebakanezer with 192.168.42.12
Station Mode
Webserver enabled on port: 80
Index page registered
Scan page registered
Config::begin(): config.calendars = 0
from configmanager.
@nrwiersma Should that initial save be doen at the cold start
https://github.com/nrwiersma/ConfigManager/blob/master/src/ConfigManager.cpp#L64
from configmanager.
@cgmckeever I am reluctant to as normally nothing is written to EEPROM until the WiFI is setup. It seems simpler to add the config at the same time as the Wifi.
from configmanager.
Related Issues (20)
- Unable to save WiFi settings to EEPROM [esp32] HOT 3
- Saving char arrays in EEPROM HOT 2
- Delay restarting device to allow web server response
- Metadata adding config values HOT 2
- reading and writing from struct config data HOT 2
- Compiler warning HOT 1
- CORS errors HOT 6
- How can I make it to auto reconnect? HOT 4
- not possible to save the value 0 via settings.html
- Issue using LittleFS HOT 1
- Compiling / version issue with ArduinoJson HOT 3
- settings endpoint will only return last saved value HOT 5
- image file (.jpg/.png) cannot be used in index.html HOT 3
- v3 tracking issue HOT 11
- Saving config with wrong type wipes EEPROM memory HOT 3
- ESP32 Wifi Sucks .. connects every two tries .. Workaround thoughts HOT 4
- Problems with with variables in the sketch HOT 9
- One little problem with one parameter HOT 5
- Is it possible to send a Webpage from ESP32 ? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from configmanager.