skaarj1989 / mWebSockets

WebSockets for microcontrollers
https://skaarj1989.github.io/mWebSockets/autobahn-testsuite/servers/
MIT License
108 stars 23 forks source link

NETWORK_CONTROLLER switched by user #55

Closed Sampozzo closed 2 years ago

Sampozzo commented 3 years ago

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.

skaarj1989 commented 3 years ago

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.

Sampozzo commented 3 years ago

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[bot] commented 2 years ago

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.