Skip to content

Commit 737a356

Browse files
committed
Manually merged changes from BlueAndy fork
Minor updates of my custom stuff
1 parent d803e12 commit 737a356

File tree

12 files changed

+33
-8
lines changed

12 files changed

+33
-8
lines changed
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

examples/SmartSwitch/SmartSwitch.ino

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,23 @@ void setup(){
672672
#ifdef USE_AUTH_STAT
673673
if(!request->authenticate(http_username, http_password)) return request->requestAuthentication();
674674
#endif
675-
request->onDisconnect([]() {
676-
WiFi.disconnect(true);
675+
request->onDisconnect([]() {
677676
#ifdef ESP32
677+
/*
678+
//https://github.com/espressif/arduino-esp32/issues/400#issuecomment-499631249
679+
//WiFi.disconnect(true); // doesn't work on esp32, below needs #include "esp_wifi.h"
680+
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); //load the flash-saved configs
681+
esp_wifi_init(&cfg); //initiate and allocate wifi resources (does not matter if connection fails)
682+
if(esp_wifi_restore()!=ESP_OK){
683+
Serial.print(F("WiFi is not initialized by esp_wifi_init "));
684+
} else {
685+
Serial.print(F("WiFi Configurations Cleared!"));
686+
}
687+
*/
688+
WiFi.disconnect(true, true); // Works on esp32
678689
ESP.restart();
679690
#elif defined(ESP8266)
691+
WiFi.disconnect(true);
680692
ESP.reset();
681693
#endif
682694
});
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.

src/AsyncWebSocket.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,9 @@ void AsyncWebSocketClient::_onData(void *pbuf, size_t plen){
664664
if(_pinfo.opcode){
665665
_pinfo.message_opcode = _pinfo.opcode;
666666
_pinfo.num = 0;
667-
} else _pinfo.num += 1;
667+
}
668668
}
669-
_server->_handleEvent(this, WS_EVT_DATA, (void *)&_pinfo, (uint8_t*)data, datalen);
669+
if (datalen > 0) _server->_handleEvent(this, WS_EVT_DATA, (void *)&_pinfo, (uint8_t*)data, datalen);
670670

671671
_pinfo.index += datalen;
672672
} else if((datalen + _pinfo.index) == _pinfo.len){
@@ -694,6 +694,8 @@ void AsyncWebSocketClient::_onData(void *pbuf, size_t plen){
694694
_server->_handleEvent(this, WS_EVT_PONG, NULL, data, datalen);
695695
} else if(_pinfo.opcode < 8){//continuation or text/binary frame
696696
_server->_handleEvent(this, WS_EVT_DATA, (void *)&_pinfo, data, datalen);
697+
if (_pinfo.final) _pinfo.num = 0;
698+
else _pinfo.num += 1;
697699
}
698700
} else {
699701
//os_printf("frame error: len: %u, index: %llu, total: %llu\n", datalen, _pinfo.index, _pinfo.len);

0 commit comments

Comments
 (0)