项目打包后,开始连接低耗能蓝牙,时间长了会连接超时失败,这里我并未设置timeout参数,就不会存在超时的现象

- 发布:2023-03-14 18:26
- 更新:2023-04-03 19:54
- 阅读:387
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: windows10
HBuilderX类型: 正式
HBuilderX版本号: 3.7.6
手机系统: Android
手机系统版本号: Android 9.0
手机厂商: pda
手机机型: handheld
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
操作步骤:
预期结果:
低耗能蓝牙连接成功,并非超时
低耗能蓝牙连接成功,并非超时
实际结果:
提示蓝牙超时,状态码10012
提示蓝牙超时,状态码10012
bug描述:
本地调试基座代码createBLEConnection没有加timeout,链接蓝牙设备正常。但是在打包之后,就会提示连接超时的状态码,
只有打包后才会有次问题,本地调试没有此问题,附件是打包后提示的超时问题,只有打包后才会出现此问题,本体基座调试不会出现
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', res);
console.log(res, "11111111")
}
})
