1.api:wx.makeBluetoothPair
2.复现手机:iqoo Z9
3.调试基础库:2.30.4
const randomString = () => {
let cutLen = 6;
var str = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz";
var len = str.length;
var n = "";
for (var i = 0; i < cutLen; i++) n += str.charAt(Math.floor(Math.random() * len));
return n + Date.now();
}
wx.makeBluetoothPair({
deviceId: deviceItem.deviceId,
pin: randomString(),
timeout: 5000,
success(res) {
that.getServiceId(deviceItem, 0) // 获取蓝牙设备的服务uuid
wx.stopBluetoothDevicesDiscovery({
success: function (res) {
console.log('连接蓝牙成功之后关闭蓝牙搜索');
}
})
},
fail(err) {
console.log("makeBluetoothPair-err", err)
wx.hideLoading()
wx.showToast({
title: '连接失败,请稍后重试!',
icon: 'none'
})
}
})
makeBluetoothPair:fail:system error, createBond fail 这是报错信息