First off. is there a way to use Serial print to show the current state of the Preferences…
i.e. what keys and their values… assuming one doesn’t know what may have been saved before… assuming we do not know what keys were used.
Second is there a way to remove all the preferences including namespace keys and values without erasing the entire flash?
Then comes the bug I have…
This is the terminal output:
EEMem Read Global Door Info
Key: DOOR001
[E][Preferences.cpp:504] getBytes(): not enough space in buffer: 4 < 68
EEMem Read Global Door Info
Key: DOOR002
[E][Preferences.cpp:504] getBytes(): not enough space in buffer: 4 < 68
EEMem Read Global Door Info
Key: DOOR003
[E][Preferences.cpp:504] getBytes(): not enough space in buffer: 4 < 68
EEMem Read Global Door Info
Key: DOOR004
[E][Preferences.cpp:504] getBytes(): not enough space in buffer: 4 < 68
EEMem Read Global Door Info
I can’t see where the ‘not enough space…’ error comes from. In Preferences.cpp the same text is all in caps.
I only want to read 4 bytes, so don’t know what the 4 < 68 means as regards the error.
The Preferences class does not directly expose this functionality. However, since all that the preferences class does it use the ESP-IDF NVS (non-volatile-storage) functions, you can do the same. And there are functions to iterate through all available keys, see
From my understandign the .clear() function already exposes this functionality, only erasing all NVS entries from the namespace (that was given in the .begin() call)? See code).
It seems you’ve saved a 68 byte big object under that key but attempt to retrieve it again using a 4 byte buffer. That won’t work. The error message comes from
Review the buffer and buffer size for retrieving the object again or double-check the size of what you write in that key.
The headers are found but do not resolve the issue
However when I include
#include <ArduinoNvs.h>
The issues are resolved ( The underscores vanish, so presumably the symbols were found) but it fails to compile with error
src\startup.cpp:12:24: fatal error: ArduinoNvs.h: No such file or directory
I would ask what / how / why / is going on and how to resolve.
Thanks
does not apply because that’s for the latest ESP-IDF. PlatformIO is using Arduino-ESP32 version 1.0.6 which uses 3.3.5 (source), and that ESP-IDF version does not have these functions.