mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-25 02:06:00 +00:00
Fixed Zmartcharge configuration issue
This commit is contained in:
@@ -905,14 +905,12 @@ bool AmsConfiguration::getZmartChargeConfig(ZmartChargeConfig& config) {
|
||||
EEPROM.end();
|
||||
stripNonAscii((uint8_t*) config.token, 21);
|
||||
stripNonAscii((uint8_t*) config.baseUrl, 64);
|
||||
if(strlen(config.token) != 20) {
|
||||
if(strlen(config.token) != 20 || !config.enabled) {
|
||||
config.enabled = false;
|
||||
memset(config.token, 0, 64);
|
||||
memset(config.baseUrl, 0, 64);
|
||||
}
|
||||
if(strncmp_P(config.baseUrl, PSTR("https"), 5) != 0) {
|
||||
config.enabled = false;
|
||||
memset(config.token, 0, 64);
|
||||
if(strlen(config.baseUrl) == 0 || strncmp_P(config.baseUrl, PSTR("https"), 5) != 0) {
|
||||
memset(config.baseUrl, 0, 64);
|
||||
snprintf_P(config.baseUrl, 64, PSTR("https://main.zmartcharge.com/api"));
|
||||
}
|
||||
@@ -927,8 +925,8 @@ bool AmsConfiguration::setZmartChargeConfig(ZmartChargeConfig& config) {
|
||||
ZmartChargeConfig existing;
|
||||
if(getZmartChargeConfig(existing)) {
|
||||
zcChanged |= config.enabled != existing.enabled;
|
||||
zcChanged |= memcmp(config.token, existing.token, 21) != 0;
|
||||
zcChanged |= memcmp(config.token, existing.baseUrl, 64) != 0;
|
||||
zcChanged |= strcmp(config.token, existing.token) != 0;
|
||||
zcChanged |= strcmp(config.baseUrl, existing.baseUrl) != 0;
|
||||
} else {
|
||||
zcChanged = true;
|
||||
}
|
||||
@@ -1356,10 +1354,10 @@ void AmsConfiguration::print(Print* debugger)
|
||||
debugger->printf_P(PSTR("Area: %s\r\n"), price.area);
|
||||
debugger->printf_P(PSTR("Currency: %s\r\n"), price.currency);
|
||||
debugger->printf_P(PSTR("ENTSO-E Token: %s\r\n"), price.entsoeToken);
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
UiConfig ui;
|
||||
@@ -1377,9 +1375,29 @@ void AmsConfiguration::print(Print* debugger)
|
||||
String uuid = ESPRandom::uuidToString(cc.clientId);;
|
||||
debugger->println(F("--Cloud configuration--"));
|
||||
debugger->printf_P(PSTR("Enabled: %s\r\n"), cc.enabled ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("Hostname: %s\r\n"), cc.hostname);
|
||||
debugger->printf_P(PSTR("Client ID: %s\r\n"), uuid.c_str());
|
||||
debugger->printf_P(PSTR("Interval: %d\r\n"), cc.interval);
|
||||
if(cc.enabled) {
|
||||
debugger->printf_P(PSTR("Hostname: %s\r\n"), cc.hostname);
|
||||
debugger->printf_P(PSTR("Client ID: %s\r\n"), uuid.c_str());
|
||||
debugger->printf_P(PSTR("Interval: %d\r\n"), cc.interval);
|
||||
}
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ZMART_CHARGE)
|
||||
ZmartChargeConfig zc;
|
||||
if(getZmartChargeConfig(zc)) {
|
||||
debugger->println(F("--ZmartCharge configuration--"));
|
||||
debugger->printf_P(PSTR("Enabled: %s\r\n"), zc.enabled ? "Yes" : "No");
|
||||
if(zc.enabled) {
|
||||
debugger->printf_P(PSTR("Base URL: '%s'\r\n"), zc.baseUrl);
|
||||
debugger->printf_P(PSTR("Token: '%s'\r\n"), zc.token);
|
||||
}
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
debugger->flush();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user