Skip to content

Commit

Permalink
Version 2.9.0-beta3
Browse files Browse the repository at this point in the history
Changes since 2.9.0-beta2

fix: regression of RF debug logging to web interface
fix: issues with websocket connection when using Safari
  • Loading branch information
arjenhiemstra committed Nov 26, 2024
1 parent 67da758 commit b1b415f
Show file tree
Hide file tree
Showing 10 changed files with 923 additions and 849 deletions.
8 changes: 4 additions & 4 deletions compiled_firmware_files/firmware.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"2": {
"latest_fw": "2.8.0",
"link": "https://github.com/arjenhiemstra/ithowifi/raw/master/compiled_firmware_files/unified_hw2_noncve/nrgitho-v2.8.0.bin",
"latest_beta_fw": "2.9.0-beta2",
"link_beta": "https://github.com/arjenhiemstra/ithowifi/raw/master/compiled_firmware_files/unified_hw2_noncve/nrgitho-v2.9.0-beta2.bin"
"latest_beta_fw": "2.9.0-beta3",
"link_beta": "https://github.com/arjenhiemstra/ithowifi/raw/master/compiled_firmware_files/unified_hw2_noncve/nrgitho-v2.9.0-beta3.bin"
},
"NON-CVE 1": {
"latest_fw": "2.8.0",
"link": "https://github.com/arjenhiemstra/ithowifi/raw/master/compiled_firmware_files/unified_hw2_noncve/nrgitho-v2.8.0.bin",
"latest_beta_fw": "2.9.0-beta2",
"link_beta": "https://github.com/arjenhiemstra/ithowifi/raw/master/compiled_firmware_files/unified_hw2_noncve/nrgitho-v2.9.0-beta2.bin"
"latest_beta_fw": "2.9.0-beta3",
"link_beta": "https://github.com/arjenhiemstra/ithowifi/raw/master/compiled_firmware_files/unified_hw2_noncve/nrgitho-v2.9.0-beta3.bin"
}
}
}
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion software/NRG_itho_wifi/main/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

#define FWVERSION "2.9.0-beta2"
#define FWVERSION "2.9.0-beta3"
1,577 changes: 793 additions & 784 deletions software/NRG_itho_wifi/main/webroot/controls_js_gz.h

Large diffs are not rendered by default.

83 changes: 57 additions & 26 deletions software/NRG_itho_wifi/main/webroot_source/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,66 @@ var settingIndex = -1;
var websocketServerLocation = location.protocol.indexOf("https") > -1 ? 'wss://' + window.location.hostname + ':8000/ws' : 'ws://' + window.location.hostname + ':8000/ws';

let messageQueue = [];
let connectTimeout, pingTimeout;
let websock;

