Skip to content

Commit

Permalink
Add blink_leds request
Browse files Browse the repository at this point in the history
Leds can be blinked by issuing a POST request to the bt.tn socket
server with the following payload.

```
auth = MY_PASSWORD
blink_leds = ffffff;400;0;400;123456;400;0;400;321299;400;0;400
```

First field tells the shift register which leds to light up, second is
the delay before issuing the next shift. This pattern repeats, e.g.
`LEDS;DELAY;LEDS;DELAY;LEDS;DELAY`.
  • Loading branch information
mafredri committed Nov 26, 2016
1 parent 0279abc commit d2a22cb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -181,6 +182,31 @@ int main(void) {
if (strncmp(pch, "dump_config", 12) == 0) {
dumpConfig = true;
break;
} else if (parseParamValue(&value, pch, "blink_leds")) {
char *pNum;
uint32_t num;
bool isDelay = false;
bool hasNext = true;

while (hasNext) {
pNum = value;

while (isxdigit(*value++))
;
if (pNum == value) {
break;
}

num = (uint32_t)strtoul(pNum, NULL, 16);
if (isDelay) {
delay(num);
} else {
led_Set(num);
}

isDelay = !isDelay;
hasNext = (*(value - 1) == ';');
}
} else if (parseParamValue(&value, pch, "url1")) {
conf_Set(CONF_URL1, value);
} else if (parseParamValue(&value, pch, "url2")) {
Expand Down

0 comments on commit d2a22cb

Please sign in to comment.