From 8eb01a725b8a485840b4071bf7ac021b9a56fc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 19 Mar 2017 00:35:12 +0100 Subject: [PATCH] 0.5.3 - added auto reconnect fn to javascript to fix broken page loads in some cases --- html_orig/js/app.js | 20 +++++++++++--------- html_orig/jssrc/term.js | 10 ++++------ html_orig/packjs.sh | 2 ++ html_orig/term.html | 18 ++++++++++++++++-- user/user_main.h | 2 +- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/html_orig/js/app.js b/html_orig/js/app.js index 787b4d0..7aed10d 100644 --- a/html_orig/js/app.js +++ b/html_orig/js/app.js @@ -896,7 +896,8 @@ $._loader = function(vis) { var screen = []; var blinkIval; - /** Clear screen */ +/* + /!** Clear screen *!/ function cls() { screen.forEach(function(cell, i) { cell.t = ' '; @@ -905,6 +906,7 @@ $._loader = function(vis) { blit(cell); }); } +*/ /** Set text and color at XY */ function cellAt(y, x) { @@ -916,14 +918,15 @@ $._loader = function(vis) { return cellAt(cursor.y, cursor.x); } - /** Enable or disable cursor visibility */ +/* + /!** Enable or disable cursor visibility *!/ function cursorEnable(enable) { cursor.hidden = !enable; cursor.a &= enable; blit(cursorCell(), cursor.a); } - /** Safely move cursor */ + /!** Safely move cursor *!/ function cursorSet(y, x) { // Hide and prevent from showing up during the move cursor.suppress = true; @@ -936,6 +939,7 @@ $._loader = function(vis) { cursor.suppress = false; blit(cursorCell(), cursor.a); } +*/ /** Update cell on display. inv = invert (for cursor) */ function blit(cell, inv) { @@ -1081,7 +1085,10 @@ $._loader = function(vis) { } function onClose(evt) { - console.error("SOCKET CLOSED"); + console.warn("SOCKET CLOSED, code "+evt.code+". Reconnecting..."); + setTimeout(function() { + init(); + }, 2000); } function onMessage(evt) { @@ -1094,10 +1101,6 @@ $._loader = function(vis) { } } - function onError(evt) { - console.error(evt.data); - } - function doSend(message) { console.log("TX: ", message); if (ws.readyState != 1) { @@ -1115,7 +1118,6 @@ $._loader = function(vis) { ws.onopen = onOpen; ws.onclose = onClose; ws.onmessage = onMessage; - ws.onerror = onError; console.log("Opening socket."); } diff --git a/html_orig/jssrc/term.js b/html_orig/jssrc/term.js index 78ac418..b9253d6 100644 --- a/html_orig/jssrc/term.js +++ b/html_orig/jssrc/term.js @@ -197,7 +197,10 @@ } function onClose(evt) { - console.error("SOCKET CLOSED"); + console.warn("SOCKET CLOSED, code "+evt.code+". Reconnecting..."); + setTimeout(function() { + init(); + }, 1000); } function onMessage(evt) { @@ -210,10 +213,6 @@ } } - function onError(evt) { - console.error(evt.data); - } - function doSend(message) { console.log("TX: ", message); if (ws.readyState != 1) { @@ -231,7 +230,6 @@ ws.onopen = onOpen; ws.onclose = onClose; ws.onmessage = onMessage; - ws.onerror = onError; console.log("Opening socket."); } diff --git a/html_orig/packjs.sh b/html_orig/packjs.sh index f00f6c1..37c976c 100755 --- a/html_orig/packjs.sh +++ b/html_orig/packjs.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "Packing js..." + cat jssrc/chibi.js \ jssrc/utils.js \ jssrc/modal.js \ diff --git a/html_orig/term.html b/html_orig/term.html index a6fc06a..c0d5106 100644 --- a/html_orig/term.html +++ b/html_orig/term.html @@ -5,6 +5,15 @@ ESP8266 Remote Terminal + + @@ -31,8 +40,13 @@ diff --git a/user/user_main.h b/user/user_main.h index 4300827..19e5a0c 100644 --- a/user/user_main.h +++ b/user/user_main.h @@ -1,7 +1,7 @@ #ifndef USER_MAIN_H_H #define USER_MAIN_H_H -#define FIRMWARE_VERSION "0.5.2" +#define FIRMWARE_VERSION "0.5.3" #define TERMINAL_GITHUB_REPO "https://github.com/MightyPork/esp-vt100-firmware" #endif //USER_MAIN_H_H