esp32/modnetwork: Add network.(W)LAN.ifconfig('dhcp') support.
@@ -461,6 +461,7 @@ STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) {
return mp_obj_new_tuple(4, tuple);
} else {
// set
+ if (MP_OBJ_IS_TYPE(args[1], &mp_type_tuple) || MP_OBJ_IS_TYPE(args[1], &mp_type_list)) {
mp_obj_t *items;
mp_obj_get_array_fixed_n(args[1], 4, &items);
netutils_parse_ipv4_addr(items[0], (void*)&info.ip, NETUTILS_BIG);
@@ -489,6 +490,14 @@ STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) {
ESP_EXCEPTIONS(tcpip_adapter_set_dns_info(WIFI_IF_AP, TCPIP_ADAPTER_DNS_MAIN, &dns_info));
ESP_EXCEPTIONS(tcpip_adapter_dhcps_start(WIFI_IF_AP));
}
+ } else {
+ // check for the correct string
+ const char *mode = mp_obj_str_get_str(args[1]);
+ if ((self->if_id != WIFI_IF_STA && self->if_id != ESP_IF_ETH) || strcmp("dhcp", mode)) {
+ mp_raise_ValueError("invalid arguments");
+ }
+ ESP_EXCEPTIONS(tcpip_adapter_dhcpc_start(self->if_id));
+ }
return mp_const_none;
}
}
