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