-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow non-CYW43 network interfaces (W5500, etc.)
WIP - Builds and can get a DHCP address using W5500. Lots of infrastructure work still required: [ ] Separate CYW43 stuff and LWIP stuff (mutex, etc.) [ ] Add async worker for pumping frames [ ] Real LWIP-only mutex [ ] Should WiFiClient be available as TCPClient? etc. Fixes #775
- Loading branch information
1 parent
5639ede
commit e1274dc
Showing
9 changed files
with
1,236 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
98 changes: 98 additions & 0 deletions
98
libraries/lwIP_w5500/examples/TelnetConnect/TelnetConnect.ino
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include <LwipEthernet.h> | ||
#include <W5500lwIP.h> | ||
#include <WiFi.h> | ||
|
||
Wiznet5500lwIP eth(/*SS*/ 1); // <== adapt to your hardware | ||
|
||
const char* host = "djxmmx.net"; | ||
const uint16_t port = 17; | ||
|
||
void setup() { | ||
SPI.setSCK(2); | ||
SPI.setTX(3); | ||
SPI.setRX(0); | ||
SPI.setCS(1); | ||
|
||
delay(5000); | ||
Serial.begin(115200); | ||
|
||
Serial.println("\nEthernet\n"); | ||
|
||
// 1. Currently when no default is set, esp8266-Arduino uses the first | ||
// DHCP client interface receiving a valid address and gateway to | ||
// become the new lwIP default interface. | ||
// 2. Otherwise - when using static addresses - lwIP for every packets by | ||
// defaults selects automatically the best suited output interface | ||
// matching the destination address. If several interfaces match, | ||
// the first one is picked. On esp8266/Arduno: WiFi interfaces are | ||
// checked first. | ||
// 3. Or, use `::setDefault()` to force routing through this interface. | ||
// eth.setDefault(); // default route set through this interface | ||
|
||
if (!ethInitDHCP(eth)) { | ||
Serial.printf("no hardware found\n"); | ||
while (1) { | ||
delay(1000); | ||
} | ||
} | ||
|
||
while (!eth.connected()) { | ||
eth.handlePackets(); | ||
sys_check_timeouts(); | ||
Serial.printf("."); | ||
delay(1000); | ||
} | ||
|
||
Serial.printf("Ethernet: IP Address: %s\n", | ||
eth.localIP().toString().c_str()); | ||
} | ||
|
||
void loop() { | ||
|
||
Serial.print("connecting to "); | ||
Serial.print(host); | ||
Serial.print(':'); | ||
Serial.println(port); | ||
|
||
Serial.printf("Link sense: %d (detectable: %d)\n", eth.isLinked(), eth.isLinkDetectable()); | ||
|
||
// Use WiFiClient class to create TCP connections | ||
// (this class could have been named TCPClient) | ||
WiFiClient 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"); | ||
while (client.available()) { | ||
char ch = static_cast<char>(client.read()); | ||
Serial.print(ch); | ||
} | ||
|
||
// Close the connection | ||
Serial.println(); | ||
Serial.println("closing connection"); | ||
client.stop(); | ||
|
||
delay(300000); // execute once every 5 minutes, don't flood remote service | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name=lwIP_w5500 | ||
version=1 | ||
author=Nicholas Humfrey | ||
maintainer=esp8266/Arduino | ||
sentence=Ethernet driver | ||
paragraph=Wiznet5500 ethernet drivers for lwIP and esp8266 Arduino from https://github.com/njh/W5500MacRaw | ||
category=Communication | ||
url=https://github.com/esp8266/Arduino | ||
architectures=rp2040 | ||
dot_a_linkage=true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
#ifndef _W5500LWIP_H | ||
#define _W5500LWIP_H | ||
|
||
#include <LwipIntfDev.h> | ||
#include <utility/w5500.h> | ||
|
||
using Wiznet5500lwIP = LwipIntfDev<Wiznet5500>; | ||
|
||
#endif // _W5500LWIP_H |
Oops, something went wrong.