mirror of
https://github.com/arendst/Tasmota.git
synced 2025-05-01 18:27:16 +00:00
Merge pull request #12311 from s-hadinger/berry_fix_md5_idf4
Berry fix MD5 compilation for idf4
This commit is contained in:
commit
7acb10bb8b
@ -21,7 +21,7 @@
|
|||||||
#ifdef USE_BERRY
|
#ifdef USE_BERRY
|
||||||
|
|
||||||
#include <berry.h>
|
#include <berry.h>
|
||||||
#include "mbedtls/md5.h"
|
#include "MD5Builder.h"
|
||||||
#include "be_mem.h"
|
#include "be_mem.h"
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
@ -33,7 +33,7 @@ extern "C" {
|
|||||||
int free_ctx(bvm* vm) {
|
int free_ctx(bvm* vm) {
|
||||||
int argc = be_top(vm);
|
int argc = be_top(vm);
|
||||||
if (argc > 0) {
|
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) {
|
if (ctx != NULL) {
|
||||||
be_os_free(ctx);
|
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);
|
||||||
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) {
|
if (!ctx) {
|
||||||
be_throw(vm, BE_MALLOC_FAIL);
|
be_throw(vm, BE_MALLOC_FAIL);
|
||||||
}
|
}
|
||||||
mbedtls_md5_init(ctx);
|
MD5Init(ctx);
|
||||||
mbedtls_md5_starts_ret(ctx);
|
|
||||||
|
|
||||||
be_newcomobj(vm, ctx, &free_ctx);
|
be_newcomobj(vm, ctx, &free_ctx);
|
||||||
be_setmember(vm, 1, ".p");
|
be_setmember(vm, 1, ".p");
|
||||||
@ -72,12 +71,12 @@ extern "C" {
|
|||||||
if (!bytes) break;
|
if (!bytes) break;
|
||||||
|
|
||||||
be_getmember(vm, 1, ".p");
|
be_getmember(vm, 1, ".p");
|
||||||
mbedtls_md5_context * ctx;
|
struct MD5Context * ctx;
|
||||||
ctx = (mbedtls_md5_context*) be_tocomptr(vm, -1);
|
ctx = (struct MD5Context *) be_tocomptr(vm, -1);
|
||||||
if (!ctx) break;
|
if (!ctx) break;
|
||||||
|
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
mbedtls_md5_update_ret(ctx, (const uint8_t*) bytes, length);
|
MD5Update(ctx, (const uint8_t*) bytes, length);
|
||||||
}
|
}
|
||||||
be_return_nil(vm);
|
be_return_nil(vm);
|
||||||
// success
|
// success
|
||||||
@ -92,11 +91,11 @@ extern "C" {
|
|||||||
int32_t m_md5_finish(struct bvm *vm);
|
int32_t m_md5_finish(struct bvm *vm);
|
||||||
int32_t m_md5_finish(struct bvm *vm) {
|
int32_t m_md5_finish(struct bvm *vm) {
|
||||||
be_getmember(vm, 1, ".p");
|
be_getmember(vm, 1, ".p");
|
||||||
mbedtls_md5_context * ctx;
|
struct MD5Context * ctx;
|
||||||
ctx = (mbedtls_md5_context*) be_tocomptr(vm, -1);
|
ctx = (struct MD5Context *) be_tocomptr(vm, -1);
|
||||||
|
|
||||||
uint8_t output[16];
|
uint8_t output[16];
|
||||||
mbedtls_md5_finish_ret(ctx, output);
|
MD5Final(output, ctx);
|
||||||
be_pushbytes(vm, output, sizeof(output));
|
be_pushbytes(vm, output, sizeof(output));
|
||||||
be_return(vm);
|
be_return(vm);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ void InitTimeFromRTC(void) {
|
|||||||
|
|
||||||
void BM8563EverySecond(void) {
|
void BM8563EverySecond(void) {
|
||||||
if (bm8563_driver.rtc_ready) {
|
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);
|
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"),
|
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());
|
GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user