Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 5829a7e

Browse files
authored
v1.5.0 to fix AsyncWebSocket bug
#### Releases v1.5.0 1. Fix AsyncWebSocket bug
1 parent 6ca7b3e commit 5829a7e

35 files changed

+2597
-248
lines changed

CONTRIBUTING.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1515
Please ensure to specify the following:
1616

1717
* Arduino IDE version (e.g. 1.8.16) or Platform.io version
18-
* Board Core Version (e.g. ESP32 core v2.0.1)
18+
* Board Core Version (e.g. ESP32 core v2.0.5)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
2121
* Anything that might be relevant in your opinion, such as:
@@ -26,14 +26,14 @@ Please ensure to specify the following:
2626
### Example
2727

2828
```
29-
Arduino IDE version: 1.8.16
29+
Arduino IDE version: 1.8.19
3030
WT32_ETH01 board
31-
ESP32 core v2.0.1
31+
ESP32 core v2.0.5
3232
OS: Ubuntu 20.04 LTS
33-
Linux xy-Inspiron-3593 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
33+
Linux xy-Inspiron-3593 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3434
3535
Context:
36-
I encountered a crash while trying to use the Timer Interrupt.
36+
I encountered a crash while trying to use this library
3737
3838
Steps to reproduce:
3939
1. ...

README.md

+53-197
Large diffs are not rendered by default.

changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
## Table of contents
1212

1313
* [Changelog](#changelog)
14+
* [Releases v1.5.0](#releases-v150)
1415
* [Releases v1.4.1](#releases-v141)
1516
* [Releases v1.4.0](#releases-v140)
1617
* [Releases v1.3.0](#releases-v130)
@@ -24,6 +25,10 @@
2425

2526
## Changelog
2627

28+
#### Releases v1.5.0
29+
30+
1. Fix AsyncWebSocket bug
31+
2732
#### Releases v1.4.1
2833

2934
1. Fix bug in examples to reduce connection time

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"AsyncWebServer_WT32_ETH01",
3-
"version": "1.4.1",
3+
"version": "1.5.0",
44
"description":"Asynchronous HTTP and WebSocket Server Library for WT32_ETH01 (ESP32 + LAN8720)",
55
"keywords":"http, async, async-webserver, websocket, webserver, esp32, wt32-eth01, lan8720, lan8720a",
66
"authors":

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AsyncWebServer_WT32_ETH01
2-
version=1.4.1
2+
version=1.5.0
33
author=Hristo Gochkov,Khoi Hoang
44
maintainer=Khoi Hoang <[email protected]>
55
license=GPLv3

src/AsyncEventSource.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
You should have received a copy of the GNU Lesser General Public License along with this library;
2323
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
25-
Version: 1.4.1
25+
Version: 1.5.0
2626
2727
Version Modified By Date Comments
2828
------- ----------- ---------- -----------
@@ -32,6 +32,7 @@
3232
1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+
3333
1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version
3434
1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time
35+
1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug
3536
*****************************************************************************************************************************/
3637

3738
#include "Arduino.h"

src/AsyncEventSource.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
You should have received a copy of the GNU Lesser General Public License along with this library;
2323
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
25-
Version: 1.4.1
25+
Version: 1.5.0
2626
2727
Version Modified By Date Comments
2828
------- ----------- ---------- -----------
@@ -32,6 +32,7 @@
3232
1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+
3333
1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version
3434
1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time
35+
1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug
3536
*****************************************************************************************************************************/
3637

3738
#ifndef ASYNCEVENTSOURCE_H_

src/AsyncJson.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
You should have received a copy of the GNU Lesser General Public License along with this library;
2323
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
25-
Version: 1.4.1
25+
Version: 1.5.0
2626
2727
Version Modified By Date Comments
2828
------- ----------- ---------- -----------
@@ -32,6 +32,7 @@
3232
1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+
3333
1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version
3434
1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time
35+
1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug
3536
*****************************************************************************************************************************/
3637
/*
3738
Async Response to use with ArduinoJson and AsyncWebServer

src/AsyncWebServer_WT32_ETH01.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
You should have received a copy of the GNU Lesser General Public License along with this library;
2323
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
25-
Version: 1.4.1
25+
Version: 1.5.0
2626
2727
Version Modified By Date Comments
2828
------- ----------- ---------- -----------
@@ -32,6 +32,7 @@
3232
1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+
3333
1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version
3434
1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time
35+
1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug
3536
*****************************************************************************************************************************/
3637

3738
#include "AsyncWebServer_WT32_ETH01.h"

src/AsyncWebServer_WT32_ETH01.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
You should have received a copy of the GNU Lesser General Public License along with this library;
2323
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
25-
Version: 1.4.1
25+
Version: 1.5.0
2626
2727
Version Modified By Date Comments
2828
------- ----------- ---------- -----------
@@ -32,6 +32,7 @@
3232
1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+
3333
1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version
3434
1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time
35+
1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug
3536
*****************************************************************************************************************************/
3637

3738
#ifndef _AsyncWebServer_WT32_ETH01_H_
@@ -55,14 +56,14 @@
5556
#warning Using code for ESP32 core v2.0.0+ in AsyncWebServer_WT32_ETH01.h
5657
#endif
5758

58-
#define ASYNC_WEBSERVER_WT32_ETH01_VERSION "AsyncWebServer_WT32_ETH01 v1.4.1 for core v2.0.0+"
59+
#define ASYNC_WEBSERVER_WT32_ETH01_VERSION "AsyncWebServer_WT32_ETH01 v1.5.0 for core v2.0.0+"
5960
#else
6061

6162
#if (_ASYNC_WEBSERVER_LOGLEVEL_ > 2 )
6263
#warning Using code for ESP32 core v1.0.6- in AsyncWebServer_WT32_ETH01.h
6364
#endif
6465

65-
#define ASYNC_WEBSERVER_WT32_ETH01_VERSION "AsyncWebServer_WT32_ETH01 v1.4.1 for core v1.0.6-"
66+
#define ASYNC_WEBSERVER_WT32_ETH01_VERSION "AsyncWebServer_WT32_ETH01 v1.5.0 for core v1.0.6-"
6667
#endif
6768

6869

src/AsyncWebServer_WT32_ETH01_Debug.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
You should have received a copy of the GNU Lesser General Public License along with this library;
2323
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
25-
Version: 1.4.1
25+
Version: 1.5.0
2626
2727
Version Modified By Date Comments
2828
------- ----------- ---------- -----------
@@ -32,6 +32,7 @@
3232
1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+
3333
1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version
3434
1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time
35+
1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug
3536
*****************************************************************************************************************************/
3637

3738
#pragma once

src/AsyncWebSocket.cpp

+18-23
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
You should have received a copy of the GNU Lesser General Public License along with this library;
2323
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
25-
Version: 1.4.1
25+
Version: 1.5.0
2626
2727
Version Modified By Date Comments
2828
------- ----------- ---------- -----------
@@ -32,27 +32,16 @@
3232
1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+
3333
1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version
3434
1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time
35+
1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug
3536
*****************************************************************************************************************************/
3637

3738
#include "Arduino.h"
3839
#include "AsyncWebSocket.h"
3940

4041
#include <libb64/cencode.h>
4142

42-
extern "C"
43-
{
44-
typedef struct
45-
{
46-
uint32_t state[5];
47-
uint32_t count[2];
48-
unsigned char buffer[64];
49-
} SHA1_CTX;
50-
51-
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
52-
void SHA1Init(SHA1_CTX* context);
53-
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
54-
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
55-
}
43+
#include "Crypto/sha1.h"
44+
#include "Crypto/Hash.h"
5645

5746
#define MAX_PRINTF_LEN 64
5847

@@ -1653,13 +1642,13 @@ AsyncWebSocket::AsyncWebSocketClientLinkedList AsyncWebSocket::getClients() cons
16531642
Authentication code from https://github.com/Links2004/arduinoWebSockets/blob/master/src/WebSockets.cpp#L480
16541643
*/
16551644

1656-
AsyncWebSocketResponse::AsyncWebSocketResponse(const String& key, AsyncWebSocket *server)
1645+
AsyncWebSocketResponse::AsyncWebSocketResponse(const String & key, AsyncWebSocket * server)
16571646
{
16581647
_server = server;
16591648
_code = 101;
16601649
_sendContentLength = false;
16611650

1662-
uint8_t * hash = (uint8_t*)malloc(20);
1651+
uint8_t * hash = (uint8_t*) malloc(HASH_BUFFER_SIZE);
16631652

16641653
if (hash == NULL)
16651654
{
@@ -1676,23 +1665,29 @@ AsyncWebSocketResponse::AsyncWebSocketResponse(const String& key, AsyncWebSocket
16761665
return;
16771666
}
16781667

1679-
(String&)key += WS_STR_UUID;
1680-
SHA1_CTX ctx;
1681-
SHA1Init(&ctx);
1682-
SHA1Update(&ctx, (const unsigned char*)key.c_str(), key.length());
1683-
SHA1Final(hash, &ctx);
1668+
sha1_context _ctx;
1669+
1670+
(String&) key += WS_STR_UUID;
1671+
1672+
sha1_starts(&_ctx);
1673+
sha1_update(&_ctx, (const unsigned char*) key.c_str(), key.length());
1674+
sha1_finish(&_ctx, hash);
1675+
//////
16841676

16851677
base64_encodestate _state;
16861678
base64_init_encodestate(&_state);
1687-
int len = base64_encode_block((const char *) hash, 20, buffer, &_state);
1679+
int len = base64_encode_block((const char *) hash, HASH_BUFFER_SIZE, buffer, &_state);
16881680
len = base64_encode_blockend((buffer + len), &_state);
1681+
16891682
addHeader(WS_STR_CONNECTION, WS_STR_UPGRADE);
16901683
addHeader(WS_STR_UPGRADE, "websocket");
16911684
addHeader(WS_STR_ACCEPT, buffer);
1685+
16921686
free(buffer);
16931687
free(hash);
16941688
}
16951689

1690+
16961691
void AsyncWebSocketResponse::_respond(AsyncWebServerRequest *request)
16971692
{
16981693
if (_state == RESPONSE_FAILED)

src/AsyncWebSocket.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
You should have received a copy of the GNU Lesser General Public License along with this library;
2323
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
25-
Version: 1.4.1
25+
Version: 1.5.0
2626
2727
Version Modified By Date Comments
2828
------- ----------- ---------- -----------
@@ -32,6 +32,7 @@
3232
1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+
3333
1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version
3434
1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time
35+
1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug
3536
*****************************************************************************************************************************/
3637

3738
#ifndef ASYNCWEBSOCKET_H_

src/AsyncWebSynchronization.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
You should have received a copy of the GNU Lesser General Public License along with this library;
2323
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2424
25-
Version: 1.4.1
25+
Version: 1.5.0
2626
2727
Version Modified By Date Comments
2828
------- ----------- ---------- -----------
@@ -32,6 +32,7 @@
3232
1.3.0 K Hoang 23/10/2021 Making compatible with breaking core v2.0.0+
3333
1.4.0 K Hoang 27/11/2021 Auto detect ESP32 core version
3434
1.4.1 K Hoang 29/11/2021 Fix bug in examples to reduce connection time
35+
1.5.0 K Hoang 01/10/2022 Fix AsyncWebSocket bug
3536
*****************************************************************************************************************************/
3637

3738
#ifndef ASYNCWEBSYNCHRONIZATION_H_

0 commit comments

Comments
 (0)