Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for V1.2.17 #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ 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.

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()
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name=mDash
version=1.2.16
version=1.2.17X3
author=Cesanta Software Limited <[email protected]>
maintainer=Cesanta Software Limited <[email protected]>
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
40 changes: 38 additions & 2 deletions src/mDash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -413,7 +413,36 @@ int mDashNotify(const char *name, const char *fmt, ...) {
mg_iobuf_free(&io);
res = 1;
}
MDashMutexUnlock();
//MDashMutexUnlock();
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;
}

Expand Down Expand Up @@ -790,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));
}
5 changes: 5 additions & 0 deletions src/mDash.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ 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__)

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;
Expand Down