mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-25 20:06:08 +00:00
General optimizations
This commit is contained in:
@@ -411,39 +411,39 @@ bool AmsConfiguration::setGpioConfig(GpioConfig& config) {
|
||||
}
|
||||
/* This currently does not work, as it checks its own pin
|
||||
if(pinUsed(config.hanPin, config)) {
|
||||
Serial.println("HAN pin already used");
|
||||
debugger->println(F("HAN pin already used"));
|
||||
return false;
|
||||
}
|
||||
if(pinUsed(config.apPin, config)) {
|
||||
Serial.println("AP pin already used");
|
||||
debugger->println(F("AP pin already used"));
|
||||
return false;
|
||||
}
|
||||
if(pinUsed(config.ledPin, config)) {
|
||||
Serial.println("LED pin already used");
|
||||
debugger->println(F("LED pin already used"));
|
||||
return false;
|
||||
}
|
||||
if(pinUsed(config.ledPinRed, config)) {
|
||||
Serial.println("LED RED pin already used");
|
||||
debugger->println(F("LED RED pin already used"));
|
||||
return false;
|
||||
}
|
||||
if(pinUsed(config.ledPinGreen, config)) {
|
||||
Serial.println("LED GREEN pin already used");
|
||||
debugger->println(F("LED GREEN pin already used"));
|
||||
return false;
|
||||
}
|
||||
if(pinUsed(config.ledPinBlue, config)) {
|
||||
Serial.println("LED BLUE pin already used");
|
||||
debugger->println(F("LED BLUE pin already used"));
|
||||
return false;
|
||||
}
|
||||
if(pinUsed(config.tempSensorPin, config)) {
|
||||
Serial.println("Temp sensor pin already used");
|
||||
debugger->println(F("Temp sensor pin already used"));
|
||||
return false;
|
||||
}
|
||||
if(pinUsed(config.tempAnalogSensorPin, config)) {
|
||||
Serial.println("Analog temp sensor pin already used");
|
||||
debugger->println(F("Analog temp sensor pin already used"));
|
||||
return false;
|
||||
}
|
||||
if(pinUsed(config.vccPin, config)) {
|
||||
Serial.println("Vcc pin already used");
|
||||
debugger->println(F("Vcc pin already used"));
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
@@ -875,8 +875,6 @@ void AmsConfiguration::loadTempSensors() {
|
||||
int address = EEPROM_TEMP_CONFIG_ADDRESS;
|
||||
int c = 0;
|
||||
int storedCount = EEPROM.read(address++);
|
||||
Serial.print("Sensors: ");
|
||||
Serial.println(storedCount);
|
||||
if(storedCount > 0 && storedCount <= 32) {
|
||||
for(int i = 0; i < storedCount; i++) {
|
||||
TempSensorConfig* tsc = new TempSensorConfig();
|
||||
@@ -1178,155 +1176,155 @@ void AmsConfiguration::deleteFromFs(uint8_t version) {
|
||||
|
||||
void AmsConfiguration::print(Print* debugger)
|
||||
{
|
||||
debugger->println("-----------------------------------------------");
|
||||
debugger->println(F("-----------------------------------------------"));
|
||||
WiFiConfig wifi;
|
||||
if(getWiFiConfig(wifi)) {
|
||||
debugger->println("--WiFi configuration--");
|
||||
debugger->printf("SSID: '%s'\r\n", wifi.ssid);
|
||||
debugger->printf("Psk: '%s'\r\n", wifi.psk);
|
||||
debugger->println(F("--WiFi configuration--"));
|
||||
debugger->printf_P(PSTR("SSID: '%s'\r\n"), wifi.ssid);
|
||||
debugger->printf_P(PSTR("Psk: '%s'\r\n"), wifi.psk);
|
||||
if(strlen(wifi.ip) > 0) {
|
||||
debugger->printf("IP: '%s'\r\n", wifi.ip);
|
||||
debugger->printf("Gateway: '%s'\r\n", wifi.gateway);
|
||||
debugger->printf("Subnet: '%s'\r\n", wifi.subnet);
|
||||
debugger->printf("DNS1: '%s'\r\n", wifi.dns1);
|
||||
debugger->printf("DNS2: '%s'\r\n", wifi.dns2);
|
||||
debugger->printf_P(PSTR("IP: '%s'\r\n"), wifi.ip);
|
||||
debugger->printf_P(PSTR("Gateway: '%s'\r\n"), wifi.gateway);
|
||||
debugger->printf_P(PSTR("Subnet: '%s'\r\n"), wifi.subnet);
|
||||
debugger->printf_P(PSTR("DNS1: '%s'\r\n"), wifi.dns1);
|
||||
debugger->printf_P(PSTR("DNS2: '%s'\r\n"), wifi.dns2);
|
||||
}
|
||||
debugger->printf("Hostname: '%s'\r\n", wifi.hostname);
|
||||
debugger->printf("mDNS: '%s'\r\n", wifi.mdns ? "Yes" : "No");
|
||||
debugger->println("");
|
||||
debugger->printf_P(PSTR("Hostname: '%s'\r\n"), wifi.hostname);
|
||||
debugger->printf_P(PSTR("mDNS: '%s'\r\n"), wifi.mdns ? "Yes" : "No");
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
Serial.flush();
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
MqttConfig mqtt;
|
||||
if(getMqttConfig(mqtt)) {
|
||||
debugger->println("--MQTT configuration--");
|
||||
debugger->println(F("--MQTT configuration--"));
|
||||
if(strlen(mqtt.host) > 0) {
|
||||
debugger->printf("Enabled: Yes\r\n");
|
||||
debugger->printf("Host: '%s'\r\n", mqtt.host);
|
||||
debugger->printf("Port: %i\r\n", mqtt.port);
|
||||
debugger->printf("Client ID: '%s'\r\n", mqtt.clientId);
|
||||
debugger->printf("Publish topic: '%s'\r\n", mqtt.publishTopic);
|
||||
debugger->printf("Subscribe topic: '%s'\r\n", mqtt.subscribeTopic);
|
||||
debugger->printf_P(PSTR("Enabled: Yes\r\n"));
|
||||
debugger->printf_P(PSTR("Host: '%s'\r\n"), mqtt.host);
|
||||
debugger->printf_P(PSTR("Port: %i\r\n"), mqtt.port);
|
||||
debugger->printf_P(PSTR("Client ID: '%s'\r\n"), mqtt.clientId);
|
||||
debugger->printf_P(PSTR("Publish topic: '%s'\r\n"), mqtt.publishTopic);
|
||||
debugger->printf_P(PSTR("Subscribe topic: '%s'\r\n"), mqtt.subscribeTopic);
|
||||
if (strlen(mqtt.username) > 0) {
|
||||
debugger->printf("Username: '%s'\r\n", mqtt.username);
|
||||
debugger->printf("Password: '%s'\r\n", mqtt.password);
|
||||
debugger->printf_P(PSTR("Username: '%s'\r\n"), mqtt.username);
|
||||
debugger->printf_P(PSTR("Password: '%s'\r\n"), mqtt.password);
|
||||
}
|
||||
debugger->printf("Payload format: %i\r\n", mqtt.payloadFormat);
|
||||
debugger->printf("SSL: %s\r\n", mqtt.ssl ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("Payload format: %i\r\n"), mqtt.payloadFormat);
|
||||
debugger->printf_P(PSTR("SSL: %s\r\n"), mqtt.ssl ? "Yes" : "No");
|
||||
} else {
|
||||
debugger->printf("Enabled: No\r\n");
|
||||
debugger->printf_P(PSTR("Enabled: No\r\n"));
|
||||
}
|
||||
debugger->println("");
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
Serial.flush();
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
WebConfig web;
|
||||
if(getWebConfig(web)) {
|
||||
debugger->println("--Web configuration--");
|
||||
debugger->printf("Security: %i\r\n", web.security);
|
||||
debugger->println(F("--Web configuration--"));
|
||||
debugger->printf_P(PSTR("Security: %i\r\n"), web.security);
|
||||
if (web.security > 0) {
|
||||
debugger->printf("Username: '%s'\r\n", web.username);
|
||||
debugger->printf("Password: '%s'\r\n", web.password);
|
||||
debugger->printf_P(PSTR("Username: '%s'\r\n"), web.username);
|
||||
debugger->printf_P(PSTR("Password: '%s'\r\n"), web.password);
|
||||
}
|
||||
debugger->println("");
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
Serial.flush();
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
MeterConfig meter;
|
||||
if(getMeterConfig(meter)) {
|
||||
debugger->println("--Meter configuration--");
|
||||
debugger->printf("Baud: %i\r\n", meter.baud);
|
||||
debugger->printf("Parity: %i\r\n", meter.parity);
|
||||
debugger->printf("Invert serial: %s\r\n", meter.invert ? "Yes" : "No");
|
||||
debugger->printf("Distribution system: %i\r\n", meter.distributionSystem);
|
||||
debugger->printf("Main fuse: %i\r\n", meter.mainFuse);
|
||||
debugger->printf("Production Capacity: %i\r\n", meter.productionCapacity);
|
||||
debugger->println("");
|
||||
debugger->println(F("--Meter configuration--"));
|
||||
debugger->printf_P(PSTR("Baud: %i\r\n"), meter.baud);
|
||||
debugger->printf_P(PSTR("Parity: %i\r\n"), meter.parity);
|
||||
debugger->printf_P(PSTR("Invert serial: %s\r\n"), meter.invert ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("Distribution system: %i\r\n"), meter.distributionSystem);
|
||||
debugger->printf_P(PSTR("Main fuse: %i\r\n"), meter.mainFuse);
|
||||
debugger->printf_P(PSTR("Production Capacity: %i\r\n"), meter.productionCapacity);
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
Serial.flush();
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
GpioConfig gpio;
|
||||
if(getGpioConfig(gpio)) {
|
||||
debugger->println("--GPIO configuration--");
|
||||
debugger->printf("HAN pin: %i\r\n", gpio.hanPin);
|
||||
debugger->printf("HAN pin pullup %s\r\n", gpio.hanPinPullup ? "Yes" : "No");
|
||||
debugger->printf("LED pin: %i\r\n", gpio.ledPin);
|
||||
debugger->printf("LED inverted: %s\r\n", gpio.ledInverted ? "Yes" : "No");
|
||||
debugger->printf("LED red pin: %i\r\n", gpio.ledPinRed);
|
||||
debugger->printf("LED green pin: %i\r\n", gpio.ledPinGreen);
|
||||
debugger->printf("LED blue pin: %i\r\n", gpio.ledPinBlue);
|
||||
debugger->printf("LED inverted: %s\r\n", gpio.ledRgbInverted ? "Yes" : "No");
|
||||
debugger->printf("AP pin: %i\r\n", gpio.apPin);
|
||||
debugger->printf("Temperature pin: %i\r\n", gpio.tempSensorPin);
|
||||
debugger->printf("Temp analog pin: %i\r\n", gpio.tempAnalogSensorPin);
|
||||
debugger->printf("Vcc pin: %i\r\n", gpio.vccPin);
|
||||
debugger->println(F("--GPIO configuration--"));
|
||||
debugger->printf_P(PSTR("HAN pin: %i\r\n"), gpio.hanPin);
|
||||
debugger->printf_P(PSTR("HAN pin pullup %s\r\n"), gpio.hanPinPullup ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("LED pin: %i\r\n"), gpio.ledPin);
|
||||
debugger->printf_P(PSTR("LED inverted: %s\r\n"), gpio.ledInverted ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("LED red pin: %i\r\n"), gpio.ledPinRed);
|
||||
debugger->printf_P(PSTR("LED green pin: %i\r\n"), gpio.ledPinGreen);
|
||||
debugger->printf_P(PSTR("LED blue pin: %i\r\n"), gpio.ledPinBlue);
|
||||
debugger->printf_P(PSTR("LED inverted: %s\r\n"), gpio.ledRgbInverted ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("AP pin: %i\r\n"), gpio.apPin);
|
||||
debugger->printf_P(PSTR("Temperature pin: %i\r\n"), gpio.tempSensorPin);
|
||||
debugger->printf_P(PSTR("Temp analog pin: %i\r\n"), gpio.tempAnalogSensorPin);
|
||||
debugger->printf_P(PSTR("Vcc pin: %i\r\n"), gpio.vccPin);
|
||||
if(gpio.vccMultiplier > 0) {
|
||||
debugger->printf("Vcc multiplier: %f\r\n", gpio.vccMultiplier / 1000.0);
|
||||
debugger->printf_P(PSTR("Vcc multiplier: %f\r\n"), gpio.vccMultiplier / 1000.0);
|
||||
}
|
||||
if(gpio.vccOffset > 0) {
|
||||
debugger->printf("Vcc offset: %f\r\n", gpio.vccOffset / 100.0);
|
||||
debugger->printf_P(PSTR("Vcc offset: %f\r\n"), gpio.vccOffset / 100.0);
|
||||
}
|
||||
if(gpio.vccBootLimit > 0) {
|
||||
debugger->printf("Vcc boot limit: %f\r\n", gpio.vccBootLimit / 10.0);
|
||||
debugger->printf_P(PSTR("Vcc boot limit: %f\r\n"), gpio.vccBootLimit / 10.0);
|
||||
}
|
||||
debugger->printf("GND resistor: %i\r\n", gpio.vccResistorGnd);
|
||||
debugger->printf("Vcc resistor: %i\r\n", gpio.vccResistorVcc);
|
||||
debugger->println("");
|
||||
debugger->printf_P(PSTR("GND resistor: %i\r\n"), gpio.vccResistorGnd);
|
||||
debugger->printf_P(PSTR("Vcc resistor: %i\r\n"), gpio.vccResistorVcc);
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
Serial.flush();
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
DomoticzConfig domo;
|
||||
if(getDomoticzConfig(domo)) {
|
||||
debugger->println("--Domoticz configuration--");
|
||||
debugger->println(F("--Domoticz configuration--"));
|
||||
if(mqtt.payloadFormat == 3 && domo.elidx > 0) {
|
||||
debugger->printf("Enabled: Yes\r\n");
|
||||
debugger->printf("Domoticz ELIDX: %i\r\n", domo.elidx);
|
||||
debugger->printf("Domoticz VL1IDX: %i\r\n", domo.vl1idx);
|
||||
debugger->printf("Domoticz VL2IDX: %i\r\n", domo.vl2idx);
|
||||
debugger->printf("Domoticz VL3IDX: %i\r\n", domo.vl3idx);
|
||||
debugger->printf("Domoticz CL1IDX: %i\r\n", domo.cl1idx);
|
||||
debugger->printf_P(PSTR("Enabled: Yes\r\n"));
|
||||
debugger->printf_P(PSTR("Domoticz ELIDX: %i\r\n"), domo.elidx);
|
||||
debugger->printf_P(PSTR("Domoticz VL1IDX: %i\r\n"), domo.vl1idx);
|
||||
debugger->printf_P(PSTR("Domoticz VL2IDX: %i\r\n"), domo.vl2idx);
|
||||
debugger->printf_P(PSTR("Domoticz VL3IDX: %i\r\n"), domo.vl3idx);
|
||||
debugger->printf_P(PSTR("Domoticz CL1IDX: %i\r\n"), domo.cl1idx);
|
||||
} else {
|
||||
debugger->printf("Enabled: No\r\n");
|
||||
debugger->printf_P(PSTR("Enabled: No\r\n"));
|
||||
}
|
||||
debugger->println("");
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
Serial.flush();
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
NtpConfig ntp;
|
||||
if(getNtpConfig(ntp)) {
|
||||
debugger->println("--NTP configuration--");
|
||||
debugger->printf("Enabled: %s\r\n", ntp.enable ? "Yes" : "No");
|
||||
debugger->println(F("--NTP configuration--"));
|
||||
debugger->printf_P(PSTR("Enabled: %s\r\n"), ntp.enable ? "Yes" : "No");
|
||||
if(ntp.enable) {
|
||||
debugger->printf("Timezone: %s\r\n", ntp.timezone);
|
||||
debugger->printf("Server: %s\r\n", ntp.server);
|
||||
debugger->printf("DHCP: %s\r\n", ntp.dhcp ? "Yes" : "No");
|
||||
debugger->printf_P(PSTR("Timezone: %s\r\n"), ntp.timezone);
|
||||
debugger->printf_P(PSTR("Server: %s\r\n"), ntp.server);
|
||||
debugger->printf_P(PSTR("DHCP: %s\r\n"), ntp.dhcp ? "Yes" : "No");
|
||||
}
|
||||
debugger->println("");
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
Serial.flush();
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
EntsoeConfig entsoe;
|
||||
if(getEntsoeConfig(entsoe)) {
|
||||
if(strlen(entsoe.area) > 0) {
|
||||
debugger->println("--ENTSO-E configuration--");
|
||||
debugger->printf("Area: %s\r\n", entsoe.area);
|
||||
debugger->printf("Currency: %s\r\n", entsoe.currency);
|
||||
debugger->printf("Multiplier: %f\r\n", entsoe.multiplier / 1000.0);
|
||||
debugger->printf("Token: %s\r\n", entsoe.token);
|
||||
debugger->println(F("--ENTSO-E configuration--"));
|
||||
debugger->printf_P(PSTR("Area: %s\r\n"), entsoe.area);
|
||||
debugger->printf_P(PSTR("Currency: %s\r\n"), entsoe.currency);
|
||||
debugger->printf_P(PSTR("Multiplier: %f\r\n"), entsoe.multiplier / 1000.0);
|
||||
debugger->printf_P(PSTR("Token: %s\r\n"), entsoe.token);
|
||||
}
|
||||
debugger->println("");
|
||||
debugger->println(F(""));
|
||||
delay(10);
|
||||
Serial.flush();
|
||||
debugger->flush();
|
||||
}
|
||||
|
||||
debugger->printf("Temp sensor count: %i\r\n", this->getTempSensorCount());
|
||||
debugger->printf_P(PSTR("Temp sensor count: %i\r\n"), this->getTempSensorCount());
|
||||
|
||||
debugger->println("-----------------------------------------------");
|
||||
debugger->println(F("-----------------------------------------------"));
|
||||
}
|
||||
|
||||
@@ -18,32 +18,32 @@ void AmsDataStorage::setTimezone(Timezone* tz) {
|
||||
|
||||
bool AmsDataStorage::update(AmsData* data) {
|
||||
if(isHappy()) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Data is up to date\n");
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Data is up to date\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
time_t now = time(nullptr);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Time is: %lu\n", (int32_t) now);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Time is: %lu\n"), (int32_t) now);
|
||||
if(tz == NULL) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Timezone is missing\n");
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Timezone is missing\n"));
|
||||
return false;
|
||||
}
|
||||
if(now < BUILD_EPOCH) {
|
||||
if(data->getMeterTimestamp() > BUILD_EPOCH) {
|
||||
now = data->getMeterTimestamp();
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
debugger->printf("(AmsDataStorage) Using meter timestamp, which is: %lu\n", (int32_t) now);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Using meter timestamp, which is: %lu\n"), (int32_t) now);
|
||||
}
|
||||
} else if(data->getPackageTimestamp() > BUILD_EPOCH) {
|
||||
now = data->getPackageTimestamp();
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
debugger->printf("(AmsDataStorage) Using package timestamp, which is: %lu\n", (int32_t) now);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Using package timestamp, which is: %lu\n"), (int32_t) now);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(now < BUILD_EPOCH) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) {
|
||||
debugger->printf("(AmsDataStorage) Invalid time: %lu\n", (int32_t) now);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Invalid time: %lu\n"), (int32_t) now);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
// Clear hours between last update and now
|
||||
if(day.lastMeterReadTime > now) {
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) {
|
||||
debugger->printf("(AmsDataStorage) Invalid future timestamp for day plot, resetting\n");
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Invalid future timestamp for day plot, resetting\n"));
|
||||
}
|
||||
day.activeImport = importCounter;
|
||||
day.activeExport = exportCounter;
|
||||
@@ -68,13 +68,13 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
return true;
|
||||
} else {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
debugger->printf("(AmsDataStorage) Last day update: %lu\n", (int32_t) day.lastMeterReadTime);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Last day update: %lu\n"), (int32_t) day.lastMeterReadTime);
|
||||
}
|
||||
tmElements_t last;
|
||||
breakTime(day.lastMeterReadTime, last);
|
||||
for(int i = last.Hour; i < utc.Hour; i++) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) {
|
||||
debugger->printf("(AmsDataStorage) Clearing hour: %d\n", i);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Clearing hour: %d\n"), i);
|
||||
}
|
||||
setHourImport(i, 0);
|
||||
setHourExport(i, 0);
|
||||
@@ -84,20 +84,20 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
// Clear days between last update and now
|
||||
if(month.lastMeterReadTime > now) {
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) {
|
||||
debugger->printf("(AmsDataStorage) Invalid future timestamp for month plot, resetting\n");
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Invalid future timestamp for month plot, resetting\n"));
|
||||
}
|
||||
month.activeImport = importCounter;
|
||||
month.activeExport = exportCounter;
|
||||
month.lastMeterReadTime = now;
|
||||
} else {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
debugger->printf("(AmsDataStorage) Last month update: %lu\n", (int32_t) month.lastMeterReadTime);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Last month update: %lu\n"), (int32_t) month.lastMeterReadTime);
|
||||
}
|
||||
tmElements_t last;
|
||||
breakTime(tz->toLocal(month.lastMeterReadTime), last);
|
||||
for(int i = last.Day; i < ltz.Day; i++) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) {
|
||||
debugger->printf("(AmsDataStorage) Clearing day: %d\n", i);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Clearing day: %d\n"), i);
|
||||
}
|
||||
setDayImport(i, 0);
|
||||
setDayExport(i, 0);
|
||||
@@ -105,7 +105,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
}
|
||||
|
||||
if(data->getListType() < 3) {
|
||||
debugger->printf("(AmsDataStorage) Not enough data in list type: %d\n", data->getListType());
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Not enough data in list type: %d\n"), data->getListType());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
day.activeExport = exportCounter;
|
||||
day.lastMeterReadTime = now;
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) {
|
||||
debugger->printf("(AmsDataStorage) Too long since last day update, clearing data\n");
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Too long since last day update, clearing data\n"));
|
||||
}
|
||||
for(int i = 0; i<24; i++) {
|
||||
setHourImport(i, 0);
|
||||
@@ -136,7 +136,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
setHourImport(utcYesterday.Hour, imp);
|
||||
setHourExport(utcYesterday.Hour, exp);
|
||||
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(AmsDataStorage) Usage for hour %d: %d - %d\n", ltzYesterDay.Hour, imp, exp);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(AmsDataStorage) Usage for hour %d: %d - %d\n"), ltzYesterDay.Hour, imp, exp);
|
||||
day.activeImport = importCounter;
|
||||
day.activeExport = exportCounter;
|
||||
day.lastMeterReadTime = now;
|
||||
@@ -148,7 +148,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
float epm = ex / mins;
|
||||
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
debugger->printf("(AmsDataStorage) Since last day update, minutes: %.1f, import: %d (%.2f/min), export: %d (%.2f/min)\n", mins, im, ipm, ex, epm);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Since last day update, minutes: %.1f, import: %d (%.2f/min), export: %d (%.2f/min)\n"), mins, im, ipm, ex, epm);
|
||||
}
|
||||
|
||||
tmElements_t last;
|
||||
@@ -167,7 +167,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
setHourExport(last.Hour, exp);
|
||||
|
||||
if(debugger->isActive(RemoteDebug::INFO)) {
|
||||
debugger->printf("(AmsDataStorage) Estimated usage for hour %u: %.1f - %.1f (%lu)\n", last.Hour, imp, exp, (int32_t) cur);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Estimated usage for hour %u: %.1f - %.1f (%lu)\n"), last.Hour, imp, exp, (int32_t) cur);
|
||||
}
|
||||
|
||||
day.activeImport += imp;
|
||||
@@ -191,7 +191,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
month.activeExport = exportCounter;
|
||||
month.lastMeterReadTime = now;
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) {
|
||||
debugger->printf("(AmsDataStorage) Too long since last month update, clearing data\n");
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Too long since last month update, clearing data\n"));
|
||||
}
|
||||
for(int i = 1; i<=31; i++) {
|
||||
setDayImport(i, 0);
|
||||
@@ -202,7 +202,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
int32_t exp = exportCounter - month.activeExport;
|
||||
|
||||
if(debugger->isActive(RemoteDebug::INFO)) {
|
||||
debugger->printf("(AmsDataStorage) Usage for day %d: %d - %d\n", ltzYesterDay.Day, imp, exp);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Usage for day %d: %d - %d\n"), ltzYesterDay.Day, imp, exp);
|
||||
}
|
||||
|
||||
setDayImport(ltzYesterDay.Day, imp);
|
||||
@@ -216,7 +216,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
breakTime(tz->toLocal(month.lastMeterReadTime), last);
|
||||
month.lastMeterReadTime = month.lastMeterReadTime - (last.Hour * 3600) - (last.Minute * 60) - last.Second;
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
debugger->printf("(AmsDataStorage) Last month read after resetting to midnight: %lu\n", (int32_t) month.lastMeterReadTime);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Last month read after resetting to midnight: %lu\n"), (int32_t) month.lastMeterReadTime);
|
||||
}
|
||||
|
||||
float hrs = (now - month.lastMeterReadTime) / 3600.0;
|
||||
@@ -226,7 +226,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
float eph = ex / hrs;
|
||||
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
debugger->printf("(AmsDataStorage) Since last month update, hours: %.1f, import: %d (%.2f/hr), export: %d (%.2f/hr)\n", hrs, im, iph, ex, eph);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Since last month update, hours: %.1f, import: %d (%.2f/hr), export: %d (%.2f/hr)\n"), hrs, im, iph, ex, eph);
|
||||
}
|
||||
|
||||
time_t stopAt = now - (ltz.Hour * 3600) - (ltz.Minute * 60) - ltz.Second;
|
||||
@@ -241,7 +241,7 @@ bool AmsDataStorage::update(AmsData* data) {
|
||||
setDayExport(last.Day, exp);
|
||||
|
||||
if(debugger->isActive(RemoteDebug::INFO)) {
|
||||
debugger->printf("(AmsDataStorage) Estimated usage for day %u: %.1f - %.1f (%lu)\n", last.Day, imp, exp, (int32_t) cur);
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Estimated usage for day %u: %.1f - %.1f (%lu)\n"), last.Day, imp, exp, (int32_t) cur);
|
||||
}
|
||||
|
||||
month.activeImport += imp;
|
||||
@@ -413,7 +413,7 @@ uint32_t AmsDataStorage::getDayExport(uint8_t day) {
|
||||
bool AmsDataStorage::load() {
|
||||
if(!LittleFS.begin()) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) {
|
||||
debugger->printf("(AmsDataStorage) Unable to load LittleFS\n");
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Unable to load LittleFS\n"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -445,7 +445,7 @@ bool AmsDataStorage::load() {
|
||||
bool AmsDataStorage::save() {
|
||||
if(!LittleFS.begin()) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) {
|
||||
debugger->printf("(AmsDataStorage) Unable to load LittleFS\n");
|
||||
debugger->printf_P(PSTR("(AmsDataStorage) Unable to load LittleFS\n"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -559,17 +559,17 @@ bool AmsDataStorage::isDayHappy() {
|
||||
tmElements_t tm, last;
|
||||
|
||||
if(now < day.lastMeterReadTime) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Day data timestamp %lu < %lu\n", (int32_t) now, (int32_t) day.lastMeterReadTime);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Day data timestamp %lu < %lu\n"), (int32_t) now, (int32_t) day.lastMeterReadTime);
|
||||
return false;
|
||||
}
|
||||
breakTime(tz->toLocal(now), tm);
|
||||
breakTime(tz->toLocal(day.lastMeterReadTime), last);
|
||||
if(now-day.lastMeterReadTime > 3600) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Day data timestamp age %lu - %lu > 3600\n", (int32_t) now, (int32_t) day.lastMeterReadTime);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Day data timestamp age %lu - %lu > 3600\n"), (int32_t) now, (int32_t) day.lastMeterReadTime);
|
||||
return false;
|
||||
}
|
||||
if(tm.Hour > last.Hour) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Day data hour of last timestamp %d > %d\n", tm.Hour, last.Hour);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Day data hour of last timestamp %d > %d\n"), tm.Hour, last.Hour);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ bool AmsDataStorage::isDayHappy() {
|
||||
|
||||
bool AmsDataStorage::isMonthHappy() {
|
||||
if(tz == NULL) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Timezone is missing\n");
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Timezone is missing\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -587,14 +587,14 @@ bool AmsDataStorage::isMonthHappy() {
|
||||
tmElements_t tm, last;
|
||||
|
||||
if(now < month.lastMeterReadTime) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Month data timestamp %lu < %lu\n", (int32_t) now, (int32_t) month.lastMeterReadTime);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Month data timestamp %lu < %lu\n"), (int32_t) now, (int32_t) month.lastMeterReadTime);
|
||||
return false;
|
||||
}
|
||||
|
||||
breakTime(tz->toLocal(now), tm);
|
||||
breakTime(tz->toLocal(month.lastMeterReadTime), last);
|
||||
if(tm.Day > last.Day) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Month data day of last timestamp %d > %d\n", tm.Day, last.Day);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(AmsDataStorage) Month data day of last timestamp %d > %d\n"), tm.Day, last.Day);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
double getIncomeThisMonth();
|
||||
uint16_t getIncomeLastMonth();
|
||||
|
||||
float getMonthMax();
|
||||
double getMonthMax();
|
||||
uint8_t getCurrentThreshold();
|
||||
EnergyAccountingPeak getPeak(uint8_t);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
time_t now = time(nullptr);
|
||||
if(now < BUILD_EPOCH) return false;
|
||||
if(tz == NULL) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) Timezone is missing\n");
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) Timezone is missing\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
if(!init) {
|
||||
currentHour = local.Hour;
|
||||
currentDay = local.Day;
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Initializing data at %lu\n", (int32_t) now);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EnergyAccounting) Initializing data at %lu\n"), (int32_t) now);
|
||||
if(!load()) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) Unable to load existing data\n");
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EnergyAccounting) Unable to load existing data\n"));
|
||||
data = { 5, local.Month,
|
||||
0, 0, 0, // Cost
|
||||
0, 0, 0, // Income
|
||||
@@ -60,22 +60,22 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
};
|
||||
} else if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
for(uint8_t i = 0; i < 5; i++) {
|
||||
debugger->printf("(EnergyAccounting) Peak hour from day %d: %d\n", data.peaks[i].day, data.peaks[i].value*10);
|
||||
debugger->printf_P(PSTR("(EnergyAccounting) Peak hour from day %d: %d\n"), data.peaks[i].day, data.peaks[i].value*10);
|
||||
}
|
||||
debugger->printf("(EnergyAccounting) Loaded cost yesterday: %.2f, this month: %d, last month: %d\n", data.costYesterday / 10.0, data.costThisMonth, data.costLastMonth);
|
||||
debugger->printf("(EnergyAccounting) Loaded income yesterday: %.2f, this month: %d, last month: %d\n", data.incomeYesterday / 10.0, data.incomeThisMonth, data.incomeLastMonth);
|
||||
debugger->printf_P(PSTR("(EnergyAccounting) Loaded cost yesterday: %.2f, this month: %d, last month: %d\n"), data.costYesterday / 10.0, data.costThisMonth, data.costLastMonth);
|
||||
debugger->printf_P(PSTR("(EnergyAccounting) Loaded income yesterday: %.2f, this month: %d, last month: %d\n"), data.incomeYesterday / 10.0, data.incomeThisMonth, data.incomeLastMonth);
|
||||
}
|
||||
init = true;
|
||||
}
|
||||
|
||||
float price = getPriceForHour(0);
|
||||
if(!initPrice && eapi != NULL && price != ENTSOE_NO_VALUE) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Initializing prices at %lu\n", (int32_t) now);
|
||||
double price = getPriceForHour(0);
|
||||
if(!initPrice && price != ENTSOE_NO_VALUE) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EnergyAccounting) Initializing prices at %lu\n"), (int32_t) now);
|
||||
calcDayCost();
|
||||
}
|
||||
|
||||
if(local.Hour != currentHour && (amsData->getListType() >= 3 || local.Minute == 1)) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) New local hour %d\n", local.Hour);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EnergyAccounting) New local hour %d\n"), local.Hour);
|
||||
|
||||
tmElements_t oneHrAgo, oneHrAgoLocal;
|
||||
breakTime(now-3600, oneHrAgo);
|
||||
@@ -95,7 +95,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
incomeHour = 0;
|
||||
|
||||
if(local.Day != currentDay) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) New day %d\n", local.Day);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EnergyAccounting) New day %d\n"), local.Day);
|
||||
data.costYesterday = costDay * 10;
|
||||
data.costThisMonth += costDay;
|
||||
costDay = 0;
|
||||
@@ -109,7 +109,7 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
}
|
||||
|
||||
if(local.Month != data.month) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) New month %d\n", local.Month);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EnergyAccounting) New month %d\n"), local.Month);
|
||||
data.costLastMonth = data.costThisMonth;
|
||||
data.costThisMonth = 0;
|
||||
data.incomeLastMonth = data.incomeThisMonth;
|
||||
@@ -124,34 +124,34 @@ bool EnergyAccounting::update(AmsData* amsData) {
|
||||
}
|
||||
|
||||
unsigned long ms = this->lastUpdateMillis > amsData->getLastUpdateMillis() ? 0 : amsData->getLastUpdateMillis() - this->lastUpdateMillis;
|
||||
float kwhi = (amsData->getActiveImportPower() * (((float) ms) / 3600000.0)) / 1000.0;
|
||||
float kwhe = (amsData->getActiveExportPower() * (((float) ms) / 3600000.0)) / 1000.0;
|
||||
double kwhi = (amsData->getActiveImportPower() * (((double) ms) / 3600000.0)) / 1000.0;
|
||||
double kwhe = (amsData->getActiveExportPower() * (((double) ms) / 3600000.0)) / 1000.0;
|
||||
lastUpdateMillis = amsData->getLastUpdateMillis();
|
||||
if(kwhi > 0) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) Adding %.4f kWh import\n", kwhi);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) Adding %.4f kWh import\n"), kwhi);
|
||||
use += kwhi;
|
||||
if(price != ENTSOE_NO_VALUE) {
|
||||
float cost = price * kwhi;
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) and %.4f %s\n", cost / 100.0, eapi->getCurrency());
|
||||
double cost = price * kwhi;
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), cost / 100.0, eapi->getCurrency());
|
||||
costHour += cost;
|
||||
costDay += cost;
|
||||
}
|
||||
}
|
||||
if(kwhe > 0) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) Adding %.4f kWh export\n", kwhe);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) Adding %.4f kWh export\n"), kwhe);
|
||||
produce += kwhe;
|
||||
if(price != ENTSOE_NO_VALUE) {
|
||||
float income = price * kwhe;
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) and %.4f %s\n", income / 100.0, eapi->getCurrency());
|
||||
double income = price * kwhe;
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) and %.4f %s\n"), income / 100.0, eapi->getCurrency());
|
||||
incomeHour += income;
|
||||
incomeDay += income;
|
||||
}
|
||||
}
|
||||
|
||||
if(config != NULL) {
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) calculating threshold, currently at %d\n", currentThresholdIdx);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) calculating threshold, currently at %d\n"), currentThresholdIdx);
|
||||
while(getMonthMax() > config->thresholds[currentThresholdIdx] && currentThresholdIdx < 10) currentThresholdIdx++;
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(EnergyAccounting) new threshold %d\n", currentThresholdIdx);
|
||||
if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf_P(PSTR("(EnergyAccounting) new threshold %d\n"), currentThresholdIdx);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -162,13 +162,13 @@ void EnergyAccounting::calcDayCost() {
|
||||
tmElements_t local, utc;
|
||||
breakTime(tz->toLocal(now), local);
|
||||
|
||||
if(eapi != NULL && getPriceForHour(0) != ENTSOE_NO_VALUE) {
|
||||
if(getPriceForHour(0) != ENTSOE_NO_VALUE) {
|
||||
if(initPrice) {
|
||||
costDay = 0;
|
||||
incomeDay = 0;
|
||||
}
|
||||
for(int i = 0; i < currentHour; i++) {
|
||||
float price = getPriceForHour(i - local.Hour);
|
||||
double price = getPriceForHour(i - local.Hour);
|
||||
if(price == ENTSOE_NO_VALUE) break;
|
||||
breakTime(now - ((local.Hour - i) * 3600), utc);
|
||||
int16_t wh = ds->getHourImport(utc.Hour);
|
||||
@@ -186,7 +186,7 @@ double EnergyAccounting::getUseThisHour() {
|
||||
}
|
||||
|
||||
double EnergyAccounting::getUseToday() {
|
||||
float ret = 0.0;
|
||||
double ret = 0.0;
|
||||
time_t now = time(nullptr);
|
||||
if(now < BUILD_EPOCH) return 0.0;
|
||||
if(tz == NULL) return 0.0;
|
||||
@@ -202,7 +202,7 @@ double EnergyAccounting::getUseToday() {
|
||||
double EnergyAccounting::getUseThisMonth() {
|
||||
time_t now = time(nullptr);
|
||||
if(now < BUILD_EPOCH) return 0.0;
|
||||
float ret = 0;
|
||||
double ret = 0;
|
||||
for(int i = 0; i < currentDay; i++) {
|
||||
ret += ds->getDayImport(i) / 1000.0;
|
||||
}
|
||||
@@ -214,7 +214,7 @@ double EnergyAccounting::getProducedThisHour() {
|
||||
}
|
||||
|
||||
double EnergyAccounting::getProducedToday() {
|
||||
float ret = 0.0;
|
||||
double ret = 0.0;
|
||||
time_t now = time(nullptr);
|
||||
if(now < BUILD_EPOCH) return 0.0;
|
||||
tmElements_t utc, local;
|
||||
@@ -229,7 +229,7 @@ double EnergyAccounting::getProducedToday() {
|
||||
double EnergyAccounting::getProducedThisMonth() {
|
||||
time_t now = time(nullptr);
|
||||
if(now < BUILD_EPOCH) return 0.0;
|
||||
float ret = 0;
|
||||
double ret = 0;
|
||||
for(int i = 0; i < currentDay; i++) {
|
||||
ret += ds->getDayExport(i) / 1000.0;
|
||||
}
|
||||
@@ -283,7 +283,7 @@ uint8_t EnergyAccounting::getCurrentThreshold() {
|
||||
return config->thresholds[currentThresholdIdx];
|
||||
}
|
||||
|
||||
float EnergyAccounting::getMonthMax() {
|
||||
double EnergyAccounting::getMonthMax() {
|
||||
if(config == NULL)
|
||||
return 0.0;
|
||||
uint8_t count = 0;
|
||||
@@ -352,7 +352,7 @@ EnergyAccountingPeak EnergyAccounting::getPeak(uint8_t num) {
|
||||
bool EnergyAccounting::load() {
|
||||
if(!LittleFS.begin()) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) {
|
||||
debugger->printf("(EnergyAccounting) Unable to load LittleFS\n");
|
||||
debugger->printf_P(PSTR("(EnergyAccounting) Unable to load LittleFS\n"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ bool EnergyAccounting::load() {
|
||||
char buf[file.size()];
|
||||
file.readBytes(buf, file.size());
|
||||
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Data version %d\n", buf[0]);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EnergyAccounting) Data version %d\n"), buf[0]);
|
||||
if(buf[0] == 5) {
|
||||
EnergyAccountingData* data = (EnergyAccountingData*) buf;
|
||||
memcpy(&this->data, data, sizeof(this->data));
|
||||
@@ -428,14 +428,14 @@ bool EnergyAccounting::load() {
|
||||
this->data.peaks[0].value = data->maxHour;
|
||||
ret = true;
|
||||
} else {
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf("(EnergyAccounting) Unknown version\n");
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("(EnergyAccounting) Unknown version\n"));
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
} else {
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf("(EnergyAccounting) File not found\n");
|
||||
if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("(EnergyAccounting) File not found\n"));
|
||||
}
|
||||
|
||||
LittleFS.end();
|
||||
@@ -446,7 +446,7 @@ bool EnergyAccounting::load() {
|
||||
bool EnergyAccounting::save() {
|
||||
if(!LittleFS.begin()) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) {
|
||||
debugger->printf("(EnergyAccounting) Unable to load LittleFS\n");
|
||||
debugger->printf_P(PSTR("(EnergyAccounting) Unable to load LittleFS\n"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -476,7 +476,7 @@ bool EnergyAccounting::updateMax(uint16_t val, uint8_t day) {
|
||||
for(uint8_t i = 0; i < 5; i++) {
|
||||
if(data.peaks[i].day == day || data.peaks[i].day == 0) {
|
||||
if(val > data.peaks[i].value) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) Adding new max %d for day %d which is larger than %d\n", val*10, day, data.peaks[i].value*10);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EnergyAccounting) Adding new max %d for day %d which is larger than %d\n"), val*10, day, data.peaks[i].value*10);
|
||||
data.peaks[i].day = day;
|
||||
data.peaks[i].value = val;
|
||||
return true;
|
||||
@@ -495,7 +495,7 @@ bool EnergyAccounting::updateMax(uint16_t val, uint8_t day) {
|
||||
}
|
||||
}
|
||||
if(idx < 5) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) Adding new max %d for day %d\n", val*10, day);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EnergyAccounting) Adding new max %d for day %d\n"), val*10, day);
|
||||
data.peaks[idx].value = val;
|
||||
data.peaks[idx].day = day;
|
||||
return true;
|
||||
|
||||
@@ -61,8 +61,6 @@ private:
|
||||
bool retrieve(const char* url, Stream* doc);
|
||||
float getCurrencyMultiplier(const char* from, const char* to, time_t t);
|
||||
|
||||
void printD(String fmt, ...);
|
||||
void printE(String fmt, ...);
|
||||
void debugPrint(byte *buffer, int start, int length);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -158,7 +158,7 @@ bool EntsoeApi::loop() {
|
||||
}
|
||||
|
||||
if(currentDay != tm.Day) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Rotating price objects at %lu\n", t);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EntsoeApi) Rotating price objects at %lu\n"), t);
|
||||
if(today != NULL) delete today;
|
||||
if(tomorrow != NULL) {
|
||||
today = tomorrow;
|
||||
@@ -204,7 +204,7 @@ bool EntsoeApi::loop() {
|
||||
bool EntsoeApi::retrieve(const char* url, Stream* doc) {
|
||||
#if defined(ESP32)
|
||||
if(http.begin(url)) {
|
||||
printD("Connection established");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Connection established"));
|
||||
|
||||
#if defined(ESP32)
|
||||
esp_task_wdt_reset();
|
||||
@@ -221,16 +221,16 @@ bool EntsoeApi::retrieve(const char* url, Stream* doc) {
|
||||
#endif
|
||||
|
||||
if(status == HTTP_CODE_OK) {
|
||||
printD("Receiving data");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Receiving data"));
|
||||
http.writeToStream(doc);
|
||||
http.end();
|
||||
lastError = 0;
|
||||
return true;
|
||||
} else {
|
||||
lastError = status;
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("(EntsoeApi) Communication error, returned status: %d\n", status);
|
||||
printE(http.errorToString(status));
|
||||
printD(http.getString());
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(EntsoeApi) Communication error, returned status: %d\n"), status);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf(http.errorToString(status).c_str());
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(http.getString().c_str());
|
||||
|
||||
http.end();
|
||||
return false;
|
||||
@@ -259,17 +259,17 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to, time_t
|
||||
#endif
|
||||
|
||||
snprintf(buf, BufferSize, "https://data.norges-bank.no/api/data/EXR/M.%s.NOK.SP?lastNObservations=1", from);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Retrieving %s to NOK conversion\n", from);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", buf);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EntsoeApi) Retrieving %s to NOK conversion\n"), from);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) url: %s\n"), buf);
|
||||
if(retrieve(buf, &p)) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) got exchange rate %.4f\n", p.getValue());
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) got exchange rate %.4f\n"), p.getValue());
|
||||
currencyMultiplier = p.getValue();
|
||||
if(strncmp(to, "NOK", 3) != 0) {
|
||||
snprintf(buf, BufferSize, "https://data.norges-bank.no/api/data/EXR/M.%s.NOK.SP?lastNObservations=1", to);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Retrieving %s to NOK conversion\n", to);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", buf);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EntsoeApi) Retrieving %s to NOK conversion\n"), to);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) url: %s\n"), buf);
|
||||
if(retrieve(buf, &p)) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) got exchange rate %.4f\n", p.getValue());
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) got exchange rate %.4f\n"), p.getValue());
|
||||
currencyMultiplier /= p.getValue();
|
||||
} else {
|
||||
return 0;
|
||||
@@ -278,7 +278,7 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to, time_t
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) Resulting currency multiplier: %.4f\n", currencyMultiplier);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) Resulting currency multiplier: %.4f\n"), currencyMultiplier);
|
||||
tmElements_t tm;
|
||||
breakTime(t, tm);
|
||||
lastCurrencyFetch = now + (SECS_PER_DAY * 1000) - (((((tm.Hour * 60) + tm.Minute) * 60) + tm.Second) * 1000);
|
||||
@@ -308,8 +308,8 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) {
|
||||
ESP.wdtFeed();
|
||||
#endif
|
||||
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Fetching prices for %d.%d.%d\n", tm.Day, tm.Month, tm.Year+1970);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) url: %s\n", buf);
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("(EntsoeApi) Fetching prices for %d.%d.%d\n"), tm.Day, tm.Month, tm.Year+1970);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) url: %s\n"), buf);
|
||||
EntsoeA44Parser a44;
|
||||
if(retrieve(buf, &a44) && a44.getPoint(0) != ENTSOE_NO_VALUE) {
|
||||
PricesContainer* ret = new PricesContainer();
|
||||
@@ -344,13 +344,13 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) {
|
||||
#endif
|
||||
|
||||
if(status == HTTP_CODE_OK) {
|
||||
printD("Receiving data");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Receiving data"));
|
||||
data = http.getString();
|
||||
http.end();
|
||||
|
||||
uint8_t* content = (uint8_t*) (data.c_str());
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
printD("Received content for prices:");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received content for prices:"));
|
||||
debugPrint(content, 0, data.length());
|
||||
}
|
||||
|
||||
@@ -359,11 +359,11 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) {
|
||||
GCMParser gcm(key, auth);
|
||||
int8_t gcmRet = gcm.parse(content, ctx);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) {
|
||||
printD("Decrypted content for prices:");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Decrypted content for prices:"));
|
||||
debugPrint(content, 0, data.length());
|
||||
}
|
||||
if(gcmRet > 0) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EntsoeApi) Price data starting at: %d\n", gcmRet);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("(EntsoeApi) Price data starting at: %d\n"), gcmRet);
|
||||
PricesContainer* ret = new PricesContainer();
|
||||
for(uint8_t i = 0; i < 25; i++) {
|
||||
ret->points[i] = ENTSOE_NO_VALUE;
|
||||
@@ -376,13 +376,13 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) {
|
||||
return ret;
|
||||
} else {
|
||||
lastError = gcmRet;
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("(EntsoeApi) Error code while decrypting prices: %d\n", gcmRet);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(EntsoeApi) Error code while decrypting prices: %d\n"), gcmRet);
|
||||
}
|
||||
} else {
|
||||
lastError = status;
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf("(EntsoeApi) Communication error, returned status: %d\n", status);
|
||||
printE(http.errorToString(status));
|
||||
printD(http.getString());
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("(EntsoeApi) Communication error, returned status: %d\n"), status);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf(http.errorToString(status).c_str());
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(http.getString().c_str());
|
||||
|
||||
http.end();
|
||||
}
|
||||
@@ -391,34 +391,20 @@ PricesContainer* EntsoeApi::fetchPrices(time_t t) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void EntsoeApi::printD(String fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(String("(EntsoeApi)" + fmt + "\n").c_str(), args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void EntsoeApi::printE(String fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf(String("(EntsoeApi)" + fmt + "\n").c_str(), args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void EntsoeApi::debugPrint(byte *buffer, int start, int length) {
|
||||
for (int i = start; i < start + length; i++) {
|
||||
if (buffer[i] < 0x10)
|
||||
debugger->print("0");
|
||||
debugger->print(F("0"));
|
||||
debugger->print(buffer[i], HEX);
|
||||
debugger->print(" ");
|
||||
debugger->print(F(" "));
|
||||
if ((i - start + 1) % 16 == 0)
|
||||
debugger->println("");
|
||||
debugger->println(F(""));
|
||||
else if ((i - start + 1) % 4 == 0)
|
||||
debugger->print(" ");
|
||||
debugger->print(F(" "));
|
||||
|
||||
yield(); // Let other get some resources too
|
||||
}
|
||||
debugger->println("");
|
||||
debugger->println(F(""));
|
||||
}
|
||||
|
||||
int16_t EntsoeApi::getLastError() {
|
||||
|
||||
@@ -216,7 +216,6 @@ bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||
memset(ts1hr, 0, 24);
|
||||
if(min1hrIdx > -1) {
|
||||
time_t ts = now + (SECS_PER_HOUR * min1hrIdx);
|
||||
//Serial.printf("1hr: %d %lu\n", min1hrIdx, ts);
|
||||
tmElements_t tm;
|
||||
breakTime(ts, tm);
|
||||
sprintf_P(ts1hr, PSTR("%04d-%02d-%02dT%02d:00:00Z"), tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||
@@ -225,7 +224,6 @@ bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||
memset(ts3hr, 0, 24);
|
||||
if(min3hrIdx > -1) {
|
||||
time_t ts = now + (SECS_PER_HOUR * min3hrIdx);
|
||||
//Serial.printf("3hr: %d %lu\n", min3hrIdx, ts);
|
||||
tmElements_t tm;
|
||||
breakTime(ts, tm);
|
||||
sprintf_P(ts3hr, PSTR("%04d-%02d-%02dT%02d:00:00Z"), tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||
@@ -234,7 +232,6 @@ bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||
memset(ts6hr, 0, 24);
|
||||
if(min6hrIdx > -1) {
|
||||
time_t ts = now + (SECS_PER_HOUR * min6hrIdx);
|
||||
//Serial.printf("6hr: %d %lu\n", min6hrIdx, ts);
|
||||
tmElements_t tm;
|
||||
breakTime(ts, tm);
|
||||
sprintf_P(ts6hr, PSTR("%04d-%02d-%02dT%02d:00:00Z"), tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||
|
||||
@@ -234,7 +234,6 @@ bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||
memset(ts1hr, 0, 24);
|
||||
if(min1hrIdx > -1) {
|
||||
time_t ts = now + (SECS_PER_HOUR * min1hrIdx);
|
||||
//Serial.printf("1hr: %d %lu\n", min1hrIdx, ts);
|
||||
tmElements_t tm;
|
||||
breakTime(ts, tm);
|
||||
sprintf(ts1hr, "%04d-%02d-%02dT%02d:00:00Z", tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||
@@ -243,7 +242,6 @@ bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||
memset(ts3hr, 0, 24);
|
||||
if(min3hrIdx > -1) {
|
||||
time_t ts = now + (SECS_PER_HOUR * min3hrIdx);
|
||||
//Serial.printf("3hr: %d %lu\n", min3hrIdx, ts);
|
||||
tmElements_t tm;
|
||||
breakTime(ts, tm);
|
||||
sprintf(ts3hr, "%04d-%02d-%02dT%02d:00:00Z", tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||
@@ -252,7 +250,6 @@ bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||
memset(ts6hr, 0, 24);
|
||||
if(min6hrIdx > -1) {
|
||||
time_t ts = now + (SECS_PER_HOUR * min6hrIdx);
|
||||
//Serial.printf("6hr: %d %lu\n", min6hrIdx, ts);
|
||||
tmElements_t tm;
|
||||
breakTime(ts, tm);
|
||||
sprintf(ts6hr, "%04d-%02d-%02dT%02d:00:00Z", tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||
|
||||
@@ -184,7 +184,6 @@ bool RawMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||
char ts1hr[24];
|
||||
if(min1hrIdx > -1) {
|
||||
time_t ts = now + (SECS_PER_HOUR * min1hrIdx);
|
||||
//Serial.printf("1hr: %d %lu\n", min1hrIdx, ts);
|
||||
tmElements_t tm;
|
||||
breakTime(ts, tm);
|
||||
sprintf(ts1hr, "%04d-%02d-%02dT%02d:00:00Z", tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||
@@ -192,7 +191,6 @@ bool RawMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||
char ts3hr[24];
|
||||
if(min3hrIdx > -1) {
|
||||
time_t ts = now + (SECS_PER_HOUR * min3hrIdx);
|
||||
//Serial.printf("3hr: %d %lu\n", min3hrIdx, ts);
|
||||
tmElements_t tm;
|
||||
breakTime(ts, tm);
|
||||
sprintf(ts3hr, "%04d-%02d-%02dT%02d:00:00Z", tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||
@@ -200,7 +198,6 @@ bool RawMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||
char ts6hr[24];
|
||||
if(min6hrIdx > -1) {
|
||||
time_t ts = now + (SECS_PER_HOUR * min6hrIdx);
|
||||
//Serial.printf("6hr: %d %lu\n", min6hrIdx, ts);
|
||||
tmElements_t tm;
|
||||
breakTime(ts, tm);
|
||||
sprintf(ts6hr, "%04d-%02d-%02dT%02d:00:00Z", tm.Year+1970, tm.Month, tm.Day, tm.Hour);
|
||||
|
||||
@@ -170,9 +170,6 @@ bool AmsWebServer::checkSecurity(byte level, bool send401) {
|
||||
String expectedBase64 = base64::encode(expectedAuth);
|
||||
#endif
|
||||
|
||||
debugger->printf("Expected auth: %s\n", expectedBase64.c_str());
|
||||
debugger->printf("Provided auth: %s\n", providedPwd.c_str());
|
||||
|
||||
access = providedPwd.equals(expectedBase64);
|
||||
}
|
||||
|
||||
@@ -192,21 +189,21 @@ void AmsWebServer::notFound() {
|
||||
}
|
||||
|
||||
void AmsWebServer::githubSvg() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /github.svg over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /github.svg over http...\n"));
|
||||
|
||||
server.sendHeader(HEADER_CACHE_CONTROL, CACHE_1HR);
|
||||
server.send_P(200, "image/svg+xml", GITHUB_SVG);
|
||||
}
|
||||
|
||||
void AmsWebServer::faviconSvg() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /favicon.ico over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /favicon.ico over http...\n"));
|
||||
|
||||
server.sendHeader(HEADER_CACHE_CONTROL, CACHE_1HR);
|
||||
server.send_P(200, "image/svg+xml", FAVICON_SVG);
|
||||
}
|
||||
|
||||
void AmsWebServer::sysinfoJson() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /sysinfo.json over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /sysinfo.json over http...\n"));
|
||||
|
||||
SystemConfig sys;
|
||||
config->getSystemConfig(sys);
|
||||
@@ -343,7 +340,7 @@ void AmsWebServer::sysinfoJson() {
|
||||
if(ds != NULL) {
|
||||
ds->save();
|
||||
}
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf(PSTR("Rebooting"));
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Rebooting"));
|
||||
delay(1000);
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
@@ -355,7 +352,7 @@ void AmsWebServer::sysinfoJson() {
|
||||
}
|
||||
|
||||
void AmsWebServer::dataJson() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /data.json over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /data.json over http...\n"));
|
||||
uint64_t millis = millis64();
|
||||
|
||||
if(!checkSecurity(2, true))
|
||||
@@ -498,7 +495,7 @@ void AmsWebServer::dataJson() {
|
||||
}
|
||||
|
||||
void AmsWebServer::dayplotJson() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /dayplot.json over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /dayplot.json over http...\n"));
|
||||
|
||||
if(!checkSecurity(2))
|
||||
return;
|
||||
@@ -567,7 +564,7 @@ void AmsWebServer::dayplotJson() {
|
||||
}
|
||||
|
||||
void AmsWebServer::monthplotJson() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /monthplot.json over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /monthplot.json over http...\n"));
|
||||
|
||||
if(!checkSecurity(2))
|
||||
return;
|
||||
@@ -650,7 +647,7 @@ void AmsWebServer::monthplotJson() {
|
||||
}
|
||||
|
||||
void AmsWebServer::energyPriceJson() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /energyprice.json over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /energyprice.json over http...\n"));
|
||||
|
||||
if(!checkSecurity(2))
|
||||
return;
|
||||
@@ -709,7 +706,7 @@ void AmsWebServer::energyPriceJson() {
|
||||
}
|
||||
|
||||
void AmsWebServer::temperatureJson() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /temperature.json over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /temperature.json over http...\n"));
|
||||
|
||||
if(!checkSecurity(2))
|
||||
return;
|
||||
@@ -744,7 +741,7 @@ void AmsWebServer::temperatureJson() {
|
||||
}
|
||||
|
||||
void AmsWebServer::indexHtml() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /index.html over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /index.html over http...\n"));
|
||||
|
||||
server.sendHeader(HEADER_CACHE_CONTROL, CACHE_CONTROL_NO_CACHE);
|
||||
server.sendHeader(HEADER_PRAGMA, PRAGMA_NO_CACHE);
|
||||
@@ -757,7 +754,7 @@ void AmsWebServer::indexHtml() {
|
||||
}
|
||||
|
||||
void AmsWebServer::indexCss() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /index.css over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /index.css over http...\n"));
|
||||
|
||||
if(!checkSecurity(2))
|
||||
return;
|
||||
@@ -768,7 +765,7 @@ void AmsWebServer::indexCss() {
|
||||
}
|
||||
|
||||
void AmsWebServer::indexJs() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /index.js over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /index.js over http...\n"));
|
||||
|
||||
if(!checkSecurity(2))
|
||||
return;
|
||||
@@ -779,7 +776,7 @@ void AmsWebServer::indexJs() {
|
||||
}
|
||||
|
||||
void AmsWebServer::configurationJson() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /configuration.json over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /configuration.json over http...\n"));
|
||||
|
||||
if(!checkSecurity(1))
|
||||
return;
|
||||
@@ -971,7 +968,7 @@ void AmsWebServer::configurationJson() {
|
||||
}
|
||||
|
||||
void AmsWebServer::handleSave() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Handling save method from http"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Handling save method from http"));
|
||||
if(!checkSecurity(1))
|
||||
return;
|
||||
|
||||
@@ -1183,7 +1180,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("m")) && server.arg(F("m")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received meter config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received meter config"));
|
||||
config->getMeterConfig(*meterConfig);
|
||||
meterConfig->baud = server.arg(F("mb")).toInt();
|
||||
meterConfig->parity = server.arg(F("mp")).toInt();
|
||||
@@ -1222,7 +1219,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("w")) && server.arg(F("w")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received WiFi config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received WiFi config"));
|
||||
WiFiConfig wifi;
|
||||
config->getWiFiConfig(wifi);
|
||||
strcpy(wifi.ssid, server.arg(F("ws")).c_str());
|
||||
@@ -1264,7 +1261,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("q")) && server.arg(F("q")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received MQTT config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received MQTT config"));
|
||||
MqttConfig mqtt;
|
||||
config->getMqttConfig(mqtt);
|
||||
if(server.hasArg(F("qh")) && !server.arg(F("qh")).isEmpty()) {
|
||||
@@ -1295,7 +1292,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("o")) && server.arg(F("o")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received Domoticz config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received Domoticz config"));
|
||||
DomoticzConfig domo {
|
||||
static_cast<uint16_t>(server.arg(F("oe")).toInt()),
|
||||
static_cast<uint16_t>(server.arg(F("ou1")).toInt()),
|
||||
@@ -1307,7 +1304,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("h")) && server.arg(F("h")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received Home-Assistant config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received Home-Assistant config"));
|
||||
HomeAssistantConfig haconf;
|
||||
config->getHomeAssistantConfig(haconf);
|
||||
strcpy(haconf.discoveryPrefix, server.arg(F("ht")).c_str());
|
||||
@@ -1317,7 +1314,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("g")) && server.arg(F("g")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received web config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received web config"));
|
||||
webConfig.security = server.arg(F("gs")).toInt();
|
||||
if(webConfig.security > 0) {
|
||||
strcpy(webConfig.username, server.arg(F("gu")).c_str());
|
||||
@@ -1347,7 +1344,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("i")) && server.arg(F("i")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received GPIO config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received GPIO config"));
|
||||
gpioConfig->hanPin = server.hasArg(F("ihp")) && !server.arg(F("ihp")).isEmpty() ? server.arg(F("ihp")).toInt() : 3;
|
||||
gpioConfig->hanPinPullup = server.hasArg(F("ihu")) && server.arg(F("ihu")) == F("true");
|
||||
gpioConfig->ledPin = server.hasArg(F("ilp")) && !server.arg(F("ilp")).isEmpty() ? server.arg(F("ilp")).toInt() : 0xFF;
|
||||
@@ -1366,7 +1363,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("iv")) && server.arg(F("iv")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received Vcc config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received Vcc config"));
|
||||
gpioConfig->vccOffset = server.hasArg(F("ivo")) && !server.arg(F("ivo")).isEmpty() ? server.arg(F("ivo")).toFloat() * 100 : 0;
|
||||
gpioConfig->vccMultiplier = server.hasArg(F("ivm")) && !server.arg(F("ivm")).isEmpty() ? server.arg(F("ivm")).toFloat() * 1000 : 1000;
|
||||
gpioConfig->vccBootLimit = server.hasArg(F("ivb")) && !server.arg(F("ivb")).isEmpty() ? server.arg(F("ivb")).toFloat() * 10 : 0;
|
||||
@@ -1374,7 +1371,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("d")) && server.arg(F("d")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received Debug config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received Debug config"));
|
||||
DebugConfig debug;
|
||||
config->getDebugConfig(debug);
|
||||
bool active = debug.serial || debug.telnet;
|
||||
@@ -1421,7 +1418,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("p")) && server.arg(F("p")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received price API config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received price API config"));
|
||||
|
||||
priceRegion = server.arg(F("pr"));
|
||||
|
||||
@@ -1436,7 +1433,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
if(server.hasArg(F("t")) && server.arg(F("t")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Received energy accounting config"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received energy accounting config"));
|
||||
EnergyAccountingConfig eac;
|
||||
eac.thresholds[0] = server.arg(F("t0")).toInt();
|
||||
eac.thresholds[1] = server.arg(F("t1")).toInt();
|
||||
@@ -1451,10 +1448,10 @@ void AmsWebServer::handleSave() {
|
||||
config->setEnergyAccountingConfig(eac);
|
||||
}
|
||||
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf(PSTR("Saving configuration now..."));
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Saving configuration now..."));
|
||||
|
||||
if (config->save()) {
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf(PSTR("Successfully saved."));
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Successfully saved."));
|
||||
if(config->isWifiChanged() || performRestart) {
|
||||
performRestart = true;
|
||||
} else {
|
||||
@@ -1479,7 +1476,7 @@ void AmsWebServer::handleSave() {
|
||||
if(ds != NULL) {
|
||||
ds->save();
|
||||
}
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf(PSTR("Rebooting"));
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Rebooting"));
|
||||
delay(1000);
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
@@ -1491,7 +1488,7 @@ void AmsWebServer::handleSave() {
|
||||
}
|
||||
|
||||
void AmsWebServer::reboot() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /reboot over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /reboot over http...\n"));
|
||||
|
||||
if(!checkSecurity(1))
|
||||
return;
|
||||
@@ -1501,7 +1498,7 @@ void AmsWebServer::reboot() {
|
||||
server.handleClient();
|
||||
delay(250);
|
||||
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf(PSTR("Rebooting"));
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Rebooting"));
|
||||
delay(1000);
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
@@ -1512,7 +1509,7 @@ void AmsWebServer::reboot() {
|
||||
}
|
||||
|
||||
void AmsWebServer::upgrade() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /upgrade over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /upgrade over http...\n"));
|
||||
|
||||
if(!checkSecurity(1))
|
||||
return;
|
||||
@@ -1579,13 +1576,13 @@ void AmsWebServer::upgradeFromUrl(String url, String nextVersion) {
|
||||
config->setUpgradeInformation(ret, ret == HTTP_UPDATE_OK ? 0 : lastError, VERSION, nextVersion.c_str());
|
||||
switch(ret) {
|
||||
case HTTP_UPDATE_FAILED:
|
||||
debugger->printf(PSTR("Update failed\n"));
|
||||
debugger->printf_P(PSTR("Update failed\n"));
|
||||
break;
|
||||
case HTTP_UPDATE_NO_UPDATES:
|
||||
debugger->printf(PSTR("No Update\n"));
|
||||
debugger->printf_P(PSTR("No Update\n"));
|
||||
break;
|
||||
case HTTP_UPDATE_OK:
|
||||
debugger->printf(PSTR("Update OK\n"));
|
||||
debugger->printf_P(PSTR("Update OK\n"));
|
||||
debugger->flush();
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
@@ -1597,7 +1594,7 @@ void AmsWebServer::upgradeFromUrl(String url, String nextVersion) {
|
||||
}
|
||||
|
||||
void AmsWebServer::firmwareHtml() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Serving /firmware.html over http..."));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /firmware.html over http..."));
|
||||
|
||||
if(!checkSecurity(1))
|
||||
return;
|
||||
@@ -1611,7 +1608,7 @@ void AmsWebServer::firmwareHtml() {
|
||||
}
|
||||
|
||||
void AmsWebServer::firmwarePost() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Handling firmware post..."));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Handling firmware post..."));
|
||||
if(!checkSecurity(1))
|
||||
return;
|
||||
|
||||
@@ -1621,7 +1618,7 @@ void AmsWebServer::firmwarePost() {
|
||||
if(server.hasArg(F("url"))) {
|
||||
String url = server.arg(F("url"));
|
||||
if(!url.isEmpty() && (url.startsWith(F("http://")) || url.startsWith(F("https://")))) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Custom firmware URL was provided"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Custom firmware URL was provided"));
|
||||
|
||||
upgradeFromUrl(url, "");
|
||||
server.send(200, MIME_PLAIN, "OK");
|
||||
@@ -1642,7 +1639,7 @@ void AmsWebServer::firmwareUpload() {
|
||||
if(upload.status == UPLOAD_FILE_START) {
|
||||
String filename = upload.filename;
|
||||
if(filename.isEmpty()) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf(PSTR("No file, falling back to post\n"));
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("No file, falling back to post\n"));
|
||||
return;
|
||||
}
|
||||
if(!filename.endsWith(".bin")) {
|
||||
@@ -1668,10 +1665,10 @@ HTTPUpload& AmsWebServer::uploadFile(const char* path) {
|
||||
HTTPUpload& upload = server.upload();
|
||||
if(upload.status == UPLOAD_FILE_START){
|
||||
if(uploading) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf(PSTR("Upload already in progress\n"));
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("Upload already in progress\n"));
|
||||
server.send_P(500, MIME_HTML, PSTR("<html><body><h1>Upload already in progress!</h1></body></html>"));
|
||||
} else if (!LittleFS.begin()) {
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf(PSTR("An Error has occurred while mounting LittleFS\n"));
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("An Error has occurred while mounting LittleFS\n"));
|
||||
server.send_P(500, MIME_HTML, PSTR("<html><body><h1>Unable to mount LittleFS!</h1></body></html>"));
|
||||
} else {
|
||||
uploading = true;
|
||||
@@ -1706,7 +1703,7 @@ HTTPUpload& AmsWebServer::uploadFile(const char* path) {
|
||||
LittleFS.remove(path);
|
||||
LittleFS.end();
|
||||
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf(PSTR("An Error has occurred while writing file"));
|
||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR("An Error has occurred while writing file"));
|
||||
snprintf_P(buf, BufferSize, RESPONSE_JSON,
|
||||
"false",
|
||||
"File size does not match",
|
||||
@@ -1747,13 +1744,13 @@ void AmsWebServer::factoryResetPost() {
|
||||
if(!checkSecurity(1))
|
||||
return;
|
||||
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Performing factory reset"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Performing factory reset"));
|
||||
|
||||
bool success = false;
|
||||
if(server.hasArg(F("perform")) && server.arg(F("perform")) == F("true")) {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Formatting LittleFS"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Formatting LittleFS"));
|
||||
LittleFS.format();
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf(PSTR("Clearing configuration"));
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Clearing configuration"));
|
||||
config->clear();
|
||||
|
||||
success = true;
|
||||
@@ -1770,7 +1767,7 @@ void AmsWebServer::factoryResetPost() {
|
||||
server.handleClient();
|
||||
delay(250);
|
||||
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf(PSTR("Rebooting"));
|
||||
if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Rebooting"));
|
||||
delay(1000);
|
||||
#if defined(ESP8266)
|
||||
ESP.reset();
|
||||
@@ -1833,7 +1830,7 @@ void AmsWebServer::mqttKeyUpload() {
|
||||
}
|
||||
|
||||
void AmsWebServer::tariffJson() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /tariff.json over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /tariff.json over http...\n"));
|
||||
|
||||
if(!checkSecurity(2))
|
||||
return;
|
||||
@@ -1882,7 +1879,7 @@ void AmsWebServer::setPriceSettings(String region, String currency) {
|
||||
}
|
||||
|
||||
void AmsWebServer::configFileDownload() {
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("Serving /configfile.cfg over http...\n");
|
||||
if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Serving /configfile.cfg over http...\n"));
|
||||
|
||||
if(!checkSecurity(1))
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user