Open Apollon77 opened 7 months ago
Is HardwareAdapter better than just Adapter? I know there's an internal adapter class, but since users don't see that, I'm wondering if the shorter getAdapters()
might be better. It also might be a good idea to throw an error if the user tries to change the adapter while scanning is active.
Other than that, I like this idea.
The naming is exactly one topic to discuss. You are right with "internal iuse of Adapter vs external use" - in fact I also thought that for library devs it should be clear and there Adapter is highly overlapping. But I'm very open to change. @thegecko WDYT?
For your secondcomment: In fact the code shoud throw on "useHardwareAdapter" call as soon as "this.adapter" is set already. This happens in https://github.com/thegecko/webbluetooth/blob/dfcdc5c7dba2dc831d694ff994ca590f107b372c/src/adapters/simpleble-adapter.ts#L172 ... so it should already be as you proposed.
I will try to update here with all comments from above the next days.
I will try to update here with all comments from above the next days.
Any progress @Apollon77 ?
did not found time yet, but your comment pushed it up in the queue gg
This PR adds the option to query the available "Hardware BLE Adapters" (I did not wanted to say USB sticks because it could also be UART, so if you have a better name that do not conflict with "Adapter" already used just say :-) ) and define which one to use.
The Constructor of the WebBluetooth class is used to allow to specify the hadware adapter to use as optional option. If the option is not defined it will initialize the adapter HW with id 0 as before too laziely on first real use.
Additionally the method "getSimpleBleHardwareAdapters()" is exported and can be used. I added an example to show the usage. It outputs the following on my raspi
fixes #178