蓝牙相关 wx.writeBLECharacteristicValue写入数据
发布于 6 年前 作者 guiyinghou 359 次浏览 来自 问答

向低功耗蓝牙设备特征值中写入二进制数据:

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

这里希望写入的数据是放在

这里的 dataView.setUint8(0,希望写入的数据)吗?

1 回复

我也遇到相同的困惑。。。大佬解决这个问题了吗?

回到顶部