@@ -268,19 +268,30 @@ mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self) {
268
268
}
269
269
270
270
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 );
272
274
}
273
275
274
276
void common_hal_wifi_radio_start_dhcp_client (wifi_radio_obj_t * self ) {
275
- mp_raise_NotImplementedError ( NULL );
277
+ dhcp_start ( NETIF_STA );
276
278
}
277
279
278
280
void common_hal_wifi_radio_stop_dhcp_client (wifi_radio_obj_t * self ) {
279
- mp_raise_NotImplementedError ( NULL );
281
+ dhcp_stop ( NETIF_STA );
280
282
}
281
283
282
284
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
+ }
284
295
}
285
296
286
297
volatile bool ping_received ;
0 commit comments