Working WiFi Operator and switched back to connect with timeout.
This commit is contained in:
parent
db81c8ef1b
commit
5c5e12361e
|
|
@ -27,24 +27,28 @@ int wifi_operator_init(enum wifi_operator_mode_t mode)
|
|||
// Setup as station
|
||||
cyw43_arch_enable_sta_mode();
|
||||
|
||||
int ret = cyw43_arch_wifi_connect_blocking(WIFI_OPERATOR_SSID, WIFI_OPERATOR_PASSWORD, WIFI_OPERATOR_AUTH);
|
||||
for(int ret = 1; ret; )
|
||||
{
|
||||
puts("Attempting to connect to WiFi network.");
|
||||
|
||||
int ret = cyw43_arch_wifi_connect_timeout_ms(WIFI_OPERATOR_SSID, WIFI_OPERATOR_PASSWORD, WIFI_OPERATOR_AUTH, WIFI_OPERATOR_CONNECTION_TIMEOUT_MS);
|
||||
|
||||
switch(ret)
|
||||
{
|
||||
case PICO_ERROR_TIMEOUT:
|
||||
puts("Timeout reached while trying to connect to WiFi network.");
|
||||
break;
|
||||
|
||||
case PICO_ERROR_BADAUTH:
|
||||
puts("Failed to autentificate to WiFi network.");
|
||||
break;
|
||||
|
||||
case PICO_ERROR_CONNECT_FAILED:
|
||||
puts("Failed to connect to WiFi network.");
|
||||
break;
|
||||
return ret;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
puts("Failed to connect to WiFi network.");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wifi_operator_mode = WIFI_OPERATOR_MODE_UNINITIALIZED;
|
||||
|
||||
|
|
@ -66,6 +70,9 @@ int wifi_operator_exit(void)
|
|||
// Exit as access point
|
||||
cyw43_arch_disable_ap_mode();
|
||||
|
||||
|
||||
wifi_operator_mode = WIFI_OPERATOR_MODE_UNINITIALIZED;
|
||||
|
||||
return PICO_OK;
|
||||
}
|
||||
else if(wifi_operator_mode == WIFI_OPERATOR_MODE_STATION)
|
||||
|
|
@ -73,6 +80,8 @@ int wifi_operator_exit(void)
|
|||
// Exit as station
|
||||
cyw43_arch_disable_sta_mode();
|
||||
|
||||
wifi_operator_mode = WIFI_OPERATOR_MODE_UNINITIALIZED;
|
||||
|
||||
return PICO_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue