mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-26 18:33:12 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c38c305bab | ||
|
|
bfee2a1d64 | ||
|
|
ec7edae9a1 | ||
|
|
d8e265b7ac | ||
|
|
1987cddab7 | ||
|
|
e18be5f97c | ||
|
|
537597d6d1 | ||
|
|
a89013cec3 | ||
|
|
9c7a0cb7ff | ||
|
|
ade12199b9 | ||
|
|
39b68aca51 | ||
|
|
8ac1e034b1 | ||
|
|
f446dff865 |
1
.github/ISSUE_TEMPLATE/bug_report.md
vendored
1
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -33,6 +33,7 @@ If applicable, add screenshots to help explain your problem.
|
|||||||
**Relevant firmware information:**
|
**Relevant firmware information:**
|
||||||
- Version: [e.g. 2.1.0]
|
- Version: [e.g. 2.1.0]
|
||||||
- MQTT: [yes/no]
|
- MQTT: [yes/no]
|
||||||
|
- MQTT payload type: [e.g. JSON]
|
||||||
- HAN GPIO: [e.g. GPIO5]
|
- HAN GPIO: [e.g. GPIO5]
|
||||||
- HAN baud and parity: [e.g. 2400 8E1]
|
- HAN baud and parity: [e.g. 2400 8E1]
|
||||||
- Temperature sensors [e.g. 3xDS18B20]
|
- Temperature sensors [e.g. 3xDS18B20]
|
||||||
|
|||||||
1
.github/ISSUE_TEMPLATE/support.md
vendored
1
.github/ISSUE_TEMPLATE/support.md
vendored
@@ -20,6 +20,7 @@ A clear and concise description of what the problem is.
|
|||||||
**Relevant firmware information:**
|
**Relevant firmware information:**
|
||||||
- Version: [e.g. 2.1.0]
|
- Version: [e.g. 2.1.0]
|
||||||
- MQTT: [yes/no]
|
- MQTT: [yes/no]
|
||||||
|
- MQTT payload type: [e.g. JSON]
|
||||||
- HAN GPIO: [e.g. GPIO5]
|
- HAN GPIO: [e.g. GPIO5]
|
||||||
- HAN baud and parity: [e.g. 2400 8E1]
|
- HAN baud and parity: [e.g. 2400 8E1]
|
||||||
- Temperature sensors [e.g. 3xDS18B20]
|
- Temperature sensors [e.g. 3xDS18B20]
|
||||||
|
|||||||
@@ -510,6 +510,7 @@ bool AmsConfiguration::getEnergyAccountingConfig(EnergyAccountingConfig& config)
|
|||||||
if(config.thresholds[9] != 255) {
|
if(config.thresholds[9] != 255) {
|
||||||
clearEnergyAccountingConfig(config);
|
clearEnergyAccountingConfig(config);
|
||||||
}
|
}
|
||||||
|
if(config.hours > 5) config.hours = 5;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -549,6 +550,7 @@ void AmsConfiguration::clearEnergyAccountingConfig(EnergyAccountingConfig& confi
|
|||||||
config.thresholds[7] = 100;
|
config.thresholds[7] = 100;
|
||||||
config.thresholds[8] = 150;
|
config.thresholds[8] = 150;
|
||||||
config.thresholds[9] = 255;
|
config.thresholds[9] = 255;
|
||||||
|
config.hours = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AmsConfiguration::isEnergyAccountingChanged() {
|
bool AmsConfiguration::isEnergyAccountingChanged() {
|
||||||
|
|||||||
@@ -7,20 +7,20 @@
|
|||||||
|
|
||||||
struct DayDataPoints {
|
struct DayDataPoints {
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
int16_t hImport[24];
|
uint16_t hImport[24];
|
||||||
time_t lastMeterReadTime;
|
time_t lastMeterReadTime;
|
||||||
uint32_t activeImport;
|
uint32_t activeImport;
|
||||||
uint32_t activeExport;
|
uint32_t activeExport;
|
||||||
int16_t hExport[24];
|
uint16_t hExport[24];
|
||||||
}; // 112 bytes
|
}; // 112 bytes
|
||||||
|
|
||||||
struct MonthDataPoints {
|
struct MonthDataPoints {
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
int16_t dImport[31];
|
uint16_t dImport[31];
|
||||||
time_t lastMeterReadTime;
|
time_t lastMeterReadTime;
|
||||||
uint32_t activeImport;
|
uint32_t activeImport;
|
||||||
uint32_t activeExport;
|
uint32_t activeExport;
|
||||||
int16_t dExport[31];
|
uint16_t dExport[31];
|
||||||
}; // 141 bytes
|
}; // 141 bytes
|
||||||
|
|
||||||
class AmsDataStorage {
|
class AmsDataStorage {
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
debugI(" flashing");
|
debugI(" flashing");
|
||||||
File firmwareFile = LittleFS.open(FILE_FIRMWARE, "r");
|
File firmwareFile = LittleFS.open(FILE_FIRMWARE, (char*) "r");
|
||||||
debugD(" firmware size: %d", firmwareFile.size());
|
debugD(" firmware size: %d", firmwareFile.size());
|
||||||
uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
|
uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
|
||||||
debugD(" available: %d", maxSketchSpace);
|
debugD(" available: %d", maxSketchSpace);
|
||||||
@@ -358,7 +358,7 @@ void setup() {
|
|||||||
|
|
||||||
NtpConfig ntp;
|
NtpConfig ntp;
|
||||||
if(config.getNtpConfig(ntp)) {
|
if(config.getNtpConfig(ntp)) {
|
||||||
configTime(ntp.offset*10, ntp.summerOffset*10, ntp.enable ? strlen(ntp.server) > 0 ? ntp.server : "pool.ntp.org" : ""); // Add NTP server by default if none is configured
|
configTime(ntp.offset*10, ntp.summerOffset*10, ntp.enable ? strlen(ntp.server) > 0 ? ntp.server : (char*) F("pool.ntp.org") : (char*) F("")); // Add NTP server by default if none is configured
|
||||||
sntp_servermode_dhcp(ntp.enable && ntp.dhcp ? 1 : 0);
|
sntp_servermode_dhcp(ntp.enable && ntp.dhcp ? 1 : 0);
|
||||||
ntpEnabled = ntp.enable;
|
ntpEnabled = ntp.enable;
|
||||||
TimeChangeRule std = {"STD", Last, Sun, Oct, 3, ntp.offset / 6};
|
TimeChangeRule std = {"STD", Last, Sun, Oct, 3, ntp.offset / 6};
|
||||||
@@ -473,7 +473,7 @@ void loop() {
|
|||||||
if(strlen(wifi.hostname) > 0 && wifi.mdns) {
|
if(strlen(wifi.hostname) > 0 && wifi.mdns) {
|
||||||
debugD("mDNS is enabled, using host: %s", wifi.hostname);
|
debugD("mDNS is enabled, using host: %s", wifi.hostname);
|
||||||
if(MDNS.begin(wifi.hostname)) {
|
if(MDNS.begin(wifi.hostname)) {
|
||||||
MDNS.addService("http", "tcp", 80);
|
MDNS.addService(F("http"), F("tcp"), 80);
|
||||||
} else {
|
} else {
|
||||||
debugE("Failed to set up mDNS!");
|
debugE("Failed to set up mDNS!");
|
||||||
}
|
}
|
||||||
@@ -607,7 +607,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert) {
|
void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert) {
|
||||||
if(Debug.isActive(RemoteDebug::INFO)) Debug.printf("(setupHanPort) Setting up HAN on pin %d with baud %d and parity %d\n", pin, baud, parityOrdinal);
|
if(Debug.isActive(RemoteDebug::INFO)) Debug.printf((char*) F("(setupHanPort) Setting up HAN on pin %d with baud %d and parity %d\n"), pin, baud, parityOrdinal);
|
||||||
|
|
||||||
HardwareSerial *hwSerial = NULL;
|
HardwareSerial *hwSerial = NULL;
|
||||||
if(pin == 3 || pin == 113) {
|
if(pin == 3 || pin == 113) {
|
||||||
@@ -658,14 +658,11 @@ void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert
|
|||||||
|
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32S2)
|
#if defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||||
hwSerial->begin(baud, serialConfig, -1, -1, invert);
|
hwSerial->begin(baud, serialConfig, -1, -1, invert);
|
||||||
hwSerial->setRxBufferSize(768);
|
|
||||||
uart_set_pin(UART_NUM_1, UART_PIN_NO_CHANGE, pin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
uart_set_pin(UART_NUM_1, UART_PIN_NO_CHANGE, pin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
hwSerial->begin(baud, serialConfig, -1, -1, invert);
|
hwSerial->begin(baud, serialConfig, -1, -1, invert);
|
||||||
hwSerial->setRxBufferSize(768);
|
|
||||||
#else
|
#else
|
||||||
hwSerial->begin(baud, serialConfig, SERIAL_FULL, 1, invert);
|
hwSerial->begin(baud, serialConfig, SERIAL_FULL, 1, invert);
|
||||||
hwSerial->setRxBufferSize(768);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
@@ -765,14 +762,14 @@ void swapWifiMode() {
|
|||||||
|
|
||||||
if (mode != WIFI_AP || !config.hasConfig()) {
|
if (mode != WIFI_AP || !config.hasConfig()) {
|
||||||
if(Debug.isActive(RemoteDebug::INFO)) debugI("Swapping to AP mode");
|
if(Debug.isActive(RemoteDebug::INFO)) debugI("Swapping to AP mode");
|
||||||
WiFi.softAP("AMS2MQTT");
|
WiFi.softAP((char*) F("AMS2MQTT"));
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
|
|
||||||
if(dnsServer == NULL) {
|
if(dnsServer == NULL) {
|
||||||
dnsServer = new DNSServer();
|
dnsServer = new DNSServer();
|
||||||
}
|
}
|
||||||
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||||
dnsServer->start(53, "*", WiFi.softAPIP());
|
dnsServer->start(53, (char*) F("*"), WiFi.softAPIP());
|
||||||
} else {
|
} else {
|
||||||
if(Debug.isActive(RemoteDebug::INFO)) debugI("Swapping to STA mode");
|
if(Debug.isActive(RemoteDebug::INFO)) debugI("Swapping to STA mode");
|
||||||
if(dnsServer != NULL) {
|
if(dnsServer != NULL) {
|
||||||
@@ -978,47 +975,30 @@ void printHanReadError(int pos) {
|
|||||||
void debugPrint(byte *buffer, int start, int length) {
|
void debugPrint(byte *buffer, int start, int length) {
|
||||||
for (int i = start; i < start + length; i++) {
|
for (int i = start; i < start + length; i++) {
|
||||||
if (buffer[i] < 0x10)
|
if (buffer[i] < 0x10)
|
||||||
Debug.print("0");
|
Debug.print(F("0"));
|
||||||
Debug.print(buffer[i], HEX);
|
Debug.print(buffer[i], HEX);
|
||||||
Debug.print(" ");
|
Debug.print(F(" "));
|
||||||
if ((i - start + 1) % 16 == 0)
|
if ((i - start + 1) % 16 == 0)
|
||||||
Debug.println("");
|
Debug.println("");
|
||||||
else if ((i - start + 1) % 4 == 0)
|
else if ((i - start + 1) % 4 == 0)
|
||||||
Debug.print(" ");
|
Debug.print(F(" "));
|
||||||
|
|
||||||
yield(); // Let other get some resources too
|
yield(); // Let other get some resources too
|
||||||
}
|
}
|
||||||
Debug.println("");
|
Debug.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long wifiTimeout = WIFI_CONNECTION_TIMEOUT;
|
||||||
unsigned long lastWifiRetry = -WIFI_CONNECTION_TIMEOUT;
|
unsigned long lastWifiRetry = -WIFI_CONNECTION_TIMEOUT;
|
||||||
void WiFi_connect() {
|
void WiFi_connect() {
|
||||||
|
if(millis() - lastWifiRetry < wifiTimeout) {
|
||||||
|
delay(50);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastWifiRetry = millis();
|
||||||
|
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
if(WiFi.status() == WL_DISCONNECTED) {
|
|
||||||
if(millis() - lastWifiRetry < WIFI_CONNECTION_TIMEOUT) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(WiFi.getMode() != WIFI_OFF) {
|
if(WiFi.getMode() != WIFI_OFF) {
|
||||||
switch(WiFi.status()) {
|
|
||||||
case WL_NO_SSID_AVAIL:
|
|
||||||
debugE("WiFi error, no SSID available");
|
|
||||||
break;
|
|
||||||
case WL_CONNECT_FAILED:
|
|
||||||
debugE("WiFi error, connection failed");
|
|
||||||
break;
|
|
||||||
case WL_CONNECTION_LOST:
|
|
||||||
debugE("WiFi error, connection lost");
|
|
||||||
break;
|
|
||||||
#if defined(ESP8266)
|
|
||||||
case WL_WRONG_PASSWORD:
|
|
||||||
debugE("WiFi error, wrong password");
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
debugE("WiFi error, %d", WiFi.status());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(wifiReconnectCount > 3) {
|
if(wifiReconnectCount > 3) {
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
return;
|
return;
|
||||||
@@ -1052,13 +1032,11 @@ void WiFi_connect() {
|
|||||||
WiFi.softAPdisconnect(true);
|
WiFi.softAPdisconnect(true);
|
||||||
WiFi.enableAP(false);
|
WiFi.enableAP(false);
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
#if defined(ESP8266)
|
|
||||||
WiFi.forceSleepBegin();
|
|
||||||
#endif
|
|
||||||
yield();
|
yield();
|
||||||
|
wifiTimeout = 5000;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastWifiRetry = millis();
|
wifiTimeout = WIFI_CONNECTION_TIMEOUT;
|
||||||
|
|
||||||
WiFiConfig wifi;
|
WiFiConfig wifi;
|
||||||
if(!config.getWiFiConfig(wifi) || strlen(wifi.ssid) == 0) {
|
if(!config.getWiFiConfig(wifi) || strlen(wifi.ssid) == 0) {
|
||||||
@@ -1118,7 +1096,7 @@ void WiFi_connect() {
|
|||||||
if(strlen(wifi.dns2) > 0) {
|
if(strlen(wifi.dns2) > 0) {
|
||||||
dns2.fromString(wifi.dns2);
|
dns2.fromString(wifi.dns2);
|
||||||
} else if(dns1.toString().isEmpty()) {
|
} else if(dns1.toString().isEmpty()) {
|
||||||
dns2.fromString("208.67.220.220"); // Add OpenDNS as second by default if nothing is configured
|
dns2.fromString(F("208.67.220.220")); // Add OpenDNS as second by default if nothing is configured
|
||||||
}
|
}
|
||||||
if(!WiFi.config(ip, gw, sn, dns1, dns2)) {
|
if(!WiFi.config(ip, gw, sn, dns1, dns2)) {
|
||||||
debugE("Static IP configuration is invalid, not using");
|
debugE("Static IP configuration is invalid, not using");
|
||||||
@@ -1346,7 +1324,7 @@ void MQTT_connect() {
|
|||||||
|
|
||||||
if(LittleFS.exists(FILE_MQTT_CA)) {
|
if(LittleFS.exists(FILE_MQTT_CA)) {
|
||||||
debugI("Found MQTT CA file (%dkb free heap)", ESP.getFreeHeap());
|
debugI("Found MQTT CA file (%dkb free heap)", ESP.getFreeHeap());
|
||||||
file = LittleFS.open(FILE_MQTT_CA, "r");
|
file = LittleFS.open(FILE_MQTT_CA, (char*) "r");
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
BearSSL::X509List *serverTrustedCA = new BearSSL::X509List(file);
|
BearSSL::X509List *serverTrustedCA = new BearSSL::X509List(file);
|
||||||
mqttSecureClient->setTrustAnchors(serverTrustedCA);
|
mqttSecureClient->setTrustAnchors(serverTrustedCA);
|
||||||
@@ -1359,12 +1337,12 @@ void MQTT_connect() {
|
|||||||
if(LittleFS.exists(FILE_MQTT_CERT) && LittleFS.exists(FILE_MQTT_KEY)) {
|
if(LittleFS.exists(FILE_MQTT_CERT) && LittleFS.exists(FILE_MQTT_KEY)) {
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
debugI("Found MQTT certificate file (%dkb free heap)", ESP.getFreeHeap());
|
debugI("Found MQTT certificate file (%dkb free heap)", ESP.getFreeHeap());
|
||||||
file = LittleFS.open(FILE_MQTT_CERT, "r");
|
file = LittleFS.open(FILE_MQTT_CERT, (char*) "r");
|
||||||
BearSSL::X509List *serverCertList = new BearSSL::X509List(file);
|
BearSSL::X509List *serverCertList = new BearSSL::X509List(file);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
debugI("Found MQTT key file (%dkb free heap)", ESP.getFreeHeap());
|
debugI("Found MQTT key file (%dkb free heap)", ESP.getFreeHeap());
|
||||||
file = LittleFS.open(FILE_MQTT_KEY, "r");
|
file = LittleFS.open(FILE_MQTT_KEY, (char*) "r");
|
||||||
BearSSL::PrivateKey *serverPrivKey = new BearSSL::PrivateKey(file);
|
BearSSL::PrivateKey *serverPrivKey = new BearSSL::PrivateKey(file);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
@@ -1372,12 +1350,12 @@ void MQTT_connect() {
|
|||||||
mqttSecureClient->setClientRSACert(serverCertList, serverPrivKey);
|
mqttSecureClient->setClientRSACert(serverCertList, serverPrivKey);
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
debugI("Found MQTT certificate file (%dkb free heap)", ESP.getFreeHeap());
|
debugI("Found MQTT certificate file (%dkb free heap)", ESP.getFreeHeap());
|
||||||
file = LittleFS.open(FILE_MQTT_CERT, "r");
|
file = LittleFS.open(FILE_MQTT_CERT, (char*) "r");
|
||||||
mqttSecureClient->loadCertificate(file, file.size());
|
mqttSecureClient->loadCertificate(file, file.size());
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
debugI("Found MQTT key file (%dkb free heap)", ESP.getFreeHeap());
|
debugI("Found MQTT key file (%dkb free heap)", ESP.getFreeHeap());
|
||||||
file = LittleFS.open(FILE_MQTT_KEY, "r");
|
file = LittleFS.open(FILE_MQTT_KEY, (char*) "r");
|
||||||
mqttSecureClient->loadPrivateKey(file, file.size());
|
mqttSecureClient->loadPrivateKey(file, file.size());
|
||||||
file.close();
|
file.close();
|
||||||
#endif
|
#endif
|
||||||
@@ -1443,7 +1421,7 @@ void configFileParse() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = LittleFS.open(FILE_CFG, "r");
|
File file = LittleFS.open(FILE_CFG, (char*) "r");
|
||||||
|
|
||||||
bool lSys = false;
|
bool lSys = false;
|
||||||
bool lWiFi = false;
|
bool lWiFi = false;
|
||||||
@@ -1473,195 +1451,196 @@ void configFileParse() {
|
|||||||
char* buf = (char*) commonBuffer;
|
char* buf = (char*) commonBuffer;
|
||||||
memset(buf, 0, 1024);
|
memset(buf, 0, 1024);
|
||||||
while((size = file.readBytesUntil('\n', buf, 1024)) > 0) {
|
while((size = file.readBytesUntil('\n', buf, 1024)) > 0) {
|
||||||
if(strncmp(buf, "boardType ", 10) == 0) {
|
if(strncmp_P(buf, PSTR("boardType "), 10) == 0) {
|
||||||
if(!lSys) { config.getSystemConfig(sys); lSys = true; };
|
if(!lSys) { config.getSystemConfig(sys); lSys = true; };
|
||||||
sys.boardType = String(buf+10).toInt();
|
sys.boardType = String(buf+10).toInt();
|
||||||
} else if(strncmp(buf, "ssid ", 5) == 0) {
|
} else if(strncmp_P(buf, PSTR("ssid "), 5) == 0) {
|
||||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||||
memcpy(wifi.ssid, buf+5, size-5);
|
memcpy(wifi.ssid, buf+5, size-5);
|
||||||
} else if(strncmp(buf, "psk ", 4) == 0) {
|
} else if(strncmp_P(buf, PSTR("psk "), 4) == 0) {
|
||||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||||
memcpy(wifi.psk, buf+4, size-4);
|
memcpy(wifi.psk, buf+4, size-4);
|
||||||
} else if(strncmp(buf, "ip ", 3) == 0) {
|
} else if(strncmp_P(buf, PSTR("ip "), 3) == 0) {
|
||||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||||
memcpy(wifi.ip, buf+3, size-3);
|
memcpy(wifi.ip, buf+3, size-3);
|
||||||
} else if(strncmp(buf, "gateway ", 8) == 0) {
|
} else if(strncmp_P(buf, PSTR("gateway "), 8) == 0) {
|
||||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||||
memcpy(wifi.gateway, buf+8, size-8);
|
memcpy(wifi.gateway, buf+8, size-8);
|
||||||
} else if(strncmp(buf, "subnet ", 7) == 0) {
|
} else if(strncmp_P(buf, PSTR("subnet "), 7) == 0) {
|
||||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||||
memcpy(wifi.subnet, buf+7, size-7);
|
memcpy(wifi.subnet, buf+7, size-7);
|
||||||
} else if(strncmp(buf, "dns1 ", 5) == 0) {
|
} else if(strncmp_P(buf, PSTR("dns1 "), 5) == 0) {
|
||||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||||
memcpy(wifi.dns1, buf+5, size-5);
|
memcpy(wifi.dns1, buf+5, size-5);
|
||||||
} else if(strncmp(buf, "dns2 ", 5) == 0) {
|
} else if(strncmp_P(buf, PSTR("dns2 "), 5) == 0) {
|
||||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||||
memcpy(wifi.dns2, buf+5, size-5);
|
memcpy(wifi.dns2, buf+5, size-5);
|
||||||
} else if(strncmp(buf, "hostname ", 9) == 0) {
|
} else if(strncmp_P(buf, PSTR("hostname "), 9) == 0) {
|
||||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||||
memcpy(wifi.hostname, buf+9, size-9);
|
memcpy(wifi.hostname, buf+9, size-9);
|
||||||
} else if(strncmp(buf, "mdns ", 5) == 0) {
|
} else if(strncmp_P(buf, PSTR("mdns "), 5) == 0) {
|
||||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||||
wifi.mdns = String(buf+5).toInt() == 1;;
|
wifi.mdns = String(buf+5).toInt() == 1;;
|
||||||
} else if(strncmp(buf, "mqttHost ", 9) == 0) {
|
} else if(strncmp_P(buf, PSTR("mqttHost "), 9) == 0) {
|
||||||
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
||||||
memcpy(mqtt.host, buf+9, size-9);
|
memcpy(mqtt.host, buf+9, size-9);
|
||||||
} else if(strncmp(buf, "mqttPort ", 9) == 0) {
|
} else if(strncmp_P(buf, PSTR("mqttPort "), 9) == 0) {
|
||||||
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
||||||
mqtt.port = String(buf+9).toInt();
|
mqtt.port = String(buf+9).toInt();
|
||||||
} else if(strncmp(buf, "mqttClientId ", 13) == 0) {
|
} else if(strncmp_P(buf, PSTR("mqttClientId "), 13) == 0) {
|
||||||
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
||||||
memcpy(mqtt.clientId, buf+13, size-13);
|
memcpy(mqtt.clientId, buf+13, size-13);
|
||||||
} else if(strncmp(buf, "mqttPublishTopic ", 17) == 0) {
|
} else if(strncmp_P(buf, PSTR("mqttPublishTopic "), 17) == 0) {
|
||||||
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
||||||
memcpy(mqtt.publishTopic, buf+17, size-17);
|
memcpy(mqtt.publishTopic, buf+17, size-17);
|
||||||
} else if(strncmp(buf, "mqttUsername ", 13) == 0) {
|
} else if(strncmp_P(buf, PSTR("mqttUsername "), 13) == 0) {
|
||||||
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
||||||
memcpy(mqtt.username, buf+13, size-13);
|
memcpy(mqtt.username, buf+13, size-13);
|
||||||
} else if(strncmp(buf, "mqttPassword ", 13) == 0) {
|
} else if(strncmp_P(buf, PSTR("mqttPassword "), 13) == 0) {
|
||||||
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
||||||
memcpy(mqtt.password, buf+13, size-13);
|
memcpy(mqtt.password, buf+13, size-13);
|
||||||
} else if(strncmp(buf, "mqttPayloadFormat ", 18) == 0) {
|
} else if(strncmp_P(buf, PSTR("mqttPayloadFormat "), 18) == 0) {
|
||||||
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
||||||
mqtt.payloadFormat = String(buf+18).toInt();
|
mqtt.payloadFormat = String(buf+18).toInt();
|
||||||
} else if(strncmp(buf, "mqttSsl ", 8) == 0) {
|
} else if(strncmp_P(buf, PSTR("mqttSsl "), 8) == 0) {
|
||||||
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
if(!lMqtt) { config.getMqttConfig(mqtt); lMqtt = true; };
|
||||||
mqtt.ssl = String(buf+8).toInt() == 1;;
|
mqtt.ssl = String(buf+8).toInt() == 1;;
|
||||||
} else if(strncmp(buf, "webSecurity ", 12) == 0) {
|
} else if(strncmp_P(buf, PSTR("webSecurity "), 12) == 0) {
|
||||||
if(!lWeb) { config.getWebConfig(web); lWeb = true; };
|
if(!lWeb) { config.getWebConfig(web); lWeb = true; };
|
||||||
web.security = String(buf+12).toInt();
|
web.security = String(buf+12).toInt();
|
||||||
} else if(strncmp(buf, "webUsername ", 12) == 0) {
|
} else if(strncmp_P(buf, PSTR("webUsername "), 12) == 0) {
|
||||||
if(!lWeb) { config.getWebConfig(web); lWeb = true; };
|
if(!lWeb) { config.getWebConfig(web); lWeb = true; };
|
||||||
memcpy(web.username, buf+12, size-12);
|
memcpy(web.username, buf+12, size-12);
|
||||||
} else if(strncmp(buf, "webPassword ", 12) == 0) {
|
} else if(strncmp_P(buf, PSTR("webPassword "), 12) == 0) {
|
||||||
if(!lWeb) { config.getWebConfig(web); lWeb = true; };
|
if(!lWeb) { config.getWebConfig(web); lWeb = true; };
|
||||||
memcpy(web.username, buf+12, size-12);
|
memcpy(web.username, buf+12, size-12);
|
||||||
} else if(strncmp(buf, "meterBaud ", 10) == 0) {
|
} else if(strncmp_P(buf, PSTR("meterBaud "), 10) == 0) {
|
||||||
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
||||||
meter.baud = String(buf+10).toInt();
|
meter.baud = String(buf+10).toInt();
|
||||||
} else if(strncmp(buf, "meterParity ", 12) == 0) {
|
} else if(strncmp_P(buf, PSTR("meterParity "), 12) == 0) {
|
||||||
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
||||||
if(strncmp(buf+12, "7N1", 3) == 0) meter.parity = 2;
|
if(strncmp_P(buf+12, PSTR("7N1"), 3) == 0) meter.parity = 2;
|
||||||
if(strncmp(buf+12, "8N1", 3) == 0) meter.parity = 3;
|
if(strncmp_P(buf+12, PSTR("8N1"), 3) == 0) meter.parity = 3;
|
||||||
if(strncmp(buf+12, "7E1", 3) == 0) meter.parity = 10;
|
if(strncmp_P(buf+12, PSTR("7E1"), 3) == 0) meter.parity = 10;
|
||||||
if(strncmp(buf+12, "8E1", 3) == 0) meter.parity = 11;
|
if(strncmp_P(buf+12, PSTR("8E1"), 3) == 0) meter.parity = 11;
|
||||||
} else if(strncmp(buf, "meterInvert ", 12) == 0) {
|
} else if(strncmp_P(buf, PSTR("meterInvert "), 12) == 0) {
|
||||||
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
||||||
meter.invert = String(buf+12).toInt() == 1;;
|
meter.invert = String(buf+12).toInt() == 1;;
|
||||||
} else if(strncmp(buf, "meterDistributionSystem ", 24) == 0) {
|
} else if(strncmp_P(buf, PSTR("meterDistributionSystem "), 24) == 0) {
|
||||||
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
||||||
meter.distributionSystem = String(buf+24).toInt();
|
meter.distributionSystem = String(buf+24).toInt();
|
||||||
} else if(strncmp(buf, "meterMainFuse ", 14) == 0) {
|
} else if(strncmp_P(buf, PSTR("meterMainFuse "), 14) == 0) {
|
||||||
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
||||||
meter.mainFuse = String(buf+14).toInt();
|
meter.mainFuse = String(buf+14).toInt();
|
||||||
} else if(strncmp(buf, "meterProductionCapacity ", 24) == 0) {
|
} else if(strncmp_P(buf, PSTR("meterProductionCapacity "), 24) == 0) {
|
||||||
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
||||||
meter.productionCapacity = String(buf+24).toInt();
|
meter.productionCapacity = String(buf+24).toInt();
|
||||||
} else if(strncmp(buf, "meterEncryptionKey ", 19) == 0) {
|
} else if(strncmp_P(buf, PSTR("meterEncryptionKey "), 19) == 0) {
|
||||||
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
||||||
fromHex(meter.encryptionKey, String(buf+19), 16);
|
fromHex(meter.encryptionKey, String(buf+19), 16);
|
||||||
} else if(strncmp(buf, "meterAuthenticationKey ", 23) == 0) {
|
} else if(strncmp_P(buf, PSTR("meterAuthenticationKey "), 23) == 0) {
|
||||||
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
if(!lMeter) { config.getMeterConfig(meter); lMeter = true; };
|
||||||
fromHex(meter.authenticationKey, String(buf+19), 16);
|
fromHex(meter.authenticationKey, String(buf+19), 16);
|
||||||
} else if(strncmp(buf, "gpioHanPin ", 11) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioHanPin "), 11) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.hanPin = String(buf+11).toInt();
|
gpio.hanPin = String(buf+11).toInt();
|
||||||
} else if(strncmp(buf, "gpioApPin ", 10) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioApPin "), 10) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.apPin = String(buf+10).toInt();
|
gpio.apPin = String(buf+10).toInt();
|
||||||
} else if(strncmp(buf, "gpioLedPin ", 11) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioLedPin "), 11) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.ledPin = String(buf+11).toInt();
|
gpio.ledPin = String(buf+11).toInt();
|
||||||
} else if(strncmp(buf, "gpioLedInverted ", 16) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioLedInverted "), 16) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.ledInverted = String(buf+16).toInt() == 1;
|
gpio.ledInverted = String(buf+16).toInt() == 1;
|
||||||
} else if(strncmp(buf, "gpioLedPinRed ", 14) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioLedPinRed "), 14) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.ledPinRed = String(buf+14).toInt();
|
gpio.ledPinRed = String(buf+14).toInt();
|
||||||
} else if(strncmp(buf, "gpioLedPinGreen ", 16) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioLedPinGreen "), 16) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.ledPinGreen = String(buf+16).toInt();
|
gpio.ledPinGreen = String(buf+16).toInt();
|
||||||
} else if(strncmp(buf, "gpioLedPinBlue ", 15) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioLedPinBlue "), 15) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.ledPinBlue = String(buf+15).toInt();
|
gpio.ledPinBlue = String(buf+15).toInt();
|
||||||
} else if(strncmp(buf, "gpioLedRgbInverted ", 19) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioLedRgbInverted "), 19) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.ledRgbInverted = String(buf+19).toInt() == 1;
|
gpio.ledRgbInverted = String(buf+19).toInt() == 1;
|
||||||
} else if(strncmp(buf, "gpioTempSensorPin ", 18) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioTempSensorPin "), 18) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.tempSensorPin = String(buf+18).toInt();
|
gpio.tempSensorPin = String(buf+18).toInt();
|
||||||
} else if(strncmp(buf, "gpioTempAnalogSensorPin ", 24) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioTempAnalogSensorPin "), 24) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.tempAnalogSensorPin = String(buf+24).toInt();
|
gpio.tempAnalogSensorPin = String(buf+24).toInt();
|
||||||
} else if(strncmp(buf, "gpioVccPin ", 11) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioVccPin "), 11) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.vccPin = String(buf+11).toInt();
|
gpio.vccPin = String(buf+11).toInt();
|
||||||
} else if(strncmp(buf, "gpioVccOffset ", 14) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioVccOffset "), 14) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.vccOffset = String(buf+14).toDouble() * 100;
|
gpio.vccOffset = String(buf+14).toDouble() * 100;
|
||||||
} else if(strncmp(buf, "gpioVccMultiplier ", 18) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioVccMultiplier "), 18) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.vccMultiplier = String(buf+18).toDouble() * 1000;
|
gpio.vccMultiplier = String(buf+18).toDouble() * 1000;
|
||||||
} else if(strncmp(buf, "gpioVccBootLimit ", 17) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioVccBootLimit "), 17) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.vccBootLimit = String(buf+17).toDouble() * 10;
|
gpio.vccBootLimit = String(buf+17).toDouble() * 10;
|
||||||
} else if(strncmp(buf, "gpioVccResistorGnd ", 19) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioVccResistorGnd "), 19) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.vccResistorGnd = String(buf+19).toInt();
|
gpio.vccResistorGnd = String(buf+19).toInt();
|
||||||
} else if(strncmp(buf, "gpioVccResistorVcc ", 19) == 0) {
|
} else if(strncmp_P(buf, PSTR("gpioVccResistorVcc "), 19) == 0) {
|
||||||
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
if(!lGpio) { config.getGpioConfig(gpio); lGpio = true; };
|
||||||
gpio.vccResistorVcc = String(buf+19).toInt();
|
gpio.vccResistorVcc = String(buf+19).toInt();
|
||||||
} else if(strncmp(buf, "domoticzElidx ", 14) == 0) {
|
} else if(strncmp_P(buf, PSTR("domoticzElidx "), 14) == 0) {
|
||||||
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
||||||
domo.elidx = String(buf+14).toInt();
|
domo.elidx = String(buf+14).toInt();
|
||||||
} else if(strncmp(buf, "domoticzVl1idx ", 15) == 0) {
|
} else if(strncmp_P(buf, PSTR("domoticzVl1idx "), 15) == 0) {
|
||||||
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
||||||
domo.vl1idx = String(buf+15).toInt();
|
domo.vl1idx = String(buf+15).toInt();
|
||||||
} else if(strncmp(buf, "domoticzVl2idx ", 15) == 0) {
|
} else if(strncmp_P(buf, PSTR("domoticzVl2idx "), 15) == 0) {
|
||||||
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
||||||
domo.vl2idx = String(buf+15).toInt();
|
domo.vl2idx = String(buf+15).toInt();
|
||||||
} else if(strncmp(buf, "domoticzVl3idx ", 15) == 0) {
|
} else if(strncmp_P(buf, PSTR("domoticzVl3idx "), 15) == 0) {
|
||||||
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
||||||
domo.vl3idx = String(buf+15).toInt();
|
domo.vl3idx = String(buf+15).toInt();
|
||||||
} else if(strncmp(buf, "domoticzCl1idx ", 15) == 0) {
|
} else if(strncmp_P(buf, PSTR("domoticzCl1idx "), 15) == 0) {
|
||||||
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
if(!lDomo) { config.getDomoticzConfig(domo); lDomo = true; };
|
||||||
domo.cl1idx = String(buf+15).toInt();
|
domo.cl1idx = String(buf+15).toInt();
|
||||||
} else if(strncmp(buf, "ntpEnable ", 10) == 0) {
|
} else if(strncmp_P(buf, PSTR("ntpEnable "), 10) == 0) {
|
||||||
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
||||||
ntp.enable = String(buf+10).toInt() == 1;
|
ntp.enable = String(buf+10).toInt() == 1;
|
||||||
} else if(strncmp(buf, "ntpDhcp ", 8) == 0) {
|
} else if(strncmp_P(buf, PSTR("ntpDhcp "), 8) == 0) {
|
||||||
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
||||||
ntp.dhcp = String(buf+8).toInt() == 1;
|
ntp.dhcp = String(buf+8).toInt() == 1;
|
||||||
} else if(strncmp(buf, "ntpOffset ", 10) == 0) {
|
} else if(strncmp_P(buf, PSTR("ntpOffset "), 10) == 0) {
|
||||||
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
||||||
ntp.offset = String(buf+10).toInt() / 10;
|
ntp.offset = String(buf+10).toInt() / 10;
|
||||||
} else if(strncmp(buf, "ntpSummerOffset ", 16) == 0) {
|
} else if(strncmp_P(buf, PSTR("ntpSummerOffset "), 16) == 0) {
|
||||||
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
||||||
ntp.summerOffset = String(buf+16).toInt() / 10;
|
ntp.summerOffset = String(buf+16).toInt() / 10;
|
||||||
} else if(strncmp(buf, "ntpServer ", 10) == 0) {
|
} else if(strncmp_P(buf, PSTR("ntpServer "), 10) == 0) {
|
||||||
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
if(!lNtp) { config.getNtpConfig(ntp); lNtp = true; };
|
||||||
memcpy(ntp.server, buf+10, size-10);
|
memcpy(ntp.server, buf+10, size-10);
|
||||||
} else if(strncmp(buf, "entsoeToken ", 12) == 0) {
|
} else if(strncmp_P(buf, PSTR("entsoeToken "), 12) == 0) {
|
||||||
if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; };
|
if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; };
|
||||||
memcpy(entsoe.token, buf+12, size-12);
|
memcpy(entsoe.token, buf+12, size-12);
|
||||||
} else if(strncmp(buf, "entsoeArea ", 11) == 0) {
|
} else if(strncmp_P(buf, PSTR("entsoeArea "), 11) == 0) {
|
||||||
if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; };
|
if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; };
|
||||||
memcpy(entsoe.area, buf+11, size-11);
|
memcpy(entsoe.area, buf+11, size-11);
|
||||||
} else if(strncmp(buf, "entsoeCurrency ", 15) == 0) {
|
} else if(strncmp_P(buf, PSTR("entsoeCurrency "), 15) == 0) {
|
||||||
if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; };
|
if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; };
|
||||||
memcpy(entsoe.currency, buf+15, size-15);
|
memcpy(entsoe.currency, buf+15, size-15);
|
||||||
} else if(strncmp(buf, "entsoeMultiplier ", 17) == 0) {
|
} else if(strncmp_P(buf, PSTR("entsoeMultiplier "), 17) == 0) {
|
||||||
if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; };
|
if(!lEntsoe) { config.getEntsoeConfig(entsoe); lEntsoe = true; };
|
||||||
entsoe.multiplier = String(buf+17).toDouble() * 1000;
|
entsoe.multiplier = String(buf+17).toDouble() * 1000;
|
||||||
} else if(strncmp(buf, "thresholds ", 11) == 0) {
|
} else if(strncmp_P(buf, PSTR("thresholds "), 11) == 0) {
|
||||||
if(!lEac) { config.getEnergyAccountingConfig(eac); lEac = true; };
|
if(!lEac) { config.getEnergyAccountingConfig(eac); lEac = true; };
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char * pch = strtok (buf+11," ");
|
char * pch = strtok (buf+11," ");
|
||||||
while (pch != NULL) {
|
while (pch != NULL && i < 10) {
|
||||||
eac.thresholds[i++] = String(pch).toInt();
|
eac.thresholds[i++] = String(pch).toInt();
|
||||||
pch = strtok (NULL, " ");
|
pch = strtok (NULL, " ");
|
||||||
}
|
}
|
||||||
} else if(strncmp(buf, "dayplot ", 8) == 0) {
|
eac.hours = String(pch).toInt();
|
||||||
|
} else if(strncmp_P(buf, PSTR("dayplot "), 8) == 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
DayDataPoints day = { 4 }; // Use a version we know the multiplier of the data points
|
DayDataPoints day = { 4 }; // Use a version we know the multiplier of the data points
|
||||||
char * pch = strtok (buf+8," ");
|
char * pch = strtok (buf+8," ");
|
||||||
@@ -1684,7 +1663,7 @@ void configFileParse() {
|
|||||||
}
|
}
|
||||||
ds.setDayData(day);
|
ds.setDayData(day);
|
||||||
sDs = true;
|
sDs = true;
|
||||||
} else if(strncmp(buf, "monthplot ", 10) == 0) {
|
} else if(strncmp_P(buf, PSTR("monthplot "), 10) == 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
MonthDataPoints month = { 5 }; // Use a version we know the multiplier of the data points
|
MonthDataPoints month = { 5 }; // Use a version we know the multiplier of the data points
|
||||||
char * pch = strtok (buf+10," ");
|
char * pch = strtok (buf+10," ");
|
||||||
@@ -1707,7 +1686,7 @@ void configFileParse() {
|
|||||||
}
|
}
|
||||||
ds.setMonthData(month);
|
ds.setMonthData(month);
|
||||||
sDs = true;
|
sDs = true;
|
||||||
} else if(strncmp(buf, "energyaccounting ", 17) == 0) {
|
} else if(strncmp_P(buf, PSTR("energyaccounting "), 17) == 0) {
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
EnergyAccountingData ead = { 4, 0,
|
EnergyAccountingData ead = { 4, 0,
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
@@ -1772,6 +1751,7 @@ void configFileParse() {
|
|||||||
if(lDomo) config.setDomoticzConfig(domo);
|
if(lDomo) config.setDomoticzConfig(domo);
|
||||||
if(lNtp) config.setNtpConfig(ntp);
|
if(lNtp) config.setNtpConfig(ntp);
|
||||||
if(lEntsoe) config.setEntsoeConfig(entsoe);
|
if(lEntsoe) config.setEntsoeConfig(entsoe);
|
||||||
|
if(lEac) config.setEnergyAccountingConfig(eac);
|
||||||
if(sDs) ds.save();
|
if(sDs) ds.save();
|
||||||
if(sEa) ea.save();
|
if(sEa) ea.save();
|
||||||
config.save();
|
config.save();
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ float EnergyAccounting::getMonthMax() {
|
|||||||
uint32_t maxHour = 0.0;
|
uint32_t maxHour = 0.0;
|
||||||
bool included[5] = { false, false, false, false, false };
|
bool included[5] = { false, false, false, false, false };
|
||||||
|
|
||||||
while(count < config->hours && count <= 5) {
|
for(uint8_t x = 0;x < min((uint8_t) 5, config->hours); x++) {
|
||||||
uint8_t maxIdx = 0;
|
uint8_t maxIdx = 0;
|
||||||
uint16_t maxVal = 0;
|
uint16_t maxVal = 0;
|
||||||
for(uint8_t i = 0; i < 5; i++) {
|
for(uint8_t i = 0; i < 5; i++) {
|
||||||
@@ -248,8 +248,10 @@ float EnergyAccounting::getMonthMax() {
|
|||||||
maxIdx = i;
|
maxIdx = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
included[maxIdx] = true;
|
if(maxVal > 0) {
|
||||||
count++;
|
included[maxIdx] = true;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint8_t i = 0; i < 5; i++) {
|
for(uint8_t i = 0; i < 5; i++) {
|
||||||
@@ -265,7 +267,7 @@ float EnergyAccounting::getPeak(uint8_t num) {
|
|||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
bool included[5] = { false, false, false, false, false };
|
bool included[5] = { false, false, false, false, false };
|
||||||
|
|
||||||
while(count < config->hours && count <= 5) {
|
for(uint8_t x = 0;x < min((uint8_t) 5, config->hours); x++) {
|
||||||
uint8_t maxIdx = 0;
|
uint8_t maxIdx = 0;
|
||||||
uint16_t maxVal = 0;
|
uint16_t maxVal = 0;
|
||||||
for(uint8_t i = 0; i < 5; i++) {
|
for(uint8_t i = 0; i < 5; i++) {
|
||||||
@@ -275,8 +277,10 @@ float EnergyAccounting::getPeak(uint8_t num) {
|
|||||||
maxIdx = i;
|
maxIdx = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
included[maxIdx] = true;
|
if(maxVal > 0) {
|
||||||
count++;
|
included[maxIdx] = true;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t pos = 0;
|
uint8_t pos = 0;
|
||||||
|
|||||||
@@ -373,8 +373,7 @@ bool HwTools::ledBlink(uint8_t color, uint8_t blink) {
|
|||||||
if(!ledOn(color)) return false;
|
if(!ledOn(color)) return false;
|
||||||
delay(50);
|
delay(50);
|
||||||
ledOff(color);
|
ledOff(color);
|
||||||
if(i != blink-1)
|
delay(200);
|
||||||
delay(200);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,13 +371,11 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo
|
|||||||
memcpy(str, mid->oct.data, mid->oct.length);
|
memcpy(str, mid->oct.data, mid->oct.length);
|
||||||
str[mid->oct.length] = 0x00;
|
str[mid->oct.length] = 0x00;
|
||||||
meterId = String(str);
|
meterId = String(str);
|
||||||
meterId[mid->str.length] = 0;
|
|
||||||
break;
|
break;
|
||||||
case CosemTypeOctetString:
|
case CosemTypeOctetString:
|
||||||
memcpy(str, mid->str.data, mid->str.length);
|
memcpy(str, mid->str.data, mid->str.length);
|
||||||
str[mid->str.length] = 0x00;
|
str[mid->str.length] = 0x00;
|
||||||
meterId = String(str);
|
meterId = String(str);
|
||||||
meterId[mid->str.length] = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,9 @@ bool RawMqttHandler::publish(AmsData* data, AmsData* meterState, EnergyAccountin
|
|||||||
}
|
}
|
||||||
mqtt->publish(topic + "/realtime/import/hour", String(ea->getUseThisHour(), 3));
|
mqtt->publish(topic + "/realtime/import/hour", String(ea->getUseThisHour(), 3));
|
||||||
mqtt->publish(topic + "/realtime/import/day", String(ea->getUseToday(), 2));
|
mqtt->publish(topic + "/realtime/import/day", String(ea->getUseToday(), 2));
|
||||||
for(uint8_t i = 1; i <= ea->getConfig()->hours; i++) {
|
uint8_t peakCount = ea->getConfig()->hours;
|
||||||
|
if(peakCount > 5) peakCount = 5;
|
||||||
|
for(uint8_t i = 1; i <= peakCount; i++) {
|
||||||
mqtt->publish(topic + "/realtime/import/peak/" + String(i, 10), String(ea->getPeak(i), 10), true, 0);
|
mqtt->publish(topic + "/realtime/import/peak/" + String(i, 10), String(ea->getPeak(i), 10), true, 0);
|
||||||
}
|
}
|
||||||
mqtt->publish(topic + "/realtime/import/threshold", String(ea->getCurrentThreshold(), 10), true, 0);
|
mqtt->publish(topic + "/realtime/import/threshold", String(ea->getCurrentThreshold(), 10), true, 0);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ static const char HEADER_CACHE_CONTROL[] PROGMEM = "Cache-Control";
|
|||||||
static const char HEADER_PRAGMA[] PROGMEM = "Pragma";
|
static const char HEADER_PRAGMA[] PROGMEM = "Pragma";
|
||||||
static const char HEADER_EXPIRES[] PROGMEM = "Expires";
|
static const char HEADER_EXPIRES[] PROGMEM = "Expires";
|
||||||
static const char HEADER_AUTHENTICATE[] PROGMEM = "WWW-Authenticate";
|
static const char HEADER_AUTHENTICATE[] PROGMEM = "WWW-Authenticate";
|
||||||
|
static const char HEADER_LOCATION[] PROGMEM = "Location";
|
||||||
|
|
||||||
static const char CACHE_CONTROL_NO_CACHE[] PROGMEM = "no-cache, no-store, must-revalidate";
|
static const char CACHE_CONTROL_NO_CACHE[] PROGMEM = "no-cache, no-store, must-revalidate";
|
||||||
static const char CACHE_1HR[] PROGMEM = "public, max-age=3600";
|
static const char CACHE_1HR[] PROGMEM = "public, max-age=3600";
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -657,7 +657,7 @@ var fetch = function() {
|
|||||||
|
|
||||||
if(ip) {
|
if(ip) {
|
||||||
var v = parseInt(json.i);
|
var v = parseInt(json.i);
|
||||||
var pct = (v*100)/parseInt(json.im);
|
var pct = Math.min((v*100)/parseInt(json.im), 100);
|
||||||
var append = "W";
|
var append = "W";
|
||||||
if(v > 1000 && !swatt) {
|
if(v > 1000 && !swatt) {
|
||||||
v = (v/1000).toFixed(1);
|
v = (v/1000).toFixed(1);
|
||||||
@@ -683,7 +683,7 @@ var fetch = function() {
|
|||||||
$('.rim').hide();
|
$('.rim').hide();
|
||||||
if(xp) {
|
if(xp) {
|
||||||
var v = parseInt(json.e);
|
var v = parseInt(json.e);
|
||||||
var pct = (v*100)/(om*1000);
|
var pct = Math.min((v*100)/(om*1000), 100);
|
||||||
var append = "W";
|
var append = "W";
|
||||||
if(v > 1000 && !swatt) {
|
if(v > 1000 && !swatt) {
|
||||||
v = (v/1000).toFixed(1);
|
v = (v/1000).toFixed(1);
|
||||||
@@ -723,21 +723,21 @@ var fetch = function() {
|
|||||||
var u1 = parseFloat(json.u1);
|
var u1 = parseFloat(json.u1);
|
||||||
t += u1;
|
t += u1;
|
||||||
c++;
|
c++;
|
||||||
var pct = (Math.max(parseFloat(json.u1)-195.5, 1)*100/69);
|
var pct = Math.min(Math.max(parseFloat(json.u1)-195.5, 1)*100/69, 100);
|
||||||
arr[r++] = [ds == 1 ? 'L1-L2' : 'L1', u1, "color: " + voltcol(pct) + ";opacity: 0.9;", u1 + "V"];
|
arr[r++] = [ds == 1 ? 'L1-L2' : 'L1', u1, "color: " + voltcol(pct) + ";opacity: 0.9;", u1 + "V"];
|
||||||
}
|
}
|
||||||
if(json.u2) {
|
if(json.u2) {
|
||||||
var u2 = parseFloat(json.u2);
|
var u2 = parseFloat(json.u2);
|
||||||
t += u2;
|
t += u2;
|
||||||
c++;
|
c++;
|
||||||
var pct = (Math.max(parseFloat(json.u2)-195.5, 1)*100/69);
|
var pct = Math.min(Math.max(parseFloat(json.u2)-195.5, 1)*100/69, 100);
|
||||||
arr[r++] = [ds == 1 ? 'L1-L3' : 'L2', u2, "color: " + voltcol(pct) + ";opacity: 0.9;", u2 + "V"];
|
arr[r++] = [ds == 1 ? 'L1-L3' : 'L2', u2, "color: " + voltcol(pct) + ";opacity: 0.9;", u2 + "V"];
|
||||||
}
|
}
|
||||||
if(json.u3) {
|
if(json.u3) {
|
||||||
var u3 = parseFloat(json.u3);
|
var u3 = parseFloat(json.u3);
|
||||||
t += u3;
|
t += u3;
|
||||||
c++;
|
c++;
|
||||||
var pct = (Math.max(parseFloat(json.u3)-195.5, 1)*100/69);
|
var pct = Math.min(Math.max(parseFloat(json.u3)-195.5, 1)*100/69, 100);
|
||||||
arr[r++] = [ds == 1 ? 'L2-L3' : 'L3', u3, "color: " + voltcol(pct) + ";opacity: 0.9;", u3 + "V"];
|
arr[r++] = [ds == 1 ? 'L2-L3' : 'L3', u3, "color: " + voltcol(pct) + ";opacity: 0.9;", u3 + "V"];
|
||||||
}
|
}
|
||||||
v = t/c;
|
v = t/c;
|
||||||
@@ -762,19 +762,19 @@ var fetch = function() {
|
|||||||
if(json.i1 || json.u1) {
|
if(json.i1 || json.u1) {
|
||||||
var i1 = parseFloat(json.i1);
|
var i1 = parseFloat(json.i1);
|
||||||
dA = true;
|
dA = true;
|
||||||
var pct = (parseFloat(json.i1)/parseInt(json.mf))*100;
|
var pct = Math.min((parseFloat(json.i1)/parseInt(json.mf))*100, 100);
|
||||||
arr[r++] = ['L1', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i1 + "A"];
|
arr[r++] = ['L1', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i1 + "A"];
|
||||||
}
|
}
|
||||||
if(json.i2 || json.u2) {
|
if(json.i2 || json.u2) {
|
||||||
var i2 = parseFloat(json.i2);
|
var i2 = parseFloat(json.i2);
|
||||||
dA = true;
|
dA = true;
|
||||||
var pct = (parseFloat(json.i2)/parseInt(json.mf))*100;
|
var pct = Math.min((parseFloat(json.i2)/parseInt(json.mf))*100, 100);
|
||||||
arr[r++] = ['L2', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i2 + "A"];
|
arr[r++] = ['L2', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i2 + "A"];
|
||||||
}
|
}
|
||||||
if(json.i3 || json.u3) {
|
if(json.i3 || json.u3) {
|
||||||
var i3 = parseFloat(json.i3);
|
var i3 = parseFloat(json.i3);
|
||||||
dA = true;
|
dA = true;
|
||||||
var pct = (parseFloat(json.i3)/parseInt(json.mf))*100;
|
var pct = Math.min((parseFloat(json.i3)/parseInt(json.mf))*100, 100);
|
||||||
arr[r++] = ['L3', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i3 + "A"];
|
arr[r++] = ['L3', pct, "color: " + ampcol(pct) + ";opacity: 0.9;", i3 + "A"];
|
||||||
}
|
}
|
||||||
if(dA) {
|
if(dA) {
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
"tPO" : %.2f,
|
"tPO" : %.2f,
|
||||||
"tQI" : %.2f,
|
"tQI" : %.2f,
|
||||||
"tQO" : %.2f,
|
"tQO" : %.2f,
|
||||||
"rtc" : %lld
|
"rtc" : %lu
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"id" : "%s",
|
"id" : "%s",
|
||||||
"name" : "%s",
|
"name" : "%s",
|
||||||
"up" : %u,
|
"up" : %u,
|
||||||
"t" : %lld,
|
"t" : %lu,
|
||||||
"vcc" : %.3f,
|
"vcc" : %.3f,
|
||||||
"rssi": %d,
|
"rssi": %d,
|
||||||
"temp": %.2f,
|
"temp": %.2f,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"id" : "%s",
|
"id" : "%s",
|
||||||
"name" : "%s",
|
"name" : "%s",
|
||||||
"up" : %u,
|
"up" : %u,
|
||||||
"t" : %lld,
|
"t" : %lu,
|
||||||
"vcc" : %.3f,
|
"vcc" : %.3f,
|
||||||
"rssi": %d,
|
"rssi": %d,
|
||||||
"temp": %.2f,
|
"temp": %.2f,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"id" : "%s",
|
"id" : "%s",
|
||||||
"name" : "%s",
|
"name" : "%s",
|
||||||
"up" : %u,
|
"up" : %u,
|
||||||
"t" : %lld,
|
"t" : %lu,
|
||||||
"vcc" : %.3f,
|
"vcc" : %.3f,
|
||||||
"rssi": %d,
|
"rssi": %d,
|
||||||
"temp": %.2f,
|
"temp": %.2f,
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"tPO" : %.3f,
|
"tPO" : %.3f,
|
||||||
"tQI" : %.3f,
|
"tQI" : %.3f,
|
||||||
"tQO" : %.3f,
|
"tQO" : %.3f,
|
||||||
"rtc" : %lld
|
"rtc" : %lu
|
||||||
},
|
},
|
||||||
"realtime" : {
|
"realtime" : {
|
||||||
"h" : %.2f,
|
"h" : %.2f,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"id" : "%s",
|
"id" : "%s",
|
||||||
"name" : "%s",
|
"name" : "%s",
|
||||||
"up" : %u,
|
"up" : %u,
|
||||||
"t" : %lld,
|
"t" : %lu,
|
||||||
"vcc" : %.3f,
|
"vcc" : %.3f,
|
||||||
"rssi": %d,
|
"rssi": %d,
|
||||||
"temp": %.2f,
|
"temp": %.2f,
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"tPO" : %.2f,
|
"tPO" : %.2f,
|
||||||
"tQI" : %.2f,
|
"tQI" : %.2f,
|
||||||
"tQO" : %.2f,
|
"tQO" : %.2f,
|
||||||
"rtc" : %lld
|
"rtc" : %lu
|
||||||
},
|
},
|
||||||
"realtime" : {
|
"realtime" : {
|
||||||
"h" : %.2f,
|
"h" : %.2f,
|
||||||
|
|||||||
Reference in New Issue
Block a user