fix(wifi): fix compatibility issues with AP which configured to 11n only

This commit is contained in:
Chen Wen
2019-06-13 21:37:28 +08:00
committed by Zhang Jun Hao
parent a227a22a36
commit af0fcc0492
47 changed files with 328 additions and 47 deletions

View File

@ -71,6 +71,9 @@ char recv_data[1024] = {0};
static esp_err_t event_handler(void *ctx, system_event_t *event)
{
/* For accessing reason codes in case of disconnection */
system_event_info_t *info = &event->event_info;
switch(event->event_id) {
case SYSTEM_EVENT_STA_START:
esp_wifi_connect();
@ -79,8 +82,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
/* This is a workaround as ESP32 WiFi libs don't currently
auto-reassociate. */
ESP_LOGE(TAG, "Disconnect reason : %d", info->disconnected.reason);
if (info->disconnected.reason == WIFI_REASON_BASIC_RATE_NOT_SUPPORT) {
/*Switch to 802.11 bgn mode */
esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCAL_11B | WIFI_PROTOCAL_11G | WIFI_PROTOCAL_11N);
}
esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
break;