BleCharacteristic

This class is a representation of a BLE Advertisement for a BlePeripheral in Homey. This class must not be initiated by the developer, but retrieved by calling BleService#discoverCharacteristics or BleService#getCharacteristic.

Properties

descriptors

descriptors: Array.<BleDescriptor>

Type

id

id: string

Id of the characteristic assigned by Homey

Type

  • string

name

name: string

The name of the characteristic

Type

  • string

properties

properties: Array.<string>

The properties of the characteristic

Type

  • Array.<string>

type

type: string

The type of the characteristic

Type

  • string

uuid

uuid: string

Uuid of the characteristic

Type

  • string

value

value: Buffer|null

The value of the characteristic. Note this is set to the last result of $BleCharacteristic#read and is initially null

Type

  • Buffer | null

Methods

discoverDescriptors

(async) discoverDescriptors(descriptorsFilteropt): Promise.<Array.<BleDescriptor>>

Discovers descriptors for this characteristic

Parameters

Name Type Description
descriptorsFilter
Array.<string> <optional>

list of descriptorUuids to search for

Returns

Promise.<Array.<BleDescriptor>>

read

(async) read(): Promise.<Buffer>

Read the value for this characteristic

Returns

Promise.<Buffer>

subscribeToNotifications

(async) subscribeToNotifications(callback): Promise.<void>

Subscribe to BLE notifications from the characteristic. The callback will be called with the data as buffer

Parameters

Name Type Description
callback
BleCharacteristic.NotificationCallback

Returns

  • resolves when the subscription is succesful
Promise.<void>

unsubscribeFromNotifications

(async) unsubscribeFromNotifications(): Promise.<void>

Unsubscribes notifications from this characteristic.

Returns

  • resolves when unsubscribe has performed successful and the callback has been removed.
Promise.<void>

write

(async) write(data): Promise.<Buffer>

Write a value to this characteristic

Parameters

Name Type Description
data
Buffer

The data that should be written

Returns

Promise.<Buffer>

Type Definitions

NotificationCallback

NotificationCallback(data)

Parameters

Name Type Description
data
Buffer

the received notification data