mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
fix: give every NVS user its own Preferences handle
loop() and the async web server task shared one global Preferences. A begin() from one task failed while the other had a namespace open, and the clear() or remove() after it then hit the other task's namespace: saving the radio settings while a command committed its rolling code could erase every rolling code. Each function now opens NVS with a local Preferences. NVS serializes access internally and the destructor closes the handle, so no lock is added (see docs/adr/0001). No new tests: nothing here builds natively, and deleting the global makes any missed use a compile error. The read-then-commit races on rolling codes across tasks remain and are tracked in docs/KNOWN_ISSUES.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4135f21ee7
commit
c1b47f898c
6 changed files with 94 additions and 27 deletions
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
static const char *TAG = "ConfigFile";
|
||||
|
||||
extern Preferences pref;
|
||||
|
||||
#define SHADE_HDR_VER 24
|
||||
#define SHADE_HDR_SIZE 76
|
||||
|
|
@ -739,6 +738,7 @@ bool ShadeConfigFile::readSettingsRecord() {
|
|||
return true;
|
||||
}
|
||||
bool ShadeConfigFile::readGroupRecord(SomfyGroup *group) {
|
||||
Preferences pref;
|
||||
pref.begin("ShadeCodes");
|
||||
uint32_t startPos = this->file.position();
|
||||
group->setGroupId(this->readUInt8(255));
|
||||
|
|
@ -802,6 +802,7 @@ bool ShadeConfigFile::readRoomRecord(SomfyRoom *room) {
|
|||
}
|
||||
|
||||
bool ShadeConfigFile::readShadeRecord(SomfyShade *shade) {
|
||||
Preferences pref;
|
||||
pref.begin("ShadeCodes");
|
||||
uint32_t startPos = this->file.position();
|
||||
shade->setShadeId(this->readUInt8(255));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue