Closed
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: Wemos D1 mini lite + ENC28J60 or W5500 module
- Core Version: 3.0.0 + PR LwipIntfDev - static IP config for eth interfaces #8076
- Development Env: Eclipse Sloeber
- Operating System: Linux Mint
Settings in IDE
- Module: Wemos D1 mini lite
- Flash Size: 1MB
- lwip Variant: v2 Higher Bandwidth
- CPU Frequency: 80Mhz
- Upload Using: SERIAL
- Upload Speed: 921600
Problem Description
Ethernet LwIP interfaces static IP configuration only works if eth.config is followed by eth.setDefault().
MCVE Sketch
It is a modified TCPClient example from the LwIP_w5500 library:
/*
This sketch establishes a TCP connection to a "quote of the day" service.
It sends a "hello" message, and then prints received data.
*/
#include <SPI.h>
//#include <W5500lwIP.h>
//or #include <W5100lwIP.h>
#include <ENC28J60lwIP.h>
#include <WiFiClient.h> // WiFiClient (-> TCPClient)
const char* host = "djxmmx.net";
const uint16_t port = 17;
using TCPClient = WiFiClient;
#define CSPIN D1 // wemos/lolin/nodemcu D0
ENC28J60lwIP eth(CSPIN);
void setup() {
Serial.begin(115200);
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV4); // 4 MHz?
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
eth.setDefault(); // use ethernet for default route
IPAddress ip(192, 168, 1, 118);
IPAddress gw(192, 168, 1, 1);
IPAddress nm(255, 255, 255, 0);
eth.config(ip, gw, nm, gw);
if (!eth.begin()) {
Serial.println("ethernet hardware not found ... sleeping");
while (1) {
delay(1000);
}
} else {
Serial.print("connecting ethernet");
while (!eth.connected()) {
Serial.print(".");
delay(1000);
}
}
Serial.println();
Serial.print("ethernet IP address: ");
Serial.println(eth.localIP());
}
void loop() {
static bool wait = false;
Serial.print("connecting to ");
Serial.print(host);
Serial.print(':');
Serial.println(port);
TCPClient client;
if (!client.connect(host, port)) {
Serial.println("connection failed");
delay(5000);
return;
}
// This will send a string to the server
Serial.println("sending data to server");
if (client.connected()) {
client.println("hello from ESP8266");
}
// wait for data to be available
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
delay(60000);
return;
}
}
// Read all the lines of the reply from server and print them to Serial
Serial.println("receiving from remote server");
// not testing 'client.connected()' since we do not need to send data here
while (client.available()) {
char ch = static_cast<char>(client.read());
Serial.print(ch);
}
// Close the connection
Serial.println();
Serial.println("closing connection");
client.stop();
if (wait) {
delay(300000); // execute once every 5 minutes, don't flood remote service
}
wait = true;
}
Debug Messages
SDK:2.2.2-dev(38a443e)/Core:3.0.0=30000000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:c0b69df
connecting ethernet
ethernet IP address: 192.168.1.118
connecting to djxmmx.net:17
[hostByName] request IP for: djxmmx.net
[hostByName] Host: djxmmx.net lookup error: -5!
connection failed
connecting to djxmmx.net:17
[hostByName] request IP for: djxmmx.net
[hostByName] Host: djxmmx.net IP: 104.9.242.101
connection failed
connecting to djxmmx.net:17
[hostByName] request IP for: djxmmx.net
[hostByName] Host: djxmmx.net IP: 104.9.242.101
connection failed
with setDefault
after config
SDK:2.2.2-dev(38a443e)/Core:3.0.0=30000000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:c0b69df
connecting ethernet
ethernet IP address: 192.168.1.118
connecting to djxmmx.net:17
[hostByName] request IP for: djxmmx.net
[hostByName] Host: djxmmx.net lookup error: -5!
connection failed
connecting to djxmmx.net:17
[hostByName] request IP for: djxmmx.net
[hostByName] Host: djxmmx.net IP: 23.28.179.206
sending data to server
receiving from remote server
"Here's the rule for bargains: "Do other men, for they would do you."
That's the true business precept." Charles Dickens (1812-70)
closing connection
connecting to djxmmx.net:17
[hostByName] request IP for: djxmmx.net
[hostByName] Host: djxmmx.net IP: 23.28.179.206
sending data to server
receiving from remote server
"A wonderful fact to reflect upon, that every human creature is constituted
to be that profound secret and mystery to every other."
Charles Dickens (1812-70)
closing connection
Metadata
Metadata
Assignees
Labels
No labels