Skip to content

Commit

Permalink
release 1.0.49
Browse files Browse the repository at this point in the history
  • Loading branch information
cpq committed Sep 28, 2019
1 parent 0926fce commit cfb0b88
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library.properties
@@ -1,5 +1,5 @@
name=mDash
version=1.0.48
version=1.0.49
author=Cesanta Software Limited <support@cesanta.com>
maintainer=Cesanta Software Limited <support@cesanta.com>
sentence=Remote control and OTA for ESP32 via mdash.net IoT backend
Expand Down
12 changes: 12 additions & 0 deletions other/Makefile
@@ -0,0 +1,12 @@
LDFLAGS ?= -L/usr/local/Cellar/mbedtls/2.13.0/lib -lmbedtls -lmbedx509 -lmbedcrypto -lmbedtls -lmbedx509 -lmbedcrypto
CFLAGS ?= -W -Wall -I../src
PROG ?= mDashDevice
EXTRA ?=
#CFLAGS += -fsanitize=address

linux:
$(CC) posix.c $(EXTRA) $(CFLAGS) $(LDFLAGS) ../src/linux-x64/libmDash.a -o $(PROG)

mac:
$(CC) posix.c $(EXTRA) $(CFLAGS) $(LDFLAGS) ../src/macos/libmDash.a -o $(PROG)

77 changes: 77 additions & 0 deletions other/posix.c
@@ -0,0 +1,77 @@
// This is mdash.net device simulator on POSIX systems.

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include "mDash.h"

static int s_stop;

static void sighandler(int sig) {
MLOG(LL_CRIT, "Got signal %d, exiting...", sig);
s_stop = 1;
}

// This shadow delta callback sets reported equal to desired, thus
// clearing the delta - whatever it is, without performing any actual action.
static void onDelta(void *ctx, void *cbdata) {
const char *s;
int len;
if (mDashGetTok(mDashGetParams(ctx), "$.state", &s, &len)) {
mDashShadowUpdate("{%Q:{%Q:%.*s}}", "state", "reported", len, s);
}
(void) cbdata;
}

int main(int argc, char *argv[]) {
const char *id = NULL, *pass = NULL, *report_interval = "5";

for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--id") == 0) {
id = argv[++i];
} else if (strcmp(argv[i], "--pass") == 0) {
pass = argv[++i];
} else if (strcmp(argv[i], "--server") == 0) {
mDashConfigSet("server.name", argv[++i]);
} else if (strcmp(argv[i], "--port") == 0) {
mDashConfigSet("server.port", argv[++i]);
} else if (strcmp(argv[i], "--log-level") == 0) {
mDashSetLogLevel(atoi(argv[++i]));
} else if (strcmp(argv[i], "--report-interval") == 0) {
report_interval = argv[++i];
} else if (strcmp(argv[i], "--http-server") == 0) {
// initial_status = MDASH_AP_IP;
} else {
MLOG(LL_CRIT, "Invalid option: [%s]\n", argv[i]);
MLOG(LL_CRIT, "Usage: %s --pass DEVICE_PASSWORD", argv[0]);
return 1;
}
}

if (pass == NULL) {
MLOG(LL_CRIT, "%s", "Please specify --pass DEVICE_PASSWORD");
return 1;
}

mDashStart(id, pass);
mDashExport("Shadow.Delta", onDelta, NULL);

mDashInitJS(4096);

srand(time(0));
sleep(1);
signal(SIGINT, sighandler);
signal(SIGTERM, sighandler);
signal(SIGPIPE, SIG_IGN);

while (s_stop == 0) {
mDashNotify("DB.Save", "{%Q:%u}", "ram", mDashGetFreeRam());
sleep(atoi(report_interval));
}

return 0;
}
Binary file modified src/esp32/libmDash.a
Binary file not shown.
Binary file modified src/esp8266/libmDash.a
Binary file not shown.
Binary file added src/linux-x64/libmDash.a
Binary file not shown.
3 changes: 3 additions & 0 deletions src/mDash.h
Expand Up @@ -96,6 +96,9 @@ int mDashConfigGet(const char *name, char *buf, int bufsize);
int mDashConfigSet(const char *name, const char *value);
void mDashCLI(unsigned char input_byte);

// JS API
int mDashInitJS(int ram_size);

#ifdef __cplusplus
}
#endif
Binary file added src/macos/libmDash.a
Binary file not shown.

0 comments on commit cfb0b88

Please sign in to comment.