-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Register Ethernet netif
in WiFiGeneric to
#7632
Conversation
Code analysis performed on arduino-esp32 v2.0.5. Disclaimer: I don't fully understand why WiFiGeneric tracks eth_netif_t entries, or how ETH module works. Discussion: add_esp_interface_netif() isn't used anywhere else in code. If used, it should probably be exported in WiFiGeneric.h. WiFiGeneric.cpp keeps track of network interfaces in private array Ethernet interface is created in ETH begin:
I agree Note Would it be better to create the ethernet entry in |
Yep, WiFi events also need to be unregistered, or else you will get them multiple times. N.B. For WiFi events you need to register their callback function(s) each time you enable some interface that wasn't enabled before. e.g. AP only will not register STA events. So it makes sense to register these events when you call begin() and unregister them when you call end(). If there still isn't an end() function, then you can register those events in the lowlevel init function (given it will only called once) |
wifiLowLevelInit() checks for event handle before registering again. Looks safe.
AP and STA registered once in wifiLowLevelInit().
Correct. Currently no ETH.end(). |
But when you add your own event callback functions, the ones meant for interfaces not being enabled, will not be registered. |
By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes
Checklist
This entire section above can be deleted if all items are checked.
Description of Change
Register the ethernet
netif
object inWiFiGeneric
esp_netifs
. Without this registry, IP6 events are never sent back to event callback, because of the tests here:arduino-esp32/libraries/WiFi/src/WiFiGeneric.cpp
Lines 453 to 464 in b63f947
Tests scenarios
Tested on Olimex POE ESP32 board, now connecting Ethernet to a network supporting IPv6 SLAAC,
ARDUINO_EVENT_ETH_GOT_IP6
is correctly sent to callbacks. Before this fix, no event was called.Related links