]> git.scottworley.com Git - tattlekey/blob - client/tattlekey.c
76e9168df08da2640a8ce3ff8a94a2eaa329ca5b
[tattlekey] / client / tattlekey.c
1 #include "pico/cyw43_arch.h"
2 #include "pico/stdlib.h"
3
4 char ssid[] = "THEWIFISSID";
5 char pass[] = "THEWIFIPASSWORD";
6
7 void one_blink(int duration) {
8 cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
9 sleep_ms(duration);
10 cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
11 sleep_ms(duration);
12 }
13
14 void signal(int count, int duration) {
15 for (int i = 0; i < count; i++)
16 one_blink(duration);
17 sleep_ms(1000);
18 }
19
20 void blink_forever(int duration) {
21 while (true) {
22 one_blink(duration);
23 }
24 }
25
26 void signal_error_by_blinking() { blink_forever(100); }
27 void signal_success_by_blinking() { blink_forever(400); }
28
29 int main() {
30 stdio_init_all();
31 if (cyw43_arch_init_with_country(CYW43_COUNTRY_USA))
32 signal_error_by_blinking();
33 signal(1, 200);
34 cyw43_arch_enable_sta_mode();
35 signal(2, 200);
36 if (cyw43_arch_wifi_connect_timeout_ms(ssid, pass, CYW43_AUTH_WPA2_AES_PSK,
37 10000))
38 signal_error_by_blinking();
39 signal(3, 200);
40 signal_success_by_blinking();
41 }