Properties
address
address: string|undefinedThe mac address of the peripheral
Type
- string | undefined
addressType
addressType: string|undefinedThe address type of the peripheral
Type
- string | undefined
connectable
connectable: boolean|undefinedIndicates if Homey can connect to the peripheral
Type
- boolean | undefined
id
id: stringId of the peripheral assigned by Homey
Type
- string
isConnected
isConnectedIf the peripheral is currently connected to Homey
rssi
rssi: number|undefinedThe 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
- Array.<BleService>
state
state: stringThe state of the peripheral
Type
- string
uuid
uuid: stringUuid 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
disconnect
(async) disconnect(): Promise.<void>Disconnect Homey from the peripheral
Returns
discoverAllServicesAndCharacteristics
(async) discoverAllServicesAndCharacteristics(): Promise.<Array.<BleService>>Discovers all services and characteristics of the peripheral
Throws
Will throw an error if peripheral is not connected
Returns
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 |
Throws
Will throw an error if peripheral is not connected
Returns
getService
(async) getService(uuid): Promise.<BleService>Get a service with the given uuid
Parameters
Name | Type | Description |
---|---|---|
uuid
|
string | The uuid of the service |
Throws
Will throw an error if peripheral is not connected
Returns
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 |
Throws
Will throw an error if peripheral is not connected
Returns
updateRssi
(async) updateRssi(): Promise.<string>Updates the RSSI signal strength value
Returns
rssi
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 |
Throws
Will throw an error if peripheral is not connected
Returns
Type Definitions
Advertisement
AdvertisementType
- 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 |