You wouldn't believe this simple trick that freed 10 kB of RAM!

http-comm
Ondřej Hruška 7 years ago
parent 830ec073bf
commit 8d7419b666
  1. 3
      CMakeLists.txt
  2. 4
      esphttpdconfig.mk
  3. 45
      html_orig/js/app.js
  4. 2
      libesphttpd
  5. 4
      user/apars_csi.c
  6. 6
      user/character_sets.h
  7. 2
      user/routes.c
  8. 2
      user/routes.h

@ -110,8 +110,6 @@ set(SOURCE_FILES
user/serial.h user/serial.h
user/routes.c user/routes.c
user/routes.h user/routes.h
user/uart_asyncdrv.c-
user/uart_asyncdrv.h-
user/cgi_main.c user/cgi_main.c
user/cgi_main.h user/cgi_main.h
user/cgi_sockets.c user/cgi_sockets.c
@ -155,6 +153,7 @@ include_directories(esp_iot_sdk_v1.5.2/include)
add_definitions( add_definitions(
-D__ets__ -D__ets__
-DICACHE_FLASH -DICACHE_FLASH
-DUSE_OPTIMIZE_PRINTF=1
-DHTTPD_MAX_CONNECTIONS=5 -DHTTPD_MAX_CONNECTIONS=5
-DHTTPD_STACKSIZE=1000 -DHTTPD_STACKSIZE=1000
-DICACHE_FLASH_ATTR= -DICACHE_FLASH_ATTR=

@ -54,4 +54,6 @@ GLOBAL_CFLAGS = \
-DHTTPD_MAX_POST_LEN=512 \ -DHTTPD_MAX_POST_LEN=512 \
-DDEBUG_INPUT=0 \ -DDEBUG_INPUT=0 \
-DDEBUG_HEAP=1 \ -DDEBUG_HEAP=1 \
-DDEBUG_MALLOC=0 -DDEBUG_MALLOC=0 \
-mforce-l32 \
-DUSE_OPTIMIZE_PRINTF=1

@ -1609,22 +1609,27 @@ function tr(key) { return _tr[key] || '?'+key+'?'; }
w.startScanning = startScanning; w.startScanning = startScanning;
})(window.WiFi = {}); })(window.WiFi = {});
/** Handle connections */ /** Handle connections */
var Conn = (function() { var Conn = (function () {
var ws; var ws;
var heartbeatTout; var heartbeatTout;
var pingIv; var pingIv;
var xoff = false; var xoff = false;
var autoXoffTout; var autoXoffTout;
var reconTout;
var pageShown = false;
function onOpen(evt) { function onOpen(evt) {
console.log("CONNECTED"); console.log("CONNECTED");
doSend("i");
} }
function onClose(evt) { function onClose(evt) {
console.warn("SOCKET CLOSED, code "+evt.code+". Reconnecting..."); console.warn("SOCKET CLOSED, code " + evt.code + ". Reconnecting...");
setTimeout(function() { clearTimeout(reconTout);
reconTout = setTimeout(function () {
init(); init();
}, 200); }, 2000);
// this happens when the buffer gets fucked up via invalid unicode. // this happens when the buffer gets fucked up via invalid unicode.
// we basically use polling instead of socket then // we basically use polling instead of socket then
} }
@ -1637,12 +1642,18 @@ var Conn = (function() {
case 'T': case 'T':
case 'S': case 'S':
Screen.load(evt.data); Screen.load(evt.data);
if(!pageShown) {
showPage();
pageShown = true;
}
break; break;
case '-': case '-':
//console.log('xoff'); //console.log('xoff');
xoff = true; xoff = true;
autoXoffTout = setTimeout(function(){xoff=false;}, 250); autoXoffTout = setTimeout(function () {
xoff = false;
}, 250);
break; break;
case '+': case '+':
@ -1652,7 +1663,7 @@ var Conn = (function() {
break; break;
} }
heartbeat(); heartbeat();
} catch(e) { } catch (e) {
console.error(e); console.error(e);
} }
} }
@ -1691,24 +1702,16 @@ var Conn = (function() {
showPage(); showPage();
return; return;
} }
heartbeat();
ws = new WebSocket("ws://"+_root+"/term/update.ws"); clearTimeout(reconTout);
clearTimeout(heartbeatTout);
ws = new WebSocket("ws://" + _root + "/term/update.ws");
ws.onopen = onOpen; ws.onopen = onOpen;
ws.onclose = onClose; ws.onclose = onClose;
ws.onmessage = onMessage; ws.onmessage = onMessage;
console.log("Opening socket."); console.log("Opening socket.");
// Ask for initial data
$.get('http://'+_root+'/term/init', function(resp, status) {
if (status !== 200) location.reload(true);
console.log("Data received!");
Screen.load(resp);
heartbeat(); heartbeat();
showPage();
});
} }
function heartbeat() { function heartbeat() {
@ -1718,9 +1721,9 @@ var Conn = (function() {
function heartbeatFail() { function heartbeatFail() {
console.error("Heartbeat lost, probing server..."); console.error("Heartbeat lost, probing server...");
pingIv = setInterval(function() { pingIv = setInterval(function () {
console.log("> ping"); console.log("> ping");
$.get('http://'+_root+'/system/ping', function(resp, status) { $.get('http://' + _root + '/system/ping', function (resp, status) {
if (status == 200) { if (status == 200) {
clearInterval(pingIv); clearInterval(pingIv);
console.info("Server ready, reloading page..."); console.info("Server ready, reloading page...");
@ -1729,7 +1732,7 @@ var Conn = (function() {
}, { }, {
timeout: 100, timeout: 100,
}); });
}, 500); }, 1000);
} }
return { return {

@ -1 +1 @@
Subproject commit 13fa224963081e9ff298abd74a59faafcb9bf816 Subproject commit 3479ab3efcb4581669370cde6a607f936ff5515a

@ -760,7 +760,7 @@ do_csi_xterm_screen_cmd(CSI_Data *opts)
// data tables for the DECREPTPARM command response // data tables for the DECREPTPARM command response
struct DECREPTPARM_parity { int parity; const char * msg; }; struct DECREPTPARM_parity { int parity; const char * msg; };
static const struct DECREPTPARM_parity DECREPTPARM_parity_arr[] = { static const struct DECREPTPARM_parity DECREPTPARM_parity_arr[] ESP_CONST_DATA = {
{PARITY_NONE, "1"}, {PARITY_NONE, "1"},
{PARITY_ODD, "4"}, {PARITY_ODD, "4"},
{PARITY_EVEN, "5"}, {PARITY_EVEN, "5"},
@ -768,7 +768,7 @@ static const struct DECREPTPARM_parity DECREPTPARM_parity_arr[] = {
}; };
struct DECREPTPARM_baud { int baud; const char * msg; }; struct DECREPTPARM_baud { int baud; const char * msg; };
static const struct DECREPTPARM_baud DECREPTPARM_baud_arr[] = { static const struct DECREPTPARM_baud DECREPTPARM_baud_arr[] ESP_CONST_DATA = {
{BIT_RATE_300, "48"}, {BIT_RATE_300, "48"},
{BIT_RATE_600, "56"}, {BIT_RATE_600, "56"},
{BIT_RATE_1200, "64"}, {BIT_RATE_1200, "64"},

@ -12,7 +12,7 @@
#define CODEPAGE_A_BEGIN 35 #define CODEPAGE_A_BEGIN 35
#define CODEPAGE_A_END 35 #define CODEPAGE_A_END 35
static const u16 codepage_A[] = static const u16 codepage_A[] ESP_CONST_DATA =
{// Unicode ASCII SYM {// Unicode ASCII SYM
// %%BEGIN:A%% // %%BEGIN:A%%
0x20a4, // 35 # £ 0x20a4, // 35 # £
@ -26,7 +26,7 @@ static const u16 codepage_A[] =
* translates VT100 ACS escape codes to Unicode values. * translates VT100 ACS escape codes to Unicode values.
* Based on rxvt-unicode screen.C table. * Based on rxvt-unicode screen.C table.
*/ */
static const u16 codepage_0[] = static const u16 codepage_0[] ESP_CONST_DATA =
{// Unicode ASCII SYM {// Unicode ASCII SYM
// %%BEGIN:0%% // %%BEGIN:0%%
0x2666, // 96 ` ♦ 0x2666, // 96 ` ♦
@ -66,7 +66,7 @@ static const u16 codepage_0[] =
#define CODEPAGE_1_BEGIN 33 #define CODEPAGE_1_BEGIN 33
#define CODEPAGE_1_END 126 #define CODEPAGE_1_END 126
static const u16 codepage_1[] = static const u16 codepage_1[] ESP_CONST_DATA =
{// Unicode ASCII SYM DOS {// Unicode ASCII SYM DOS
// %%BEGIN:1%% // %%BEGIN:1%%
0x263A, // 33 ! ☺ (1) - low ASCII symbols from DOS, moved to +32 0x263A, // 33 ! ☺ (1) - low ASCII symbols from DOS, moved to +32

@ -22,7 +22,7 @@ static int wifiPassFn(HttpdConnData *connData, int no, char *user, int userLen,
/** /**
* Application routes * Application routes
*/ */
HttpdBuiltInUrl routes[] = { const HttpdBuiltInUrl routes[] ESP_CONST_DATA = {
// redirect func for the captive portal // redirect func for the captive portal
ROUTE_CGI_ARG("*", cgiRedirectApClientToHostname, "esp-terminal.ap"), ROUTE_CGI_ARG("*", cgiRedirectApClientToHostname, "esp-terminal.ap"),

@ -4,7 +4,7 @@
#include <esp8266.h> #include <esp8266.h>
#include <httpd.h> #include <httpd.h>
extern HttpdBuiltInUrl routes[]; extern const HttpdBuiltInUrl routes[];
/** Broadcast screen state to sockets */ /** Broadcast screen state to sockets */
void screen_notifyChange(); void screen_notifyChange();

Loading…
Cancel
Save