diff --git a/Makefile b/Makefile index 10be512..fb6c253 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ DATE := $(shell date '+%F %T') BRANCH := $(shell git describe --tags) SHA := $(shell if git diff --quiet HEAD; then git rev-parse --short HEAD | cut -d"/" -f 3; \ else echo "development"; fi) -VERSION ?="esp-link $(BRANCH) - $(DATE) - \#$(SHA)" +VERSION ?=esp-link $(BRANCH) - $(DATE) - $(SHA) # --------------- esphttpd config options --------------- diff --git a/httpd/httpd.c b/httpd/httpd.c index 6aabddc..61b20cf 100644 --- a/httpd/httpd.c +++ b/httpd/httpd.c @@ -23,7 +23,7 @@ Esp8266 http server - core routines //Max post buffer len #define MAX_POST 1024 //Max send buffer len -#define MAX_SENDBUFF_LEN 2048 +#define MAX_SENDBUFF_LEN 2600 //This gets set at init time. @@ -235,7 +235,10 @@ int ICACHE_FLASH_ATTR cgiRedirect(HttpdConnData *connData) { //Returns 1 for success, 0 for out-of-memory. int ICACHE_FLASH_ATTR httpdSend(HttpdConnData *conn, const char *data, int len) { if (len<0) len=strlen(data); - if (conn->priv->sendBuffLen+len>MAX_SENDBUFF_LEN) return 0; + if (conn->priv->sendBuffLen+len>MAX_SENDBUFF_LEN) { + os_printf("ERROR! httpdSend full (%d of %d)\n", conn->priv->sendBuffLen, MAX_SENDBUFF_LEN); + return 0; + } os_memcpy(conn->priv->sendBuff+conn->priv->sendBuffLen, data, len); conn->priv->sendBuffLen+=len; return 1; @@ -244,7 +247,10 @@ int ICACHE_FLASH_ATTR httpdSend(HttpdConnData *conn, const char *data, int len) //Helper function to send any data in conn->priv->sendBuff static void ICACHE_FLASH_ATTR xmitSendBuff(HttpdConnData *conn) { if (conn->priv->sendBuffLen!=0) { - espconn_sent(conn->conn, (uint8_t*)conn->priv->sendBuff, conn->priv->sendBuffLen); + sint8 status = espconn_sent(conn->conn, (uint8_t*)conn->priv->sendBuff, conn->priv->sendBuffLen); + if (status != 0) { + os_printf("ERROR! espconn_sent returned %d\n", status); + } conn->priv->sendBuffLen=0; } } @@ -517,6 +523,8 @@ static void ICACHE_FLASH_ATTR httpdConnectCb(void *arg) { espconn_regist_reconcb(conn, httpdReconCb); espconn_regist_disconcb(conn, httpdDisconCb); espconn_regist_sentcb(conn, httpdSentCb); + + espconn_set_opt(conn, ESPCONN_REUSEADDR|ESPCONN_NODELAY); } //Httpd initialization routine. Call this to kick off webserver functionality. diff --git a/user/cgi.c b/user/cgi.c index 917262e..8f6ca67 100644 --- a/user/cgi.c +++ b/user/cgi.c @@ -101,6 +101,8 @@ int ICACHE_FLASH_ATTR printNav(char *buff) { "
  • %s
  • ", navLinks[i][1], navLinks[i][0]); } + len += os_sprintf(buff+len, "
  • %dKB
  • ", + system_get_free_heap_size()/1024); //os_printf("nav(%d): %s\n", len, buff); return len; } @@ -110,7 +112,6 @@ void ICACHE_FLASH_ATTR printHead(HttpdConnData *connData) { struct EspFsFile *file = espFsOpen("/head.tpl"); if (file == NULL) { - espFsClose(file); os_printf("Header file 'head.tpl' not found\n"); return; } @@ -136,6 +137,7 @@ void ICACHE_FLASH_ATTR printHead(HttpdConnData *connData) { httpdSend(connData, buff, len); } } + espFsClose(file); } #define TOKEN(x) (os_strcmp(token, x) == 0)