Skip to content
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

Allow custom WEBSOCKETS_NETWORK_TYPE #779

Open
Naheel-Azawy opened this issue Sep 25, 2022 · 5 comments
Open

Allow custom WEBSOCKETS_NETWORK_TYPE #779

Naheel-Azawy opened this issue Sep 25, 2022 · 5 comments

Comments

@Naheel-Azawy
Copy link

Hello,

I've been using this library and it's really impressive. Big thanks to the devs.
But now, I want to build my own WEBSOCKETS_NETWORK_TYPE.
I understand that this can be achieved by modifying WebSockets.h. But that would be dirty.

My suggestion, if not implemented somehow?, is to simply replace

...
#else
#error "no network type selected!"
#endif

with something like

...
#elif !defined(WEBSOCKET_ALLOW_CUSTOM_NETWORK_TYPE)
#error "no network type selected!"
#endif

Other checks can be optionally done for extra safety if you like.

I guess this would be nice to allow the user to define custom WEBSOCKETS_NETWORK_CLASS and others before including WebSockets.h.

@SwapB5632
Copy link

hello @Naheel-Azawy

any finding on custom WEBSOCKETS_NETWORK_TYPE. I want to switch between GSM and Wi-Fi.

@Naheel-Azawy
Copy link
Author

Hi @SwapB5632,
It has been a while since I worked on this. The easiest solution was to keep the library under the lib directory and modify manually. In this patch, you can see me creating a new network type NETWORK_TSIM and setting my own network client.
As for switching GSM and Wi-Fi, you can check my library.

@Links2004
Copy link
Owner

@Naheel-Azawy fell free to make a PR for the patch you have (with out the auto detection change)

a WEBSOCKETS_NETWORK_TYPE can be forced via a compiler option e.g.
#910 (comment)

@moritz89
Copy link
Contributor

Funny that this is exactly what I'm also looking for 😅 @Naheel-Azawy Thanks for the POC. I'll look to extend it to any TinyGSM supported modem. I'll also create an MR proposal for user-defined network types.

@moritz89
Copy link
Contributor

@Naheel-Azawy @Links2004 @SwapB5632 Could you have a look at #921 (comment) and if that approach would also work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants