Interface: IBluetoothCharacteristic

miot/Bluetooth.IBluetoothCharacteristic

BLE蓝牙特征值

Members

(readonly) isDiscovered :boolean

是否已经被发现

(readonly) isValueLoaded :boolean

数值是否已经加载, 为 true 时,本类才能读到正确的 value

(readonly) UUID :string

特征值的 UUID

(readonly) value :*

数值, 配合 isValueLoaded 使用

Example
...
  if(charateristic.isValueLoaded){
      const val = characteristic.value;
      ...
  }
  ...

Methods

read() → {Promise.<IBluetoothCharacteristic>}

读取蓝牙数据

Returns:
Type
Promise.<IBluetoothCharacteristic>

setNotify(flag) → {Promise.<IBluetoothCharacteristic>}

设置数值变化监听开关

Parameters:
Name Type Description
flag boolean

true 打开监听, false 则关闭监听

Returns:
Type
Promise.<IBluetoothCharacteristic>

write(value) → {Promise.<IBluetoothCharacteristic>}

写数据 对应 writeWithResponse

Parameters:
Name Type Description
value *

hexstring

Returns:
Type
Promise.<IBluetoothCharacteristic>

writeWithoutResponse(value) → {Promise.<IBluetoothCharacteristic>}

直接写数据 对应 writeWithoutResponse

Parameters:
Name Type Description
value *
Returns:
Type
Promise.<IBluetoothCharacteristic>