nathankellenicki / node-poweredup

A Javascript module to interface with LEGO Powered Up components.
https://nathankellenicki.github.io/node-poweredup/
MIT License
477 stars 59 forks source link

Race in _determineLPF2HubType #157

Open antlai opened 2 years ago

antlai commented 2 years ago

In Android smartphones (with webbluetooth) device.subscribeToCharacteristic() and device.writeToCharacteristic() cannot run concurrently without triggering the error in #131 , i.e., GATT operation failed for unknown reason.

To avoid that, in _determineLPF2HubType we need to await device.subscribeToCharacteristic() before starting device.writeToCharacteristic(). We also need subscribeToCharacteristic() to return the promise returned by startNotifications() (in webbleabstraction.ts)

This seems to have fixed all my connection problems.

It is just four lines changed, I'll submit a pull request...

Thanks for a great library!

Antonio

vene4ka commented 1 year ago

not helping with #131