Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71530

How to stopScan using BluetoothLE?

$
0
0

@samaybhavsar wrote:

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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71530

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>