蓝牙写入的接口writeBLECharacteristicValue接口问题

发布于 7 年前作者 qinming14558 次浏览最后编辑 7 年前来自 ask

小程序蓝牙中向蓝牙发送一个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 回复
llin
llin1 楼6 年前

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

xcheng
xcheng2 楼6 年前

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

liaoxiulan
liaoxiulan3 楼6 年前

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

minshao
minshao4 楼6 年前

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

https://developers.weixin.qq.com/blogdetail?action=get\_post\_info&docid=6ab06b72993057daf6b26ffba1d96e73

weizou
weizou5 楼5 年前

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