From 0914b71653adafccb6bb7f656d3833fd60e9c4ae Mon Sep 17 00:00:00 2001 From: anecdata <16617689+anecdata@users.noreply.github.com> Date: Wed, 30 Dec 2020 09:26:25 -0600 Subject: [PATCH 1/3] remove unneeded set_config (wrong param; called in connect anyway) --- ports/esp32s2/common-hal/wifi/Radio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index 05506783e7..a9617af653 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -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) { From d537d94a4c6ca36fba4aa7c11a1de93d2a38cf6b Mon Sep 17 00:00:00 2001 From: anecdata <16617689+anecdata@users.noreply.github.com> Date: Wed, 30 Dec 2020 09:45:15 -0600 Subject: [PATCH 2/3] see what we're missing --- ports/esp32s2/common-hal/wifi/__init__.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c index 8de3775375..878c903521 100644 --- a/ports/esp32s2/common-hal/wifi/__init__.c +++ b/ports/esp32s2/common-hal/wifi/__init__.c @@ -78,12 +78,15 @@ static void event_handler(void* arg, esp_event_base_t event_base, 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_EARLY_LOGW(TAG, "event %d 0x%02x", event_id, event_id); break; + } } } From 98c9492a8c5da5a40e92c60e0f891b6c3038355d Mon Sep 17 00:00:00 2001 From: anecdata <16617689+anecdata@users.noreply.github.com> Date: Tue, 5 Jan 2021 18:39:51 -0600 Subject: [PATCH 3/3] change ESP_EARLY_LOG* to ESP_LOG* throughout event_handler --- ports/esp32s2/common-hal/wifi/__init__.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c index 878c903521..08d7a164f4 100644 --- a/ports/esp32s2/common-hal/wifi/__init__.c +++ b/ports/esp32s2/common-hal/wifi/__init__.c @@ -47,23 +47,23 @@ 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 || @@ -71,7 +71,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, 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; } @@ -84,14 +84,14 @@ static void event_handler(void* arg, esp_event_base_t event_base, // Cases to handle later. // case WIFI_EVENT_STA_AUTHMODE_CHANGE: default: { - ESP_EARLY_LOGW(TAG, "event %d 0x%02x", event_id, event_id); + 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); }