]> git.scottworley.com Git - tattlekey/blame - client/tattlekey.c
client: Initial wifi connection time: 10s → 90s
[tattlekey] / client / tattlekey.c
CommitLineData
e2173399 1#include "pico/cyw43_arch.h"
5ec2b60a 2#include "pico/stdlib.h"
1427141a 3#include "pico/util/queue.h"
5ec2b60a 4
dae35db7 5#include "blink.h"
d1521eda 6#include "button.h"
fbc57595 7#include "config.h"
1e0a316e 8#include "net.h"
d234f6b3 9
1427141a 10queue_t queue;
d1521eda
SW
11
12static void button_pressed() {
1427141a
SW
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);
d1521eda
SW
18}
19
75649fe3
SW
20int main() {
21 stdio_init_all();
d234f6b3 22 if (cyw43_arch_init_with_country(CYW43_COUNTRY_USA))
75649fe3
SW
23 signal_error_by_blinking();
24 signal(1, 200);
d234f6b3 25 cyw43_arch_enable_sta_mode();
75649fe3 26 signal(2, 200);
fbc57595 27 if (cyw43_arch_wifi_connect_timeout_ms(wifi_ssid, wifi_pass,
9efef936 28 CYW43_AUTH_WPA2_AES_PSK, 90000))
d234f6b3 29 signal_error_by_blinking();
75649fe3 30 signal(3, 200);
1427141a
SW
31
32 queue_init(&queue, 1, 99);
33
d1521eda 34 begin_listening_for_button_press(button_pressed);
1e0a316e 35
1427141a
SW
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 }
75649fe3 43}