- 安卓手机通过设备的deviceID获取所有服务失败 报10004
与蓝牙设备连接成功后,在ios上通过 [代码]wx.getBLEDeviceServices({ // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接 deviceId, success(res) { console.log('device services:', res.services) } })[代码]输入deviceId可以获取到设备的所有services,可是在Android上确报10004错误,测试很多次,在Android设备上有一两次可以获取成功,在ios上每一次都是成功的,请问一下这是什么原因?
2019-05-23 - 向蓝牙设备写入十六进制字符串指令,设备无响应
向蓝牙设备发送“AA040500010105”的指令,代码如下: bluetoothLock:function(){ var that = this; that.writeBluetoothData1('AA040500010105',7); }, writeBluetoothData1: function (e, num) { //写入执行1指令 var that = this; wx.writeBLECharacteristicValue({ deviceId: that._deviceId, serviceId: that._serviceId, characteristicId: that._characteristicId, value: that.getBinaryData1(e, num), success(res) { console.log('writeBLECharacteristicValue success', res.errMsg) }, fail(res) { console.log('writeBLECharacteristicValue fail', res.errMsg) } }); }, getBinaryData1: function (message, num) { //将数据转为二进制数组 let buffer = new ArrayBuffer(num); let dataView = new DataView(buffer); var numTitle = 0; for (var i = 0; i < message.length; i = i + 2) { var numStr16 = message.substr(i, 2); var num1 = parseInt(numStr16, 16); dataView.setUint8(numTitle, num1); numTitle++; } return buffer; }, 能够接受到返回值,可是设备就是没有响应,但同事用app下发相同指令,设备会有滴一声的响应,请问各位大佬,我是哪里写的有问题吗?
2019-05-17