mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-13 15:37:03 +00:00
Some changes
This commit is contained in:
parent
afcc542e25
commit
bfa1a65dfd
@ -20,7 +20,7 @@ bool AmsConfiguration::getSystemConfig(SystemConfig& config) {
|
||||
config.userConfigured = false;
|
||||
config.dataCollectionConsent = 0;
|
||||
config.energyspeedometer = 0;
|
||||
strcpy(config.country, "");
|
||||
memset(config.country, 0, 3);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -103,8 +103,8 @@ bool AmsConfiguration::setNetworkConfig(NetworkConfig& config) {
|
||||
}
|
||||
|
||||
void AmsConfiguration::clearNetworkConfig(NetworkConfig& config) {
|
||||
strcpy(config.ssid, "");
|
||||
strcpy(config.psk, "");
|
||||
memset(config.ssid, 0, 32);
|
||||
memset(config.psk, 0, 64);
|
||||
clearNetworkConfigIp(config);
|
||||
|
||||
uint16_t chipId;
|
||||
@ -122,11 +122,11 @@ void AmsConfiguration::clearNetworkConfig(NetworkConfig& config) {
|
||||
}
|
||||
|
||||
void AmsConfiguration::clearNetworkConfigIp(NetworkConfig& config) {
|
||||
strcpy(config.ip, "");
|
||||
strcpy(config.gateway, "");
|
||||
strcpy(config.subnet, "");
|
||||
strcpy(config.dns1, "");
|
||||
strcpy(config.dns2, "");
|
||||
memset(config.ip, 0, 16);
|
||||
memset(config.gateway, 0, 16);
|
||||
memset(config.subnet, 0, 16);
|
||||
memset(config.dns1, 0, 16);
|
||||
memset(config.dns2, 0, 16);
|
||||
}
|
||||
|
||||
bool AmsConfiguration::isNetworkConfigChanged() {
|
||||
@ -180,13 +180,14 @@ bool AmsConfiguration::setMqttConfig(MqttConfig& config) {
|
||||
}
|
||||
|
||||
void AmsConfiguration::clearMqtt(MqttConfig& config) {
|
||||
strcpy(config.host, "");
|
||||
memset(config.host, 0, 128);
|
||||
config.port = 1883;
|
||||
strcpy(config.clientId, "");
|
||||
strcpy(config.publishTopic, "");
|
||||
strcpy(config.subscribeTopic, "");
|
||||
strcpy(config.username, "");
|
||||
strcpy(config.password, "");
|
||||
|
||||
memset(config.clientId, 0, 32);
|
||||
memset(config.publishTopic, 0, 64);
|
||||
memset(config.subscribeTopic, 0, 64);
|
||||
memset(config.username, 0, 128);
|
||||
memset(config.password, 0, 256);
|
||||
config.payloadFormat = 0;
|
||||
config.ssl = false;
|
||||
}
|
||||
@ -230,9 +231,9 @@ bool AmsConfiguration::setWebConfig(WebConfig& config) {
|
||||
|
||||
void AmsConfiguration::clearWebConfig(WebConfig& config) {
|
||||
config.security = 0;
|
||||
strcpy(config.username, "");
|
||||
strcpy(config.password, "");
|
||||
strcpy(config.context, "");
|
||||
memset(config.username, 0, 37);
|
||||
memset(config.password, 0, 37);
|
||||
memset(config.context, 0, 37);
|
||||
}
|
||||
|
||||
bool AmsConfiguration::getMeterConfig(MeterConfig& config) {
|
||||
@ -412,9 +413,9 @@ bool AmsConfiguration::setHomeAssistantConfig(HomeAssistantConfig& config) {
|
||||
}
|
||||
|
||||
void AmsConfiguration::clearHomeAssistantConfig(HomeAssistantConfig& config) {
|
||||
strcpy(config.discoveryPrefix, "");
|
||||
strcpy(config.discoveryHostname, "");
|
||||
strcpy(config.discoveryNameTag, "");
|
||||
memset(config.discoveryPrefix, 0, 64);
|
||||
memset(config.discoveryHostname, 0, 64);
|
||||
memset(config.discoveryNameTag, 0, 16);
|
||||
}
|
||||
|
||||
bool AmsConfiguration::pinUsed(uint8_t pin, GpioConfig& config) {
|
||||
@ -570,8 +571,8 @@ void AmsConfiguration::ackNtpChange() {
|
||||
void AmsConfiguration::clearNtp(NtpConfig& config) {
|
||||
config.enable = true;
|
||||
config.dhcp = true;
|
||||
strcpy(config.server, "pool.ntp.org");
|
||||
strcpy(config.timezone, "Europe/Oslo");
|
||||
strcpy_P(config.server, PSTR("pool.ntp.org"));
|
||||
strcpy_P(config.timezone, PSTR("Europe/Oslo"));
|
||||
}
|
||||
|
||||
bool AmsConfiguration::getPriceServiceConfig(PriceServiceConfig& config) {
|
||||
@ -612,9 +613,9 @@ bool AmsConfiguration::setPriceServiceConfig(PriceServiceConfig& config) {
|
||||
}
|
||||
|
||||
void AmsConfiguration::clearPriceServiceConfig(PriceServiceConfig& config) {
|
||||
strcpy(config.entsoeToken, "");
|
||||
strcpy(config.area, "");
|
||||
strcpy(config.currency, "");
|
||||
memset(config.entsoeToken, 0, 37);
|
||||
memset(config.area, 0, 17);
|
||||
memset(config.currency, 0, 4);
|
||||
config.unused1 = 1000;
|
||||
config.enabled = false;
|
||||
config.unused2 = 0;
|
||||
@ -733,7 +734,7 @@ void AmsConfiguration::clearUiConfig(UiConfig& config) {
|
||||
config.showPerPhasePower = 2;
|
||||
config.showPowerFactor = 2;
|
||||
config.darkMode = 2;
|
||||
strcpy(config.language, "");
|
||||
memset(config.language, 0, 3);
|
||||
}
|
||||
|
||||
bool AmsConfiguration::isUiLanguageChanged() {
|
||||
@ -818,7 +819,7 @@ bool AmsConfiguration::setCloudConfig(CloudConfig& config) {
|
||||
|
||||
void AmsConfiguration::clearCloudConfig(CloudConfig& config) {
|
||||
config.enabled = false;
|
||||
strcpy(config.hostname, "cloud.amsleser.no");
|
||||
strcpy_P(config.hostname, PSTR("cloud.amsleser.no"));
|
||||
config.port = 7443;
|
||||
config.interval = 10;
|
||||
memset(config.clientId, 0, 16);
|
||||
@ -844,7 +845,7 @@ void AmsConfiguration::clear() {
|
||||
sys.userConfigured = false;
|
||||
sys.dataCollectionConsent = 0;
|
||||
sys.energyspeedometer = 0;
|
||||
strcpy(sys.country, "");
|
||||
memset(sys.country, 0, 3);
|
||||
EEPROM.put(CONFIG_SYSTEM_START, sys);
|
||||
|
||||
MeterConfig meter;
|
||||
@ -1055,11 +1056,11 @@ bool AmsConfiguration::relocateConfig103() {
|
||||
};
|
||||
|
||||
WebConfig web = {web103.security};
|
||||
strcpy(web.username, web103.username);
|
||||
strcpy(web.password, web103.password);
|
||||
strcpy(web.context, "");
|
||||
strcpy_P(web.username, web103.username);
|
||||
strcpy_P(web.password, web103.password);
|
||||
memset(web.context, 0, 37);
|
||||
|
||||
strcpy(ui.language, "en");
|
||||
strcpy_P(ui.language, PSTR("en"));
|
||||
|
||||
EEPROM.put(CONFIG_UPGRADE_INFO_START, upinfo);
|
||||
EEPROM.put(CONFIG_NETWORK_START, wifi);
|
||||
|
||||
@ -32,8 +32,8 @@ CloudConnector::CloudConnector(RemoteDebug* debugger) {
|
||||
esp_wifi_get_mac((wifi_interface_t)ESP_IF_WIFI_STA, mac);
|
||||
esp_wifi_get_mac((wifi_interface_t)ESP_IF_WIFI_AP, apmac);
|
||||
#endif
|
||||
sprintf(this->mac, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
sprintf(this->apmac, "%02X:%02X:%02X:%02X:%02X:%02X", apmac[0], apmac[1], apmac[2], apmac[3], apmac[4], apmac[5]);
|
||||
sprintf_P(this->mac, PSTR("%02X:%02X:%02X:%02X:%02X:%02X"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
sprintf_P(this->apmac, PSTR("%02X:%02X:%02X:%02X:%02X:%02X"), apmac[0], apmac[1], apmac[2], apmac[3], apmac[4], apmac[5]);
|
||||
}
|
||||
|
||||
bool CloudConnector::setup(CloudConfig& config, MeterConfig& meter, HwTools* hw) {
|
||||
@ -68,10 +68,10 @@ bool CloudConnector::init() {
|
||||
//if(config.port == 0)
|
||||
config.port = 7443;
|
||||
//if(strlen(config.hostname) == 0)
|
||||
strcpy(config.hostname, "cloud.amsleser.no");
|
||||
strcpy_P(config.hostname, PSTR("cloud.amsleser.no"));
|
||||
|
||||
snprintf_P(clearBuffer, CC_BUF_SIZE, PSTR("http://%s/hub/cloud/public.key"), config.hostname);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(CloudConnector) Downloading public key from %s\n", clearBuffer);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(CloudConnector) Downloading public key from %s\n"), clearBuffer);
|
||||
#if defined(ESP8266)
|
||||
WiFiClient client;
|
||||
client.setTimeout(5000);
|
||||
@ -94,14 +94,14 @@ bool CloudConnector::init() {
|
||||
memset(clearBuffer, 0, CC_BUF_SIZE);
|
||||
snprintf(clearBuffer, CC_BUF_SIZE, pub.c_str());
|
||||
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Cloud public key:\n%s\n", clearBuffer);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Cloud public key:\n%s\n"), clearBuffer);
|
||||
|
||||
mbedtls_pk_context pk;
|
||||
mbedtls_pk_init(&pk);
|
||||
|
||||
int error_code = 0;
|
||||
if((error_code = mbedtls_pk_parse_public_key(&pk, (unsigned char*) clearBuffer, strlen((const char*) clearBuffer)+1)) == 0){
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("RSA public key OK\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("RSA public key OK\n"));
|
||||
rsa = mbedtls_pk_rsa(pk);
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
mbedtls_entropy_init(&entropy);
|
||||
@ -110,7 +110,7 @@ bool CloudConnector::init() {
|
||||
&entropy, (const unsigned char *) pers,
|
||||
strlen(pers));
|
||||
if(ret != 0) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("mbedtls_ctr_drbg_seed return code: %d\n", ret);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("mbedtls_ctr_drbg_seed return code: %d\n"), ret);
|
||||
}
|
||||
return ret == 0;
|
||||
} else {
|
||||
@ -136,7 +136,7 @@ void CloudConnector::update(AmsData& data, EnergyAccounting& ea) {
|
||||
if(now-lastUpdate < config.interval*1000) return;
|
||||
lastUpdate = now;
|
||||
if(!ESPRandom::isValidV4Uuid(config.clientId)) {
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf("(CloudConnector) Client ID is not valid\n");
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("(CloudConnector) Client ID is not valid\n"));
|
||||
return;
|
||||
}
|
||||
if(data.getListType() < 2) return;
|
||||
@ -267,7 +267,7 @@ void CloudConnector::update(AmsData& data, EnergyAccounting& ea) {
|
||||
pos += snprintf_P(clearBuffer+pos, CC_BUF_SIZE-pos, PSTR("}"));
|
||||
} else {
|
||||
if(!init()) {
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf("Unable to initialize cloud connector\n");
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("Unable to initialize cloud connector\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -305,9 +305,9 @@ void CloudConnector::update(AmsData& data, EnergyAccounting& ea) {
|
||||
if(rsa == nullptr) return;
|
||||
int ret = mbedtls_rsa_check_pubkey(rsa);
|
||||
if(ret != 0) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("mbedtls_rsa_pkcs1_encrypt return code: %d\n", ret);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("mbedtls_rsa_pkcs1_encrypt return code: %d\n"), ret);
|
||||
mbedtls_strerror(ret, clearBuffer, CC_BUF_SIZE);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("%s\n", clearBuffer);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("%s\n"), clearBuffer);
|
||||
return;
|
||||
}
|
||||
memset(encryptedBuffer, 0, rsa->len);
|
||||
@ -322,9 +322,9 @@ void CloudConnector::update(AmsData& data, EnergyAccounting& ea) {
|
||||
udp.write(encryptedBuffer, rsa->len);
|
||||
delay(1);
|
||||
} else {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("mbedtls_rsa_pkcs1_encrypt return code: %d\n", ret);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("mbedtls_rsa_pkcs1_encrypt return code: %d\n"), ret);
|
||||
mbedtls_strerror(ret, clearBuffer, CC_BUF_SIZE);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("%s\n", clearBuffer);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("%s\n"), clearBuffer);
|
||||
}
|
||||
}
|
||||
udp.endPacket();
|
||||
|
||||
2
lib/SvelteUi/app/dist/index.js
vendored
2
lib/SvelteUi/app/dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -20,18 +20,18 @@
|
||||
{#if epoch}
|
||||
{translations.header?.uptime ?? "Up"}
|
||||
{#if days > 1}
|
||||
{days} {translations.common?.days ?? "days"}
|
||||
{days} {translations.common?.days ?? "d"}
|
||||
{:else if days > 0}
|
||||
{days} {translations.common?.day ?? "day"}
|
||||
{days} {translations.common?.day ?? "d"}
|
||||
{:else if hours > 1}
|
||||
{hours} {translations.common?.hours ?? "hours"}
|
||||
{hours} {translations.common?.hours ?? "h"}
|
||||
{:else if hours > 0}
|
||||
{hours} {translations.common?.hour ?? "hour"}
|
||||
{hours} {translations.common?.hour ?? "h"}
|
||||
{:else if minutes > 1}
|
||||
{minutes} {translations.common?.minutes ?? "minutes"}
|
||||
{minutes} {translations.common?.minutes ?? "m"}
|
||||
{:else if minutes > 0}
|
||||
{minutes} {translations.common?.minute ?? "minute"}
|
||||
{minutes} {translations.common?.minute ?? "m"}
|
||||
{:else}
|
||||
{epoch} {translations.common?.seconds ?? "seconds"}
|
||||
{epoch} {translations.common?.seconds ?? "s"}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
@ -1611,8 +1611,8 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
debugger->setPassword(webConfig.password);
|
||||
} else {
|
||||
strcpy_P(webConfig.username, PSTR(""));
|
||||
strcpy_P(webConfig.password, PSTR(""));
|
||||
memset(webConfig.username, 0, 37);
|
||||
memset(webConfig.password, 0, 37);
|
||||
debugger->setPassword(F(""));
|
||||
}
|
||||
strcpy(webConfig.context, server.arg(F("gc")).c_str());
|
||||
|
||||
@ -72,7 +72,7 @@ bool PassiveMeterCommunicator::loop() {
|
||||
|
||||
dataAvailable = false;
|
||||
ctx = {0,0,0,0};
|
||||
strcpy_P((char*) ctx.system_title, PSTR(""));
|
||||
memset(ctx.system_title, 0, 8);
|
||||
pos = DATA_PARSE_INCOMPLETE;
|
||||
// For each byte received, check if we have a complete frame we can handle
|
||||
start = millis();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user