sharpbrick / powered-up

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

kernel-implementation of Hub_Properties probably dependant on the way WinRT-bluetooth works #142

Closed dkurok closed 3 years ago

dkurok commented 3 years ago

In Hub_Properties you do: private async Task InitialHubPropertiesQueryAsync() { await Task.WhenAll(_knownProperties.Select(property => RequestHubPropertySingleUpdate(property))); } This actually fires up 14 writes to the Hub in parallel. Because the notifications of the Hub with the results are fired "slower" a lot of the notifications get lost. I have this problem when using a BlueGiga-implementation ahering to your interfaces for Bluetooth. If I change your above code to: private async Task InitialHubPropertiesQueryAsync() { foreach (HubProperty property in _knownProperties) { await RequestHubPropertySingleUpdate(property); } } this works perfect because it does the request of an update and awaits the result one after another! With WinRT-implementation I geuss it works with your implementation because WinRT's _characteristic.WriteValueWithResultAsync() does some background-waiting or alike (it nearly not commented at MS) Maybe you can change that, because other bluetooth-implementations (BlueZ is in progress) may have the same problem.

tthiery commented 3 years ago

I will create a Pull Request. That is a reasonable change. The BLE send message adapter we have is reasonable underspeced to not be clear on this.

tthiery commented 3 years ago

Pull Request is prepared, awaiting review @dkurok