initble: function () {
{
// if (wx.openBluetoothAdapter) {
wx.openBluetoothAdapter({
success: function (res) {
wx.getConnectedBluetoothDevices({
services: [that.data.serviceid],
success: function (res)
{
let findcon = false;
if(debug)
{
console.log("获取处于连接状态的设备", res);
}
var devices = res['devices'];
for (let i = 0; i < devices.length; i++)
{
if(debug)
{
console.log("获取处于连接状态的设备1", devices[i]);
console.log("获取处于连接状态的设备2", that.data.deviceName);
}
if(devices[i].name ===that.data.deviceName)
{
if(debug)
{
console.log("获取处于连接状态的设备3", that.data.deviceName);
}
findcon = true;
break;
}
}
if(findcon)
{
if(debug)
{
console.log("获取处于连接状态的设备4", that.data.deviceName);
}
that.SendCmd();
}
else
{
wx.showToast({
title: '寻找设备:'+that.data.deviceName ,
});
that.getBluetoothAdapterState();
}
},fail: function (err) {
/*没有理解的设备,获取本机的蓝牙状态 */
that.getBluetoothAdapterState()
}
});
},
fail: function (err) {
wx.showModal({
title: '提示',
content: '请检查手机蓝牙是否打开'+err,
})
}
})
// } else {
// that.getBluetoothAdapterState()
// }
}
更新下用户隐私协议然后再试试