Commit 613ae4ee authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Fix led toggline in CC3200 sensor demo

PUBLISHED_FROM=10369c7903f3c9433e8c9f6f9725f014aed5768d
parent ab208b71
...@@ -96,17 +96,12 @@ static double send_acc_data_since(struct mg_connection *nc, ...@@ -96,17 +96,12 @@ static double send_acc_data_since(struct mg_connection *nc,
static void process_command(struct mg_connection *nc, unsigned char *data, static void process_command(struct mg_connection *nc, unsigned char *data,
size_t len) { size_t len) {
// TODO(lsm): use proper JSON parser // TODO(lsm): use proper JSON parser
int cmd, n, val; int cmd, val;
double t; if (sscanf((char *) data, "{\"t\":%d,\"v\":%d}", &cmd, &val) != 2) {
if (sscanf((char *) data, "{\t\": %d, \"ts\": %lf, %n", &cmd, &t, &n) != 2) { LOG(LL_ERROR, ("Invalid request: %.*s", (int) len, data));
LOG(LL_ERROR, ("Invalid command: %.*s", (int) len, data));
return;
}
if (t == 1) {
if (sscanf((char *) data + n, "\"v\": %d", &val) != 1) {
LOG(LL_ERROR, ("Missing value: %.*s", (int) len, data));
return; return;
} }
if (cmd == 1) {
switch (val) { switch (val) {
case '0': { case '0': {
GPIO_IF_LedOff(MCU_RED_LED_GPIO); GPIO_IF_LedOff(MCU_RED_LED_GPIO);
......
...@@ -97,7 +97,7 @@ bool wifi_setup_ap(const char *ssid, const char *pass, int channel) { ...@@ -97,7 +97,7 @@ bool wifi_setup_ap(const char *ssid, const char *pass, int channel) {
LOG(LL_ERROR, ("DHCP server failed to start")); LOG(LL_ERROR, ("DHCP server failed to start"));
return false; return false;
} }
LOG(LL_INFO, ("WiFi: AP %s configured", ssid)); LOG(LL_INFO, ("WiFi: AP %s configured, IP 192.168.4.1", ssid));
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment