在本地正式调试的时候是可以进到success的值中的,deviceid打印也是有值的,但是打包发布之后,就一直进到fail里面,提示createBLEConnection:fail operate time out, 状态码10012
uni.createBLEConnection({
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
deviceId: that.deviceId,
success(res) {
console.log(res)
uni.hideLoading()
that.linkName = name;
console.log('连接成功---', "Bluetooth," + that.deviceId)
let code = HPRTPrinterHelper.PortOpen("Bluetooth," + that.deviceId);
that.$refs.myTipsPop.showTipsPop(true, 'success', '连接成功');
console.log(code)
uni.setStorageSync('content_bluetooth', that.deviceId)
uni.setStorageSync('content_bluetoothname', that.linkName)
uni.getConnectedBluetoothDevices({
success(res) {
console.log(res)
}
})
},
fail(res) { //如果手机上的蓝牙没有打开,可以提醒用户
uni.hideLoading()
that.$refs.myTipsPop.showTipsPop(true, 'errortoast', '连接失败');
console.log(res, "11111111")
}
1 个回复
DCloud_App_Array
确认有没有配置蓝牙权限