Skip to content

ETH.end clears static IP config #9674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
JAndrassy opened this issue May 23, 2024 · 8 comments
Closed
1 task done

ETH.end clears static IP config #9674

JAndrassy opened this issue May 23, 2024 · 8 comments
Assignees
Labels
Area: WiFi Issue related to WiFi Status: Awaiting triage Issue is waiting for triage

Comments

@JAndrassy
Copy link
Contributor

JAndrassy commented May 23, 2024

Board

Esp32 Dev module

Device Description

Espressif Dev module

Hardware Configuration

Wiz850io wired on default SPI pins

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

Linux

Flash frequency

40

PSRAM enabled

yes

Upload speed

any

Description

In other Ethernet libraries with config method (esp8266 and RP2040 core), end doesn't clear the static IP configuration set by config and In WiFi libraries disconnect doesn't clear the static IP configuration.

Sketch

#define ETH_PHY_TYPE        ETH_PHY_W5500
#define ETH_PHY_ADDR        -1
#define ETH_PHY_CS           5
#define ETH_PHY_IRQ         -1
#define ETH_PHY_RST         -1
#define ETH_PHY_SPI         SPI

#include <ETH.h>

void setup() {

  Serial.begin(115200);
  delay(500);

  SPI.begin();

  // first begin with DHCP as workaround for issue #9673
  ETH.begin();
  while (!ETH.hasIP()) {
    Serial.print('.');
    delay(1000);
  }

  IPAddress ip(192, 168, 1, 177);
  IPAddress gw(192, 168, 1, 1);
  IPAddress dns(192, 168, 1, 1);
  IPAddress mask(255, 255, 255, 0);

  ETH.config(ip, dns, gw, mask);
  ETH.begin();
  while (!ETH.hasIP()) {
    Serial.print('.');
    delay(1000);
  }
  if (ip != ETH.localIP()) {
    Serial.println("ERROR: Static IP was not used.");
  }

  ETH.end();

  ETH.begin();
  while (!ETH.hasIP()) {
    Serial.print('.');
    delay(1000);
  }
  if (ip != ETH.localIP()) {
    Serial.println("ERROR: Static IP was not remembered.");
  }

 }

void loop() {

}

Debug Message

ERROR: Static IP was not remembered.

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@JAndrassy JAndrassy added the Status: Awaiting triage Issue is waiting for triage label May 23, 2024
@JAndrassy
Copy link
Contributor Author

maybe the solution to solve this and #9673 is to store the static IP configuration outside netif.
maybe sultion for #9435 could be changed to use the stored config too.

@me-no-dev
Copy link
Member

I really think it's up to the application to decide what to store and what not to store. In majority of cases, the app already has the IPs stored, so why not just call config() instead of storing class objects twice?

@VojtechBartoska VojtechBartoska added the Area: WiFi Issue related to WiFi label May 23, 2024
@Jason2866
Copy link
Collaborator

For me it is more logical as it is currently. When doing ETH.end(); and going to do ETH.begin(); again there should no old config be reused.
There is a reason for calling ETH.begin(); again, probably because settings have changed.

@JAndrassy
Copy link
Contributor Author

@Jason2866

In other Ethernet libraries with config method (esp8266 and RP2040 core), end doesn't clear the static IP configuration set by config and In WiFi libraries disconnect doesn't clear the static IP configuration.

@Jason2866
Copy link
Collaborator

esp32 is very different in many aspects, no need to be compatible to anything existing in the world. Such stuff bloats and increases the core unnecessary.

@JAndrassy
Copy link
Contributor Author

yes but maybe this issue will be solved with the solution for #9673

@me-no-dev
Copy link
Member

@JAndrassy begin then config makes total sense. The fact that it works the other way round for WiFi is just luck, because we can init the WiFi netifs earlier (no pin configs or anything else necessary). That is not the case for ETH, as we need to know what ETH, which pins and so on. As for saving the IP, I already talked about that. It's unnecessary complicating the network libraries and diverging ETH from the rest of the interfaces. Just call to config again will solve this otherwise tedious task to lug around class instances (of IPAddress) that you already store in your sketch anyway

@JAndrassy
Copy link
Contributor Author

#9673 is the important one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: WiFi Issue related to WiFi Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

4 participants