From 737a3567b760e8a38600b1e4ac4f5045ed37b5ae Mon Sep 17 00:00:00 2001 From: lorol Date: Thu, 3 Sep 2020 11:26:49 -0400 Subject: [PATCH] Manually merged changes from BlueAndy fork Minor updates of my custom stuff --- .../ESP_AsyncFSBrowser/data/acefull.js.gz | Bin 117524 -> 117524 bytes .../ESP_AsyncFSBrowser/data/worker-css.js.gz | Bin 32927 -> 32927 bytes .../ESP_AsyncFSBrowser/data/worker-html.js.gz | Bin 45019 -> 45019 bytes .../data/worker-javascript.js.gz | Bin 112558 -> 112558 bytes examples/SmartSwitch/SmartSwitch.ino | 16 ++++++++++++++-- examples/SmartSwitch/data/acefull.js.gz | Bin 117524 -> 117524 bytes examples/SmartSwitch/data/worker-css.js.gz | Bin 32927 -> 32927 bytes examples/SmartSwitch/data/worker-html.js.gz | Bin 45019 -> 45019 bytes .../SmartSwitch/data/worker-javascript.js.gz | Bin 112558 -> 112558 bytes src/AsyncWebSocket.cpp | 6 ++++-- src/WebRequest.cpp | 17 ++++++++++++++--- src/edit.htm.gz.h | 2 +- 12 files changed, 33 insertions(+), 8 deletions(-) diff --git a/examples/ESP_AsyncFSBrowser/data/acefull.js.gz b/examples/ESP_AsyncFSBrowser/data/acefull.js.gz index 4a0ae6120f768922447ecf68f82f4451857a4b89..4b10ee879cb1238a59fb0f23064da41ba4b6da28 100644 GIT binary patch delta 21 dcmbO-jeW{Ac6Rx04vwM;UXAQq*%^6H0{}}n28{p! delta 21 ccmbO-jeW{Ac6Rx04vwB|+eY@S?2Npp0ZNAkbpQYW diff --git a/examples/ESP_AsyncFSBrowser/data/worker-css.js.gz b/examples/ESP_AsyncFSBrowser/data/worker-css.js.gz index dc267b31e163d3823d510176f61c26af9c3bed49..97beeb133712d3e716a32b360301942afee6ae4a 100644 GIT binary patch delta 18 ZcmbQ=$TYu^iCw;%gQIYQ*GBdk4FEWM1|a|d delta 18 ZcmbQ=$TYu^iCw;%gQGj!b|d?Y1^_q`1_=NF diff --git a/examples/ESP_AsyncFSBrowser/data/worker-html.js.gz b/examples/ESP_AsyncFSBrowser/data/worker-html.js.gz index c551f7094c333e68b393be4d7be9024fe733c183..819a3b7842296f34a262479417b33cc94809069b 100644 GIT binary patch delta 18 acmcb8pXv5}CU*I54vvBeUK`o3tOo#0IS0Q0 delta 18 acmcb8pXv5}CU*I54vwyD+l}m3)&l@b&authenticate(http_username, http_password)) return request->requestAuthentication(); #endif - request->onDisconnect([]() { - WiFi.disconnect(true); + request->onDisconnect([]() { #ifdef ESP32 +/* + //https://github.com/espressif/arduino-esp32/issues/400#issuecomment-499631249 + //WiFi.disconnect(true); // doesn't work on esp32, below needs #include "esp_wifi.h" + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); //load the flash-saved configs + esp_wifi_init(&cfg); //initiate and allocate wifi resources (does not matter if connection fails) + if(esp_wifi_restore()!=ESP_OK){ + Serial.print(F("WiFi is not initialized by esp_wifi_init ")); + } else { + Serial.print(F("WiFi Configurations Cleared!")); + } +*/ + WiFi.disconnect(true, true); // Works on esp32 ESP.restart(); #elif defined(ESP8266) + WiFi.disconnect(true); ESP.reset(); #endif }); diff --git a/examples/SmartSwitch/data/acefull.js.gz b/examples/SmartSwitch/data/acefull.js.gz index 4a0ae6120f768922447ecf68f82f4451857a4b89..4b10ee879cb1238a59fb0f23064da41ba4b6da28 100644 GIT binary patch delta 21 dcmbO-jeW{Ac6Rx04vwM;UXAQq*%^6H0{}}n28{p! delta 21 ccmbO-jeW{Ac6Rx04vwB|+eY@S?2Npp0ZNAkbpQYW diff --git a/examples/SmartSwitch/data/worker-css.js.gz b/examples/SmartSwitch/data/worker-css.js.gz index dc267b31e163d3823d510176f61c26af9c3bed49..97beeb133712d3e716a32b360301942afee6ae4a 100644 GIT binary patch delta 18 ZcmbQ=$TYu^iCw;%gQIYQ*GBdk4FEWM1|a|d delta 18 ZcmbQ=$TYu^iCw;%gQGj!b|d?Y1^_q`1_=NF diff --git a/examples/SmartSwitch/data/worker-html.js.gz b/examples/SmartSwitch/data/worker-html.js.gz index c551f7094c333e68b393be4d7be9024fe733c183..819a3b7842296f34a262479417b33cc94809069b 100644 GIT binary patch delta 18 acmcb8pXv5}CU*I54vvBeUK`o3tOo#0IS0Q0 delta 18 acmcb8pXv5}CU*I54vwyD+l}m3)&l@b&_handleEvent(this, WS_EVT_DATA, (void *)&_pinfo, (uint8_t*)data, datalen); + if (datalen > 0) _server->_handleEvent(this, WS_EVT_DATA, (void *)&_pinfo, (uint8_t*)data, datalen); _pinfo.index += datalen; } else if((datalen + _pinfo.index) == _pinfo.len){ @@ -694,6 +694,8 @@ void AsyncWebSocketClient::_onData(void *pbuf, size_t plen){ _server->_handleEvent(this, WS_EVT_PONG, NULL, data, datalen); } else if(_pinfo.opcode < 8){//continuation or text/binary frame _server->_handleEvent(this, WS_EVT_DATA, (void *)&_pinfo, data, datalen); + if (_pinfo.final) _pinfo.num = 0; + else _pinfo.num += 1; } } else { //os_printf("frame error: len: %u, index: %llu, total: %llu\n", datalen, _pinfo.index, _pinfo.len); diff --git a/src/WebRequest.cpp b/src/WebRequest.cpp index 5031f26..6d79726 100644 --- a/src/WebRequest.cpp +++ b/src/WebRequest.cpp @@ -192,8 +192,16 @@ void AsyncWebServerRequest::_removeNotInterestingHeaders(){ void AsyncWebServerRequest::_onPoll(){ //os_printf("p\n"); - if(_response != NULL && _client != NULL && _client->canSend() && !_response->_finished()){ - _response->_ack(this, 0, 0); + if(_response != NULL && _client != NULL && _client->canSend()){ + if(!_response->_finished()){ + _response->_ack(this, 0, 0); + } else { + AsyncWebServerResponse* r = _response; + _response = NULL; + delete r; + + _client->close(); + } } } @@ -202,10 +210,13 @@ void AsyncWebServerRequest::_onAck(size_t len, uint32_t time){ if(_response != NULL){ if(!_response->_finished()){ _response->_ack(this, len, time); - } else { + } + if(_response->_finished()){ AsyncWebServerResponse* r = _response; _response = NULL; delete r; + + _client->close(); } } } diff --git a/src/edit.htm.gz.h b/src/edit.htm.gz.h index ae6dcea..3b163a0 100644 --- a/src/edit.htm.gz.h +++ b/src/edit.htm.gz.h @@ -2,7 +2,7 @@ //File: edit.htm.gz, Size: 4503 #define edit_htm_gz_len 4503 const uint8_t edit_htm_gz[] PROGMEM = { -0x1F,0x8B,0x08,0x08,0x66,0x6B,0x3D,0x5F,0x02,0x00,0x65,0x64,0x69,0x74,0x2E,0x68,0x74,0x6D,0x00,0xB5, +0x1F,0x8B,0x08,0x08,0x54,0x90,0x4A,0x5F,0x02,0x00,0x65,0x64,0x69,0x74,0x2E,0x68,0x74,0x6D,0x00,0xB5, 0x1A,0x0B,0x5B,0xDB,0x36,0xF0,0xAF,0x18,0x6F,0x63,0xF6,0xE2,0x38,0x0E,0x50,0xD6,0x3A,0x18,0x16,0x1E, 0xEB,0xBB,0x50,0x12,0xDA,0xD1,0x8E,0xED,0x53,0x6C,0x25,0x56,0xB1,0x25,0xCF,0x96,0x09,0x34,0xCD,0x7F, 0xDF,0x49,0xF2,0x93,0x84,0xEE,0xF1,0x6D,0xA5,0x60,0x49,0xA7,0x3B,0xDD,0x9D,0xEE,0x25,0xD9,0x7B,0x1B,