蓝牙发送
发布于 5 年前 作者 aguo 6504 次浏览 来自 问答

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

2 回复

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

// 向蓝牙设备发送一个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)
  }
})
回到顶部