Fix led toggline in CC3200 sensor demo

PUBLISHED_FROM=10369c7903f3c9433e8c9f6f9725f014aed5768d
This commit is contained in:
Deomid Ryabkov
2016-07-13 20:04:48 +00:00
committed by Cesanta Bot
parent ab208b71c4
commit 613ae4ee34
2 changed files with 5 additions and 10 deletions
+4 -9
View File
@@ -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,
size_t len) {
// TODO(lsm): use proper JSON parser
int cmd, n, val;
double t;
if (sscanf((char *) data, "{\t\": %d, \"ts\": %lf, %n", &cmd, &t, &n) != 2) {
LOG(LL_ERROR, ("Invalid command: %.*s", (int) len, data));
int cmd, val;
if (sscanf((char *) data, "{\"t\":%d,\"v\":%d}", &cmd, &val) != 2) {
LOG(LL_ERROR, ("Invalid request: %.*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;
}
if (cmd == 1) {
switch (val) {
case '0': {
GPIO_IF_LedOff(MCU_RED_LED_GPIO);
+1 -1
View File
@@ -97,7 +97,7 @@ bool wifi_setup_ap(const char *ssid, const char *pass, int channel) {
LOG(LL_ERROR, ("DHCP server failed to start"));
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;
}