From 36eb62ab94c9647a6bcbc3aa0b46ad09eee5ba57 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 6 Jun 2021 19:29:05 +0200 Subject: [PATCH 1/2] Berry fix MD5 compilation for idf4 --- tasmota/xdrv_52_3_berry_md5.ino | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tasmota/xdrv_52_3_berry_md5.ino b/tasmota/xdrv_52_3_berry_md5.ino index 18a3787bf..4ae85d4b3 100644 --- a/tasmota/xdrv_52_3_berry_md5.ino +++ b/tasmota/xdrv_52_3_berry_md5.ino @@ -21,7 +21,7 @@ #ifdef USE_BERRY #include -#include "mbedtls/md5.h" +#include "MD5Builder.h" #include "be_mem.h" /*********************************************************************************************\ @@ -33,7 +33,7 @@ extern "C" { int free_ctx(bvm* vm) { int argc = be_top(vm); if (argc > 0) { - mbedtls_md5_context * ctx = (mbedtls_md5_context*) be_tocomptr(vm, 1); + struct MD5Context * ctx = (struct MD5Context *) be_tocomptr(vm, 1); if (ctx != NULL) { be_os_free(ctx); } @@ -45,12 +45,11 @@ extern "C" { int32_t m_md5_init(struct bvm *vm); int32_t m_md5_init(struct bvm *vm) { - mbedtls_md5_context * ctx = (mbedtls_md5_context*) be_os_malloc(sizeof(mbedtls_md5_context)); + struct MD5Context * ctx = (struct MD5Context *) be_os_malloc(sizeof(struct MD5Context)); if (!ctx) { be_throw(vm, BE_MALLOC_FAIL); } - mbedtls_md5_init(ctx); - mbedtls_md5_starts_ret(ctx); + MD5Init(ctx); be_newcomobj(vm, ctx, &free_ctx); be_setmember(vm, 1, ".p"); @@ -72,12 +71,12 @@ extern "C" { if (!bytes) break; be_getmember(vm, 1, ".p"); - mbedtls_md5_context * ctx; - ctx = (mbedtls_md5_context*) be_tocomptr(vm, -1); + struct MD5Context * ctx; + ctx = (struct MD5Context *) be_tocomptr(vm, -1); if (!ctx) break; if (length > 0) { - mbedtls_md5_update_ret(ctx, (const uint8_t*) bytes, length); + MD5Update(ctx, (const uint8_t*) bytes, length); } be_return_nil(vm); // success @@ -92,11 +91,11 @@ extern "C" { int32_t m_md5_finish(struct bvm *vm); int32_t m_md5_finish(struct bvm *vm) { be_getmember(vm, 1, ".p"); - mbedtls_md5_context * ctx; - ctx = (mbedtls_md5_context*) be_tocomptr(vm, -1); + struct MD5Context * ctx; + ctx = (struct MD5Context *) be_tocomptr(vm, -1); uint8_t output[16]; - mbedtls_md5_finish_ret(ctx, output); + MD5Final(output, ctx); be_pushbytes(vm, output, sizeof(output)); be_return(vm); } From a748e4703878e7fc10847cb4cfffd06baf02c65a Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 6 Jun 2021 19:36:26 +0200 Subject: [PATCH 2/2] Fix compilation for BM8563 under idf4 --- tasmota/xdrv_56_BM8563_RTC.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xdrv_56_BM8563_RTC.ino b/tasmota/xdrv_56_BM8563_RTC.ino index 96eeeefde..7184b2336 100644 --- a/tasmota/xdrv_56_BM8563_RTC.ino +++ b/tasmota/xdrv_56_BM8563_RTC.ino @@ -114,7 +114,7 @@ void InitTimeFromRTC(void) { void BM8563EverySecond(void) { if (bm8563_driver.rtc_ready) { - if (!bm8563_driver.ntp_time_ok && Rtc.utc_time > START_VALID_TIME && abs(Rtc.utc_time - BM8563GetUtc()) > 3) { + if (!bm8563_driver.ntp_time_ok && Rtc.utc_time > START_VALID_TIME && abs((int32_t)Rtc.utc_time - (int32_t)BM8563GetUtc()) > 3) { BM8563SetUtc(Rtc.utc_time); AddLog(LOG_LEVEL_INFO, PSTR("I2C: Write Time TO BM8563 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());