v2.1.6 Update

* Added Virtual Remote
* Added Dry Contact
* Fixed processed flag
* Added backup and restore options
This commit is contained in:
Robert Strouse 2023-09-16 11:19:49 -07:00
parent 7b255e3acb
commit 4ad2cf7567
17 changed files with 1206 additions and 378 deletions

View file

@ -1,12 +1,16 @@
#include <ArduinoJson.h>
#include <LittleFS.h>
#include "Somfy.h"
#include "ConfigSettings.h"
#ifndef configfile_h
#define configfile_h
#define CFG_VALUE_SEP ','
#define CFG_REC_END '\n'
#define CFG_TOK_NONE 0x00
#define CFG_TOK_QUOTE '"'
struct config_header_t {
uint8_t version = 1;
@ -14,6 +18,10 @@ struct config_header_t {
uint8_t shadeRecords = 0;
uint16_t groupRecordSize = 0;
uint8_t groupRecords = 0;
uint16_t settingsRecordSize = 0;
uint16_t netRecordSize = 0;
uint16_t transRecordSize = 0;
char serverId[10] = ""; // This must match the server id size in the ConfigSettings.
int8_t length = 0;
};
class ConfigFile {
@ -25,7 +33,6 @@ class ConfigFile {
bool _opened = false;
public:
config_header_t header;
bool save();
void end();
bool isOpen();
bool seekRecordByIndex(uint16_t ndx);
@ -36,14 +43,18 @@ class ConfigFile {
bool writeSeparator();
bool writeRecordEnd();
bool writeChar(const char val);
bool writeInt8(const int8_t val, const char tok = CFG_VALUE_SEP);
bool writeUInt8(const uint8_t val, const char tok = CFG_VALUE_SEP);
bool writeUInt16(const uint16_t val, const char tok = CFG_VALUE_SEP);
bool writeUInt32(const uint32_t val, const char tok = CFG_VALUE_SEP);
bool writeBool(const bool val, const char tok = CFG_VALUE_SEP);
bool writeFloat(const float val, const uint8_t prec, const char tok = CFG_VALUE_SEP);
bool readString(char *buff, size_t len);
bool readVarString(char *buff, size_t len);
bool writeString(const char *val, size_t len, const char tok = CFG_VALUE_SEP);
bool writeVarString(const char *val, const char tok = CFG_VALUE_SEP);
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);
uint32_t readUInt32(const uint32_t defVal = 0);
@ -54,14 +65,25 @@ class ShadeConfigFile : public ConfigFile {
protected:
bool writeShadeRecord(SomfyShade *shade);
bool writeGroupRecord(SomfyGroup *group);
bool writeSettingsRecord();
bool writeNetRecord();
bool writeTransRecord(transceiver_config_t &cfg);
bool readShadeRecord(SomfyShade *shade);
bool readGroupRecord(SomfyGroup *group);
bool readSettingsRecord();
bool readNetRecord();
bool readTransRecord(transceiver_config_t &cfg);
public:
static bool getAppVersion(appver_t &ver);
static bool exists();
static bool load(SomfyShadeController *somfy, const char *filename = "/shades.cfg");
static bool restore(SomfyShadeController *somfy, const char *filename, restore_options_t &opts);
bool begin(const char *filename, bool readOnly = false);
bool begin(bool readOnly = false);
bool save(SomfyShadeController *sofmy);
bool backup(SomfyShadeController *somfy);
bool loadFile(SomfyShadeController *somfy, const char *filename = "/shades.cfg");
bool restoreFile(SomfyShadeController *somfy, const char *filename, restore_options_t &opts);
void end();
//bool seekRecordById(uint8_t id);
bool validate();