Enable DNS info
This commit is contained in:
parent
deefeecb45
commit
66d55738c1
@ -192,6 +192,20 @@ mp_obj_t common_hal_wifi_radio_get_ipv4_address(wifi_radio_obj_t *self) {
|
||||
return common_hal_ipaddress_new_ipv4address(self->ip_info.ip.addr);
|
||||
}
|
||||
|
||||
mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self) {
|
||||
if (!esp_netif_is_netif_up(self->netif)) {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
esp_netif_get_dns_info(self->netif, ESP_NETIF_DNS_MAIN, &self->dns_info);
|
||||
|
||||
// dns_info is of type esp_netif_dns_info_t, which is just ever so slightly
|
||||
// different than esp_netif_ip_info_t used for
|
||||
// common_hal_wifi_radio_get_ipv4_address (includes both ipv4 and 6),
|
||||
// so some extra jumping is required to get to the actual address
|
||||
return common_hal_ipaddress_new_ipv4address(self->dns_info.ip.u_addr.ip4.addr);
|
||||
}
|
||||
|
||||
mp_int_t common_hal_wifi_radio_ping(wifi_radio_obj_t *self, mp_obj_t ip_address, mp_float_t timeout) {
|
||||
esp_ping_config_t ping_config = ESP_PING_DEFAULT_CONFIG();
|
||||
ipaddress_ipaddress_to_esp_idf(ip_address, &ping_config.target_addr);
|
||||
|
@ -48,6 +48,7 @@ typedef struct {
|
||||
wifi_config_t sta_config;
|
||||
wifi_ap_record_t ap_info;
|
||||
esp_netif_ip_info_t ip_info;
|
||||
esp_netif_dns_info_t dns_info;
|
||||
esp_netif_t *netif;
|
||||
bool started;
|
||||
bool ap_mode;
|
||||
|
@ -227,6 +227,22 @@ const mp_obj_property_t wifi_radio_ipv4_address_obj = {
|
||||
(mp_obj_t)&mp_const_none_obj },
|
||||
};
|
||||
|
||||
//| ipv4_dns: Optional[ipaddress.IPv4Address]
|
||||
//| """IP v4 Address of the DNS server in use when connected to an access point. None otherwise."""
|
||||
//|
|
||||
STATIC mp_obj_t wifi_radio_get_ipv4_dns(mp_obj_t self) {
|
||||
return common_hal_wifi_radio_get_ipv4_dns(self);
|
||||
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_dns_obj, wifi_radio_get_ipv4_dns);
|
||||
|
||||
const mp_obj_property_t wifi_radio_ipv4_dns_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = { (mp_obj_t)&wifi_radio_get_ipv4_dns_obj,
|
||||
(mp_obj_t)&mp_const_none_obj,
|
||||
(mp_obj_t)&mp_const_none_obj },
|
||||
};
|
||||
|
||||
//| def ping(self, ip, *, timeout: float = 0.5) -> float:
|
||||
//| """Ping an IP to test connectivity. Returns echo time in seconds.
|
||||
//| Returns None when it times out."""
|
||||
@ -268,6 +284,7 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
|
||||
// { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_ap_rssi), MP_ROM_PTR(&wifi_radio_ap_rssi_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ipv4_dns), MP_ROM_PTR(&wifi_radio_ipv4_dns_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ipv4_gateway), MP_ROM_PTR(&wifi_radio_ipv4_gateway_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ipv4_subnet), MP_ROM_PTR(&wifi_radio_ipv4_subnet_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ipv4_address), MP_ROM_PTR(&wifi_radio_ipv4_address_obj) },
|
||||
|
@ -54,6 +54,7 @@ extern void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self)
|
||||
extern wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t* ssid, size_t ssid_len, uint8_t* password, size_t password_len, uint8_t channel, mp_float_t timeout, uint8_t* bssid, size_t bssid_len);
|
||||
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ap_rssi(wifi_radio_obj_t *self);
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self);
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ipv4_gateway(wifi_radio_obj_t *self);
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ipv4_subnet(wifi_radio_obj_t *self);
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ipv4_address(wifi_radio_obj_t *self);
|
||||
|
Loading…
Reference in New Issue
Block a user