Skip to main content

BluetoothRemoteGATTDescriptor.writeValue()

BFChainInterfaceBluetoothRemoteGATTDescriptorwriteValueLess than 1 minute

BluetoothRemoteGATTDescriptor.writeValue();
Write the value described by a certain service to the Bluetooth device;

BluetoothRemoteGATTDescriptor.writeValue(data)

参数

返回值

Return a Promise, resolve to fulfill a BluetoothDataViewResponse;

Example

  import { bluetoothPlugin } from "@plaoc/plugins";

  bluetoothPlugin
  .open()
  .then(res => {
    if(res.success){
      const options = {
        acceptAllDevices: true,
        optionalServices: ["00003802-0000-1000-8000-00805f9b34fb"],
      }
      return bluetoothPlugin.requestAndConnectDevice(options)
    }
  })
  .then(res => {
    if(res.success){
      // 成功的查询和连接了蓝牙设备;
      const bluetoothRemoteGATTServer = res.data;
      return bluetoothRemoteGATTServer
      .getPrimaryService("00003802-0000-1000-8000-00805f9b34fb")
    }
  })
  .then(res => {
    if(res.success){
      const bluetoothRemoteGATTService = res.data;
      bluetoothRemoteGATTService.getCharacteristic("00004a02-0000-1000-8000-00805f9b34fb")
    }
  })
  .then(res => {
    if(res.success){
      const bluetoothRemoteGATTCharacteristic = res.data;
      return bluetoothRemoteGATTCharacteristic.getDescriptor()
      // 获取了 特征的 标识符;
    }
  })
  .then(async (res) => {
    if(res.success){
      const bluetoothRemoteGATTDescriptor = res.data;
      const value = await bluetoothRemoteGATTDescriptor.writeValue(new ArrayBuffer(8))
    }
  })
  .catch(err => console.error(err))

Platform Compatibility

Property/Method/EventAndroidIOSDesktop-DevDesktop
writeValueX

BluetoothRemoteGATTDescriptor

Comments
  • Latest
  • Oldest
  • Hottest
Powered by Waline v2.15.7