Doc fix and add set for DNS

This commit is contained in:
gamblor21 2022-05-31 22:13:18 -05:00
parent 90fe20a153
commit 4f6d4e2284
3 changed files with 21 additions and 6 deletions

View File

@ -398,6 +398,12 @@ mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self) {
return common_hal_ipaddress_new_ipv4address(self->dns_info.ip.u_addr.ip4.addr);
}
void common_hal_wifi_radio_set_ipv4_dns(wifi_radio_obj_t *self, mp_obj_t ipv4_dns_addr) {
esp_netif_dns_info_t dns_addr;
ipaddress_ipaddress_to_esp_idf_ip4(ipv4_dns_addr, &dns_addr.ip.u_addr.ip4);
esp_netif_set_dns_info(self->netif, ESP_NETIF_DNS_MAIN, &dns_addr);
}
void common_hal_wifi_radio_start_dhcp_client(wifi_radio_obj_t *self) {
esp_netif_dhcpc_start(self->netif);
}

View File

@ -459,8 +459,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_address_ap_obj, wifi_radio_get_ipv
MP_PROPERTY_GETTER(wifi_radio_ipv4_address_ap_obj,
(mp_obj_t)&wifi_radio_get_ipv4_address_ap_obj);
//| ipv4_dns: Optional[ipaddress.IPv4Address]
//| """IP v4 Address of the DNS server in use when connected to an access point. None otherwise."""
//| ipv4_dns: ipaddress.IPv4Address
//| """IP v4 Address of the DNS server to be used."""
//|
STATIC mp_obj_t wifi_radio_get_ipv4_dns(mp_obj_t self) {
return common_hal_wifi_radio_get_ipv4_dns(self);
@ -468,8 +468,16 @@ STATIC mp_obj_t wifi_radio_get_ipv4_dns(mp_obj_t self) {
}
MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ipv4_dns_obj, wifi_radio_get_ipv4_dns);
MP_PROPERTY_GETTER(wifi_radio_ipv4_dns_obj,
(mp_obj_t)&wifi_radio_get_ipv4_dns_obj);
STATIC mp_obj_t wifi_radio_set_ipv4_dns(mp_obj_t self, mp_obj_t ipv4_dns_addr) {
common_hal_wifi_radio_set_ipv4_dns(self, ipv4_dns_addr);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_ipv4_dns_obj, wifi_radio_set_ipv4_dns);
MP_PROPERTY_GETSET(wifi_radio_ipv4_dns_obj,
(mp_obj_t)&wifi_radio_get_ipv4_dns_obj,
(mp_obj_t)&wifi_radio_set_ipv4_dns_obj);
//| ap_info: Optional[Network]
//| """Network object containing BSSID, SSID, authmode, channel, country and RSSI when connected to an access point. None otherwise."""
@ -480,7 +488,7 @@ STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) {
}
MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_info_obj, wifi_radio_get_ap_info);
//| def wifi_radio_start_dhcp_client(self) -> None:
//| def start_dhcp(self) -> None:
//| """Starts the DHCP client."""
//| ...
//|
@ -490,7 +498,7 @@ STATIC mp_obj_t wifi_radio_start_dhcp_client(mp_obj_t self) {
}
MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_start_dhcp_client_obj, wifi_radio_start_dhcp_client);
//| def wifi_radio_stop_dhcp_client(self) -> None:
//| def stop_dhcp(self) -> None:
//| """Stops the DHCP client. Needed to assign a static IP address."""
//| ...
//|

View File

@ -98,6 +98,7 @@ extern wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self,
extern mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self);
extern mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self);
extern void common_hal_wifi_radio_set_ipv4_dns(wifi_radio_obj_t *self, mp_obj_t ipv4_dns_addr);
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_gateway_ap(wifi_radio_obj_t *self);
extern mp_obj_t common_hal_wifi_radio_get_ipv4_subnet(wifi_radio_obj_t *self);