- Notifications
You must be signed in to change notification settings - Fork13.3k
make WiFi/Ethernet interface compatible with Arduino Ethernet API#8645
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
provide some minimaly adapted examples from legacy
JAndrassy commentedJul 20, 2022
everywhere I recommend to use SDK NTP functions on esp8266. so maybe don't add the NTP example. even it is a good example for UDP same arguments against it apply as for WebClient example. |
d-a-v commentedJul 20, 2022
And thank you for that :)
You are totally right. I'll replace it with another UDP example. Suggestions are welcome (even for TCP examples). |
mcspr commentedJul 22, 2022
Shouldn't ethernet thing go to the ethernet class? I have noticed |
d-a-v commentedJul 24, 2022
Global enums are now moved to the Ethernet class. NTP example is removed and replaced by UDP server example. |
mcspr left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
lgtm then :)
do we care about code in these legacy examples? like,Ethernet.begin(...) == 0 where it isbool, or switch-case on integers instead ofDHCP_CHECK..., or the pre-connection link checks that are slightly different between .ino setups
| Serial.println(Ethernet.localIP()); | ||
| break; | ||
| default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
no need
| // start the Ethernet | ||
| // Ethernet.begin(mac, ip); | ||
| if (Ethernet.begin(mac) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| if (Ethernet.begin(mac) ==0) { | |
| if (!Ethernet.begin(mac)) { |
d-a-v commentedJul 25, 2022
The goal is to keep them the closest possible to the original ethernet examples. --- ../../../Ethernet/examples/ChatServer/ChatServer.ino2022-07-18 22:17:20.550672427 +0200+++ LegacyChatServer.ino2022-07-20 03:12:30.293107744 +0200@@ -7,7 +7,7 @@ Using an Arduino Wiznet Ethernet shield. Circuit:- * Ethernet shield attached to pins 10, 11, 12, 13+ * Ethernet Wiznet5500/Wiznet5100/ENC28J60 on esp8266 created 18 Dec 2009 by David A. Mellis@@ -16,14 +16,22 @@ */-#include <SPI.h>-#include <Ethernet.h>++// specific to esp8266 w/lwIP+#include <EthernetCompat.h>+ArduinoWiznet5500lwIP Ethernet(/*SS*/ 16); // <== adapt to your hardware+// ArduinoWiznet5100lwIP Ethernet(/*SS*/ 16); // <== adapt to your hardware+// ArduinoENC28J60lwIP Ethernet(/*SS*/ 16); // <== adapt to your hardware // Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network. // gateway and subnet are optional:-byte mac[] = {- 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };+byte notNeededButAllowed_mac[] = {+ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED+};+byte* mac = nullptr; // automatic mac IPAddress ip(192, 168, 1, 177); IPAddress myDns(192, 168, 1, 1); IPAddress gateway(192, 168, 1, 1);@@ -36,12 +44,13 @@ // Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet+ // // esp8266 w/lwIP: SS set in Ethernet constructor // initialize the ethernet device Ethernet.begin(mac, ip, myDns, gateway, subnet); |
…p8266#8645)* make WiFi/Ethernet interface compatible with Arduino Ethernet APIprovide some minimaly adapted examples from legacy* move ethernet compat globals to EthernetCompat.h* LegacyEthernet: add UDP example* adjust commentsCo-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
While helping a colleague with ethernet on a portenta H7,
I noticed that it was poorly implemented with respect to Official Ethernet Arduino API,
and it does not help foreigners to understand official examples.
Before trying to fix there, looking at esp8266's own backyard first.
Some basic legacy examples are also imported with minimal changes.
They are ethernet examples but they could also run on WiFi.