-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Refactor the network stack to allow chips without WiFi and better Ethernet and ppp compatibility #8735
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
Comments
IMO we should to this as cleanly as possible even if it means rewriting some code. This will be much better in the long run for the code maintainability. |
I think it would also make sense to have each "network" device being split up into some kind of "driver" structure like how it is done in the ESP-IDF 5.1 and also have some "state" structure/class which has some generic interface to query simple states like "connected" and "gotIP" etc. Right now this is a complete mess as you need to query WiFi related code to use Ethernet. Don't get me started on all possible state changes when connecting to WiFi. (or while being connected)
But that doesn't always happen in this order and it should be dealt with in such a state machine struct/class specific to WiFi. So these state classes should also keep track of their own "addresses". (not sure how it will be called for 802.15.4, have not yet looked into it) Not sure if "Network" is generic enough to cover all connectivity options.
Maybe it is exactly what you have in mind, but please let's not make a generic class which will manage all. For ESPEasy I have tried to make it do it all just basing on events and I truly hate it how incredibly complex and unmanagable it has become. (read: a complete rewrite is pending) My idea is that you should be able to have some scenarios of preferred connectivity and if those are not available you should have some kind of fallback state/scenario. Just to give some idea of scenarios which might be useful for some (most?) users:
As you can see, those scenarios need to switch from one interface (or scenario) to another, so I think this central "Network" class should just do that and nothing more. There are of course "rules" describing which state change is allowed and which isn't. But this should be knowledge in the specific state machine class dealing with these interfaces. Also just some questions: What about the ESP-NOW layer? WiFi AP vs WiFi STA? Are those 2 separate interfaces? The same question for WiFi in promiscuous mode. Where does the ToF fit in here? |
Intriguing idea. I actually considered refactoring the WiFi class into separate modules like this, but realized it's way too much work for one person. In one of my projects I created wrapper classes to partially abstract network functionality. I may have useful input during this refactoring. |
Related area
Networking
Hardware specification
Proper H2 and P4 support
Is your feature request related to a problem?
Currently almost nothing about networking can operate without WiFi, so for chips like the ESP32-H2 and ESP32-P4 that do not have WiFi radios, almost nothing will compile, even if Ethernet is added.
Describe the solution you'd like
Network
class, that will keep track of interfaces, handle events and resolve domains (replacement for WiFiGeneric)WiFi
anymoreesp_netif
for common functionality)Describe alternatives you've considered
We could probably get around without rewriting, with just a bunch
#ifdef
, but that will be ugly and still requireWiFi
code on a chip without WiFi.Additional context
No response
I have checked existing list of Feature requests and the Contribution Guide
The text was updated successfully, but these errors were encountered: