BlePeripheral

This class is a representation of a BLE peripheral in Homey. This class must not be initiated by the developer, but retrieved by calling BleAdvertisement#connect.

Properties

address

address: string|undefined

The mac address of the peripheral

Type

  • string | undefined

addressType

addressType: string|undefined

The address type of the peripheral

Type

  • string | undefined

connectable

connectable: boolean|undefined

Indicates if Homey can connect to the peripheral

Type

  • boolean | undefined

id

id: string

Id of the peripheral assigned by Homey

Type

  • string

isConnected

isConnected

If the peripheral is currently connected to Homey

rssi

rssi: number|undefined

The rssi signal strength value for the peripheral

Type

  • number | undefined

services

services: Array.<BleService>

Array of services of the peripheral. Note that this array is only filled after the service is discovered by BleAdvertisement#discoverServices or BleAdvertisement#discoverService

Type

state

state: string|undefined

The state of the peripheral

Type

  • string | undefined

uuid

uuid: string

Uuid of the peripheral

Type

  • string

Methods

assertConnected

(async) assertConnected()

Kept for backwards compatibility

connect

(async) connect(): Promise.<this>

Connects to the peripheral if Homey disconnected from it

Returns

Promise.<this>

disconnect

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

Disconnect Homey from the peripheral

Returns

Promise.<void>

discoverAllServicesAndCharacteristics

(async) discoverAllServicesAndCharacteristics(): Promise.<Array.<BleService>>

Discovers all services and characteristics of the peripheral

Returns

Promise.<Array.<BleService>>

discoverServices

(async) discoverServices(servicesFilteropt): Promise.<Array.<BleService>>

Discovers the services of the peripheral

Parameters

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

list of services to discover, if not given all services will be discovered

Returns

Promise.<Array.<BleService>>

getService

(async) getService(uuid): Promise.<BleService>

Get a service with the given uuid

Parameters

Name Type Description
uuid
string

The uuid of the service

Returns

Promise.<BleService>

read

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

Shorthand to read a characteristic for given serviceUuid and characteristicUuid

Parameters

Name Type Description
serviceUuid
string

The uuid of the service that has given characteristic

characteristicUuid
string

The uuid of the characteristic that needs to be read

Returns

Promise.<Buffer>

updateRssi

(async) updateRssi(): Promise.<string>

Updates the RSSI signal strength value

Returns

rssi

Promise.<string>

write

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

Shorthand to write to a characteristic for given serviceUuid and characteristicUuid

Parameters

Name Type Description
serviceUuid
string

The uuid of the service that has given characteristic

characteristicUuid
string

The uuid of the characteristic that needs to be written to

data
Buffer

The data that needs to be written

Returns

Promise.<Buffer>

Type Definitions

Advertisement

Advertisement

Type

  • object

Properties

Name Type Description
localName
string

The local name of the peripheral

manufacturerData
string

Manufacturer specific data for peripheral

serviceData
Array.<string>

Array of service data entries

serviceUuids
Array.<string>

Array of service uuids