Initial WLAN connectivity.

This commit is contained in:
Martin Brodbeck 2022-12-27 13:26:17 +01:00
parent 5a32ce8bb9
commit 95d84a69a3

View file

@ -2,11 +2,41 @@
#include "pico/stdlib.h" #include "pico/stdlib.h"
#include "pico/cyw43_arch.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() int main()
{ {
stdio_init_all(); stdio_init_all();
puts("Hello, world!"); if (cyw43_arch_init())
{
return 0; printf("Failed to initialize\n");
return 1;
}
if (wifi_connect() == false)
{
return 1;
}
cyw43_arch_deinit();
} }