From 10423d7476e68565a9756b62d9935ce5fe7c21d5 Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 7 Jun 2024 00:29:20 +0200 Subject: [PATCH] 0.8.124 * support of HERF inverters, serial number is converted in Javascript #1425 * revert buffer size in `RestAPI` for ESP8266 #1650 --- src/CHANGES.md | 2 ++ src/web/RestApi.h | 4 ++++ src/web/html/setup.html | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 51723203..ebe26f58 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,8 @@ ## 0.8.124 - 2024-06-06 * improved MqTT `OnMessage` (threadsafe) +* support of HERF inverters, serial number is converted in Javascript #1425 +* revert buffer size in `RestAPI` for ESP8266 #1650 ## 0.8.123 - 2024-05-30 * fix ESP8266, ESP32 static IP #1643 #1608 diff --git a/src/web/RestApi.h b/src/web/RestApi.h index e7f23055..d1f130d4 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -83,7 +83,11 @@ class RestApi { mHeapFrag = ESP.getHeapFragmentation(); #endif + #if defined(ESP32) AsyncJsonResponse* response = new AsyncJsonResponse(false, 8000); + #else + AsyncJsonResponse* response = new AsyncJsonResponse(false, 6000); + #endif JsonObject root = response->getRoot(); String path = request->url().substring(5); diff --git a/src/web/html/setup.html b/src/web/html/setup.html index 26b7100c..9452f0e3 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -880,11 +880,16 @@ ser.dispatchEvent(new Event('change')); function ivSave() { - var o = new Object(); + var o = {} o.cmd = "save_iv" o.token = "*" o.id = obj.id - o.ser = parseInt(document.getElementsByName("ser")[0].value, 16); + + let sn = document.getElementsByName("ser")[0].value + if(sn[0] == 'A') + sn = convHerf(sn) + o.ser = parseInt(sn, 16) + o.name = document.getElementsByName("name")[0].value; o.en = document.getElementsByName("enable")[0].checked; o.ch = []; @@ -904,6 +909,30 @@ getAjax("/api/setup", cb, "POST", JSON.stringify(o)); } + function convHerf(sn) { + let sn_int = 0n; + const CHARS = "0123456789ABCDEFGHJKLMNPRSTUVWXY"; + + for (let i = 0; i < 9; ++i) { + const pos = CHARS.indexOf(sn[i]) + const shift = 42 - 5 * i - (i <= 2 ? 0 : 2) + sn_int |= BigInt(pos) << BigInt(shift) + } + + let first4Hex = (sn_int >> 32n) & 0xFFFFn + + if (first4Hex === 0x2841n) + first4Hex = 0x1121n + else if (first4Hex === 0x2821n) + first4Hex = 0x1141n + else if (first4Hex === 0x2801n) + first4Hex = 0x1161n + + sn_int = (sn_int & ~(0xFFFFn << 32n)) | (first4Hex << 32n); + + return sn_int.toString(16) + } + function cb(obj2) { var e = document.getElementById("res"); if(!obj2.success)