function startWebsock(websocketServerLocation) {
if (debug) console.log(websocketServerLocation);
messageQueue = [];
clearTimeout(connectTimeout);
clearTimeout(pingTimeout);
pingTimeout = !1;
connectTimeout = setTimeout((() => {
if (debug) console.log("websock connect timeout."),
//websock.close(),
startWebsock(websocketServerLocation);
}), 1000);
websock = null;
websock = new WebSocket(websocketServerLocation);
websock.addEventListener('message', event => {
// Add message to the queue
messageQueue.push(event.data);
});
websock.onopen = function (a) {

websock.addEventListener('open', function (event) {
if (debug) console.log('websock open');
clearTimeout(connectTimeout);
document.getElementById("layout").style.opacity = 1;
document.getElementById("loader").style.display = "none";
if (lastPageReq !== "") {
update_page(lastPageReq);
}
getSettings('syssetup');
};

websock.onclose = function (a) {
});
websock.addEventListener('message', function (event) {
"pong" == event.data ? (clearTimeout(pingTimeout),
pingTimeout = !1) : messageQueue.push(event.data);
});
websock.addEventListener('close', function (event) {
if (debug) console.log('websock close');
// Try to reconnect in 200 milliseconds
websock = null;
document.getElementById("layout").style.opacity = 0.3;
document.getElementById("loader").style.display = "block";
setTimeout(function () { startWebsock(websocketServerLocation) }, 200);
};

websock.onerror = function (a) {
try {
if (debug) console.log(a);
} catch (error) {
if (debug) console.log(error);
// setTimeout(startWebsock, 200, websocketServerLocation);
});
websock.addEventListener('error', function (event) {
if (debug) console.log("websock Error!", event);
startWebsock(websocketServerLocation);
//websock.close();
});
setInterval((() => {
pingTimeout || websock.readyState != WebSocket.OPEN || (pingTimeout = setTimeout((() => {
if (debug) console.log("websock ping timeout.");
startWebsock(websocketServerLocation);
}
};
), 3e3),
websock_send("ping"))
}
), 2e3)
}

function websock_send(message) {
if (websock.readyState === 1) {
if (debug) console.log(message);
websock.send(message);
}
else {
if (debug) console.log("websock.readyState != open");
}
}

(async function processMessages() {
Expand Down Expand Up @@ -306,6 +330,18 @@ function processMessage(message) {

}

function initButton() {
document.getElementById("command-button").addEventListener("click", sendCommand)
}
function trapKeyPress() {
document.getElementById("command-text").addEventListener("keypress", (e => {
"Enter" === e.code && (e.preventDefault(), document.getElementById("command-button").click())
})),
document.addEventListener("keydown", (e => {
document.activeElement && "command-text" === document.activeElement.id && ("ArrowUp" === e.code ? (commandHistoryIdx--, commandHistoryIdx < 0 && (commandHistoryIdx = commandHistory.length > 0 ? commandHistory.length - 1 : 0), commandHistoryIdx >= 0 && commandHistoryIdx < commandHistory.length && (document.getElementById("command-text").value = commandHistory[commandHistoryIdx])) : "ArrowDown" === e.code && (commandHistoryIdx++, commandHistoryIdx >= commandHistory.length && (commandHistoryIdx = 0), commandHistoryIdx >= 0 && commandHistoryIdx < commandHistory.length && (document.getElementById("command-text").value = commandHistory[commandHistoryIdx])))
}))
}

function clearSettingsLocStor() {
let setlen = localStorage.getItem("itho_setlen");
for (var index = 0; index < setlen; index++) {
Expand Down Expand Up @@ -859,11 +895,6 @@ $(document).ready(function () {
});
});

function websock_send(message) {
websock.send(message);
if (debug) console.log(message);
}

var timerHandle = setTimeout(function () {
$('#message_box').hide();
}, 5000);
Expand Down Expand Up @@ -1755,7 +1786,7 @@ var html_debug = `
<span style="color:red">
WPU 5G: Make sure you set the "Max manual operation time" setting on the "Itho settings" page.<br>
The itho unit will remain in manual mode until the timer expires. 0 means unlimited.<br>
Warning!!<br></vr></span><br>
Warning!!<br></span><br>
</fieldset><br><br><br>
</fieldset>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ <h1>Debug page</h1>
<span style="color:red">
WPU 5G: Make sure you set the "Max manual operation time" setting on the "Itho settings" page.<br>
The itho unit will remain in manual mode until the timer expires. 0 means unlimited.<br>
Warning!!<br></vr></span><br>
Warning!!<br></span><br>
</fieldset><br><br><br>
</fieldset>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,66 @@ var settingIndex = -1;
var websocketServerLocation = location.protocol.indexOf("https") > -1 ? 'wss://' + window.location.hostname + ':8000/ws' : 'ws://' + window.location.hostname + ':8000/ws';

let messageQueue = [];
let connectTimeout, pingTimeout;
let websock;

function startWebsock(websocketServerLocation) {
if (debug) console.log(websocketServerLocation);
messageQueue = [];
clearTimeout(connectTimeout);
clearTimeout(pingTimeout);
pingTimeout = !1;
connectTimeout = setTimeout((() => {
if (debug) console.log("websock connect timeout."),
//websock.close(),
startWebsock(websocketServerLocation);
}), 1000);
websock = null;
websock = new WebSocket(websocketServerLocation);
websock.addEventListener('message', event => {
// Add message to the queue
messageQueue.push(event.data);
});
websock.onopen = function (a) {

websock.addEventListener('open', function (event) {
if (debug) console.log('websock open');
clearTimeout(connectTimeout);
document.getElementById("layout").style.opacity = 1;
document.getElementById("loader").style.display = "none";
if (lastPageReq !== "") {
update_page(lastPageReq);
}
getSettings('syssetup');
};

websock.onclose = function (a) {
});
websock.addEventListener('message', function (event) {
"pong" == event.data ? (clearTimeout(pingTimeout),
pingTimeout = !1) : messageQueue.push(event.data);
});
websock.addEventListener('close', function (event) {
if (debug) console.log('websock close');
// Try to reconnect in 200 milliseconds
websock = null;
document.getElementById("layout").style.opacity = 0.3;
document.getElementById("loader").style.display = "block";
setTimeout(function () { startWebsock(websocketServerLocation) }, 200);
};

websock.onerror = function (a) {
try {
if (debug) console.log(a);
} catch (error) {
if (debug) console.log(error);
// setTimeout(startWebsock, 200, websocketServerLocation);
});
websock.addEventListener('error', function (event) {
if (debug) console.log("websock Error!", event);
startWebsock(websocketServerLocation);
//websock.close();
});
setInterval((() => {
pingTimeout || websock.readyState != WebSocket.OPEN || (pingTimeout = setTimeout((() => {
if (debug) console.log("websock ping timeout.");
startWebsock(websocketServerLocation);
}
};
), 3e3),
websock_send("ping"))
}
), 2e3)
}

function websock_send(message) {
if (websock.readyState === 1) {
if (debug) console.log(message);
websock.send(message);
}
else {
if (debug) console.log("websock.readyState != open");
}
}

(async function processMessages() {
Expand Down Expand Up @@ -305,6 +329,18 @@ function processMessage(message) {

}

function initButton() {
document.getElementById("command-button").addEventListener("click", sendCommand)
}
function trapKeyPress() {
document.getElementById("command-text").addEventListener("keypress", (e => {
"Enter" === e.code && (e.preventDefault(), document.getElementById("command-button").click())
})),
document.addEventListener("keydown", (e => {
document.activeElement && "command-text" === document.activeElement.id && ("ArrowUp" === e.code ? (commandHistoryIdx--, commandHistoryIdx < 0 && (commandHistoryIdx = commandHistory.length > 0 ? commandHistory.length - 1 : 0), commandHistoryIdx >= 0 && commandHistoryIdx < commandHistory.length && (document.getElementById("command-text").value = commandHistory[commandHistoryIdx])) : "ArrowDown" === e.code && (commandHistoryIdx++, commandHistoryIdx >= commandHistory.length && (commandHistoryIdx = 0), commandHistoryIdx >= 0 && commandHistoryIdx < commandHistory.length && (document.getElementById("command-text").value = commandHistory[commandHistoryIdx])))
}))
}

function clearSettingsLocStor() {
let setlen = localStorage.getItem("itho_setlen");
for (var index = 0; index < setlen; index++) {
Expand Down Expand Up @@ -858,11 +894,6 @@ $(document).ready(function () {
});
});

function websock_send(message) {
websock.send(message);
if (debug) console.log(message);
}

var timerHandle = setTimeout(function () {
$('#message_box').hide();
}, 5000);
Expand Down
17 changes: 10 additions & 7 deletions software/NRG_itho_wifi/main/websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,8 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
{
if (type == WS_EVT_CONNECT)
{
// Serial.printf("ws[%s][%u] connect\n", server->url(), client->id());
client->ping();
client->setCloseClientOnQueueFull(false);
return;
}
else if (type == WS_EVT_DISCONNECT)
{
Expand All @@ -806,14 +806,11 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
}
else if (type == WS_EVT_DATA)
{
AwsFrameInfo *info = (AwsFrameInfo *)arg;
std::string msg;
AwsFrameInfo *info = (AwsFrameInfo *)arg;

if (info->final && info->index == 0 && info->len == len)
{
// the whole message is in a single frame and we got all of it's data
// Serial.printf("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT)?"text":"binary", info->len);

if (info->opcode == WS_TEXT)
{
for (size_t i = 0; i < info->len; i++)
Expand All @@ -830,8 +827,14 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
msg += buff;
}
}
}
if (strcmp(msg.c_str(), "ping") == 0)
{
client->text("pong");
}
else
{
handle_ws_message(std::move(msg));
// Serial.printf("%s\n",msg.c_str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion software/NRG_itho_wifi/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ default_envs =
[env]
; Global data for all [env:***]
build_flags =
-D VERSION=2.9.0-beta2
-D VERSION=2.9.0-beta3
;upload_port = /dev/cu.usbserial-1410 #optional, only needed if PlatformIO autodetect is not working
;monitor_port = /dev/cu.usbserial-1410 #optional, only needed if PlatformIO autodetect is not working
platform = platformio/espressif32 @ ~6.9.0
Expand Down

0 comments on commit b1b415f

Please sign in to comment.