Before I enabled AutoIP (using menuconfig), the device was working correctly with DHCP.
My main code is
Code: Select all
dnet_init();
ESP_ERROR_CHECK(rest_start());
}
Code: Select all
bool dnet_init(void) {
... MAC stuff ...
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
start_wifi();
start_ethernet();
initialise_mdns();
netbiosns_init();
netbiosns_set_name(wifhst);
rest_api_register_get_handler("config", dnet_get_handler);
rest_api_register_post_handler("config", dnet_post_handler);
xTaskCreate(&dnet_task, "dnet_task", 4096, NULL, 10, NULL);
ESP_LOGI(TAG, "DNET task started");
return true;
}
Code: Select all
static esp_err_t start_ethernet() {
// configure ethernet parameters
eth_set_hostname(ethsid);
char eth_mod[kStringSize];
if (getParamater("ethmod", eth_mod) != ESP_OK)
return ESP_FAIL;
// esp_log_level_set("dhcpc", ESP_LOG_DEBUG);
if (strcmp(eth_mod, dnet_kDHCPClient) == 0) {
return eth_start_dhcp_client();
} else if (strcmp(eth_mod, dnet_kStaticIPAddress) == 0) {
esp_netif_ip_info_t eth_info;
memset(ð_info, 0, sizeof(eth_info));
char eth_ip[kStringSize];
if (getParamater("ethipa", eth_ip) != ESP_OK)
return ESP_FAIL;
if (dnet_str2ip4(ð_info.ip, eth_ip) == false)
return ESP_FAIL;
if (getParamater("ethipg", eth_ip) != ESP_OK)
return ESP_FAIL;
if (dnet_str2ip4(ð_info.gw, eth_ip) == false)
return ESP_FAIL;
if (getParamater("ethipm", eth_ip) != ESP_OK)
return ESP_FAIL;
if (dnet_str2ip4(ð_info.netmask, eth_ip) == false)
return ESP_FAIL;
return eth_start_dhcp_static(ð_info);
}
// if ethmod is garbage default to dhcp client mode
setParamater("ethmod", dnet_kDHCPClient);
return eth_start_dhcp_client();
}