diff --git a/Makefile b/Makefile index 2f2653a..5310111 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ LIBS += esphttpd # compiler flags using during compilation of source files CFLAGS = -Os -ggdb -std=gnu99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \ -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH \ - -Wno-address -Wno-unused + -Wno-address -Wno-unused -DHTTPD_MAX_BACKLOG_SIZE=8192 # linker flags used to generate the main object file LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static diff --git a/libesphttpd b/libesphttpd index fba7cec..a4e0fed 160000 --- a/libesphttpd +++ b/libesphttpd @@ -1 +1 @@ -Subproject commit fba7cec0b6443c5ee71afde9a45cf832c49562c9 +Subproject commit a4e0fed2b281760349ddd107b827d8f6b0f56e02 diff --git a/user/cgi_sockets.c b/user/cgi_sockets.c index e10b35b..ff3357f 100644 --- a/user/cgi_sockets.c +++ b/user/cgi_sockets.c @@ -6,28 +6,26 @@ #include "uart_driver.h" #include "screen.h" -static volatile bool timer_running = false; -static ETSTimer notifyTim; +#define SOCK_BUF_LEN 2048 +static char sock_buff[SOCK_BUF_LEN]; static void notifyTimCb(void *arg) { - timer_running = false; - void *data = NULL; - const int bufsiz = 1024; - char buff[bufsiz]; for (int i = 0; i < 20; i++) { - httpd_cgi_state cont = screenSerializeToBuffer(buff, bufsiz, &data); + httpd_cgi_state cont = screenSerializeToBuffer(sock_buff, SOCK_BUF_LEN, &data); int flg = 0; if (cont == HTTPD_CGI_MORE) flg |= WEBSOCK_FLAG_MORE; if (i > 0) flg |= WEBSOCK_FLAG_CONT; - cgiWebsockBroadcast(URL_WS_UPDATE, buff, (int) strlen(buff), flg); + cgiWebsockBroadcast(URL_WS_UPDATE, sock_buff, (int) strlen(sock_buff), flg); if (cont == HTTPD_CGI_DONE) break; } - screenSerializeToBuffer(NULL, bufsiz, &data); + screenSerializeToBuffer(NULL, SOCK_BUF_LEN, &data); } +static ETSTimer notifyTim; + /** * Broadcast screen state to sockets. * This is a callback for the Screen module, @@ -35,9 +33,6 @@ static void notifyTimCb(void *arg) { */ void ICACHE_FLASH_ATTR screen_notifyChange(void) { - if (timer_running) return; - - timer_running = true; os_timer_disarm(¬ifyTim); os_timer_setfn(¬ifyTim, notifyTimCb, NULL); os_timer_arm(¬ifyTim, 20, 0);