Adding authmode keyword
This commit is contained in:
parent
a33359762d
commit
66d87782be
|
@ -54,3 +54,38 @@ mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self) {
|
||||||
// 2 instead of strlen(cstr) as this gives us only the country-code
|
// 2 instead of strlen(cstr) as this gives us only the country-code
|
||||||
return mp_obj_new_str(cstr, 2);
|
return mp_obj_new_str(cstr, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mp_obj_t common_hal_wifi_network_get_authmode(wifi_network_obj_t *self) {
|
||||||
|
char authmode[16];
|
||||||
|
switch (self->record.authmode) {
|
||||||
|
case WIFI_AUTH_OPEN:
|
||||||
|
strcpy(authmode, "OPEN");
|
||||||
|
break;
|
||||||
|
case WIFI_AUTH_WEP:
|
||||||
|
strcpy(authmode, "WEP");
|
||||||
|
break;
|
||||||
|
case WIFI_AUTH_WPA_PSK:
|
||||||
|
strcpy(authmode, "WPA_PSK");
|
||||||
|
break;
|
||||||
|
case WIFI_AUTH_WPA2_PSK:
|
||||||
|
strcpy(authmode, "WPA2_PSK");
|
||||||
|
break;
|
||||||
|
case WIFI_AUTH_WPA_WPA2_PSK:
|
||||||
|
strcpy(authmode, "WPA_WPA2_PSK");
|
||||||
|
break;
|
||||||
|
case WIFI_AUTH_WPA2_ENTERPRISE:
|
||||||
|
strcpy(authmode, "WPA2_ENTERPRISE");
|
||||||
|
break;
|
||||||
|
case WIFI_AUTH_WPA3_PSK:
|
||||||
|
strcpy(authmode, "WPA3_PSK");
|
||||||
|
break;
|
||||||
|
case WIFI_AUTH_WPA2_WPA3_PSK:
|
||||||
|
strcpy(authmode, "WPA2_WPA3_PSK");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strcpy(authmode, "UNKNOWN");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const char* cstr = (const char*) authmode;
|
||||||
|
return mp_obj_new_str(cstr, strlen(cstr));
|
||||||
|
}
|
||||||
|
|
|
@ -124,6 +124,21 @@ const mp_obj_property_t wifi_network_country_obj = {
|
||||||
(mp_obj_t)&mp_const_none_obj },
|
(mp_obj_t)&mp_const_none_obj },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//| authmode: str
|
||||||
|
//| """String id of the authmode"""
|
||||||
|
//|
|
||||||
|
STATIC mp_obj_t wifi_network_get_authmode(mp_obj_t self) {
|
||||||
|
return common_hal_wifi_network_get_authmode(self);
|
||||||
|
|
||||||
|
}
|
||||||
|
MP_DEFINE_CONST_FUN_OBJ_1(wifi_network_get_authmode_obj, wifi_network_get_authmode);
|
||||||
|
|
||||||
|
const mp_obj_property_t wifi_network_authmode_obj = {
|
||||||
|
.base.type = &mp_type_property,
|
||||||
|
.proxy = { (mp_obj_t)&wifi_network_get_authmode_obj,
|
||||||
|
(mp_obj_t)&mp_const_none_obj,
|
||||||
|
(mp_obj_t)&mp_const_none_obj },
|
||||||
|
};
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t wifi_network_locals_dict_table[] = {
|
STATIC const mp_rom_map_elem_t wifi_network_locals_dict_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_ssid), MP_ROM_PTR(&wifi_network_ssid_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_ssid), MP_ROM_PTR(&wifi_network_ssid_obj) },
|
||||||
|
@ -131,6 +146,7 @@ STATIC const mp_rom_map_elem_t wifi_network_locals_dict_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_rssi), MP_ROM_PTR(&wifi_network_rssi_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_rssi), MP_ROM_PTR(&wifi_network_rssi_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_channel), MP_ROM_PTR(&wifi_network_channel_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_channel), MP_ROM_PTR(&wifi_network_channel_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_country), MP_ROM_PTR(&wifi_network_country_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_country), MP_ROM_PTR(&wifi_network_country_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_authmode), MP_ROM_PTR(&wifi_network_authmode_obj) },
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(wifi_network_locals_dict, wifi_network_locals_dict_table);
|
STATIC MP_DEFINE_CONST_DICT(wifi_network_locals_dict, wifi_network_locals_dict_table);
|
||||||
|
|
|
@ -40,5 +40,6 @@ extern mp_obj_t common_hal_wifi_network_get_bssid(wifi_network_obj_t *self);
|
||||||
extern mp_obj_t common_hal_wifi_network_get_rssi(wifi_network_obj_t *self);
|
extern mp_obj_t common_hal_wifi_network_get_rssi(wifi_network_obj_t *self);
|
||||||
extern mp_obj_t common_hal_wifi_network_get_channel(wifi_network_obj_t *self);
|
extern mp_obj_t common_hal_wifi_network_get_channel(wifi_network_obj_t *self);
|
||||||
extern mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self);
|
extern mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self);
|
||||||
|
extern mp_obj_t common_hal_wifi_network_get_authmode(wifi_network_obj_t *self);
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_NETWORK_H
|
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_NETWORK_H
|
||||||
|
|
|
@ -295,7 +295,7 @@ const mp_obj_property_t wifi_radio_ipv4_dns_obj = {
|
||||||
};
|
};
|
||||||
|
|
||||||
//| ap_info: Optional[Network]
|
//| ap_info: Optional[Network]
|
||||||
//| """Network object containing BSSID, SSID, channel, country and RSSI when connected to an access point. None otherwise."""
|
//| """Network object containing BSSID, SSID, authmode, channel, country and RSSI when connected to an access point. None otherwise."""
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) {
|
STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) {
|
||||||
return common_hal_wifi_radio_get_ap_info(self);
|
return common_hal_wifi_radio_get_ap_info(self);
|
||||||
|
|
Loading…
Reference in New Issue