Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
d-a-v merged 5 commits intoesp8266:masterfromd-a-v:ArduinoEthernetCompat
Jul 27, 2022

Conversation

@d-a-v
Copy link
Collaborator

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.

provide some minimaly adapted examples from legacy
@JAndrassy
Copy link
Contributor

using EthernetServer = ArduinoWiFiServer; I like that

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
Copy link
CollaboratorAuthor

using EthernetServer = ArduinoWiFiServer; I like that

And thank you for that :)

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.

You are totally right. I'll replace it with another UDP example. Suggestions are welcome (even for TCP examples).

@mcspr
Copy link
Collaborator

Shouldn't ethernet thing go to the ethernet class? I have noticedusing Ethernet = WiFi;, but now we have yet another set ofenum tokens in a global namespace.

@d-a-v
Copy link
CollaboratorAuthor

Shouldn't ethernet thing go to the ethernet class? I have noticedusing Ethernet = WiFi;, but now we have yet another set ofenum tokens in a global namespace.

Global enums are now moved to the Ethernet class.
These arduino definitions were allowing maximum compatibility with legacy sketch when using WiFi as network.
But I get it ;)

NTP example is removed and replaced by UDP server example.

Copy link
Collaborator

@mcsprmcspr left a 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:
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
if (Ethernet.begin(mac) ==0) {
if (!Ethernet.begin(mac)) {

@d-a-v
Copy link
CollaboratorAuthor

do we care

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);

@d-a-vd-a-v merged commitee7ac2f intoesp8266:masterJul 27, 2022
@d-a-vd-a-v deleted the ArduinoEthernetCompat branchJuly 27, 2022 22:01
hasenradball pushed a commit to hasenradball/Arduino that referenced this pull requestNov 18, 2024
…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>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@mcsprmcsprmcspr approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@d-a-v@JAndrassy@mcspr

[8]ページ先頭

©2009-2025 Movatter.jp