mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-10 16:31:44 +00:00
Fix led toggline in CC3200 sensor demo
PUBLISHED_FROM=10369c7903f3c9433e8c9f6f9725f014aed5768d
This commit is contained in:
1 parent
ab208b71c4
commit
613ae4ee34
2 files changed
+5
-10
No files matched your search
@@ -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;
|
return;
|
||||||
}
|
}
|
||||||
if (t == 1) {
|
if (cmd == 1) {
|
||||||
if (sscanf((char *) data + n, "\"v\": %d", &val) != 1) {
|
|
||||||
LOG(LL_ERROR, ("Missing value: %.*s", (int) len, data));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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) {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user