收藏
回答

安卓手机通过设备的deviceID获取所有服务失败 错误码:10004

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.getBluetoothDevices(Object object) 客户端 7.0.3 2.7.1

- 当前 Bug 的表现(可附上截图)


在IOS和部分安卓机上用API可以正常获取到设备的服务通道,但是在有的安卓机上获取服务通道的时候报错,错误代码:10004。(在此之前可以确定设备的deviceId已经获取到,并且设备已经连接上)。就是获取不到服务通道!


- 预期表现


- 复现路径


- 提供一个最简复现 Demo

//在努比亚Z17机型上可以正常连接上设备,但是到获取服务的API时就报错10004(确定IOS及部分安卓机可以连接并正常获取服务);

wx.createBLEConnection({

            deviceId: list.deviceId,
            success: function (res) {

                setTimeout(()=>{

                   //在进行到这个步骤的时候报错10004

                    wx.getBLEDeviceServices({
                        deviceId: list.deviceId,
                        success(sevice) {
                            console.log('获取服务', sevice)
                            let idList = sevice.services;
                            for (let i = 0; i < idList.length; i++) {
                                if (idList[i].uuid.toLowerCase().indexOf("ffe0") != -1) {    //通知服务uuid
                                    notifyServiceId = idList[i].uuid
                                }
                                if (idList[i].uuid.toLowerCase().indexOf("ffe5") != -1) {    //写入服务uuid
                                    writeServiceId = idList[i].uuid
                                }
                                if (idList[i].uuid.toLowerCase().indexOf("1530") != -1) {    //DFU服务uuid
                                    serviceUUID = idList[i].uuid
                                    wx.getBLEDeviceCharacteristics({
                                        deviceId: list.deviceId,
                                        serviceId: idList[i].uuid,         //notify通道 服务 只有一个特征值
                                        success: function (res) {
                                            console.log('特征值',res)
                                            for (let j in res.characteristics) {
                                                if (res.characteristics[j].uuid.toLowerCase().indexOf("1531") != -1) {
                                                    cd30 = res.characteristics[j].uuid;
                                                }
                                                if (res.characteristics[j].uuid.toLowerCase().indexOf("1532") != -1) {
                                                    cd32 = res.characteristics[j].uuid;
                                                }
                                            }
                                        }
                                    })
                                }
                            }
                        }
                    })
                },500)
            },
            fail: function (err) {
                console.log('失败回调', err)
            }
        })



最后一次编辑于  2019-07-04
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容