From fbf2e1a138f9a1744807353473a1baa8df831916 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Mon, 19 Apr 2021 15:53:24 -0400 Subject: [PATCH 1/5] Fix compiler error for ESP32-C3 Compile error on ESP32-C3 for even simplest example [simple_server](https://github.com/me-no-dev/ESPAsyncWebServer/tree/master/examples/simple_server) ``` /home/kh/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.cpp: In member function 'IPAddress AsyncWebSocketClient::remoteIP()': /home/kh/Arduino/libraries/ESPAsyncWebServer-master/src/AsyncWebSocket.cpp:843:28: error: call of overloaded 'IPAddress(unsigned int)' is ambiguous return IPAddress(0U); ^ ``` --- src/AsyncWebSocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp index 52dcd75f0..3d36bd83e 100644 --- a/src/AsyncWebSocket.cpp +++ b/src/AsyncWebSocket.cpp @@ -840,7 +840,7 @@ void AsyncWebSocketClient::binary(AsyncWebSocketMessageBuffer * buffer) IPAddress AsyncWebSocketClient::remoteIP() { if(!_client) { - return IPAddress(0U); + return IPAddress((uint32_t) 0); } return _client->remoteIP(); } From edabf225b4dcc49c471cd78fd3d63e0bbc583111 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Mon, 2 Aug 2021 14:38:20 -0400 Subject: [PATCH 2/5] Fix compile error Fix deprecated functions superseded from mbed TLS v2.7.0 - mbedtls_md5_starts() - mbedtls_md5_update() - mbedtls_md5_finish() leading to following compiling error ``` /home/kh/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2021r1/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: libraries/ESPAsyncWebServer-master/WebAuthentication.cpp.o:(.literal._ZL6getMD5PhtPc+0x4): undefined reference to `mbedtls_md5_starts' /home/kh/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2021r1/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: libraries/ESPAsyncWebServer-master/WebAuthentication.cpp.o: in function `getMD5(unsigned char*, unsigned short, char*)': /home/kh/Arduino/libraries/ESPAsyncWebServer-master/src/WebAuthentication.cpp:73: undefined reference to `mbedtls_md5_starts' collect2: error: ld returned 1 exit status exit status 1 Error compiling for board ESP32S2 Dev Module. ``` --- src/WebAuthentication.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/WebAuthentication.cpp b/src/WebAuthentication.cpp index 2feca5420..13b6e79a1 100644 --- a/src/WebAuthentication.cpp +++ b/src/WebAuthentication.cpp @@ -22,6 +22,7 @@ #include #ifdef ESP32 #include "mbedtls/md5.h" +#include "mbedtls/version.h" #else #include "md5.h" #endif @@ -71,9 +72,16 @@ static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or mo memset(_buf, 0x00, 16); #ifdef ESP32 mbedtls_md5_init(&_ctx); - mbedtls_md5_starts(&_ctx); - mbedtls_md5_update(&_ctx, data, len); - mbedtls_md5_finish(&_ctx, _buf); + #if (MBEDTLS_VERSION_NUMBER < 0x02070000) + // Superseded from v2.7.0 + mbedtls_md5_starts(&_ctx); + mbedtls_md5_update(&_ctx, data, len); + mbedtls_md5_finish(&_ctx, _buf); + #else + mbedtls_md5_starts_ret(&_ctx); + mbedtls_md5_update_ret(&_ctx, data, len); + mbedtls_md5_finish_ret(&_ctx, _buf); + #endif #else MD5Init(&_ctx); MD5Update(&_ctx, data, len); From 24fc8db2480287be3585502487e46fe6acdab35f Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Mon, 2 Aug 2021 21:56:41 -0400 Subject: [PATCH 3/5] Update AsyncWebSocket.h --- src/AsyncWebSocket.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/AsyncWebSocket.h b/src/AsyncWebSocket.h index 5b03aceb9..99f7ad25e 100644 --- a/src/AsyncWebSocket.h +++ b/src/AsyncWebSocket.h @@ -21,6 +21,12 @@ #ifndef ASYNCWEBSOCKET_H_ #define ASYNCWEBSOCKET_H_ +#include "mbedtls/version.h" + +#if (MBEDTLS_VERSION_NUMBER >= 0x02070000) + #error Must use ESP32 core v1.0.6-, with MBEDTLS_VERSION_NUMBER < v2.7.0 +#endif + #include #ifdef ESP32 #include From d6322e74d12f2bbdbb8e4261806d33f48d32d547 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Mon, 2 Aug 2021 22:01:38 -0400 Subject: [PATCH 4/5] Update AsyncWebSocket.h --- src/AsyncWebSocket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AsyncWebSocket.h b/src/AsyncWebSocket.h index 99f7ad25e..870a74498 100644 --- a/src/AsyncWebSocket.h +++ b/src/AsyncWebSocket.h @@ -24,7 +24,7 @@ #include "mbedtls/version.h" #if (MBEDTLS_VERSION_NUMBER >= 0x02070000) - #error Must use ESP32 core v1.0.6-, with MBEDTLS_VERSION_NUMBER < v2.7.0 + //#error Must use ESP32 core v1.0.6-, with MBEDTLS_VERSION_NUMBER < v2.7.0 #endif #include From 153bb3da26523d1f27c1606224cec99d7a76f9d7 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Fri, 13 Aug 2021 18:31:40 -0400 Subject: [PATCH 5/5] Update AsyncWebSocket.h --- src/AsyncWebSocket.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AsyncWebSocket.h b/src/AsyncWebSocket.h index 870a74498..c07f35785 100644 --- a/src/AsyncWebSocket.h +++ b/src/AsyncWebSocket.h @@ -21,14 +21,13 @@ #ifndef ASYNCWEBSOCKET_H_ #define ASYNCWEBSOCKET_H_ -#include "mbedtls/version.h" - #if (MBEDTLS_VERSION_NUMBER >= 0x02070000) //#error Must use ESP32 core v1.0.6-, with MBEDTLS_VERSION_NUMBER < v2.7.0 #endif #include #ifdef ESP32 +#include "mbedtls/version.h" #include #define WS_MAX_QUEUED_MESSAGES 32 #else