I am working on a project which involves scanning of Bluetooth devices. Can someone tell me which plugin to use BLE or BluetoothLE ?
I tried using BluetoothLE.
Can someone explain me how to stopScan ? I understand that scanScan return Observable and my code looks like
this.bluetoothle.startScan({}).subscribe(data =>this.startScanSucess(data));
startScanSucess(obj) {
if(obj.status == "scanStarted") {
console.log("BluetoothLE is scanning for devices");
}
if(obj.status == "scanResult") {
if(obj.name) {
this.devices.push(obj);
}
}
}
stopScanning() {
this.bluetoothle.stopScan().then(()=>{},()=>{});
console.log("Stopped Scanning");
console.log(this.devices);
}
Now I need to call stopScan after an interval of say 5 seconds. This is what I tried but its not working. I am not getting the list of devices. And it gives me an error
ERROR TypeError: Cannot read property ‘then’ of undefined
at push…/src/app/tab1/tab1.page.ts.Tab1Page.stopScanning