Compile with Arduino 3 (ESP-IDF 5.x)

This commit is contained in:
tueddy
2024-03-02 17:47:18 +01:00
committed by Mathieu Carbou
parent b912845230
commit 3ee4013002
3 changed files with 14 additions and 0 deletions

View File

@@ -19,6 +19,7 @@
*/
#include "Arduino.h"
#include "AsyncEventSource.h"
#include <rom/ets_sys.h>
static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect){
String ev;

View File

@@ -27,6 +27,7 @@
#ifndef ESP8266
#include "mbedtls/sha1.h"
#include <rom/ets_sys.h>
#else
#include <Hash.h>
#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;

View File

@@ -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);