z***@163.com
z***@163.com
  • 发布:2023-03-14 18:26
  • 更新:2023-04-03 19:54
  • 阅读:243

【报Bug】低耗能蓝牙本地调试连接正常,打包之后会抛出10012超时的状态码,代码中并未设置timeout

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows10

HBuilderX类型: 正式

HBuilderX版本号: 3.7.6

手机系统: Android

手机系统版本号: Android 9.0

手机厂商: pda

手机机型: handheld

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

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

预期结果:

低耗能蓝牙连接成功,并非超时

实际结果:

提示蓝牙超时,状态码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")  
                }  
            })
2023-03-14 18:26 负责人:DCloud_Android_zl 分享
已邀请:
DCloud_Android_zl

DCloud_Android_zl

打包时是否勾选蓝牙权限?如果已经勾选,麻烦提供一下安装包

要回复问题请先登录注册