From 95d84a69a39952144327c1c4bd72ccffc8c252dd Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Tue, 27 Dec 2022 13:26:17 +0100 Subject: [PATCH] Initial WLAN connectivity. --- src/abfall.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/abfall.cpp b/src/abfall.cpp index 92b48d2..63c466c 100644 --- a/src/abfall.cpp +++ b/src/abfall.cpp @@ -2,11 +2,41 @@ #include "pico/stdlib.h" #include "pico/cyw43_arch.h" +#define WIFI_SSID "Apis cerana" +#define WIFI_PASSWORD "2JkJEh2vptVT" + +bool wifi_connect() +{ + cyw43_arch_enable_sta_mode(); + + printf("Connecting to WiFi...\n"); + if (cyw43_arch_wifi_connect_timeout_ms(WIFI_SSID, WIFI_PASSWORD, CYW43_AUTH_WPA2_AES_PSK, 30000)) + { + printf("Failed to connect.\n"); + return false; + } + else + { + printf("Connected.\n"); + } + + return true; +} + int main() { stdio_init_all(); - puts("Hello, world!"); + if (cyw43_arch_init()) + { + printf("Failed to initialize\n"); + return 1; + } - return 0; + if (wifi_connect() == false) + { + return 1; + } + + cyw43_arch_deinit(); }