蓝牙模块的读写10008错误
发布于 5 年前 作者 tao70 2089 次浏览 来自 问答

在安卓6.0版本,微信6.5.10版本,连接蓝牙设备时都出现了10008错误。notifyBLECharacteristicValueChange开启notify后在获取到的characteristics中可以看到: 特征值读取对应的peoperties中notify: true。read: false。特征值写入对应的peoperties对应的notify: false,write: true。

然后调用以下代码:

let buffer = new ArrayBuffer(1)

let dataView = new DataView(buffer)

dataView.setUint8(0, 1);

wx.writeBLECharacteristicValue({

      // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取

      deviceId: deviceId,

      // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取

      serviceId: serviceId,

      // 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取

      characteristicId: characteristicId,

      // 这里的value是ArrayBuffer类型

      value: buffer,

      success: function (res) {

        console.log(‘writeBLECharacteristicValue success’, res.errMsg)

      },

      fail: function (err) {

        console.log(err);

      }

})

wx.readBLECharacteristicValue({

      // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取

      deviceId: deviceId,

      // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取

      serviceId: serviceId,

      characteristicId: characteristicId,

      success: function (res) {

        console.log(‘readBLECharacteristicValue:’)

        console.log(res)

      },

      fail: function (err) {

        console.log(err)

      }

    })

结果: 读写都出现了10008错误,无法解决。希望得到官方解答

3 回复

我都没开启notify,   只是在连接成功后响蓝牙设备写数据(15字节),而且第一次连接时还可能出现10003连接失败,ios上没问题

解决了先write 再开启notify

解决了吗,我也出现这个错了

回到顶部