chrvadala / node-ble

Bluetooth Low Energy (BLE) library written with pure Node.js (no bindings) - baked by Bluez via DBus
https://www.npmjs.com/package/node-ble
MIT License
310 stars 45 forks source link

Adding new method for listing all available (powered) adapters #44

Closed altaircunhajr closed 1 year ago

altaircunhajr commented 1 year ago

Context:

In machines with multiple bluetooth adapters, the method defaultAdapter (Bluetooth.js) considers all adapters, regardless of their power status, and returns the first item of the list. This behavior is causing errors in client code when the first adapter (hci0) is offline.

To avoid breaking the current behavior of defaultAdapter, I created a new method, activeAdapters, which will return the list of usable (isPowered == true) adapters. Then the client is able to choose which adapter to use.