evothings / cordova-ble

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

stopScan does not immediately stop scanning #114

Closed ghost closed 7 years ago

ghost commented 7 years ago

Problem:

After calling stopScan the callback in startScan can still be called with new results (due to the async nature of how scan results are reported from native code). This can cause problems for applications that call stopScan, then continue to connect. If the application assumes no more scan results (reasonable assumption), it can still happen that there is more scan results and connect can in that case be called again, with an "already connected" error as result. This is not the expected or desired behaviour.

Solution:

Implement a flag in ble.js that controls when scan results are reported. Enable the flag when calling startScan, and disable it when calling stopScan.

ghost commented 7 years ago

Fixed by this pull request: https://github.com/evothings/cordova-ble/pull/118

ghost commented 7 years ago

Fixed, part of pull request https://github.com/evothings/cordova-ble/pull/118