Compare commits

..

2 Commits

Author SHA1 Message Date
Gunnar Skjold
dd87d70876 Free value on fuse size and production capacity 2022-01-28 18:29:50 +01:00
Gunnar Skjold
52992f09ee Stability adjustments 2022-01-28 17:41:48 +01:00
5 changed files with 25 additions and 21 deletions

View File

@@ -559,8 +559,10 @@ void setupHanPort(uint8_t pin, uint32_t baud, uint8_t parityOrdinal, bool invert
#if defined(ESP32) #if 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)
@@ -705,7 +707,6 @@ bool readHanPort() {
while(hanSerial->available() && pos == HDLC_FRAME_INCOMPLETE) { while(hanSerial->available() && pos == HDLC_FRAME_INCOMPLETE) {
buf[len++] = hanSerial->read(); buf[len++] = hanSerial->read();
pos = HDLC_validate((uint8_t *) buf, len, hc, &timestamp); pos = HDLC_validate((uint8_t *) buf, len, hc, &timestamp);
delay(1);
} }
if(len > 0) { if(len > 0) {
if(len >= BUF_SIZE) { if(len >= BUF_SIZE) {
@@ -973,7 +974,9 @@ void WiFi_connect() {
} 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("208.67.220.220"); // Add OpenDNS as second by default if nothing is configured
} }
WiFi.config(ip, gw, sn, dns1, dns2); if(!WiFi.config(ip, gw, sn, dns1, dns2)) {
debugE("Static IP configuration is invalid, not using");
}
} else { } else {
#if defined(ESP32) #if defined(ESP32)
// This trick does not work anymore... // This trick does not work anymore...

View File

@@ -13,7 +13,7 @@ EntsoeApi::EntsoeApi(RemoteDebug* Debug) {
client.setInsecure(); client.setInsecure();
https.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); https.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
https.setTimeout(5000); https.setTimeout(20000);
// Entso-E uses CET/CEST // Entso-E uses CET/CEST
TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120};
@@ -270,7 +270,9 @@ float EntsoeApi::getCurrencyMultiplier(const char* from, const char* to) {
return 1.00; return 1.00;
uint64_t now = millis64(); uint64_t now = millis64();
if(lastCurrencyFetch < midnightMillis) { if(now > lastCurrencyFetch && (now - lastCurrencyFetch) < 900000) {
lastCurrencyFetch = now;
char url[256]; char url[256];
DnbCurrParser p; DnbCurrParser p;

View File

@@ -458,9 +458,6 @@ void AmsWebServer::configMeterHtml() {
html.replace("{d" + String(i) + "}", meterConfig->distributionSystem == i ? "selected" : ""); html.replace("{d" + String(i) + "}", meterConfig->distributionSystem == i ? "selected" : "");
} }
html.replace("{f}", String(meterConfig->mainFuse)); html.replace("{f}", String(meterConfig->mainFuse));
for(int i = 0; i<64; i++) {
html.replace("{f" + String(i) + "}", meterConfig->mainFuse == i ? "selected" : "");
}
html.replace("{p}", String(meterConfig->productionCapacity)); html.replace("{p}", String(meterConfig->productionCapacity));
if(meterConfig->encryptionKey[0] != 0x00) { if(meterConfig->encryptionKey[0] != 0x00) {
@@ -1127,6 +1124,7 @@ void AmsWebServer::handleSave() {
meterConfig->distributionSystem = server.arg("d").toInt(); meterConfig->distributionSystem = server.arg("d").toInt();
meterConfig->mainFuse = server.arg("f").toInt(); meterConfig->mainFuse = server.arg("f").toInt();
meterConfig->productionCapacity = server.arg("p").toInt(); meterConfig->productionCapacity = server.arg("p").toInt();
maxPwr = 0;
String encryptionKeyHex = server.arg("e"); String encryptionKeyHex = server.arg("e");
if(!encryptionKeyHex.isEmpty()) { if(!encryptionKeyHex.isEmpty()) {
@@ -1601,6 +1599,7 @@ void AmsWebServer::firmwareDownload() {
printI("Downloading firmware..."); printI("Downloading firmware...");
HTTPClient httpClient; HTTPClient httpClient;
httpClient.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); httpClient.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
httpClient.setTimeout(20000);
httpClient.addHeader("User-Agent", "ams2mqtt/" + String(VERSION)); httpClient.addHeader("User-Agent", "ams2mqtt/" + String(VERSION));
#if defined(ESP8266) #if defined(ESP8266)
@@ -1619,6 +1618,13 @@ void AmsWebServer::firmwareDownload() {
if(status == HTTP_CODE_OK) { if(status == HTTP_CODE_OK) {
printD("Received OK from server"); printD("Received OK from server");
if(LittleFS.begin()) { if(LittleFS.begin()) {
#if defined(ESP32)
esp_task_wdt_delete(NULL);
esp_task_wdt_deinit();
#elif defined(ESP8266)
ESP.wdtDisable();
#endif
printI("Downloading firmware to LittleFS"); printI("Downloading firmware to LittleFS");
file = LittleFS.open(FILE_FIRMWARE, "w"); file = LittleFS.open(FILE_FIRMWARE, "w");
int len = httpClient.writeToStream(&file); int len = httpClient.writeToStream(&file);

View File

@@ -61,7 +61,7 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xl-3 col-lg-4 col-md-5 col-sm-6"> <div class="col-xl-3 col-lg-4 col-md-5 col-sm-7">
<div class="m-2 input-group input-group-sm"> <div class="m-2 input-group input-group-sm">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text">Distribution system</span> <span class="input-group-text">Distribution system</span>
@@ -73,22 +73,15 @@
</select> </select>
</div> </div>
</div> </div>
<div class="col-xl-2 col-md-3 col-sm-5"> <div class="col-lg-3 col-md-4 col-sm-5">
<div class="m-2 input-group input-group-sm"> <div class="m-2 input-group input-group-sm">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text">Main fuse</span> <span class="input-group-text">Main fuse</span>
</div> </div>
<select class="form-control" name="f"> <input class="form-control text-right" name="f" type="number" min="5" max="255" step="1" value="{f}"/>
<option value="0" {f0}></option> <div class="input-group-append">
<option value="16" {f16}>16A</option> <span class="input-group-text">A</span>
<option value="20" {f20}>20A</option> </div>
<option value="25" {f25}>25A</option>
<option value="32" {f32}>32A</option>
<option value="35" {f35}>35A</option>
<option value="40" {f40}>40A</option>
<option value="50" {f50}>50A</option>
<option value="63" {f63}>63A</option>
</select>
</div> </div>
</div> </div>
<div class="col-xl-3 col-lg-4 col-md-5 col-sm-7"> <div class="col-xl-3 col-lg-4 col-md-5 col-sm-7">
@@ -96,7 +89,7 @@
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text">Production capacity</span> <span class="input-group-text">Production capacity</span>
</div> </div>
<input class="form-control" name="p" type="number" min="0" max="50" value="{p}"/> <input class="form-control text-right" name="p" type="number" min="0" max="255" step="1" value="{p}"/>
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text">kWp</span> <span class="input-group-text">kWp</span>
</div> </div>

BIN
webui2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB