Fix: Explicitly stop DHCP client before setting static IP#11
Open
fcorri wants to merge 1 commit intoNetworking-for-Arduino:masterfrom
Open
Fix: Explicitly stop DHCP client before setting static IP#11fcorri wants to merge 1 commit intoNetworking-for-Arduino:masterfrom
fcorri wants to merge 1 commit intoNetworking-for-Arduino:masterfrom
Conversation
Member
|
NetworkInterface.config stops the DHCP client as first |
Author
|
Maybe my fix is not necessary, but there still exist some timing problems. If you put a |
Member
|
I tested it when I published it. It was with an older version of the esp32 platform. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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