diff --git a/ports/raspberrypi/common-hal/wifi/Radio.c b/ports/raspberrypi/common-hal/wifi/Radio.c index 498ec862b2..3e95ae5cd1 100644 --- a/ports/raspberrypi/common-hal/wifi/Radio.c +++ b/ports/raspberrypi/common-hal/wifi/Radio.c @@ -268,19 +268,30 @@ mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self) { } void common_hal_wifi_radio_set_ipv4_dns(wifi_radio_obj_t *self, mp_obj_t ipv4_dns_addr) { - mp_raise_NotImplementedError(NULL); + ip4_addr_t addr; + ipaddress_ipaddress_to_lwip(ipv4_dns_addr, &addr); + dns_setserver(0, &addr); } void common_hal_wifi_radio_start_dhcp_client(wifi_radio_obj_t *self) { - mp_raise_NotImplementedError(NULL); + dhcp_start(NETIF_STA); } void common_hal_wifi_radio_stop_dhcp_client(wifi_radio_obj_t *self) { - mp_raise_NotImplementedError(NULL); + dhcp_stop(NETIF_STA); } void common_hal_wifi_radio_set_ipv4_address(wifi_radio_obj_t *self, mp_obj_t ipv4, mp_obj_t netmask, mp_obj_t gateway, mp_obj_t ipv4_dns) { - mp_raise_NotImplementedError(NULL); + common_hal_wifi_radio_stop_dhcp_client(self); + + ip4_addr_t ipv4_addr, netmask_addr, gateway_addr; + ipaddress_ipaddress_to_lwip(ipv4, &ipv4_addr); + ipaddress_ipaddress_to_lwip(netmask, &netmask_addr); + ipaddress_ipaddress_to_lwip(gateway, &gateway_addr); + netif_set_addr(NETIF_STA, &ipv4_addr, &netmask_addr, &gateway_addr); + if (ipv4_dns != MP_OBJ_NULL) { + common_hal_wifi_radio_set_ipv4_dns(self, ipv4_dns); + } } volatile bool ping_received;