Skip to content

Commit

Permalink
Increase size of cfgMqttWattJson and reduce default config
Browse files Browse the repository at this point in the history
  • Loading branch information
steff393 committed Mar 18, 2023
1 parent 40989cb commit 3d786a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/globalConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

const uint8_t m = 5;

#define WBEC_VER(s) "v" MAJOR_VER_STRING(s) ".4.7" // token stringification
#define WBEC_VER(s) "v" MAJOR_VER_STRING(s) ".4.8" // token stringification
#define MAJOR_VER_STRING(s) #s // .. with two levels of macros

char cfgWbecVersion[] = WBEC_VER(WBEC_VERSION_MAJOR); // wbec version
Expand All @@ -28,7 +28,7 @@ char cfgMqttUser[32]; // MQTT: Username
char cfgMqttPass[32]; // MQTT: Password
uint8_t cfgMqttLp[WB_CNT]; // Array with assignments to openWB loadpoints, e.g. [4,2,0,1]: Box0 = LP4, Box1 = LP2, Box2 = no MQTT, Box3 = LP1
char cfgMqttWattTopic[60]; // MQTT: Topic for setting the watt value for PV charging, default: "wbec/pv/setWatt"
char cfgMqttWattJson[15]; // MQTT: Optional: Element in a JSON string, which contains the power in watt, default: ""
char cfgMqttWattJson[30]; // MQTT: Optional: Element in a JSON string, which contains the power in watt, default: ""
char cfgNtpServer[30]; // NTP server
char cfgFoxUser[32]; // powerfox: Username
char cfgFoxPass[16]; // powerfox: Password
Expand Down Expand Up @@ -57,14 +57,11 @@ uint16_t cfgWifiConnectTimeout; // Timeout in seconds to connect to Wifi b


static bool createConfig() {
StaticJsonDocument<1024> doc;
StaticJsonDocument<128> doc;

// default configuration parameters
doc["cfgApSsid"] = F("wbec");
doc["cfgApPass"] = F("wbec1234"); // older version had "cebw1234"
doc["cfgCntWb"] = 1;
doc["cfgMqttIp"] = F("");
doc["cfgMqttLp"] = serialized("[]"); // already serialized

File configFile = LittleFS.open(F("/cfg.json"), "w");
if (!configFile) {
Expand All @@ -91,7 +88,7 @@ static boolean checkConfig(JsonDocument& doc) {
}

size_t size = configFile.size();
if (size > 1024) {
if (size > 2048) {
LOG(m, "Config file size is too large","");
return(false);
}
Expand Down Expand Up @@ -119,7 +116,7 @@ static boolean checkConfig(JsonDocument& doc) {


void loadConfig() {
StaticJsonDocument<1024> doc;
StaticJsonDocument<2048> doc;
if (!checkConfig(doc)) {
LOG(m, "Using default config", "");
deserializeJson(doc, F("{}"));
Expand Down
2 changes: 1 addition & 1 deletion src/globalConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern char cfgMqttUser[32]; // MQTT: Username
extern char cfgMqttPass[32]; // MQTT: Password
extern uint8_t cfgMqttLp[WB_CNT]; // Array with assignments to openWB loadpoints, e.g. [4,2,0,1]: Box0 = LP4, Box1 = LP2, Box2 = no MQTT, Box3 = LP1
extern char cfgMqttWattTopic[60]; // MQTT: Topic for setting the watt value for PV charging, default: "wbec/pv/setWatt"
extern char cfgMqttWattJson[15]; // MQTT: Optional: Element in a JSON string, which contains the power in watt, default: ""
extern char cfgMqttWattJson[30]; // MQTT: Optional: Element in a JSON string, which contains the power in watt, default: ""
extern char cfgNtpServer[30]; // NTP server
extern char cfgFoxUser[32]; // powerfox: Username
extern char cfgFoxPass[16]; // powerfox: Password
Expand Down

0 comments on commit 3d786a8

Please sign in to comment.