|
[插件使用]
ble模块蓝牙搜索什么都搜不到了
[复制链接]
我在小米,华为手机上试过了,都不行下面是代码
返回值一直是{"peripherals":[]}
我附近也有4.0设备
// 开始扫描蓝牙4.0以上的设备
function fnScanningBluetooth(){
ble = api.require('ble');
ble.initManager(function(ret) {
if (ret.state == "poweredOn") {
console.log(JSON.stringify(ret));
ble.scan({
serviceUUIDs: []
}, function(ret) {
console.log(JSON.stringify(ret));
if (ret.status) {
api.showProgress({
title: '努力搜索中...',
text: '先喝杯茶...',
modal: false
});
timer = setInterval(function(){
ble.getPeripheral(function(ret) {
console.log(JSON.stringify(ret));
if (ret) {
blue = ret['peripherals'];
for(var i=0; i<blue.length; i++){
if(blue['name'] != undefined){
blueName = blue['name'];
index = blueList.indexOf(blueName);
api.hideProgress();
if(index < 0){
blueList.push(blueName);
var html = "<li tapmode onclick=fnCloseBlue(this) name="+blue['name']+" txt="+blue['uuid']+"><span>"+blue['name']+"</span><img class=right src='../image/myCell_boult.png' alt='加载失败'></li><li class=line></li>";
console.log(blue['name']);
$("#blueList").append(html);
}
}
}
}
});
}, 5000);
}
});
}else {
api.alert({msg: "请打开蓝牙"});
}
});
}
|
|