mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
fix: review fixes for the shades.cfg records
- A group in a backup from before version 23 has no rolling code, and a restore wrote 0 to NVS for it. It keeps the code NVS has. - A restore reads each record into one that starts as the shade, group or settings it replaces, so what an older version lacks stays as it was (the update check below version 20 among them), as before. - restoreFile and loadFile read the rooms, shades and groups through one readModel(); the settings, network and radio are applied by helpers. - The shade's tilt is forgotten where the shades are written, not in the conversion to a record. - rollingCodeAfterLoad moves to RollingCode.h and its tests to test_rollingcode. - The topics a deleted shade or group clears are one list each (MqttTopics.h), tested against what is published. - e2e: a restore of the shades brings back every shade and group, and the README has the rollback check by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b525a800b0
commit
92cd54f097
13 changed files with 277 additions and 148 deletions
|
|
@ -61,7 +61,6 @@ class ConfigReader {
|
|||
bool readFixedString(char *buff, size_t len);
|
||||
// A quoted value of any length, cut to fit buff.
|
||||
bool readVarString(char *buff, size_t len);
|
||||
char readChar(const char defVal = '\0');
|
||||
int8_t readInt8(const int8_t defVal = 0);
|
||||
uint8_t readUInt8(const uint8_t defVal = 0);
|
||||
uint16_t readUInt16(const uint16_t defVal = 0);
|
||||
|
|
@ -139,6 +138,8 @@ struct group_record_t {
|
|||
bool flipCommands = false;
|
||||
uint8_t roomId = 0;
|
||||
uint16_t lastRollingCode = 0;
|
||||
// Versions before 23 have none.
|
||||
bool hasRollingCode = false;
|
||||
};
|
||||
struct settings_record_t {
|
||||
// The firmware that wrote the backup. Not restored.
|
||||
|
|
@ -190,10 +191,12 @@ struct trans_record_t {
|
|||
bool noiseDetection = false;
|
||||
};
|
||||
|
||||
// The readers leave alone what the record's version lacks, so a record that
|
||||
// starts as the shade, group or settings it is read into keeps their values.
|
||||
bool writeConfigHeader(ConfigWriter &w, const config_header_t &header);
|
||||
bool readConfigHeader(ConfigReader &r, config_header_t &header);
|
||||
bool writeRoomRecord(ConfigWriter &w, const room_record_t &rec);
|
||||
bool readRoomRecord(ConfigReader &r, const config_header_t &header, room_record_t &rec);
|
||||
bool readRoomRecord(ConfigReader &r, room_record_t &rec);
|
||||
bool writeShadeRecord(ConfigWriter &w, const shade_record_t &rec);
|
||||
bool readShadeRecord(ConfigReader &r, const config_header_t &header, shade_record_t &rec);
|
||||
bool writeGroupRecord(ConfigWriter &w, const group_record_t &rec);
|
||||
|
|
@ -210,13 +213,4 @@ bool readTransRecord(ConfigReader &r, trans_record_t &rec);
|
|||
// Moves past count records without reading them.
|
||||
bool skipRecords(ConfigReader &r, uint32_t count);
|
||||
|
||||
// The rolling code a remote goes on with. NVS holds the last code sent and
|
||||
// shades.cfg the code when it was saved, so a load keeps the higher. A
|
||||
// restore takes the backup's code even when it is lower. A motor ignores
|
||||
// codes below the last one it heard, so after restoring an older backup to
|
||||
// the same device it ignores the shade until the codes pass that one.
|
||||
inline uint16_t rollingCodeAfterLoad(uint16_t stored, uint16_t inFile, bool restoring) {
|
||||
if(restoring) return inFile;
|
||||
return stored > inFile ? stored : inFile;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue