Merge pull request #3992 from anecdata/reason4
wifi: more disconnect reasons for retries & include error code in exception
This commit is contained in:
commit
816cbe4704
@ -2013,7 +2013,8 @@ msgid "Unhandled ESP TLS error %d %d %x %d"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: shared-bindings/wifi/Radio.c
|
#: shared-bindings/wifi/Radio.c
|
||||||
msgid "Unknown failure"
|
#, c-format
|
||||||
|
msgid "Unknown failure %d"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ports/nrf/common-hal/_bleio/__init__.c
|
#: ports/nrf/common-hal/_bleio/__init__.c
|
||||||
|
@ -168,11 +168,11 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t
|
|||||||
} while ((bits & (WIFI_CONNECTED_BIT | WIFI_DISCONNECTED_BIT)) == 0 && !mp_hal_is_interrupted());
|
} while ((bits & (WIFI_CONNECTED_BIT | WIFI_DISCONNECTED_BIT)) == 0 && !mp_hal_is_interrupted());
|
||||||
if ((bits & WIFI_DISCONNECTED_BIT) != 0) {
|
if ((bits & WIFI_DISCONNECTED_BIT) != 0) {
|
||||||
if (self->last_disconnect_reason == WIFI_REASON_AUTH_FAIL) {
|
if (self->last_disconnect_reason == WIFI_REASON_AUTH_FAIL) {
|
||||||
return WIFI_RADIO_ERROR_AUTH;
|
return WIFI_RADIO_ERROR_AUTH_FAIL;
|
||||||
} else if (self->last_disconnect_reason == WIFI_REASON_NO_AP_FOUND) {
|
} else if (self->last_disconnect_reason == WIFI_REASON_NO_AP_FOUND) {
|
||||||
return WIFI_RADIO_ERROR_NO_AP_FOUND;
|
return WIFI_RADIO_ERROR_NO_AP_FOUND;
|
||||||
}
|
}
|
||||||
return WIFI_RADIO_ERROR_UNKNOWN;
|
return self->last_disconnect_reason;
|
||||||
}
|
}
|
||||||
return WIFI_RADIO_ERROR_NONE;
|
return WIFI_RADIO_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -65,11 +65,9 @@ static void event_handler(void* arg, esp_event_base_t event_base,
|
|||||||
uint8_t reason = d->reason;
|
uint8_t reason = d->reason;
|
||||||
ESP_LOGW(TAG, "reason %d 0x%02x", reason, reason);
|
ESP_LOGW(TAG, "reason %d 0x%02x", reason, reason);
|
||||||
if (radio->retries_left > 0 &&
|
if (radio->retries_left > 0 &&
|
||||||
(reason == WIFI_REASON_AUTH_EXPIRE ||
|
reason != WIFI_REASON_AUTH_FAIL &&
|
||||||
reason == WIFI_REASON_NOT_AUTHED ||
|
reason != WIFI_REASON_NO_AP_FOUND &&
|
||||||
reason == WIFI_REASON_ASSOC_EXPIRE ||
|
reason != WIFI_REASON_ASSOC_LEAVE) {
|
||||||
reason == WIFI_REASON_CONNECTION_FAIL ||
|
|
||||||
reason == WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT)) {
|
|
||||||
radio->retries_left--;
|
radio->retries_left--;
|
||||||
ESP_LOGI(TAG, "Retrying connect. %d retries remaining", radio->retries_left);
|
ESP_LOGI(TAG, "Retrying connect. %d retries remaining", radio->retries_left);
|
||||||
esp_wifi_connect();
|
esp_wifi_connect();
|
||||||
|
@ -218,12 +218,12 @@ STATIC mp_obj_t wifi_radio_connect(size_t n_args, const mp_obj_t *pos_args, mp_m
|
|||||||
}
|
}
|
||||||
|
|
||||||
wifi_radio_error_t error = common_hal_wifi_radio_connect(self, ssid.buf, ssid.len, password.buf, password.len, args[ARG_channel].u_int, timeout, bssid.buf, bssid.len);
|
wifi_radio_error_t error = common_hal_wifi_radio_connect(self, ssid.buf, ssid.len, password.buf, password.len, args[ARG_channel].u_int, timeout, bssid.buf, bssid.len);
|
||||||
if (error == WIFI_RADIO_ERROR_AUTH) {
|
if (error == WIFI_RADIO_ERROR_AUTH_FAIL) {
|
||||||
mp_raise_ConnectionError(translate("Authentication failure"));
|
mp_raise_ConnectionError(translate("Authentication failure"));
|
||||||
} else if (error == WIFI_RADIO_ERROR_NO_AP_FOUND) {
|
} else if (error == WIFI_RADIO_ERROR_NO_AP_FOUND) {
|
||||||
mp_raise_ConnectionError(translate("No network with that ssid"));
|
mp_raise_ConnectionError(translate("No network with that ssid"));
|
||||||
} else if (error != WIFI_RADIO_ERROR_NONE) {
|
} else if (error != WIFI_RADIO_ERROR_NONE) {
|
||||||
mp_raise_ConnectionError(translate("Unknown failure"));
|
mp_raise_msg_varg(&mp_type_ConnectionError, translate("Unknown failure %d"), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
|
@ -36,10 +36,39 @@
|
|||||||
const mp_obj_type_t wifi_radio_type;
|
const mp_obj_type_t wifi_radio_type;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
WIFI_RADIO_ERROR_NONE,
|
// 0 is circuitpython-specific; 1-53 are IEEE; 200+ are Espressif
|
||||||
WIFI_RADIO_ERROR_UNKNOWN,
|
WIFI_RADIO_ERROR_NONE = 0,
|
||||||
WIFI_RADIO_ERROR_AUTH,
|
WIFI_RADIO_ERROR_UNSPECIFIED = 1,
|
||||||
WIFI_RADIO_ERROR_NO_AP_FOUND
|
WIFI_RADIO_ERROR_AUTH_EXPIRE = 2,
|
||||||
|
WIFI_RADIO_ERROR_AUTH_LEAVE = 3,
|
||||||
|
WIFI_RADIO_ERROR_ASSOC_EXPIRE = 4,
|
||||||
|
WIFI_RADIO_ERROR_ASSOC_TOOMANY = 5,
|
||||||
|
WIFI_RADIO_ERROR_NOT_AUTHED = 6,
|
||||||
|
WIFI_RADIO_ERROR_NOT_ASSOCED = 7,
|
||||||
|
WIFI_RADIO_ERROR_ASSOC_LEAVE = 8,
|
||||||
|
WIFI_RADIO_ERROR_ASSOC_NOT_AUTHED = 9,
|
||||||
|
WIFI_RADIO_ERROR_DISASSOC_PWRCAP_BAD = 10,
|
||||||
|
WIFI_RADIO_ERROR_DISASSOC_SUPCHAN_BAD = 11,
|
||||||
|
WIFI_RADIO_ERROR_IE_INVALID = 13,
|
||||||
|
WIFI_RADIO_ERROR_MIC_FAILURE = 14,
|
||||||
|
WIFI_RADIO_ERROR_4WAY_HANDSHAKE_TIMEOUT = 15,
|
||||||
|
WIFI_RADIO_ERROR_GROUP_KEY_UPDATE_TIMEOUT = 16,
|
||||||
|
WIFI_RADIO_ERROR_IE_IN_4WAY_DIFFERS = 17,
|
||||||
|
WIFI_RADIO_ERROR_GROUP_CIPHER_INVALID = 18,
|
||||||
|
WIFI_RADIO_ERROR_PAIRWISE_CIPHER_INVALID = 19,
|
||||||
|
WIFI_RADIO_ERROR_AKMP_INVALID = 20,
|
||||||
|
WIFI_RADIO_ERROR_UNSUPP_RSN_IE_VERSION = 21,
|
||||||
|
WIFI_RADIO_ERROR_INVALID_RSN_IE_CAP = 22,
|
||||||
|
WIFI_RADIO_ERROR_802_1X_AUTH_FAILED = 23,
|
||||||
|
WIFI_RADIO_ERROR_CIPHER_SUITE_REJECTED = 24,
|
||||||
|
WIFI_RADIO_ERROR_INVALID_PMKID = 53,
|
||||||
|
WIFI_RADIO_ERROR_BEACON_TIMEOUT = 200,
|
||||||
|
WIFI_RADIO_ERROR_NO_AP_FOUND = 201,
|
||||||
|
WIFI_RADIO_ERROR_AUTH_FAIL = 202,
|
||||||
|
WIFI_RADIO_ERROR_ASSOC_FAIL = 203,
|
||||||
|
WIFI_RADIO_ERROR_HANDSHAKE_TIMEOUT = 204,
|
||||||
|
WIFI_RADIO_ERROR_CONNECTION_FAIL = 205,
|
||||||
|
WIFI_RADIO_ERROR_AP_TSF_RESET = 206,
|
||||||
} wifi_radio_error_t;
|
} wifi_radio_error_t;
|
||||||
|
|
||||||
extern bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self);
|
extern bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self);
|
||||||
|
Loading…
Reference in New Issue
Block a user