Coder Social home page Coder Social logo

Comments (22)

nrwiersma avatar nrwiersma commented on July 22, 2024 1

Awesome, then I will commit this tonight and cut a bug fix version.

from configmanager.

cgmckeever avatar cgmckeever commented on July 22, 2024

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.

d42ohpaz avatar d42ohpaz commented on July 22, 2024

@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.

cgmckeever avatar cgmckeever commented on July 22, 2024

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.

d42ohpaz avatar d42ohpaz commented on July 22, 2024

meta isnt save to the EEPROM, so it not getting clobbered the same way as the config makes sense

Agreed. I had the same thought, but I wanted to share the result nonetheless. Thanks for taking a look!

from configmanager.

cgmckeever avatar cgmckeever commented on July 22, 2024

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.

cgmckeever avatar cgmckeever commented on July 22, 2024

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.

d42ohpaz avatar d42ohpaz commented on July 22, 2024

If I save the values to eeprom, it reads them fine after a reset. This at least gets me moving forward again.

from configmanager.

cgmckeever avatar cgmckeever commented on July 22, 2024

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.

d42ohpaz avatar d42ohpaz commented on July 22, 2024

I thought NULL is the same as zero.

from configmanager.

cgmckeever avatar cgmckeever commented on July 22, 2024

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.

cgmckeever avatar cgmckeever commented on July 22, 2024

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.

d42ohpaz avatar d42ohpaz commented on July 22, 2024

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.

nrwiersma avatar nrwiersma commented on July 22, 2024

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.

d42ohpaz avatar d42ohpaz commented on July 22, 2024

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.

nrwiersma avatar nrwiersma commented on July 22, 2024

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.

nrwiersma avatar nrwiersma commented on July 22, 2024

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.

d42ohpaz avatar d42ohpaz commented on July 22, 2024

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.

nrwiersma avatar nrwiersma commented on July 22, 2024

What about on second boot, which i think is where you have the initial problem? Is that now fixed as well?

from configmanager.

d42ohpaz avatar d42ohpaz commented on July 22, 2024

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.

cgmckeever avatar cgmckeever commented on July 22, 2024

@nrwiersma Should that initial save be doen at the cold start
https://github.com/nrwiersma/ConfigManager/blob/master/src/ConfigManager.cpp#L64

from configmanager.

nrwiersma avatar nrwiersma commented on July 22, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.