From 765313a91808c73e00f6c4f748c2c801ab478b9d Mon Sep 17 00:00:00 2001 From: Thermelgy-Repo Date: Sat, 19 Aug 2023 04:29:03 +0530 Subject: [PATCH 1/4] Updated for V1.2.17 --- README.md | 5 +++++ src/mDash.c | 29 +++++++++++++++++++++++++++++ src/mDash.h | 6 +++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e50fe11..e5a622f 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,8 @@ this repo: ```sh $ make -C posix ARGS="-pass DEVICE_MDASH_PASSWORD" ``` + +Firmware V1.2.17: + +1. Resolved the bug on [mDashShadowUpdate()](https://github.com/cesanta/mDash/issues/22). +2. Added mDashNotify_shdw() for mDashShadowUpdate() with removal of MutexLock. diff --git a/src/mDash.c b/src/mDash.c index 19add28..d546f13 100644 --- a/src/mDash.c +++ b/src/mDash.c @@ -417,6 +417,35 @@ int mDashNotify(const char *name, const char *fmt, ...) { return res; } +/** + * @brief MDash Notify Shadow without mutex lock + * + * @param name Type Name + * @param fmt Format + * @param ... multiple arguments + * @return int + */ +int mDashNotify_shdw(const char *name, const char *fmt, ...) { + int res = 0; + //MDashMutexLock(); + va_list ap; + if (s_conn != NULL) { + struct mg_iobuf io = {0, 0, 0, 512}; + mg_rprintf(mg_pfn_iobuf, &io, "{%Q:%Q,%Q:", "method", name, "params"); + va_start(ap, fmt); + mg_vrprintf(mg_pfn_iobuf, &io, fmt, &ap); + va_end(ap); + mg_rprintf(mg_pfn_iobuf, &io, "}"); + if (io.buf != NULL) { + mg_ws_send(s_conn, (char *) io.buf, io.len, WEBSOCKET_OP_TEXT); + } + mg_iobuf_free(&io); + res = 1; + } + //MDashMutexUnlock(); + return res; +} + static void rpc_ota_begin(struct mg_rpc_req *r) { if (s_ota_size) { mg_rpc_err(r, 500, "%Q", "OTA already in progress"); diff --git a/src/mDash.h b/src/mDash.h index 0b7b7bc..ec8bbc3 100644 --- a/src/mDash.h +++ b/src/mDash.h @@ -38,8 +38,12 @@ int mDashStore(const char *topic, const char *json_fmt, ...); // Send notification frame to mDash int mDashNotify(const char *name, const char *fmt, ...); + +// Send notification of shadow to Mdash without Mutex lock +int mDashNotify_shdw(const char *name, const char *fmt, ...); + #define mDashShadowUpdate(fmt, ...) \ - mDashNotify("Dash.Shadow.Update", (fmt), __VA_ARGS__) + mDashNotify_shdw("Dash.Shadow.Update", (fmt), __VA_ARGS__) int mDashConfigGet(const char *name, char *buf, int bufsize); int mDashConfigSet(const char *name, const char *value); From 25db739cc6a52c8e98ea32cf2377821e4d330447 Mon Sep 17 00:00:00 2001 From: Thermelgy-Repo Date: Sat, 19 Aug 2023 04:55:11 +0530 Subject: [PATCH 2/4] Upated the Lib properties --- library.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index deff451..63b0fe1 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=mDash -version=1.2.16 +version=1.2.17 author=Cesanta Software Limited maintainer=Cesanta Software Limited sentence=Remote control and OTA for ESP32 via mdash.net IoT backend paragraph=Provides OTA, MQTT, device shadow, Filesystem management for ESP32 category=Communication -url=https://github.com/cesanta/mDash +url=https://github.com/Thermelgy-Repo/mDash architectures=esp32 includes=mDash.h From ed1ed129623b01a71b5f932de16d200c579be2db Mon Sep 17 00:00:00 2001 From: Thermelgy-Repo Date: Wed, 8 Nov 2023 16:41:33 +0530 Subject: [PATCH 3/4] Updated V1.2.17X2 with mDashOTAPercent() --- README.md | 4 ++++ library.properties | 2 +- src/mDash.c | 7 +++++++ src/mDash.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e5a622f..9cafbb1 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,7 @@ Firmware V1.2.17: 1. Resolved the bug on [mDashShadowUpdate()](https://github.com/cesanta/mDash/issues/22). 2. Added mDashNotify_shdw() for mDashShadowUpdate() with removal of MutexLock. + +Firmware V1.2.17X2: + +1. Added a function mDashOTAPercent() diff --git a/library.properties b/library.properties index 63b0fe1..0c3eec3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=mDash -version=1.2.17 +version=1.2.17X2 author=Cesanta Software Limited maintainer=Cesanta Software Limited sentence=Remote control and OTA for ESP32 via mdash.net IoT backend diff --git a/src/mDash.c b/src/mDash.c index d546f13..575f706 100644 --- a/src/mDash.c +++ b/src/mDash.c @@ -819,3 +819,10 @@ void mDashInit(const char *id, const char *pass, const char *name, xTaskCreatePinnedToCore(&mDashTask, "mDashTask", 16384, 0, 5, 0, CPU_CORE); MDashMutexUnlock(); } + +int mDashOTAPercent(void){ + if (s_ota_size == 0) + return 0; // Or an error code if you prefer + + return((int) (s_ota_written * 100 / s_ota_size)); +} \ No newline at end of file diff --git a/src/mDash.h b/src/mDash.h index ec8bbc3..9be5dda 100644 --- a/src/mDash.h +++ b/src/mDash.h @@ -49,6 +49,7 @@ int mDashConfigGet(const char *name, char *buf, int bufsize); int mDashConfigSet(const char *name, const char *value); int mDashConfigReset(void); void mDashPoll(void); +int mDashOTAPercent(void); // Registered RPC handlers. Use mg_rpc_add() to add new handlers extern struct mg_rpc *g_rpcs; From 8e86076ee8965ea9e95dc408e8477f5f88f9f619 Mon Sep 17 00:00:00 2001 From: Thermelgy-Repo Date: Tue, 14 Nov 2023 17:44:57 +0530 Subject: [PATCH 4/4] Resolved the mDashNotify() issue --- README.md | 5 +++++ library.properties | 2 +- src/mDash.c | 4 ++-- src/mDash.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9cafbb1..091f993 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,8 @@ Firmware V1.2.17: Firmware V1.2.17X2: 1. Added a function mDashOTAPercent() + +Firmware V1.2.17X3: + +1. Resolved the Mdash task exit when using mDashNotify(). +2. Removed the Mutex locks in mDashNotify() diff --git a/library.properties b/library.properties index 0c3eec3..2055e94 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=mDash -version=1.2.17X2 +version=1.2.17X3 author=Cesanta Software Limited maintainer=Cesanta Software Limited sentence=Remote control and OTA for ESP32 via mdash.net IoT backend diff --git a/src/mDash.c b/src/mDash.c index 575f706..6a6ec79 100644 --- a/src/mDash.c +++ b/src/mDash.c @@ -398,7 +398,7 @@ static void rpc_fs_list(struct mg_rpc_req *r) { int mDashNotify(const char *name, const char *fmt, ...) { int res = 0; - MDashMutexLock(); + //MDashMutexLock(); va_list ap; if (s_conn != NULL) { struct mg_iobuf io = {0, 0, 0, 512}; @@ -413,7 +413,7 @@ int mDashNotify(const char *name, const char *fmt, ...) { mg_iobuf_free(&io); res = 1; } - MDashMutexUnlock(); + //MDashMutexUnlock(); return res; } diff --git a/src/mDash.h b/src/mDash.h index 9be5dda..4576610 100644 --- a/src/mDash.h +++ b/src/mDash.h @@ -43,7 +43,7 @@ int mDashNotify(const char *name, const char *fmt, ...); int mDashNotify_shdw(const char *name, const char *fmt, ...); #define mDashShadowUpdate(fmt, ...) \ - mDashNotify_shdw("Dash.Shadow.Update", (fmt), __VA_ARGS__) + mDashNotify("Dash.Shadow.Update", (fmt), __VA_ARGS__) int mDashConfigGet(const char *name, char *buf, int bufsize); int mDashConfigSet(const char *name, const char *value);