sharpbrick / powered-up

.NET implementation of the LEGO PoweredUp Protocol
MIT License
98 stars 19 forks source link

Bluetooth api changes #116

Closed rickjansen-dev closed 3 years ago

rickjansen-dev commented 3 years ago

This would be the minimal changes I need to be able to integrate bluez support properly and avoid deadlocks.


There's something else I'd like to propose, since the library targets .net standard 2.1 (and thus C# 8 is standard) maybe it's nice to leverage IAsyncEnumerable for the Discover method, so it becomes something like:

IAsyncEnumerable<PoweredUpBluetoothDeviceInfo> Discover(CancellationToken cancellationToken = default)

This way the newly discovered devices would be streamed to whoever is invoking the discovery as they become available.


And about the BluetoothAdapter class, is this meant to be a representation of an actual bluetooth adapter, or is it more like an bluetooth managing class? Since at least on linux (and I assume on windows too), you can have multiple adapters and I guess it would be nice to have some interface to list and select the adapter you want (and provide some convenience methods to simply select the first one available)

Closes #117

tthiery commented 3 years ago

It is abstracting the adapter. I do not know how WinRT or WebBluetooth behave, whether they combine them or not. I mean the API is not exactly starting in both cases with an adapter enumeration. Will figure out.

Review and test this later

tthiery commented 3 years ago

Feedback on the merge request