]>
git.scottworley.com Git - tattlekey/blob - client/tattlekey.c
1 #include "pico/cyw43_arch.h"
2 #include "pico/stdlib.h"
11 static void button_pressed() {
12 /* TODO: This is interrupt context. We need to get out of interrupt context
13 * quickly; we should not be doing significant work here, & definitely
14 * shouldn't be sleeping here. We signal errors with blinking the LED, which
15 * involves sleeping, so this all has to move. */
16 send_report(seq
++, 0);
20 static void wait_forever() {
21 /* pico-examples/gpio/hello_gpio_irq/hello_gpio_irq.c implements wait-forever
22 * as "while (1);", but
23 * https://www.raspberrypi.com/documentation/pico-sdk/high_level.html#gaf469c6d691230e9d1008
24 * says sleeping uses less power, so we sleep. */
26 /* https://www.raspberrypi.com/documentation/pico-sdk/hardware.html#rpip7ce2cdc1662dce59296b
27 * says the maximum sleep is 2^32 - 1 microseconds (~71.58 minutes), so we
29 sleep_ms(1 << 31); /* 35.79 minutes */
35 if (cyw43_arch_init_with_country(CYW43_COUNTRY_USA
))
36 signal_error_by_blinking();
38 cyw43_arch_enable_sta_mode();
40 if (cyw43_arch_wifi_connect_timeout_ms(wifi_ssid
, wifi_pass
,
41 CYW43_AUTH_WPA2_AES_PSK
, 10000))
42 signal_error_by_blinking();
44 begin_listening_for_button_press(button_pressed
);