Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32-S2: Log all Wi-Fi events & remove unneeded call #3903

Merged
merged 3 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ports/esp32s2/common-hal/wifi/Radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ static void start_station(wifi_radio_obj_t *self) {
esp_wifi_set_mode(next_mode);

self->sta_mode = 1;

esp_wifi_set_config(WIFI_MODE_STA, &self->sta_config);
}

bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self) {
Expand Down
21 changes: 12 additions & 9 deletions ports/esp32s2/common-hal/wifi/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,48 +47,51 @@ static void event_handler(void* arg, esp_event_base_t event_base,
if (event_base == WIFI_EVENT) {
switch (event_id) {
case WIFI_EVENT_SCAN_DONE:
ESP_EARLY_LOGW(TAG, "scan");
ESP_LOGW(TAG, "scan");
xEventGroupSetBits(radio->event_group_handle, WIFI_SCAN_DONE_BIT);
break;
case WIFI_EVENT_STA_START:
ESP_EARLY_LOGW(TAG, "start");
ESP_LOGW(TAG, "start");
break;
case WIFI_EVENT_STA_STOP:
ESP_EARLY_LOGW(TAG, "stop");
ESP_LOGW(TAG, "stop");
break;
case WIFI_EVENT_STA_CONNECTED:
ESP_EARLY_LOGW(TAG, "connected");
ESP_LOGW(TAG, "connected");
break;
case WIFI_EVENT_STA_DISCONNECTED: {
ESP_EARLY_LOGW(TAG, "disconnected");
ESP_LOGW(TAG, "disconnected");
wifi_event_sta_disconnected_t* d = (wifi_event_sta_disconnected_t*) event_data;
uint8_t reason = d->reason;
ESP_EARLY_LOGW(TAG, "reason %d 0x%02x", reason, reason);
ESP_LOGW(TAG, "reason %d 0x%02x", reason, reason);
if (radio->retries_left > 0 &&
(reason == WIFI_REASON_AUTH_EXPIRE ||
reason == WIFI_REASON_NOT_AUTHED ||
reason == WIFI_REASON_ASSOC_EXPIRE ||
reason == WIFI_REASON_CONNECTION_FAIL ||
reason == WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT)) {
radio->retries_left--;
ESP_EARLY_LOGI(TAG, "Retrying connect. %d retries remaining", radio->retries_left);
ESP_LOGI(TAG, "Retrying connect. %d retries remaining", radio->retries_left);
esp_wifi_connect();
return;
}

radio->last_disconnect_reason = reason;
xEventGroupSetBits(radio->event_group_handle, WIFI_DISCONNECTED_BIT);
break;
}

// Cases to handle later.
// case WIFI_EVENT_STA_AUTHMODE_CHANGE:
default:
default: {
ESP_LOGW(TAG, "event %d 0x%02x", event_id, event_id);
break;
}
}
}

if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
ESP_EARLY_LOGW(TAG, "got ip");
ESP_LOGW(TAG, "got ip");
radio->retries_left = radio->starting_retries;
xEventGroupSetBits(radio->event_group_handle, WIFI_CONNECTED_BIT);
}
Expand Down