pull/111/merge
Ondřej Hruška 7 years ago
parent 6c9ae7e126
commit a82e14961c
  1. 1
      CMakeLists.txt
  2. 5
      esphttpdconfig.mk
  3. 4
      html_orig/build_html.php
  4. 11
      user/cgi_sockets.c
  5. 4
      user/routes.c
  6. 2
      user/screen.c
  7. 2
      user/screen.h
  8. 2
      user/serial.c
  9. 22
      user/uart_buffer.c

@ -163,6 +163,7 @@ add_definitions(
-DADMIN_PASSWORD="asdf" -DADMIN_PASSWORD="asdf"
-DGIT_HASH="blabla" -DGIT_HASH="blabla"
-DDEBUG_HEAP=1 -DDEBUG_HEAP=1
-DDEBUG_MALLOC=1
-DESPFS_HEATSHRINK) -DESPFS_HEATSHRINK)
add_executable(ESPTerm ${SOURCE_FILES}) add_executable(ESPTerm ${SOURCE_FILES})

@ -50,5 +50,8 @@ GLOBAL_CFLAGS = \
-DDEBUG_ANSI=1 \ -DDEBUG_ANSI=1 \
-DDEBUG_ANSI_NOIMPL=1 \ -DDEBUG_ANSI_NOIMPL=1 \
-DHTTPD_MAX_BACKLOG_SIZE=8192 \ -DHTTPD_MAX_BACKLOG_SIZE=8192 \
-DHTTPD_MAX_HEAD_LEN=512 \
-DHTTPD_MAX_POST_LEN=512 \
-DDEBUG_INPUT=0 \ -DDEBUG_INPUT=0 \
-DDEBUG_HEAP=1 -DDEBUG_HEAP=1 \
-DDEBUG_MALLOC=0

