The used network controller should be configurable from the sketch
Anton-V-K opened this issue · 15 comments
Anton-V-K commented
The approach with selecting the network controller inside the library's config.h
is hardly usable in real projects - it is impossible to tweak it for every build.
There are several approaches which can address this issue:
- Wrap
#define NETWORK_CONTROLLER ETHERNET_CONTROLLER_W5X00
with#ifnded NETWORK_CONTROLLER
and#endif
so if the build system support global defines, the project will choose the proper network controller. - Do a meaningful guess of the network controller (e.g., when
ESP8266
orESP32
is defined, the chances are high that WiFi is used), so for rigid build systems (like the one in Arduino IDE) the library can be used as is.
Environment info
- IDE w/version: Arduino IDE 1.8.16
- Platform/Board: esp8266
- Network controller (shield or module): WiFi
skaarj1989 commented
I've been thinking about refactoring into templates.
No more #define NETWORK_CONTROLLER
in config.h
. Instead, you will need to specialize the client/server.
WebSocketServer<WifiServer, WiFiClient> server;
WebSocketClient<EthernetClient> client;
Additionally you could use multiple network controllers in a single (more powerful) board.
skaarj1989 commented
Initial commit pushed into the meta branch.