Skip to content

Commit 4e00732

Browse files
authored
Merge pull request #7088 from jepler/picow-static-ip
pico w: implement static configuration methods in wifi.Radio
2 parents 31d7c91 + 8bef428 commit 4e00732

File tree

1 file changed

+15
-4
lines changed
  • ports/raspberrypi/common-hal/wifi

1 file changed

+15
-4
lines changed

ports/raspberrypi/common-hal/wifi/Radio.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,30 @@ mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self) {
268268
}
269269

270270
void common_hal_wifi_radio_set_ipv4_dns(wifi_radio_obj_t *self, mp_obj_t ipv4_dns_addr) {
271-
mp_raise_NotImplementedError(NULL);
271+
ip4_addr_t addr;
272+
ipaddress_ipaddress_to_lwip(ipv4_dns_addr, &addr);
273+
dns_setserver(0, &addr);
272274
}
273275

274276
void common_hal_wifi_radio_start_dhcp_client(wifi_radio_obj_t *self) {
275-
mp_raise_NotImplementedError(NULL);
277+
dhcp_start(NETIF_STA);
276278
}
277279

278280
void common_hal_wifi_radio_stop_dhcp_client(wifi_radio_obj_t *self) {
279-
mp_raise_NotImplementedError(NULL);
281+
dhcp_stop(NETIF_STA);
280282
}
281283

282284
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) {
283-
mp_raise_NotImplementedError(NULL);
285+
common_hal_wifi_radio_stop_dhcp_client(self);
286+
287+
ip4_addr_t ipv4_addr, netmask_addr, gateway_addr;
288+
ipaddress_ipaddress_to_lwip(ipv4, &ipv4_addr);
289+
ipaddress_ipaddress_to_lwip(netmask, &netmask_addr);
290+
ipaddress_ipaddress_to_lwip(gateway, &gateway_addr);
291+
netif_set_addr(NETIF_STA, &ipv4_addr, &netmask_addr, &gateway_addr);
292+
if (ipv4_dns != MP_OBJ_NULL) {
293+
common_hal_wifi_radio_set_ipv4_dns(self, ipv4_dns);
294+
}
284295
}
285296

286297
volatile bool ping_received;

0 commit comments

Comments
 (0)