Missing preconditions for WiFi.h?
Closed this issue · 1 comments
My turn to ask a question and I'm going to at least initially break the cardinal rule of not providing a self-contained test case...at least for now, while I have this in my head.
I'm trying to bring up NightDriverLED on Arduino3 and found it pretty much went splat. We managed to depend on most every system that needs changes in one way or another.
This code uses https://github.com/JoaoLopesF/RemoteDebug - I'm not exactly fond of it, but I like having a telnet interface to the board, and I don't want to replace a zillion DebugThis and DebugThat invocations, so here we are. It is, of course, abandoned. :-|
So it innocently picks up WiFi.h thusly: https://github.com/JoaoLopesF/RemoteDebug/blob/22f770f7886548c744dae71ee23e87381e5593ae/src/RemoteDebug.h#L106 now framework-arduinoespressif32@src-98cb8087edcca5875bec152528484d34 and we see it picks up WiFiGeneric.h inside libraries/WiFi/src/WiFi.h Now that file has blocks like
#define WiFiEventCb NetworkEventCb
#define WiFiEventFuncCb NetworkEventFuncCb
#define WiFiEventSysCb NetworkEventSysCb
#define wifi_event_id_t network_event_handle_t
so it's expecting definitions of those events
and
wifi_event_id_t onEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
wifi_event_id_t onEvent(WiFiEventFuncCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
wifi_event_id_t onEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
which is clearly using those event definitions. So it clearly thinks that someone should have done something like:
#include <NetworkEvents.h>
#include <NetworkInterface.h>
IMO, WiFi.h should be idempotent and include what it needs and if WiFiGeneric.h needs those things IT should include them. Now I can probably "fix" this by forking the ESPRemote package and just "fixing" it something like:
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <NetworkEvents.h> // NEW
#include <NetworkInterface.h> // NEW
#include <WiFi.h>
#else
#error "Only for ESP8266 or ESP32"
Nowever, I don't particularly want to be the responsible one and fix an outdated library that I don't like, especially when I suspect it's being victimized by a bad upstream layer.
Should I gen up a proper fix for your WiFiGeneric.h (Wifi.h?) to include these two headers or us there some better way to handle this? I'm a little shocked that everyone using this library isn't filling the internet with complaints but maybe everything else is still so broken in Arduino 3 that everyone's afraid to try moving to it yet at scale. The number of people I see pinning back old versions instead of tackling fixing things is just sad. Totally missing the point of open source. :-( (Yes, I'm both talking about NOT wanting to fork a package and complaining about people that don't fork packages. I get the hypocracy, but I'll land a fix one way or the other.)
I know this isn't quite complete. I just wanted to record the state before I passed out for the night.
Since the change in the callers is pretty trivial, I suppose I could hold my nose and stuff this into the build system (gack!) and install a patch approximately like this: https://docs.platformio.org/en/latest/scripting/examples/override_package_files.html
Thanx!
Not a pioarduino issue. Please ask in Arduino espressif32 github. pioarduino is only the build system it does not modify the Arduino source code.