Browse Source

0.8.124

* support of HERF inverters, serial number is converted in Javascript #1425
* revert buffer size in `RestAPI` for ESP8266 #1650
pull/1670/head
lumapu 8 months ago
parent
commit
10423d7476
  1. 2
      src/CHANGES.md
  2. 4
      src/web/RestApi.h
  3. 33
      src/web/html/setup.html

2
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

4
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);

33
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)

Loading…
Cancel
Save