]>
Commit | Line | Data |
---|---|---|
1 | #include "pico/cyw43_arch.h" | |
2 | #include "pico/stdlib.h" | |
3 | #include "pico/util/queue.h" | |
4 | ||
5 | #include "blink.h" | |
6 | #include "button.h" | |
7 | #include "config.h" | |
8 | #include "net.h" | |
9 | ||
10 | queue_t queue; | |
11 | ||
12 | static void button_pressed() { | |
13 | /* This runs in interrupt context; don't linger. */ | |
14 | char zero = '\0'; | |
15 | /* We don't check for failure (full queue) here because there's not much to be | |
16 | * done about it. */ | |
17 | queue_try_add(&queue, &zero); | |
18 | } | |
19 | ||
20 | int main() { | |
21 | stdio_init_all(); | |
22 | if (cyw43_arch_init_with_country(CYW43_COUNTRY_USA)) | |
23 | signal_error_by_blinking(); | |
24 | signal(1, 200); | |
25 | cyw43_arch_enable_sta_mode(); | |
26 | signal(2, 200); | |
27 | if (cyw43_arch_wifi_connect_timeout_ms(wifi_ssid, wifi_pass, | |
28 | CYW43_AUTH_WPA2_AES_PSK, 10000)) | |
29 | signal_error_by_blinking(); | |
30 | signal(3, 200); | |
31 | ||
32 | queue_init(&queue, 1, 99); | |
33 | ||
34 | begin_listening_for_button_press(button_pressed); | |
35 | ||
36 | u16_t seq = 0; | |
37 | while (1) { | |
38 | char _; | |
39 | queue_remove_blocking(&queue, &_); | |
40 | send_report(seq++, 0); | |
41 | signal(4, 200); | |
42 | } | |
43 | } |