Skip to content

Commit

Permalink
Manually merged changes from BlueAndy fork
Browse files Browse the repository at this point in the history
Minor updates of my custom stuff
  • Loading branch information
lorol committed Sep 3, 2020
1 parent d803e12 commit 737a356
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 8 deletions.
Binary file modified examples/ESP_AsyncFSBrowser/data/acefull.js.gz
Binary file not shown.
Binary file modified examples/ESP_AsyncFSBrowser/data/worker-css.js.gz
Binary file not shown.
Binary file modified examples/ESP_AsyncFSBrowser/data/worker-html.js.gz
Binary file not shown.
Binary file modified examples/ESP_AsyncFSBrowser/data/worker-javascript.js.gz
Binary file not shown.
16 changes: 14 additions & 2 deletions examples/SmartSwitch/SmartSwitch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,23 @@ void setup(){
#ifdef USE_AUTH_STAT
if(!request->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
});
Expand Down
Binary file modified examples/SmartSwitch/data/acefull.js.gz
Binary file not shown.
Binary file modified examples/SmartSwitch/data/worker-css.js.gz
Binary file not shown.
Binary file modified examples/SmartSwitch/data/worker-html.js.gz
Binary file not shown.
Binary file modified examples/SmartSwitch/data/worker-javascript.js.gz
Binary file not shown.
6 changes: 4 additions & 2 deletions src/AsyncWebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,9 @@ void AsyncWebSocketClient::_onData(void *pbuf, size_t plen){
if(_pinfo.opcode){
_pinfo.message_opcode = _pinfo.opcode;
_pinfo.num = 0;
} else _pinfo.num += 1;
}
}
_server->_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){
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 14 additions & 3 deletions src/WebRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand All @@ -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();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/edit.htm.gz.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 737a356

Please sign in to comment.