evothings / cordova-ble

Bluetooth Low Energy plugin for Cordova
http://www.evothings.com/
Apache License 2.0
242 stars 103 forks source link

Android: Queue native operations and add missing callbacks #125

Open ghost opened 7 years ago

ghost commented 7 years ago

BLE operations that are "top level" (not performed on a device) are not generally queued. This can cause problems if BLE is off and two operations are called in sequence before waiting for the first to complete. It would be more stable to queue top level operations.

In addition, callbacks should be added to functions that are missing callbacks, like stopScan and also close (check if there are more).

This would make for a cleaner flow of control and make it possible to pass error messages to the functions.

Also see the TODO comment in BLE.java in function stopScan.