stash
This commit is contained in:
parent
7424a80945
commit
8b0020c387
7 changed files with 79 additions and 20 deletions
|
|
@ -32,6 +32,7 @@ char *wifi_ap_ssid = nullptr;
|
|||
char *wifi_ap_password = nullptr;
|
||||
|
||||
SemaphoreHandle_t wifi_available_semaphore = nullptr;
|
||||
SemaphoreHandle_t wifi_alive = nullptr;
|
||||
|
||||
[[noreturn]] static void dns_task(void *pvParameters) {
|
||||
char *wifi_ap_ip_addr = nullptr;
|
||||
|
|
@ -347,5 +348,38 @@ extern "C" void wifi_task(void *pvParameters) {
|
|||
xSemaphoreGive(wifi_available_semaphore);
|
||||
|
||||
//monitor loop connection here
|
||||
vTaskDelete(nullptr);
|
||||
uint8_t status = 0;
|
||||
uint8_t retries = 30;
|
||||
|
||||
while (1) {
|
||||
while ((status != STATION_GOT_IP) && (retries)) {
|
||||
status = sdk_wifi_station_get_connect_status();
|
||||
printf("%s: status = %d\n\r", __func__, status);
|
||||
if(status == STATION_WRONG_PASSWORD) {
|
||||
printf("WiFi: wrong password\n\r");
|
||||
break;
|
||||
} else if(status == STATION_NO_AP_FOUND) {
|
||||
printf("WiFi: AP not found\n\r");
|
||||
break;
|
||||
} else if(status == STATION_CONNECT_FAIL) {
|
||||
printf("WiFi: connection failed\r\n");
|
||||
break;
|
||||
}
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
--retries;
|
||||
}
|
||||
if(status == STATION_GOT_IP) {
|
||||
printf("WiFi: Connected\n\r");
|
||||
xSemaphoreGive(wifi_alive);
|
||||
taskYIELD();
|
||||
}
|
||||
|
||||
while ((status = sdk_wifi_station_get_connect_status()) == STATION_GOT_IP) {
|
||||
xSemaphoreGive(wifi_alive);
|
||||
taskYIELD();
|
||||
}
|
||||
printf("WiFi: disconnected\n\r");
|
||||
sdk_wifi_station_disconnect();
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue