DHCP server on ethernet and netif

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

DHCP server on ethernet and netif

Postby PeterR » Tue Feb 18, 2020 4:51 pm

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.
& I also believe that IDF CAN should be fixed.

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: DHCP server on ethernet and netif

Postby PeterR » Wed Feb 19, 2020 2:40 pm

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.
& I also believe that IDF CAN should be fixed.

Who is online

Users browsing this forum: No registered users and 133 guests