2022-07-15 18:05:58 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2022-04-10 16:57:24 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2023-09-03 23:27:53 +02:00
|
|
|
#include <cstdint>
|
2022-04-10 16:57:24 +02:00
|
|
|
|
2022-11-14 22:24:16 +01:00
|
|
|
#define CONFIG_FILENAME "/config.json"
|
2023-03-28 21:48:57 +02:00
|
|
|
#define CONFIG_VERSION 0x00011900 // 0.1.24 // make sure to clean all after change
|
2022-04-10 16:57:24 +02:00
|
|
|
|
2023-02-27 14:32:55 +01:00
|
|
|
#define WIFI_MAX_SSID_STRLEN 32
|
2022-06-22 21:00:44 +02:00
|
|
|
#define WIFI_MAX_PASSWORD_STRLEN 64
|
2022-04-10 17:37:54 +02:00
|
|
|
#define WIFI_MAX_HOSTNAME_STRLEN 31
|
|
|
|
|
|
2022-04-17 23:13:36 +02:00
|
|
|
#define NTP_MAX_SERVER_STRLEN 31
|
|
|
|
|
#define NTP_MAX_TIMEZONE_STRLEN 50
|
2022-04-18 01:33:46 +02:00
|
|
|
#define NTP_MAX_TIMEZONEDESCR_STRLEN 50
|
2022-04-17 23:13:36 +02:00
|
|
|
|
2022-08-10 18:59:30 +02:00
|
|
|
#define MQTT_MAX_HOSTNAME_STRLEN 128
|
2022-11-14 22:32:24 +01:00
|
|
|
#define MQTT_MAX_USERNAME_STRLEN 64
|
|
|
|
|
#define MQTT_MAX_PASSWORD_STRLEN 64
|
2022-04-18 15:19:26 +02:00
|
|
|
#define MQTT_MAX_TOPIC_STRLEN 32
|
2022-04-21 23:43:44 +02:00
|
|
|
#define MQTT_MAX_LWTVALUE_STRLEN 20
|
2023-04-12 11:58:27 +02:00
|
|
|
#define MQTT_MAX_CERT_STRLEN 2560
|
2022-04-18 15:19:26 +02:00
|
|
|
|
2022-05-04 21:54:38 +02:00
|
|
|
#define INV_MAX_NAME_STRLEN 31
|
|
|
|
|
#define INV_MAX_COUNT 10
|
2023-03-08 22:59:14 +01:00
|
|
|
#define INV_MAX_CHAN_COUNT 6
|
2022-05-04 21:54:38 +02:00
|
|
|
|
2022-11-15 19:31:31 +01:00
|
|
|
#define CHAN_MAX_NAME_STRLEN 31
|
|
|
|
|
|
2023-01-20 17:50:13 +01:00
|
|
|
#define DEV_MAX_MAPPING_NAME_STRLEN 63
|
2023-01-16 21:09:24 +01:00
|
|
|
|
2023-02-19 22:33:35 +01:00
|
|
|
#define JSON_BUFFER_SIZE 12288
|
2022-10-11 22:09:37 +02:00
|
|
|
|
2022-11-15 19:31:31 +01:00
|
|
|
struct CHANNEL_CONFIG_T {
|
|
|
|
|
uint16_t MaxChannelPower;
|
|
|
|
|
char Name[CHAN_MAX_NAME_STRLEN];
|
2023-02-13 20:25:00 +01:00
|
|
|
float YieldTotalOffset;
|
2022-11-15 19:31:31 +01:00
|
|
|
};
|
|
|
|
|
|
2022-05-04 21:54:38 +02:00
|
|
|
struct INVERTER_CONFIG_T {
|
|
|
|
|
uint64_t Serial;
|
|
|
|
|
char Name[INV_MAX_NAME_STRLEN + 1];
|
2023-05-29 20:17:07 +02:00
|
|
|
uint8_t Order;
|
2023-02-18 19:44:16 +01:00
|
|
|
bool Poll_Enable;
|
|
|
|
|
bool Poll_Enable_Night;
|
|
|
|
|
bool Command_Enable;
|
|
|
|
|
bool Command_Enable_Night;
|
2023-09-01 19:17:12 +02:00
|
|
|
uint8_t ReachableThreshold;
|
2023-09-02 12:22:22 +02:00
|
|
|
bool ZeroRuntimeDataIfUnrechable;
|
2023-09-05 20:27:52 +02:00
|
|
|
bool ZeroYieldDayOnMidnight;
|
2022-11-15 19:31:31 +01:00
|
|
|
CHANNEL_CONFIG_T channel[INV_MAX_CHAN_COUNT];
|
2022-05-04 21:54:38 +02:00
|
|
|
};
|
|
|
|
|
|
2022-04-10 16:57:24 +02:00
|
|
|
struct CONFIG_T {
|
|
|
|
|
uint32_t Cfg_Version;
|
2023-09-03 23:27:53 +02:00
|
|
|
uint32_t Cfg_SaveCount;
|
2022-04-10 17:37:54 +02:00
|
|
|
|
|
|
|
|
char WiFi_Ssid[WIFI_MAX_SSID_STRLEN + 1];
|
|
|
|
|
char WiFi_Password[WIFI_MAX_PASSWORD_STRLEN + 1];
|
2023-09-03 23:27:53 +02:00
|
|
|
uint8_t WiFi_Ip[4];
|
|
|
|
|
uint8_t WiFi_Netmask[4];
|
|
|
|
|
uint8_t WiFi_Gateway[4];
|
|
|
|
|
uint8_t WiFi_Dns1[4];
|
|
|
|
|
uint8_t WiFi_Dns2[4];
|
2022-04-10 17:37:54 +02:00
|
|
|
bool WiFi_Dhcp;
|
|
|
|
|
char WiFi_Hostname[WIFI_MAX_HOSTNAME_STRLEN + 1];
|
2023-09-03 23:27:53 +02:00
|
|
|
uint32_t WiFi_ApTimeout;
|
2022-04-17 23:13:36 +02:00
|
|
|
|
2023-10-30 20:53:45 +01:00
|
|
|
bool Mdns_Enabled;
|
|
|
|
|
|
2022-04-17 23:13:36 +02:00
|
|
|
char Ntp_Server[NTP_MAX_SERVER_STRLEN + 1];
|
|
|
|
|
char Ntp_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1];
|
2022-04-18 01:33:46 +02:00
|
|
|
char Ntp_TimezoneDescr[NTP_MAX_TIMEZONEDESCR_STRLEN + 1];
|
2023-02-18 16:40:24 +01:00
|
|
|
double Ntp_Longitude;
|
|
|
|
|
double Ntp_Latitude;
|
2023-05-24 19:21:44 +02:00
|
|
|
uint8_t Ntp_SunsetType;
|
2022-04-18 15:19:26 +02:00
|
|
|
|
|
|
|
|
bool Mqtt_Enabled;
|
2023-07-22 17:28:58 +02:00
|
|
|
char Mqtt_Hostname[MQTT_MAX_HOSTNAME_STRLEN + 1];
|
2023-09-03 23:27:53 +02:00
|
|
|
uint32_t Mqtt_Port;
|
2022-04-18 15:19:26 +02:00
|
|
|
char Mqtt_Username[MQTT_MAX_USERNAME_STRLEN + 1];
|
|
|
|
|
char Mqtt_Password[MQTT_MAX_PASSWORD_STRLEN + 1];
|
|
|
|
|
char Mqtt_Topic[MQTT_MAX_TOPIC_STRLEN + 1];
|
2022-04-21 23:15:45 +02:00
|
|
|
bool Mqtt_Retain;
|
2022-04-21 23:43:44 +02:00
|
|
|
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];
|
2022-06-22 21:00:44 +02:00
|
|
|
uint32_t Mqtt_PublishInterval;
|
2023-09-01 18:03:30 +02:00
|
|
|
bool Mqtt_CleanSession;
|
2022-05-04 21:54:38 +02:00
|
|
|
|
2022-07-18 22:28:03 +02:00
|
|
|
bool Mqtt_Hass_Enabled;
|
|
|
|
|
bool Mqtt_Hass_Retain;
|
|
|
|
|
char Mqtt_Hass_Topic[MQTT_MAX_TOPIC_STRLEN + 1];
|
|
|
|
|
bool Mqtt_Hass_IndividualPanels;
|
2023-07-22 17:28:58 +02:00
|
|
|
bool Mqtt_Hass_Expire;
|
|
|
|
|
|
2022-07-26 16:08:45 +02:00
|
|
|
bool Mqtt_Tls;
|
2023-04-12 11:58:27 +02:00
|
|
|
char Mqtt_RootCaCert[MQTT_MAX_CERT_STRLEN + 1];
|
2023-04-12 08:30:15 +02:00
|
|
|
bool Mqtt_TlsCertLogin;
|
2023-04-12 11:58:27 +02:00
|
|
|
char Mqtt_ClientCert[MQTT_MAX_CERT_STRLEN + 1];
|
|
|
|
|
char Mqtt_ClientKey[MQTT_MAX_CERT_STRLEN + 1];
|
2022-08-10 18:59:30 +02:00
|
|
|
|
2023-07-22 17:28:58 +02:00
|
|
|
INVERTER_CONFIG_T Inverter[INV_MAX_COUNT];
|
2022-08-31 09:16:11 +02:00
|
|
|
|
2023-07-22 17:28:58 +02:00
|
|
|
uint64_t Dtu_Serial;
|
|
|
|
|
uint32_t Dtu_PollInterval;
|
|
|
|
|
uint8_t Dtu_NrfPaLevel;
|
|
|
|
|
int8_t Dtu_CmtPaLevel;
|
|
|
|
|
uint32_t Dtu_CmtFrequency;
|
2022-10-13 19:44:16 +02:00
|
|
|
|
|
|
|
|
char Security_Password[WIFI_MAX_PASSWORD_STRLEN + 1];
|
2022-11-22 23:32:52 +01:00
|
|
|
bool Security_AllowReadonly;
|
2023-01-16 21:09:24 +01:00
|
|
|
|
|
|
|
|
char Dev_PinMapping[DEV_MAX_MAPPING_NAME_STRLEN + 1];
|
2023-01-19 23:14:08 +01:00
|
|
|
|
|
|
|
|
bool Display_PowerSafe;
|
|
|
|
|
bool Display_ScreenSaver;
|
2023-03-15 20:20:14 +01:00
|
|
|
uint8_t Display_Rotation;
|
2023-01-19 23:14:08 +01:00
|
|
|
uint8_t Display_Contrast;
|
2023-05-23 18:25:12 +02:00
|
|
|
uint8_t Display_Language;
|
2022-04-10 16:57:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ConfigurationClass {
|
|
|
|
|
public:
|
|
|
|
|
void init();
|
|
|
|
|
bool read();
|
|
|
|
|
bool write();
|
|
|
|
|
void migrate();
|
|
|
|
|
CONFIG_T& get();
|
2022-05-04 21:54:38 +02:00
|
|
|
|
|
|
|
|
INVERTER_CONFIG_T* getFreeInverterSlot();
|
2022-11-15 19:55:53 +01:00
|
|
|
INVERTER_CONFIG_T* getInverterConfig(uint64_t serial);
|
2022-04-10 16:57:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern ConfigurationClass Configuration;
|