Skip to content

Conversation

@fcorri
Copy link

@fcorri fcorri commented Nov 4, 2025

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.

  if (beginETH(mac))
  {
    if (esp_netif_dhcpc_stop(netif()) != ESP_OK)
    {
      log_e("Failed to stop dhcp client");
      return;
    }
    if (config(localIP, gatewayIP, netmask, dnsIP))
    {
      hwStatus = EthernetHardwareFound;
    }
  }

Fixes #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static IP not assigned when adding <WiFi.h>

1 participant