ble.scan()frow Web Workers

时间:2016-12-25 15:08:19

标签: cordova ionic-framework bluetooth-lowenergy web-worker

你能帮帮我吗?如何开始使用Web Workers的蓝牙(cordova-ble-central)?

ble.scan([],5,function(device){postMessage(device.name)},function(error){});

1 个答案:

答案 0 :(得分:0)

我希望这适合你......

var devices=[];
        ble.startScan([],  
            function(peripheral)
            {
                devices.push(peripheral);
            },
            function(error)
            {
                console.log(error);
            });

        setTimeout(ble.stopScan, 1500,
            function() 
            {                    
                console.log("scan stopped.)
            },
            function() 
            {
                console.log("stopScan failed");
            }