Logical Labs Bluetooth Low Energy Module for Android

API Docs for: 1.2.7
Show:

Peripheral Class

Module: Readme

Methods

discoverCharacteristics

(
  • params
  • [param.UUIDs]
)
Void

Available since 1.0.0

Discovers the specified characteristic(s) of a service.

The result of this operation is returned via the discoveredCharacteristics event.

Parameters:

  • params Object

    An object with the following properties:

  • [param.UUIDs] Array of Strings optional

    An array of UUID strings, representing the characteristic types to be discovered. If not specified all characteristics of the service will be discovered, which is considerably slower and not recommended.

Returns:

Void:

discoverDescriptorsForCharacteristic

(
  • characteristic
)
Void

Available since 1.0.0

Discovers the descriptor(s) of a characteristic.

The result of this operation is returned via the Peripheral/discoveredDescriptorsForCharacteristics:event event.

Parameters:

Returns:

Void:

discoverIncludedServices

(
  • params
)
Void

Available since 1.0.0

Discovers the specified included service(s) of a service.

The result of this operation is returned via the discoveredIncludedServices event.

Parameters:

  • params Object

    An object with the following properties:

    • service Service

      A primary GATT service.

    • [serviceUUIDs] Array of Strings optional

      An array of UUID strings, representing the included service types to be discovered. If not specified, all included services will be discovered, which is considerably slower and not recommended.

Returns:

Void:

discoverServices

() Void

Available since 1.0.0

Discovers available service(s) on the peripheral.

The result of this operation is returned via the discoveredServices event.

Returns:

Void:

getAddress

() String

Available since 1.0.0

Returns the address of the remote Bluetooth device.

Returns:

String:

readRSSI

() Void

Available since 1.0.0

Retrieves the current RSSI of the link.

The result of this operation is returned via the updatedRSSI event.

Returns:

Void:

readValueForCharacteristic

(
  • characteristic
)
Void

Available since 1.0.0

Reads the value of a characteristic.

The result of this operation is returned via the updatedValueForCharacteristic event.

Parameters:

Returns:

Void:

readValueForDescriptor

(
  • descriptor
)
Void

Available since 1.0.0

Reads the value of a descriptor.

The result of this operation is returned via the updatedValueForDescriptor event.

Parameters:

Returns:

Void:

subscribeToCharacteristic

(
  • characteristic
  • [descriptorUUID="00002902-0000-1000-8000-00805f9b34fb"]
  • [descriptorValue=ENABLE_NOTIFICATION_VALUE]
)
Void

Available since 1.0.0

Enables notifications/indications for a characteristic.

Parameters:

  • characteristic Characteristic
  • [descriptorUUID="00002902-0000-1000-8000-00805f9b34fb"] String optional

    UUID of the configuration descriptor of the characteristic. The module will attempt to write descriptorValue to this descriptor. If you do not want the module to do this, set this parameter to an empty string.

  • [descriptorValue=ENABLE_NOTIFICATION_VALUE] TiBuffer optional

    The value to be written to the configuration descriptor.

Returns:

Void:

unsubscribeFromCharacteristic

(
  • characteristic
  • [descriptorUUID="00002902-0000-1000-8000-00805f9b34fb"]
  • [descriptorValue=DISABLE_NOTIFICATION_VALUE]
)
Void

Available since 1.0.0

Disables notifications/indications for a characteristic.

Parameters:

  • characteristic Characteristic
  • [descriptorUUID="00002902-0000-1000-8000-00805f9b34fb"] String optional

    UUID of the configuration descriptor of the characteristic. The module will attempt to write descriptorValue to this descriptor. If you do not want the module to do this, set this parameter to an empty string.

  • [descriptorValue=DISABLE_NOTIFICATION_VALUE] TiBuffer optional

    The value to be written to the configuration descriptor.

Returns:

Void:

writeValueForCharacteristic

(
  • params
)
Void

Available since 1.0.0

Writes a value to a characteristic.

The result of this operation is returned via the wroteValueForCharacteristic event.

Parameters:

Returns:

Void:

writeValueForDescriptor

(
  • params
)
Void

Available since 1.0.2

Writes the value of a descriptor.

The result of this operation is returned via the wroteValueForDescriptor event.

Parameters:

  • params Object

Returns:

Void:

Properties

address

String read-only

Available since 1.0.0

The address of the remote Bluetooth device.

isConnected

Boolean read-only

Available since 1.0.1

Whether or not the peripheral is currently connected.

name

String read-only

Available since 1.0.0

The name of the peripheral.

RSSI

Number read-only

Available since 1.0.0

While connected, the RSSI of the link in decibels. Note that you need to call the readRSSI method to update this value.

services

Array of Service objects read-only

Available since 1.0.0

A list of Service objects that have been discovered on the peripheral.

Events

discoveredCharacteristics

Available since 1.0.0

This event returns the result of a call to the discoverCharacteristics method. If the characteristic(s) were read successfully, they can be retrieved via the service property's characteristics property.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • service Service

    The service for which the characteristics were discovered.

  • errorCode Number

    The error code; only present if an error occurred.

discoveredDescriptionForCharacteristics

Available since 1.0.0

This event returns the result of a call to the discoverDescriptorsForCharacteristic method.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • characteristic Characteristic
  • errorCode Number

    The error code; only present if an error occurred.

discoveredIncludedServices

Available since 1.0.0

This event returns the result of a call to the discoverIncludedServices method.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • errorCode Number

    The error code; only present if an error occurred.

discoveredServices

Available since 1.0.0

This event returns the result of a call to the discoverServices method.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • errorCode Number

    The error code; only present if an error occurred.

  • errorDescription String

    The error description; only present if an error occurred.

updatedNotificationStateForCharacteristics

Available since 1.0.0

This event returns the result of a call to the subscribeToCharacteristic or unsubscribeFromCharacteristic method.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • characteristic Characteristic
  • errorCode Number

    The error code; only present if an error occurred.

  • errorDescription String

    The error description; only present if an error occurred.

updatedRSSI

Available since 1.0.0

This event returns the result of a call to the readRSSI method.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • errorCode Number

    The error code; only present if an error occurred.

  • errorDescription String

    The error description; only present if an error occurred.

updatedValueForCharacteristic

Available since 1.0.0

This event is fired after a call to the readValueForCharacteristic method, or upon receipt of a notification/indication.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • characteristic Characteristic
  • value TiBuffer

    The characteristic's value at the time the update was received. Note that due to the asynchronous nature of the Titanium messaging facility, the value of the characteristic may have been already updated again by the time the JavaScript code receives this event and consequently value and characteristic.value may be different!

  • errorCode Number

    The error code; only present if an error occurred.

updatedValueForDescriptor

Available since 1.0.0

This event returns the result of a call to the readValueForDescriptor method.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • descriptor Descriptor

    The Descriptor object corresponding to the descriptor parameter of the delegate method.

  • errorCode Number

    The error code; only present if an error occurred.

  • errorDescription String

    The error description; only present if an error occurred.

wroteValueForCharacteristic

Available since 1.0.0

This event returns the result of a call to the writeValueForCharacteristic method.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • characteristic Characteristic

    The object representing the characteristic that was changed.

  • errorCode Number

    The error code; only present if an error occurred.

wroteValueForDescriptor

Available since 1.0.0

This event returns the result of a call to the writeValueForDescriptor method.

Event Payload:

  • source Peripheral

    The peripheral sending the event.

  • descriptor Descriptor

    The object representing the descriptor that was changed.

  • errorCode Number

    The error code; only present if an error occurred.

  • errorDescription String

    The error description; only present if an error occurred.