More error handling

This commit is contained in:
Ulysse Cura 2026-02-01 18:21:45 +01:00
parent 32fd775a18
commit 8f0373cba7
1 changed files with 16 additions and 5 deletions

View File

@ -8,7 +8,7 @@
#define SSID "thinkpad-T440p" #define SSID "thinkpad-T440p"
#define PASSWORD "CDuKaka2000!" #define PASSWORD "CDuKaka2000!"
#define PORT 4243 #define CLIENT_PORT 4243
static void udp_recv_callback(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) static void udp_recv_callback(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{ {
@ -35,14 +35,20 @@ int main()
return -1; return -1;
} }
cyw43_arch_enable_sta_mode(); if(cyw43_wifi_pm(&cyw43_state, CYW43_NO_POWERSAVE_MODE))
cyw43_wifi_pm(&cyw43_state, CYW43_NO_POWERSAVE_MODE); {
puts("CYW43 no powersave mode failed");
return -1;
}
puts("CYW43 arch initialized"); puts("CYW43 arch initialized");
cyw43_arch_enable_sta_mode();
for(int error_code = 1; error_code; ) for(int error_code = 1; error_code; )
{ {
puts("WiFi connection attempt"); printf("WiFi connection attempt to \"%s\"\n", SSID);
error_code = cyw43_arch_wifi_connect_timeout_ms(SSID, PASSWORD, CYW43_AUTH_WPA2_AES_PSK, 10000); error_code = cyw43_arch_wifi_connect_timeout_ms(SSID, PASSWORD, CYW43_AUTH_WPA2_AES_PSK, 10000);
@ -81,7 +87,12 @@ int main()
udp_recv(pcb, udp_recv_callback, NULL); udp_recv(pcb, udp_recv_callback, NULL);
udp_bind(pcb, IP4_ADDR_ANY, PORT); if(udp_bind(pcb, IP4_ADDR_ANY, CLIENT_PORT))
{
puts("UDP pcb bind failed");
return -1;
}
// ========================== Main loop ========================== // ========================== Main loop ==========================
while(true) while(true)