Page 1 of 1

DHCP server on ethernet and netif

Posted: Tue Feb 18, 2020 4:51 pm
by PeterR
How do I enable DHCP server on ethernet and in general step past netif default settings?

I have successfully initialise Ethernet using netif with ESP_NETIF_DEFAULT_ETH(). Everything works fine, I receieve an IP address etc.
I then created my own ESP_NETIF_DHCPS_ETH structure which is as ESP_NETIF_DEFAULT_ETH() but .flags copied from default Wifi settings:

Code: Select all

.base.flags = ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP

This fails at:

Code: Select all

ESP_ERROR_CHECK(esp_eth_set_default_handlers(eth_netif))
with error:

Code: Select all

ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE)
The documentation is not very clear and I cannot find an example which starts/stops a DHCP server.
Any help appreciated!
Alternatively any DHCP server that will work with the stack.

Re: DHCP server on ethernet and netif

Posted: Wed Feb 19, 2020 2:40 pm
by PeterR
Think I have got it! Complicated though as its layer on layer with quite similar names.

The trick is that you must stop the DHCP server before assigning an IP address.
The server is automatically started.

I will try and factor and post something simple.