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.
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.