@ -14,6 +14,8 @@ function process_html($s) {
return $s; return $s;
} }
$no_tpl_files = ['help', 'cfg_wifi_conn'];
ob_start(); ob_start();
foreach($_pages as $_k => $p) { foreach($_pages as $_k => $p) {
if ($p->bodyclass == 'api') continue; if ($p->bodyclass == 'api') continue;
@ -30,7 +32,7 @@ foreach($_pages as $_k => $p) {
// $s = process_html($s); // $s = process_html($s);
ob_clean(); // clean up ob_clean(); // clean up
$of = __DIR__ . '/../html/' . $_k . '.tpl'; $of = __DIR__ . '/../html/' . $_k . (in_array($_k, $no_tpl_files) ? '.html' : '.tpl');
file_put_contents($of, $s); // write to a file file_put_contents($of, $s); // write to a file
} }

@ -11,8 +11,9 @@
#define LOOPBACK 0 #define LOOPBACK 0
#define SOCK_BUF_LEN 1024 #define HB_TIME 1500
static char sock_buff[SOCK_BUF_LEN];
#define SOCK_BUF_LEN 2000
volatile bool notify_available = true; volatile bool notify_available = true;
volatile bool notify_cooldown = false; volatile bool notify_cooldown = false;
@ -41,6 +42,8 @@ notifyContentTimCb(void *arg)
{ {
void *data = NULL; void *data = NULL;
int max_bl, total_bl; int max_bl, total_bl;
char sock_buff[SOCK_BUF_LEN];
cgiWebsockMeasureBacklog(URL_WS_UPDATE, &max_bl, &total_bl); cgiWebsockMeasureBacklog(URL_WS_UPDATE, &max_bl, &total_bl);
if (!notify_available || notify_cooldown || (max_bl > 2048)) { // do not send if we have anything significant backlogged if (!notify_available || notify_cooldown || (max_bl > 2048)) { // do not send if we have anything significant backlogged
@ -71,6 +74,8 @@ notifyContentTimCb(void *arg)
static void ICACHE_FLASH_ATTR static void ICACHE_FLASH_ATTR
notifyLabelsTimCb(void *arg) notifyLabelsTimCb(void *arg)
{ {
char sock_buff[SOCK_BUF_LEN];
if (!notify_available || notify_cooldown) { if (!notify_available || notify_cooldown) {
// postpone a little // postpone a little
TIMER_START(&notifyLabelsTim, notifyLabelsTimCb, 1, 0); TIMER_START(&notifyLabelsTim, notifyLabelsTimCb, 1, 0);
@ -250,5 +255,5 @@ void ICACHE_FLASH_ATTR updateSockConnect(Websock *ws)
ws_info("Socket connected to "URL_WS_UPDATE); ws_info("Socket connected to "URL_WS_UPDATE);
ws->recvCb = updateSockRx; ws->recvCb = updateSockRx;
TIMER_START(&heartbeatTim, heartbeatTimCb, 1000, 1); TIMER_START(&heartbeatTim, heartbeatTimCb, HB_TIME, 1);
} }

@ -29,7 +29,7 @@ HttpdBuiltInUrl routes[] = {
// --- Web pages --- // --- Web pages ---
ROUTE_TPL_FILE("/", tplScreen, "/term.tpl"), ROUTE_TPL_FILE("/", tplScreen, "/term.tpl"),
ROUTE_TPL_FILE("/about/?", tplAbout, "/about.tpl"), ROUTE_TPL_FILE("/about/?", tplAbout, "/about.tpl"),
ROUTE_FILE("/help/?", "/help.tpl"), ROUTE_FILE("/help/?", "/help.html"),
// --- Sockets --- // --- Sockets ---
ROUTE_CGI("/term/init", cgiTermInitialImage), ROUTE_CGI("/term/init", cgiTermInitialImage),
@ -46,7 +46,7 @@ HttpdBuiltInUrl routes[] = {
ROUTE_REDIRECT("/cfg/?", "/cfg/wifi"), ROUTE_REDIRECT("/cfg/?", "/cfg/wifi"),
ROUTE_TPL_FILE("/cfg/wifi/?", tplWlan, "/cfg_wifi.tpl"), ROUTE_TPL_FILE("/cfg/wifi/?", tplWlan, "/cfg_wifi.tpl"),
ROUTE_FILE("/cfg/wifi/connecting/?", "/cfg_wifi_conn.tpl"), ROUTE_FILE("/cfg/wifi/connecting/?", "/cfg_wifi_conn.html"),
ROUTE_CGI("/cfg/wifi/scan", cgiWiFiScan), ROUTE_CGI("/cfg/wifi/scan", cgiWiFiScan),
ROUTE_CGI("/cfg/wifi/connstatus", cgiWiFiConnStatus), ROUTE_CGI("/cfg/wifi/connstatus", cgiWiFiConnStatus),
ROUTE_CGI("/cfg/wifi/set", cgiWiFiSetParams), ROUTE_CGI("/cfg/wifi/set", cgiWiFiSetParams),

@ -201,6 +201,8 @@ terminal_apply_settings_noclear(void)
void ICACHE_FLASH_ATTR void ICACHE_FLASH_ATTR
screen_init(void) screen_init(void)
{ {
dbg("Screen buffer size = %d bytes", sizeof(screen));
NOTIFY_LOCK(); NOTIFY_LOCK();
screen_reset(); screen_reset();
NOTIFY_DONE(); NOTIFY_DONE();

@ -50,7 +50,7 @@
#define SCR_DEF_TITLE "ESPTerm" #define SCR_DEF_TITLE "ESPTerm"
/** Maximum screen size (determines size of the static data array) */ /** Maximum screen size (determines size of the static data array) */
#define MAX_SCREEN_SIZE (80*26) #define MAX_SCREEN_SIZE (80*25)
#define TERMCONF_VERSION 1 #define TERMCONF_VERSION 1

@ -4,7 +4,7 @@
#include "ansi_parser.h" #include "ansi_parser.h"
#include "syscfg.h" #include "syscfg.h"
#define LOGBUF_SIZE 1500 #define LOGBUF_SIZE 2048
static char logbuf[LOGBUF_SIZE]; static char logbuf[LOGBUF_SIZE];
static u32 lb_nw = 1; static u32 lb_nw = 1;
static u32 lb_ls = 0; static u32 lb_ls = 0;

@ -45,9 +45,9 @@ UART_AsyncBufferInit(uint32 buf_size)
return NULL; return NULL;
} }
else { else {
struct UartBuffer *pBuff = (struct UartBuffer *) os_malloc(sizeof(struct UartBuffer)); struct UartBuffer *pBuff = (struct UartBuffer *) malloc(sizeof(struct UartBuffer));
pBuff->UartBuffSize = buf_size; pBuff->UartBuffSize = buf_size;
pBuff->pUartBuff = (uint8 *) os_malloc(pBuff->UartBuffSize); pBuff->pUartBuff = (uint8 *) malloc(pBuff->UartBuffSize);
pBuff->pInPos = pBuff->pUartBuff; pBuff->pInPos = pBuff->pUartBuff;
pBuff->pOutPos = pBuff->pUartBuff; pBuff->pOutPos = pBuff->pUartBuff;
pBuff->Space = (uint16) pBuff->UartBuffSize; pBuff->Space = (uint16) pBuff->UartBuffSize;
@ -68,17 +68,17 @@ static void UART_WriteToAsyncBuffer(struct UartBuffer *pCur, const char *pdata,
uint16 tail_len = (uint16) (pCur->pUartBuff + pCur->UartBuffSize - pCur->pInPos); uint16 tail_len = (uint16) (pCur->pUartBuff + pCur->UartBuffSize - pCur->pInPos);
if (tail_len >= data_len) { //do not need to loop back the queue if (tail_len >= data_len) { //do not need to loop back the queue
os_memcpy(pCur->pInPos, pdata, data_len); memcpy(pCur->pInPos, pdata, data_len);
pCur->pInPos += (data_len); pCur->pInPos += (data_len);
pCur->pInPos = (pCur->pUartBuff + (pCur->pInPos - pCur->pUartBuff) % pCur->UartBuffSize); pCur->pInPos = (pCur->pUartBuff + (pCur->pInPos - pCur->pUartBuff) % pCur->UartBuffSize);
pCur->Space -= data_len; pCur->Space -= data_len;
} }
else { else {
os_memcpy(pCur->pInPos, pdata, tail_len); memcpy(pCur->pInPos, pdata, tail_len);
pCur->pInPos += (tail_len); pCur->pInPos += (tail_len);
pCur->pInPos = (pCur->pUartBuff + (pCur->pInPos - pCur->pUartBuff) % pCur->UartBuffSize); pCur->pInPos = (pCur->pUartBuff + (pCur->pInPos - pCur->pUartBuff) % pCur->UartBuffSize);
pCur->Space -= tail_len; pCur->Space -= tail_len;
os_memcpy(pCur->pInPos, pdata + tail_len, data_len - tail_len); memcpy(pCur->pInPos, pdata + tail_len, data_len - tail_len);
pCur->pInPos += (data_len - tail_len); pCur->pInPos += (data_len - tail_len);
pCur->pInPos = (pCur->pUartBuff + (pCur->pInPos - pCur->pUartBuff) % pCur->UartBuffSize); pCur->pInPos = (pCur->pUartBuff + (pCur->pInPos - pCur->pUartBuff) % pCur->UartBuffSize);
pCur->Space -= (data_len - tail_len); pCur->Space -= (data_len - tail_len);
@ -93,8 +93,8 @@ static void UART_WriteToAsyncBuffer(struct UartBuffer *pCur, const char *pdata,
*******************************************************************************/ *******************************************************************************/
void ICACHE_FLASH_ATTR UART_FreeAsyncBuffer(struct UartBuffer *pBuff) void ICACHE_FLASH_ATTR UART_FreeAsyncBuffer(struct UartBuffer *pBuff)
{ {
os_free(pBuff->pUartBuff); free(pBuff->pUartBuff);
os_free(pBuff); free(pBuff);
} }
u16 ICACHE_FLASH_ATTR UART_AsyncRxCount(void) u16 ICACHE_FLASH_ATTR UART_AsyncRxCount(void)
@ -116,19 +116,19 @@ UART_ReadAsync(char *pdata, uint16 data_len)
uint16 len_tmp = 0; uint16 len_tmp = 0;
len_tmp = ((data_len > buf_len) ? buf_len : data_len); len_tmp = ((data_len > buf_len) ? buf_len : data_len);
if (pRxBuffer->pOutPos <= pRxBuffer->pInPos) { if (pRxBuffer->pOutPos <= pRxBuffer->pInPos) {
os_memcpy(pdata, pRxBuffer->pOutPos, len_tmp); memcpy(pdata, pRxBuffer->pOutPos, len_tmp);
pRxBuffer->pOutPos += len_tmp; pRxBuffer->pOutPos += len_tmp;
pRxBuffer->Space += len_tmp; pRxBuffer->Space += len_tmp;
} }
else { else {
if (len_tmp > tail_len) { if (len_tmp > tail_len) {
os_memcpy(pdata, pRxBuffer->pOutPos, tail_len); memcpy(pdata, pRxBuffer->pOutPos, tail_len);
pRxBuffer->pOutPos += tail_len; pRxBuffer->pOutPos += tail_len;
pRxBuffer->pOutPos = (pRxBuffer->pUartBuff + pRxBuffer->pOutPos = (pRxBuffer->pUartBuff +
(pRxBuffer->pOutPos - pRxBuffer->pUartBuff) % pRxBuffer->UartBuffSize); (pRxBuffer->pOutPos - pRxBuffer->pUartBuff) % pRxBuffer->UartBuffSize);
pRxBuffer->Space += tail_len; pRxBuffer->Space += tail_len;
os_memcpy(pdata + tail_len, pRxBuffer->pOutPos, len_tmp - tail_len); memcpy(pdata + tail_len, pRxBuffer->pOutPos, len_tmp - tail_len);
pRxBuffer->pOutPos += (len_tmp - tail_len); pRxBuffer->pOutPos += (len_tmp - tail_len);
pRxBuffer->pOutPos = (pRxBuffer->pUartBuff + pRxBuffer->pOutPos = (pRxBuffer->pUartBuff +
(pRxBuffer->pOutPos - pRxBuffer->pUartBuff) % pRxBuffer->UartBuffSize); (pRxBuffer->pOutPos - pRxBuffer->pUartBuff) % pRxBuffer->UartBuffSize);
@ -136,7 +136,7 @@ UART_ReadAsync(char *pdata, uint16 data_len)
} }
else { else {
//os_printf("case 3 in rx deq\n\r"); //os_printf("case 3 in rx deq\n\r");
os_memcpy(pdata, pRxBuffer->pOutPos, len_tmp); memcpy(pdata, pRxBuffer->pOutPos, len_tmp);
pRxBuffer->pOutPos += len_tmp; pRxBuffer->pOutPos += len_tmp;
pRxBuffer->pOutPos = (pRxBuffer->pUartBuff + pRxBuffer->pOutPos = (pRxBuffer->pUartBuff +
(pRxBuffer->pOutPos - pRxBuffer->pUartBuff) % pRxBuffer->UartBuffSize); (pRxBuffer->pOutPos - pRxBuffer->pUartBuff) % pRxBuffer->UartBuffSize);

Loading…
Cancel
Save