esp32/network_wlan: Rename WLAN keyword args to ssid/security/key.

The WLAN.config() method now supports "ssid", "security" and "key" as
aliases to the existing "essid", "authmode" and "password", which are now
deprecated.

Addresses issue #8083.
pull/7868/merge
iabdalkader 2022-06-04 12:22:55 +02:00 zatwierdzone przez Damien George
rodzic efa73ca833
commit a7c7febe0b
1 zmienionych plików z 8 dodań i 3 usunięć

Wyświetl plik

@ -218,7 +218,7 @@ STATIC mp_obj_t network_wlan_active(size_t n_args, const mp_obj_t *args) {
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_wlan_active_obj, 1, 2, network_wlan_active);
STATIC mp_obj_t network_wlan_connect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_ssid, ARG_password, ARG_bssid };
enum { ARG_ssid, ARG_key, ARG_bssid };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_, MP_ARG_OBJ, {.u_obj = mp_const_none} },
@ -239,8 +239,8 @@ STATIC mp_obj_t network_wlan_connect(size_t n_args, const mp_obj_t *pos_args, mp
p = mp_obj_str_get_data(args[ARG_ssid].u_obj, &len);
memcpy(wifi_sta_config.sta.ssid, p, MIN(len, sizeof(wifi_sta_config.sta.ssid)));
}
if (args[ARG_password].u_obj != mp_const_none) {
p = mp_obj_str_get_data(args[ARG_password].u_obj, &len);
if (args[ARG_key].u_obj != mp_const_none) {
p = mp_obj_str_get_data(args[ARG_key].u_obj, &len);
memcpy(wifi_sta_config.sta.password, p, MIN(len, sizeof(wifi_sta_config.sta.password)));
}
if (args[ARG_bssid].u_obj != mp_const_none) {
@ -410,6 +410,7 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_
esp_exceptions(esp_wifi_set_mac(self->if_id, bufinfo.buf));
break;
}
case MP_QSTR_ssid:
case MP_QSTR_essid: {
req_if = WIFI_IF_AP;
size_t len;
@ -424,11 +425,13 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_
cfg.ap.ssid_hidden = mp_obj_is_true(kwargs->table[i].value);
break;
}
case MP_QSTR_security:
case MP_QSTR_authmode: {
req_if = WIFI_IF_AP;
cfg.ap.authmode = mp_obj_get_int(kwargs->table[i].value);
break;
}
case MP_QSTR_key:
case MP_QSTR_password: {
req_if = WIFI_IF_AP;
size_t len;
@ -503,6 +506,7 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_
goto unknown;
}
}
case MP_QSTR_ssid:
case MP_QSTR_essid:
switch (self->if_id) {
case WIFI_IF_STA:
@ -519,6 +523,7 @@ STATIC mp_obj_t network_wlan_config(size_t n_args, const mp_obj_t *args, mp_map_
req_if = WIFI_IF_AP;
val = mp_obj_new_bool(cfg.ap.ssid_hidden);
break;
case MP_QSTR_security:
case MP_QSTR_authmode:
req_if = WIFI_IF_AP;
val = MP_OBJ_NEW_SMALL_INT(cfg.ap.authmode);