From 397fea3bb2d65f501c592af53f8dd22f19943af6 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 29 Mar 2020 15:17:54 +0200 Subject: [PATCH] Add Console command history Add Console command history (#8015) --- tasmota/xdrv_01_webserver.ino | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index c6cf97580..e4336b736 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -31,7 +31,7 @@ #define WIFI_SOFT_AP_CHANNEL 1 // Soft Access Point Channel number between 1 and 11 as used by WifiManager web GUI #endif -const uint16_t CHUNKED_BUFFER_SIZE = 400; // Chunk buffer size (should be smaller than half mqtt_date size = MESSZ) +const uint16_t CHUNKED_BUFFER_SIZE = (MESSZ / 2) - 100; // Chunk buffer size (should be smaller than half mqtt_data size = MESSZ) const uint16_t HTTP_REFRESH_TIME = 2345; // milliseconds #define HTTP_RESTART_RECONNECT_TIME 9000 // milliseconds @@ -184,7 +184,7 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM = "clearTimeout(lt);" "t=eb('t1');" "if(p==1){" - "c=eb('c1');" + "c=eb('c1');" // Console command id "o='&c1='+encodeURIComponent(c.value);" "c.value='';" "t.scrollTop=99999;" @@ -211,6 +211,16 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM = "lt=setTimeout(l,%d);" "return false;" "}" + + // Console command history - part 2 + "var mh=20,hc=[],cn=0;" + "function cH(a){" + "var b=qs('#c1'),c=a.keyCode;" // c1 = Console command id + "38==c?(++cn>hc.length&&(cn=hc.length),b.value=hc[cn-1]||''):" // Arrow Up + "40==c?(0>--cn&&(cn=0),b.value=hc[cn-1]||''):" // Arrow Down + "13==c&&(hc.length>19&&hc.pop(),hc.unshift(b.value),cn=0)" // Enter + "}" + "wl(l);"; const char HTTP_MODULE_TEMPLATE_REPLACE[] PROGMEM = @@ -329,6 +339,12 @@ const char HTTP_HEAD_LAST_SCRIPT[] PROGMEM = "}" "t++;" "}" + + // Console command history - part 1 + "if(qs('#c1')){" // c1 = Console command id + "qs('#c1').addEventListener('keydown',cH);" + "}" + "}" "wl(jd);" // Add name='' to any id='' in input,button,textarea,select ""; @@ -745,7 +761,7 @@ void _WSContentSend(const String& content) // Low level sendContent for a #ifdef USE_DEBUG_DRIVER ShowFreeMem(PSTR("WSContentSend")); #endif - DEBUG_CORE_LOG(PSTR("WEB: Chunk size %d"), len); + DEBUG_CORE_LOG(PSTR("WEB: Chunk size %d/%d"), len, sizeof(mqtt_data)); } void WSContentFlush(void) @@ -1735,7 +1751,7 @@ void HandleWifiConfiguration(void) //display networks in page for (uint32_t i = 0; i < n; i++) { if (-1 == indices[i]) { continue; } // skip dups - int32_t rssi = WiFi.RSSI(indices[i]) + int32_t rssi = WiFi.RSSI(indices[i]); DEBUG_CORE_LOG(PSTR(D_LOG_WIFI D_SSID " %s, " D_BSSID " %s, " D_CHANNEL " %d, " D_RSSI " %d"), WiFi.SSID(indices[i]).c_str(), WiFi.BSSIDstr(indices[i]).c_str(), WiFi.channel(indices[i]), rssi); int quality = WifiGetRssiAsQuality(rssi);