From ea999b00e144176da5d0f9817ff1f5ae2bf376e2 Mon Sep 17 00:00:00 2001 From: tueddy Date: Sat, 2 Mar 2024 17:47:18 +0100 Subject: [PATCH 1/2] Compile with Arduino 3 (ESP-IDF 5.x) --- src/AsyncEventSource.cpp | 1 + src/AsyncWebSocket.cpp | 7 +++++++ src/WebAuthentication.cpp | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/src/AsyncEventSource.cpp b/src/AsyncEventSource.cpp index fdafb1b7a..3a2f9ea83 100644 --- a/src/AsyncEventSource.cpp +++ b/src/AsyncEventSource.cpp @@ -19,6 +19,7 @@ */ #include "Arduino.h" #include "AsyncEventSource.h" +#include static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect){ String ev; diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp index 90f14cdbc..594ffb5cf 100644 --- a/src/AsyncWebSocket.cpp +++ b/src/AsyncWebSocket.cpp @@ -27,6 +27,7 @@ #ifndef ESP8266 #include "mbedtls/sha1.h" +#include #else #include #endif @@ -1272,9 +1273,15 @@ AsyncWebSocketResponse::AsyncWebSocketResponse(const String& key, AsyncWebSocket (String&)key += WS_STR_UUID; mbedtls_sha1_context ctx; mbedtls_sha1_init(&ctx); +#if ESP_IDF_VERSION_MAJOR == 5 + mbedtls_sha1_starts(&ctx); + mbedtls_sha1_update(&ctx, (const unsigned char*)key.c_str(), key.length()); + mbedtls_sha1_finish(&ctx, hash); +#else mbedtls_sha1_starts_ret(&ctx); mbedtls_sha1_update_ret(&ctx, (const unsigned char*)key.c_str(), key.length()); mbedtls_sha1_finish_ret(&ctx, hash); +#endif mbedtls_sha1_free(&ctx); #endif base64_encodestate _state; diff --git a/src/WebAuthentication.cpp b/src/WebAuthentication.cpp index 1a22afdfc..2f122d7cd 100644 --- a/src/WebAuthentication.cpp +++ b/src/WebAuthentication.cpp @@ -77,9 +77,15 @@ 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); +#if ESP_IDF_VERSION_MAJOR == 5 + 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 3e9c8d7b30874811a706c19c25db2ec3cbc4c437 Mon Sep 17 00:00:00 2001 From: tueddy Date: Fri, 15 Mar 2024 15:44:46 +0100 Subject: [PATCH 2/2] make the build pass on esp8266 --- src/AsyncEventSource.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/AsyncEventSource.cpp b/src/AsyncEventSource.cpp index 3a2f9ea83..1c34c85ce 100644 --- a/src/AsyncEventSource.cpp +++ b/src/AsyncEventSource.cpp @@ -19,7 +19,9 @@ */ #include "Arduino.h" #include "AsyncEventSource.h" -#include +#ifndef ESP8266 + #include +#endif static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect){ String ev;