skaarj1989/mWebSockets

NETWORK_CONTROLLER switched by user

Closed this issue · 3 comments

Hello, thank you very much for this library, i'm using it in my project and it works very well.

I'm building an ESP32 device with an angular client that talks with the controller on websocket and it works well over ethernet, over wifi and over softAP.
My device at boot load the configuration from SPIFFS and start.

What i'm trying to do now is to add the ability for the user to choose the connection type (Eth/softAP/Wifi), save it in config and reboot with the new configuration.

But i think it is not possible because NETWORK_CONTROLLER must be defined in the config.h and can't be changed later.
Any idea how i can do?

Thank you very much and sorry for my english.

Hi @Sampozzo

(...) NETWORK_CONTROLLER must be defined in the config.h and can't be changed later. Any idea how i can do?

This is correct, you have to specify network controller at compile time. This can't be changed without major refactoring.

Hi, thank you for your reply!

i'm using platform.io and i did those steps:

  1. moved the library from the libdeps folder to lib folder and removed from platformio.ini
  2. made a copy of the library, named mWebSocketWifi
  3. changed the second namespace to netWifi
  4. solved some little compile errors
  5. declared EthernetClient ethClient; and WiFiClient wifiClient; as globals
  6. in setup, read config from SPIFFS and start ethernet client OR wificlient

now i can switch from wifi to ethernet without reflash.
I know this isn't the way, but it's works and i'm only learning :) next step is to go deeper in your library to learn how to write single one :)

Thank you very much!

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.