]>
Commit | Line | Data |
---|---|---|
e2173399 | 1 | #include "pico/cyw43_arch.h" |
5ec2b60a SW |
2 | #include "pico/stdlib.h" |
3 | ||
d234f6b3 SW |
4 | char ssid[] = "THEWIFISSID"; |
5 | char pass[] = "THEWIFIPASSWORD"; | |
6 | ||
75649fe3 SW |
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) { | |
5ec2b60a | 21 | while (true) { |
75649fe3 | 22 | one_blink(duration); |
5ec2b60a | 23 | } |
5ec2b60a | 24 | } |
75649fe3 SW |
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(); | |
d234f6b3 | 31 | if (cyw43_arch_init_with_country(CYW43_COUNTRY_USA)) |
75649fe3 SW |
32 | signal_error_by_blinking(); |
33 | signal(1, 200); | |
d234f6b3 | 34 | cyw43_arch_enable_sta_mode(); |
75649fe3 | 35 | signal(2, 200); |
d234f6b3 SW |
36 | if (cyw43_arch_wifi_connect_timeout_ms(ssid, pass, CYW43_AUTH_WPA2_AES_PSK, |
37 | 10000)) | |
38 | signal_error_by_blinking(); | |
75649fe3 SW |
39 | signal(3, 200); |
40 | signal_success_by_blinking(); | |
41 | } |