go IDLE after all APs have been attempted
This commit is contained in:
parent
349b0b4ff3
commit
7cf5ef49a5
2 changed files with 9 additions and 5 deletions
|
@ -10,6 +10,7 @@ void wifi_manager_reset_store();
|
||||||
#define WIFI_CONNECTED (BIT0)
|
#define WIFI_CONNECTED (BIT0)
|
||||||
#define WIFI_CONNECTING (BIT1)
|
#define WIFI_CONNECTING (BIT1)
|
||||||
#define AP_AVAILABLE (BIT2)
|
#define AP_AVAILABLE (BIT2)
|
||||||
|
#define WIFI_IDLE (BIT3)
|
||||||
|
|
||||||
uint8_t wifi_manager_ap_count();
|
uint8_t wifi_manager_ap_count();
|
||||||
uint8_t wifi_manager_add_ap(char *essid, char *password);
|
uint8_t wifi_manager_add_ap(char *essid, char *password);
|
||||||
|
|
|
@ -42,8 +42,6 @@ typedef struct ap_store_base {
|
||||||
ap_store_t ap_store;
|
ap_store_t ap_store;
|
||||||
static EventGroupHandle_t wm_event_group;
|
static EventGroupHandle_t wm_event_group;
|
||||||
|
|
||||||
void wifi_manager_connect();
|
|
||||||
|
|
||||||
uint8_t wifi_manager_ap_count() {
|
uint8_t wifi_manager_ap_count() {
|
||||||
return ap_store.count;
|
return ap_store.count;
|
||||||
};
|
};
|
||||||
|
@ -69,13 +67,18 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) {
|
||||||
|
|
||||||
vTaskDelay(CONFIG_WIFI_MANAGER_CONNECTION_DELAY / portTICK_PERIOD_MS);
|
vTaskDelay(CONFIG_WIFI_MANAGER_CONNECTION_DELAY / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
|
// inc to the next ap, if it's the last one go IDLE
|
||||||
|
// else attempt to connect
|
||||||
ap_store.last++;
|
ap_store.last++;
|
||||||
if(ap_store.count == ap_store.last) {
|
if(ap_store.count == ap_store.last) {
|
||||||
ap_store.last = 0;
|
ap_store.last = 0;
|
||||||
}
|
|
||||||
|
|
||||||
wifi_manager_connect();
|
xEventGroupSetBits(wm_event_group, WIFI_IDLE);
|
||||||
ESP_ERROR_CHECK(esp_wifi_connect());
|
break;
|
||||||
|
} else {
|
||||||
|
wifi_manager_connect();
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_connect());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue