蓝牙写入的接口writeBLECharacteristicValue接口问题
发布于 5 年前 作者 qinming 14375 次浏览 来自 问答

小程序蓝牙中向蓝牙发送一个0x00的16进制数据,填写到哪里

// 向蓝牙设备发送一个0x00的16进制数据let buffer = new ArrayBuffer(1)let dataView = new DataView(buffer)
dataView.setUint8(0, 0)

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)
  }
})
5 回复

这个真心希望微信团队能给个详细的栗子,我现在就是这里卡了…

@lhe  真机上需要调用onBluetoothDeviceFound回调函数,不停的在搜索

请问解决了吗?如何解决的?我也遇到这个问题

我也问了类似的一个问题,采用两种方式传值,但是都是空的:

https://developers.weixin.qq.com/blogdetail?action=get_post_info&docid=6ab06b72993057daf6b26ffba1d96e73

你是真机测试吗  我真机测试怎么设备都搜不到的

回到顶部