add country(code) to wifi network objects)
This commit is contained in:
parent
eda3392f50
commit
210c0ec89c
|
@ -48,3 +48,9 @@ mp_obj_t common_hal_wifi_network_get_rssi(wifi_network_obj_t *self) {
|
|||
mp_obj_t common_hal_wifi_network_get_channel(wifi_network_obj_t *self) {
|
||||
return mp_obj_new_int(self->record.primary);
|
||||
}
|
||||
|
||||
mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self) {
|
||||
const char* cstr = (const char*) self->record.country.cc;
|
||||
return mp_obj_new_str(cstr, strlen(cstr));
|
||||
}
|
||||
|
||||
|
|
|
@ -108,12 +108,29 @@ const mp_obj_property_t wifi_network_channel_obj = {
|
|||
(mp_obj_t)&mp_const_none_obj },
|
||||
};
|
||||
|
||||
//| country: str
|
||||
//| """String id of the country code"""
|
||||
//|
|
||||
STATIC mp_obj_t wifi_network_get_country(mp_obj_t self) {
|
||||
return common_hal_wifi_network_get_country(self);
|
||||
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(wifi_network_get_country_obj, wifi_network_get_country);
|
||||
|
||||
const mp_obj_property_t wifi_network_country_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = { (mp_obj_t)&wifi_network_get_country_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[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_ssid), MP_ROM_PTR(&wifi_network_ssid_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_bssid), MP_ROM_PTR(&wifi_network_bssid_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_country), MP_ROM_PTR(&wifi_network_country_obj) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(wifi_network_locals_dict, wifi_network_locals_dict_table);
|
||||
|
|
|
@ -39,5 +39,6 @@ extern mp_obj_t common_hal_wifi_network_get_ssid(wifi_network_obj_t *self);
|
|||
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_channel(wifi_network_obj_t *self);
|
||||
extern mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self);
|
||||
|
||||
#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]
|
||||
//| """Network object containing BSSID, SSID, channel, and RSSI when connected to an access point. None otherwise."""
|
||||
//| """Network object containing BSSID, SSID, 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) {
|
||||
return common_hal_wifi_radio_get_ap_info(self);
|
||||
|
|
Loading…
Reference in New Issue