BleService

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 BlePeripheral#discoverServices or BlePeripheral#getService.

Instance Properties

characteristics

characteristics: Array.<BleCharacteristic>

Type

id

id: string

Id of the service assigned by Homey

Type

  • string

name

name: string

The name of the service

Type

  • string

type

type: string

The type of the service

Type

  • string

uuid

uuid: string

Uuid of the service

Type

  • string

Instance Methods

discoverCharacteristics

(async) discoverCharacteristics(characteristicsFilteropt): Promise.<Array.<BleCharacteristic>>

Discover characteristics of this service

Parameters

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

List of characteristicUuids to search for

Throws

Will throw an error if peripheral is not connected

Returns

Promise.<Array.<BleCharacteristic>>

getCharacteristic

(async) getCharacteristic(uuid): Promise.<BleCharacteristic>

gets a characteristic for given characteristicUuid

Parameters

Name Type Description
uuid
string

The characteristicUuid to get

Throws

Will throw an error if peripheral is not connected

Returns

Promise.<BleCharacteristic>

read

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

Shorthand to read a characteristic for given characteristicUuid

Parameters

Name Type Description
characteristicUuid
string

The uuid of the characteristic that needs to be read

Throws

Will throw an error if peripheral is not connected

Returns

Promise.<Buffer>

write

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

Shorthand to write to a characteristic for given characteristicUuid

Parameters

Name Type Description
characteristicUuid
string

The uuid of the characteristic that needs to be written to

data
Buffer

The data that needs to be written

Throws

Will throw an error if peripheral is not connected

Returns

Promise.<Buffer>