diff --git a/src/AsyncEventSource.h b/src/AsyncEventSource.h index 42fd1f6a0..84e9b1453 100644 --- a/src/AsyncEventSource.h +++ b/src/AsyncEventSource.h @@ -24,6 +24,8 @@ #include #if defined(ESP32) || defined(LIBRETINY) #include +#elif defined(USE_RP2040) +#include #else #include #endif diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp index 6e88da94f..d4e046817 100644 --- a/src/AsyncWebSocket.cpp +++ b/src/AsyncWebSocket.cpp @@ -24,8 +24,13 @@ #include #ifndef ESP8266 +#if defined(USE_RP2040) +#include "bearssl/bearssl.h" +#include "bearssl/bearssl_hash.h" +#else #include "mbedtls/sha1.h" #include "mbedtls/version.h" +#endif #else #include #endif @@ -1253,6 +1258,12 @@ AsyncWebSocketResponse::AsyncWebSocketResponse(const String& key, AsyncWebSocket } #ifdef ESP8266 sha1(key + WS_STR_UUID, hash); +#elif defined(USE_RP2040) + (String&)key += WS_STR_UUID; + br_sha1_context ctx; + br_sha1_init(&ctx); + br_sha1_update(&ctx, (const unsigned char*)key.c_str(), key.length()); + br_sha1_out(&ctx, hash); #else (String&)key += WS_STR_UUID; mbedtls_sha1_context ctx; diff --git a/src/AsyncWebSocket.h b/src/AsyncWebSocket.h index d84879334..73be7e40c 100644 --- a/src/AsyncWebSocket.h +++ b/src/AsyncWebSocket.h @@ -27,6 +27,12 @@ #ifndef WS_MAX_QUEUED_MESSAGES #define WS_MAX_QUEUED_MESSAGES 32 #endif +#elif defined(USE_RP2040) +#include +#ifndef WS_MAX_QUEUED_MESSAGES +#define WS_MAX_QUEUED_MESSAGES 8 +#endif +#define ets_printf(msg) void() #else #include #ifndef WS_MAX_QUEUED_MESSAGES diff --git a/src/ESPAsyncWebServer.h b/src/ESPAsyncWebServer.h index 933091562..9080ce0fe 100644 --- a/src/ESPAsyncWebServer.h +++ b/src/ESPAsyncWebServer.h @@ -34,6 +34,9 @@ #elif defined(ESP8266) #include #include +#elif defined(USE_RP2040) +#include +#include #else #error Platform not supported #endif diff --git a/src/WebAuthentication.cpp b/src/WebAuthentication.cpp index 45246a196..6dbddb007 100644 --- a/src/WebAuthentication.cpp +++ b/src/WebAuthentication.cpp @@ -22,6 +22,8 @@ #include #ifdef ESP32 #include "mbedtls/md5.h" +#elif defined(USE_RP2040) +#include #else #include "md5.h" #endif @@ -61,6 +63,8 @@ bool checkBasicAuthentication(const char * hash, const char * username, const ch static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or more #ifdef ESP32 mbedtls_md5_context _ctx; +#elif defined(USE_RP2040) + br_md5_context _ctx; #else md5_context_t _ctx; #endif @@ -74,6 +78,10 @@ static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or mo mbedtls_md5_starts_ret(&_ctx); mbedtls_md5_update_ret(&_ctx, data, len); mbedtls_md5_finish_ret(&_ctx, _buf); +#elif defined(USE_RP2040) + br_md5_init(&_ctx); + br_md5_update(&_ctx, data, len); + br_md5_state(&_ctx, _buf); #else MD5Init(&_ctx); MD5Update(&_ctx, data, len);