Skip to content
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

Wired LAN8720 connected check / workaround / fix? #63

Open
HotNoob opened this issue Mar 18, 2024 · 2 comments
Open

Wired LAN8720 connected check / workaround / fix? #63

HotNoob opened this issue Mar 18, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@HotNoob
Copy link

HotNoob commented Mar 18, 2024

using Eth.H / EthClass.H

which piggy backs a bit off of the wifi events a bit...

this check, which is enabled by default will stop begin from working.

if (WiFi.status() != WL_CONNECTED && !_isIPSet(WiFi.softAPIP())) return false;

#include <ETH.h>

 if ( !ETH.linkUp() &&  WiFi.status() != WL_CONNECTED && !_isIPSet(WiFi.softAPIP())) return false; 

fixes this problem, alternatively as a work around, turning the check off via bool works too.

telnet.begin(23, false);

it does require making the lib more bulky... so could maybe use this WITHOUT <ETH.h>. only compatible

#if ESP_IDF_VERSION_MAJOR > 3
...
 if ( !(WiFiGenericClass::getStatusBits() & ETH_CONNECTED_BIT) &&  WiFi.status() != WL_CONNECTED && !_isIPSet(WiFi.softAPIP())) return false; 

instead, to avoid having to import Eth.H for wifi only builds.

works fine over eth \w main for me with some small modification.

@LennartHennigs
Copy link
Owner

Hey,
As you pointed out, my answer would have been to disable the check via:

telnet.begin(23, false); :-)

By looking at this #if ESP_IDF_VERSION_MAJOR > 3, I guess you use an ESP32.

Can you point me to some additional examples/explanations for this part of your suggestion:

#if ESP_IDF_VERSION_MAJOR > 3

 if ( !(WiFiGenericClass::getStatusBits() & ETH_CONNECTED_BIT))

That would allow me to judge better whether I want to include this – as there was a request about some Ethernet board before: #48.

@LennartHennigs LennartHennigs self-assigned this Mar 26, 2024
@LennartHennigs LennartHennigs added the enhancement New feature or request label Mar 26, 2024
@HotNoob
Copy link
Author

HotNoob commented Mar 26, 2024

hmm. welp, i'm new to arduino stuff... and rusty af \w c / c++ :P

but,

i'm just stealing that code from:
https://github.com/espressif/arduino-esp32/blob/e92b4ca62b7f1375b762ee18ceb9f59dbd4a04dc/libraries/Ethernet/src/ETH.cpp#L957C12-L957C45

a bit of a hack
https://github.com/espressif/arduino-esp32/blob/e92b4ca62b7f1375b762ee18ceb9f59dbd4a04dc/libraries/Ethernet/src/ETH.h#L66

since wifi.h is already including wifigenericclass yaddi yaddie.

https://github.com/espressif/arduino-esp32/blob/e92b4ca62b7f1375b762ee18ceb9f59dbd4a04dc/libraries/WiFi/src/WiFi.h#L34

Wifi.H does include ETH_CONNECTED_BIT; this is where the Eth connected status is set.

https://github.com/espressif/arduino-esp32/blob/e92b4ca62b7f1375b762ee18ceb9f59dbd4a04dc/libraries/WiFi/src/WiFiGeneric.cpp#L1159


so....

if ( !(WiFiGenericClass::getStatusBits() & ETH_CONNECTED_BIT ) && WiFi.status() != WL_CONNECTED && !_isIPSet(WiFi.softAPIP())) return false;

should be sufficient. i think #ESP_IDF_VERSION_MAJOR is probably not necessairy, as its not on the git repo, but is in the lib from platform io.

been running the modified code for a bit now, working fine. i don't think it'll effect wifi functionality because the bit status is done in the wifi libs.


as far as the other issue, #48 , he is using a W5100 chip, which goes over SPI afaik, which i think might use different libraries.
Ethernet.h is not used for me.

the LAN8720 im using is built into the board... donno if expressif's Eth.H works for his W5100.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants