More error handling
This commit is contained in:
parent
32fd775a18
commit
8f0373cba7
21
src/main.c
21
src/main.c
|
|
@ -8,7 +8,7 @@
|
|||
#define SSID "thinkpad-T440p"
|
||||
#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)
|
||||
{
|
||||
|
|
@ -35,14 +35,20 @@ int main()
|
|||
return -1;
|
||||
}
|
||||
|
||||
cyw43_arch_enable_sta_mode();
|
||||
cyw43_wifi_pm(&cyw43_state, CYW43_NO_POWERSAVE_MODE);
|
||||
if(cyw43_wifi_pm(&cyw43_state, CYW43_NO_POWERSAVE_MODE))
|
||||
{
|
||||
puts("CYW43 no powersave mode failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
puts("CYW43 arch initialized");
|
||||
|
||||
|
||||
cyw43_arch_enable_sta_mode();
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -81,7 +87,12 @@ int main()
|
|||
|
||||
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 ==========================
|
||||
while(true)
|
||||
|
|
|
|||
Loading…
Reference in New Issue