Fix: Explicitly stop DHCP client before setting static IP #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When configuring a static IP address using
void EthernetClass::begin(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet)the setup fails with the error:[E][NetworkInterface.cpp:527] config(): ETH IP could not be configured! Error: 0x5007: ESP_ERR_ESP_NETIF_DHCP_NOT_STOPPED.The
beginETH()function initializes the Ethernet interface, which (by default) has an active DHCP client. The ESP-IDF network stack (esp-netif) explicitly requires the DHCP client to be stopped before a static IP configuration can be applied. The original code did not perform this step, leading directly to the ESP_ERR_ESP_NETIF_DHCP_NOT_STOPPED error.As per the official ESP-IDF documentation on esp_netif static IP configuration, this PR fixes the bug by adding a direct call to esp_netif_dhcpc_stop() immediately after beginETH() succeeds and before config() is called.
This ensures the DHCP client is correctly stopped, satisfying the API preconditions and allowing the static IP to be set reliably.
Fixes #7