From 10974ade3e721323801c68c8efad93a648d49aad Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Wed, 22 Jun 2022 21:00:44 +0200 Subject: [PATCH] Adjust config * Allow wifi passwords length of 64 chars * Added max channel power --- include/Configuration.h | 9 +++++---- src/Configuration.cpp | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/Configuration.h b/include/Configuration.h index 6046a3c5..33a89caa 100644 --- a/include/Configuration.h +++ b/include/Configuration.h @@ -3,10 +3,10 @@ #include #define CONFIG_FILENAME "/config.bin" -#define CONFIG_VERSION 0x00011000 // 0.1.10 // make sure to clean all after change +#define CONFIG_VERSION 0x00011100 // 0.1.17 // make sure to clean all after change #define WIFI_MAX_SSID_STRLEN 31 -#define WIFI_MAX_PASSWORD_STRLEN 31 +#define WIFI_MAX_PASSWORD_STRLEN 64 #define WIFI_MAX_HOSTNAME_STRLEN 31 #define NTP_MAX_SERVER_STRLEN 31 @@ -21,10 +21,12 @@ #define INV_MAX_NAME_STRLEN 31 #define INV_MAX_COUNT 10 +#define INV_MAX_CHAN_COUNT 4 struct INVERTER_CONFIG_T { uint64_t Serial; char Name[INV_MAX_NAME_STRLEN + 1]; + uint16_t MaxChannelPower[INV_MAX_CHAN_COUNT]; }; struct CONFIG_T { @@ -55,14 +57,13 @@ struct CONFIG_T { char Mqtt_LwtTopic[MQTT_MAX_TOPIC_STRLEN + 1]; char Mqtt_LwtValue_Online[MQTT_MAX_LWTVALUE_STRLEN + 1]; char Mqtt_LwtValue_Offline[MQTT_MAX_LWTVALUE_STRLEN + 1]; + uint32_t Mqtt_PublishInterval; INVERTER_CONFIG_T Inverter[INV_MAX_COUNT]; uint64_t Dtu_Serial; uint32_t Dtu_PollInterval; uint8_t Dtu_PaLevel; - - uint32_t Mqtt_PublishInterval; }; class ConfigurationClass { diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 0a601729..f0acca85 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -37,6 +37,9 @@ void ConfigurationClass::init() for (uint8_t i = 0; i < INV_MAX_COUNT; i++) { config.Inverter[i].Serial = 0; strlcpy(config.Inverter[i].Name, "", 0); + for (uint8_t c = 0; c < INV_MAX_CHAN_COUNT; c++) { + config.Inverter[0].MaxChannelPower[c] = 0; + } } config.Dtu_Serial = DTU_SERIAL; @@ -117,6 +120,10 @@ void ConfigurationClass::migrate() config.Mqtt_PublishInterval = MQTT_PUBLISH_INTERVAL; } + if (config.Cfg_Version < 0x00011100) { + init(); // Config will be completly incompatible after this update + } + config.Cfg_Version = CONFIG_VERSION; write(); }