Skip to content

Commit

Permalink
0.8.124
Browse files Browse the repository at this point in the history
* support of HERF inverters, serial number is converted in Javascript #1425
* revert buffer size in `RestAPI` for ESP8266 #1650
  • Loading branch information
lumapu committed Jun 6, 2024
1 parent 034cbd5 commit 10423d7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 31 additions & 2 deletions src/web/html/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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)
Expand Down

0 comments on commit 10423d7

Please sign in to comment.