Skip to content

Commit

Permalink
Merge pull request #18 from BSensory/master
Browse files Browse the repository at this point in the history
Prevent stopScan to be called on timeout
  • Loading branch information
randdusing committed Jun 1, 2016
2 parents a120383 + ff6502f commit c703845
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions ng-cordova-bluetoothle.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ angular.module('ngCordovaBluetoothLE', []).factory('$cordovaBluetoothLE', ['$q',
var timeout = null;
if (params.scanTimeout) {
timeout = $timeout(function() {
window.bluetoothle.stopScan(
function(obj) {
q.resolve(obj);
},
function(obj) {
q.reject(obj);
window.bluetoothle.isScanning(function(obj) {
if (obj.isScanning) {
window.bluetoothle.stopScan(
function(obj) {
q.resolve(obj);
},
function(obj) {
q.reject(obj);
}
);
}
);
});
}, params.scanTimeout);
}

Expand Down

0 comments on commit c703845

Please sign in to comment.