蓝牙发送

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

有做个小程序蓝牙的大佬吗?求解释这个怎么发送啊

2 回复
gyan
gyan1 楼6 年前

博主弄好没?我也是不知道怎么发送数据。很尴尬

cpan
cpan2 楼5 年前
// 向蓝牙设备发送一个0x00的16进制数据const buffer = new ArrayBuffer(1)const dataView = new DataView(buffer)
dataView.setUint8(0, 0)

wx.writeBLECharacteristicValue({  // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
  deviceId,  // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
  serviceId,  // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
  characteristicId,  // 这里的value是ArrayBuffer类型
  value: buffer,
  success(res) {    console.log('writeBLECharacteristicValue success', res.errMsg)
  }
})