BluetoothLEModule Class
Item Index
Methods
- addService
- cancelPeripheralConnection
- connectPeripheral
- createBeaconRegion
- initCentralManager
- initPeripheralManager
- releaseCentralManager
- releasePeripheralManager
- removeAllServices
- removeService
- requestAlwaysAuthorization
- requestRegionState
- requestWhenInUseAuthorization
- respondToRequest
- retrieveConnectedPeripherals deprecated
- retrieveConnectedPeripheralsWithServices
- retrieveMonitoredRegions
- retrievePeripherals deprecated
- retrievePeripheralsWithIdentifiers
- setDesiredConnectionLatency
- startAdvertising
- startRangingBeacons
- startRegionMonitoring
- startScan
- stopAdvertising
- stopRangingBeacons
- stopRegionMonitoring
- stopScan
- updateValue
Properties
Constants
- ADVERT_DATA_KEY_IS_CONNECTABLE
- ADVERT_DATA_KEY_LOCAL_NAME
- ADVERT_DATA_KEY_MANUFACTURER_DATA
- ADVERT_DATA_KEY_OVERFLOW_SERVICE_UUIDS
- ADVERT_DATA_KEY_SERVICE_DATA
- ADVERT_DATA_KEY_SERVICE_UUIDS
- ADVERT_DATA_KEY_SOLICITED_SERVICE_UUIDS
- ADVERT_DATA_KEY_TX_POWER_LEVEL
- ALREADY_ADVERTISING_ERROR
- ATT_ATTRIBUTE_NOT_FOUND_ERROR
- ATT_ATTRIBUTE_NOT_LONG_ERROR
- ATT_ERROR_DOMAIN
- ATT_INSUFFICIENT_AUTHENTICATION_ERROR
- ATT_INSUFFICIENT_AUTHORIZATION_ERROR
- ATT_INSUFFICIENT_ENCRYPTION_ERROR
- ATT_INSUFFICIENT_ENCRYPTION_KEY_SIZE_ERROR
- ATT_INSUFFICIENT_RESOURCES_ERROR
- ATT_INVALID_ATTRIBUTE_VALUE_LENGTH_ERROR
- ATT_INVALID_HANDLE_ERROR
- ATT_INVALID_OFFSET_ERROR
- ATT_INVALID_PDU_ERROR
- ATT_PREPARE_QUEUE_FULL_ERROR
- ATT_READ_NOT_PERMITTED_ERROR
- ATT_REQUEST_NOT_SUPPORTED_ERROR
- ATT_SUCCESS
- ATT_UNLIKELY_ERROR
- ATT_UNSUPPORTED_GROUP_TYPE_ERROR
- ATT_WRITE_NOT_PERMITTED_ERROR
- BACKGROUND_DATA_AUTHORIZATION_STATUS_AUTHORIZED
- BACKGROUND_DATA_AUTHORIZATION_STATUS_DENIED
- BACKGROUND_DATA_AUTHORIZATION_STATUS_NOT_DETERMINED
- BACKGROUND_DATA_AUTHORIZATION_STATUS_RESTRICTED
- BEACON_PROXIMITY_FAR
- BEACON_PROXIMITY_IMMEDIATE
- BEACON_PROXIMITY_NEAR
- BEACON_PROXIMITY_UNKNOWN
- CENTRAL_MANAGER_SCAN_OPTION_KEY_ALLOW_DUPLICATES
- CENTRAL_MANAGER_STATE_POWERED_OFF
- CENTRAL_MANAGER_STATE_POWERED_ON
- CENTRAL_MANAGER_STATE_RESETTING
- CENTRAL_MANAGER_STATE_UNAUTHORIZED
- CENTRAL_MANAGER_STATE_UNINITIALIZED
- CENTRAL_MANAGER_STATE_UNKNOWN
- CENTRAL_MANAGER_STATE_UNSUPPORTED
- CHAR_PERM_NONE
- CHAR_PERM_READ_ENCRYPTED
- CHAR_PERM_READABLE
- CHAR_PERM_WRITE_ENCRYPTED
- CHAR_PERM_WRITEABLE
- CHAR_PROP_BROADCAST
- CHAR_PROP_EXTENDED_PROPERTIES
- CHAR_PROP_INDICATE
- CHAR_PROP_INDICATE_ENCRYPTION_REQUIRED
- CHAR_PROP_NOTIFY
- CHAR_PROP_NOTIFY_ENCRYPTION_REQUIRED
- CHAR_PROP_READ
- CHAR_PROP_SIGNED_WRITES
- CHAR_PROP_WRITE
- CHAR_PROP_WRITE_WITHOUT_RESPONSE
- CHARACTERISTIC_TYPE_WRITE_WITH_RESPONSE
- CHARACTERISTIC_TYPE_WRITE_WITHOUT_RESPONSE
- CONNECTION_TIMEOUT_ERROR
- ERROR_DOMAIN
- INVALID_HANDLE_ERROR
- INVALID_PARAMETERS_ERROR
- LOCATION_MANAGER_AUTHORIZATION_STATUS_AUTHORIZED
- LOCATION_MANAGER_AUTHORIZATION_STATUS_DENIED
- LOCATION_MANAGER_AUTHORIZATION_STATUS_NOT_DETERMINED
- LOCATION_MANAGER_AUTHORIZATION_STATUS_RESTRICTED
- NOT_CONNECTED_ERROR
- OPERATION_CANCELLED_ERROR
- OUT_OF_SPACE_ERROR
- PERIPHERAL_DISCONNECTED_ERROR
- PERIPHERAL_MANAGER_CONNECTION_LATENCY_HIGH
- PERIPHERAL_MANAGER_CONNECTION_LATENCY_LOW
- PERIPHERAL_MANAGER_CONNECTION_LATENCY_MEDIUM
- PERIPHERAL_MANAGER_STATE_POWERED_OFF
- PERIPHERAL_MANAGER_STATE_POWERED_ON
- PERIPHERAL_MANAGER_STATE_RESETTING
- PERIPHERAL_MANAGER_STATE_UNAUTHORIZED
- PERIPHERAL_MANAGER_STATE_UNINITIALIZED
- PERIPHERAL_MANAGER_STATE_UNKNOWN
- PERIPHERAL_MANAGER_STATE_UNSUPPORTED
- PERIPHERAL_STATE_CONNECTED
- PERIPHERAL_STATE_CONNECTING
- PERIPHERAL_STATE_DISCONNECTED
- REGION_STATE_INSIDE
- REGION_STATE_OUTSIDE
- REGION_STATE_UNKOWN
- UNKNOWN_ERROR
- UUID_NOT_ALLOWED_ERROR
Events
- addedService
- centralManagerStateChange
- centralSubscribed
- centralUnsubscribed
- centralWillRestoreState
- connectedPeripheral
- disconnectedPeripheral
- discoveredPeripheral
- enteredRegion
- exitedRegion
- failedToConnectPeripheral
- locationManagerAuthorizationChanged
- moduleReady
- peripheralManagerStateChange
- peripheralWillRestoreState
- proximityChange
- rangedBeacons
- readyToUpdateSubscribers
- receivedReadRequest
- receivedWriteRequests
- regionStateUpdated
- retrievedConnectedPeripherals
- retrievedMonitoredRegions
- retrievedPeripherals
- startedAdvertising
Methods
addService
-
params
Publishes a service and its associated characteristic(s) to the local database. If the service contains included services, they must be published first.
Parameters:
-
params
ObjectAn object with the following properties:
-
primary
BooleanDefines whether the service is primary.
-
characteristics
Array of ObjectsAn array of objects describing the characteristics of the service using the following properties:
-
uuid
StringString representing the characteristic's UUID. -
properties
NumberInteger representing the characteristic's properties; see the CHAR\_PROP\_* constants. -
permissions
NumberInteger representing the characteristic's permissions; see the CHAR\_PERM\_* constants. -
[data]
TiBuffer optionalA TiBuffer object, holding the value of the characteristic. Optional.
-
-
Returns:
cancelPeripheralConnection
-
peripheral:
Cancels an active or pending connection to the specified peripheral. This command is non-blocking, and any commands that are still pending to the peripheral may or may not complete.
It extremely important to note that canceling a connection does not guarantee the immediate disconnection of the underlying physical link. This can be caused by a variety of different factors, including other application(s) that hold an outstanding connection to the peripheral. However, in this situation, you will still immediately receive a disconnectedPeripheral event.
Parameters:
-
peripheral:
PeripheralA Peripheral object.
Returns:
connectPeripheral
-
params
Initiates a connection to the specified peripheral. Connection attempts never time out and, depending on the outcome, will result in a connectedPeripheral or failedToConnectPeripheral event.
Pending attempts are cancelled automatically upon deallocation of the peripheral, and explicitly via the cancelPeripheralConnection method.
Parameters:
-
params
ObjectAn object with the following properties:
-
peripheral:
PeripheralThe object representing the peripheral.
-
Returns:
createBeaconRegion
-
params
Creates a BeaconRegion object that can be used to start advertising an iBeacon.
Parameters:
-
params
ObjectAn object with the following properties (see the properties of the BeaconRegion class for details):
-
identifier
StringA unique identifier to associate with the returned region object. You use this identifier to differentiate regions within your application.
-
UUID
StringThe UUID of the beacon.
-
[major]
Number optionalThe major number of the beacon. If not specified, the major and minor numbers of the beacon are ignored.
-
[minor]
Number optionalThe minor number of the beacon. If not specified, the minor number of the beacon is ignored.
-
[notifyEntryStateOnDisplay=false]
Boolean optionalWhen set to
true
, the beacon notifications will be sent only when the user turns on the display and the device is already inside the region.
-
Returns:
initCentralManager
-
[params]
Initializes the module's internal central manager. This function must be called in an app that acts as a central before any other function can be used.
Parameters:
-
[params]
Object optionalAn object with the following properties:
-
[showPowerAlert=true]
Boolean optionalBoolean indicating that the system should, if Bluetooth is powered off when the central is instantialized, display a warning dialog to the user. This parameter was introduced in version 1.1.0 of the module.
-
[restoreIdentifier]
String optionalA string containing a unique identifier for the central manager that is being instantiated. This identifier is used by the system to identify a specific central manager instance for restoration and, therefore, must remain the same for subsequent application executions in order for the manager to be restored. See also the centralWillRestoreState event. This parameter was introduced in version 1.1.0 of the module.
-
Returns:
initPeripheralManager
-
[params]
Initializes the module's internal peripheral manager object. This function must be called in an app that acts as a peripheral before any other function can be used.
Parameters:
-
[params]
Object optionalAn object with the following properties:
-
[showPowerAlert=true]
Boolean optionalBoolean indicating that the system should, if Bluetooth is powered off when the peripheral is instantialized, display a warning dialog to the user. This parameter was introduced in version 1.1.0 of the module.
-
[restoreIdentifier]
String optionalA string containing a unique identifier for the peripheral manager that is being instantiated. This identifier is used by the system to identify a specific peripheral manager instance for restoration and, therefore, must remain the same for subsequent application executions in order for the manager to be restored. See also the peripheralWillRestoreState event. This parameter was introduced in version 1.1.0 of the module.
-
Returns:
releaseCentralManager
()
Void
Releases the module's internal central manager. This frees up the related resources, and effectively (after a time-out) tears down the connection on the peripheral side as well.
Returns:
releasePeripheralManager
()
Void
Releases the module's internal peripheral manager object. This frees up the related resources, and effectively (after a time-out) tears down the connection on the central side as well.
Returns:
removeAllServices
()
Void
Removes all published services from the local database.
Returns:
removeService
-
service
Removes a published service from the local database. If the service is included by other service(s), they must be removed first.
Parameters:
-
service
Service
Returns:
requestAlwaysAuthorization
()
Void
When the current authorization status is LOCATION_MANAGER_AUTHORIZATION_STATUS_NOT_DETERMINED, this method runs asynchronously and prompts the user to grant permission to the app to use location services. The user prompt contains the text from the NSLocationAlwaysUsageDescription key in your app’s Info.plist file. The presence of that key is required when calling this method.
After the status is determined, the app will receive an locationManagerAuthorizationChanged event.
If the current authorization status is anything other than LOCATION_MANAGER_AUTHORIZATION_STATUS_NOT_DETERMINED, this function does nothing.
Important: You must call this function or the requestWhenInUseAuthorization function prior to using beacon services.
Requesting “Always” authorization is discouraged by Apple because of the potential negative impacts to user privacy. You should request this level of authorization only when doing so offers a genuine benefit to the user.
Returns:
requestRegionState
-
params
Retrieves the state of a region asynchronously.
Parameters:
-
params
ObjectAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
requestWhenInUseAuthorization
()
Void
When the current authorization status is LOCATION_MANAGER_AUTHORIZATION_STATUS_NOT_DETERMINED, this method runs asynchronously and prompts the user to grant permission to the app to use location services. The user prompt contains the text from the NSLocationWhenInUseUsageDescription key in your app’s Info.plist file. The presence of that key is required when calling this method.
After the status is determined, the app will receive an locationManagerAuthorizationChanged event.
If the current authorization status is anything other than LOCATION_MANAGER_AUTHORIZATION_STATUS_NOT_DETERMINED, this function does nothing.
Important: You must call this function or the requestAlwaysAuthorization function prior to using beacon services.
If the user grants “when-in-use” authorization to your app, your app can range beacons but not monitor beacon regions.
Returns:
respondToRequest
-
params
Used to respond to request(s) received via the receivedReadRequest or receivedWriteRequests event.
Parameters:
-
params
ObjectAn object with the following properties:
-
request
RequestThe request to which the peripheral is responding.
-
result
NumberThe result code; see the ATT_* constants.
-
Returns:
retrieveConnectedPeripherals
()
Void
deprecated
Retrieves all peripherals that are connected to the system. Note that this set can include peripherals which were connected by other applications, which will need to be connected locally via connectPeripheral method.
The result of this operation is returned via the retrievedConnectedPeripherals event.
Returns:
retrieveConnectedPeripheralsWithServices
-
params
Retrieves all peripherals that are connected to the system and implement any
of the services listed in serviceUUIDs
. Note that this
set can include peripherals which were connected by other applications,
which will need to be connected locally via
connectPeripheral method.
The result of this operation is returned via the retrievedConnectedPeripherals event.
Parameters:
-
params
Object-
serviceUUIDs
Array of Strings
-
Returns:
retrieveMonitoredRegions
()
Void
Retrieves the currently monitored beacon regions. Note that this function will initialize the location manager if it's not already initialized. Thus this function, unlike the monitoredRegions property, is guaranteed to return the correct result in every case. In particular, this function is a key component of the restoration process that needs to take place when the app is restarted into the background in response to a beacon related event.
Important: Call this function after you attached the appropriate event handlers for the enteredRegion, exitedRegion, and regionStateUpdated events. If the app was restarted due to a beacon related event, that event will be fired immediately after this function is called.
Async function; returns the results in a retrievedMonitoredRegions event.
Returns:
retrievePeripherals
-
params
Attempts to retrieve the Peripheral
object(s) that correspond
to the specified UUIDs
.
The result of this operation is returned via the retrievedPeripherals event.
Parameters:
-
params
ObjectAn object with the following properties:
-
UUIDs
Array of StringsUUIDs of peripherals to retrieve.
-
Returns:
retrievePeripheralsWithIdentifiers
-
params
Attempts to retrieve the Peripheral
object(s) that correspond
to the specified UUIDs
.
Parameters:
-
params
ObjectAn object with the following properties:
-
UUIDs
Array of StringsUUIDs of peripherals to retrieve.
-
Returns:
setDesiredConnectionLatency
-
params
Sets the desired connection latency for an existing connection on the module's internal peripheral manager. Connection latency changes are not guaranteed, so the resultant latency may vary. If a desired latency is not set, the latency chosen by the central at the time of connection establishment will be used. Typically, it is not necessary to change the latency.
Parameters:
-
params
ObjectAn object with the following properties:
-
latency
NumberThe desired connection latency.
-
central
CentralA connected central
-
Returns:
startAdvertising
-
[params]
Instructs the module's internal peripheral manager to start advertising.
Important: You must call the initPeripheralManager function first!
Note: In the Beacons
module, this function can only be used
to advertise beacon regions.
Supported advertising data types are ADVERT_DATA_KEY_LOCAL_NAME and ADVERT_DATA_KEY_SERVICE_UUIDS. When in the foreground, an application can utilize up to 28 bytes of space in the initial advertisement data for any combination of the supported advertising data types. If this space is used up, there are an additional 10 bytes of space in the scan response that can be used only for the local name. Note that these sizes do not include the 2 bytes of header information that are required for each new data type. Any service UUIDs that do not fit in the allotted space will be added to a special "overflow" area, and can only be discovered by an iOS device that is explicitly scanning for them. While an application is in the background, the local name will not be used and all service UUIDs will be placed in the "overflow" area.
Parameters:
-
[params]
Object optionalObject containing the data to be advertised.
-
ADVERT_DATA_KEY_LOCAL_NAME
StringLocal name. Note that ADVERT_DATA_KEY_LOCAL_NAME is the constant whose value (!) is to be used as the key, like so:
params[BluetoothLE.ADVERT_DATA_KEY_LOCAL_NAME] = ...
-
ADVERT_DATA_KEY_SERVICE_UUIDS
Array of StringsService UUIDs. Note that ADVERT_DATA_KEY_SERVICE_UUIDS is the constant whose value (!) is to be used as the key, like so:
params[BluetoothLE.ADVERT_DATA_KEY_SERVICE_UUIDS] = ...
-
beaconRegion
BeaconRegionAn object created using the createBeaconRegion method. If this parameter is present, other parameters except
measuredPower
are ignored. -
[measuredPower]
Number optionalThe received signal strength indicator (RSSI) value (measured in decibels) for the device. This value represents the measured strength of the beacon from one meter away and is used during ranging. If not specified, the default value for the device will be used.
-
Returns:
startRangingBeacons
-
params
Starts the delivery of notifications for beacons in the specified region.
Parameters:
-
params
ObjectAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
startRegionMonitoring
-
params
Starts monitoring the specified region.
You must call this method once for each region you want to monitor. If an existing region with the same identifier is already being monitored by the application, the old region is replaced by the new one. Note that "identifier" literally means the identifier property, not the UUID! The regions you add using this method are stored in the monitoredRegions property.
Parameters:
-
params
ObjectAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
startScan
-
params
Starts scanning for peripherals. If the UUIDs
parameter is not
specified, all discovered peripherals will be returned, regardless of their
supported services (not recommended). If the central is already scanning with
different service UUIDs or options, the provided parameters will replace
them.
The result of this operation is returned via the discoveredPeripheral event.
Applications are allowed to scan while backgrounded, with two caveats: the scan must specify one or more service UUIDs, and the CENTRAL_MANAGER_SCAN_OPTION_KEY_ALLOW_DUPLICATES scan option will be ignored.
Parameters:
-
params
ObjectAn object with the following properties:
-
[UUIDs]
Array of Strings optionalThe UUIDs of services.
-
[options]
Object optionalKey/value pairs specifying options for the scan. Currently the only valid option is CENTRAL_MANAGER_SCAN_OPTION_KEY_ALLOW_DUPLICATES.
-
Returns:
stopAdvertising
()
Void
Instructs the module's internal peripheral manager to stop advertising.
Returns:
stopRangingBeacons
-
[params]
Stops the delivery of notifications for beacons in the specified region. If no beacon region is specified, then it stops ranging for all regions.
Parameters:
-
[params]
Object optionalAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
stopRegionMonitoring
-
[params]
Stops the delivery of notifications for beacons in the specified region. If no beacon region is specified, then it stops ranging for all regions.
Parameters:
-
[params]
Object optionalAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
stopScan
()
Void
Stops scanning for peripherals.
Returns:
updateValue
-
params
Instructs the module's internal peripheral manager to send an updated characteristic value to one or more centrals, via a notification or indication.
Parameters:
-
params
ObjectAn object with the following properties:
-
characteristic
Characteristic -
data
TiBufferThe value of the characteristic.
-
[centrals]
Array of Central objects optionalThe list of centrals that need to be updated. If not specified, all subscribed centrals will be updated.
-
Returns:
True if the update could be sent, or false if the underlying transmit queue is full. If false was returned, the readyToUpdateSubscribers event will be fired once space has become available, and the update should be re-sent if so desired.
Properties
backgroundDataAuthorizationStatus
Number
read-only
The current authorization status for sharing data while backgrounded. You can use it to detect restricted access and hide UI instead of prompting for access. Possible values are the BACKGROUND_DATA_AUTHORIZATION_STATUS_* constants.
centralManagerState
Number
read-only
State of the module's internal central manager. Its value is one of the CENTRAL_MANAGER_STATE_* constants.
filterDuplicateBeacons
Boolean
Determines whether the beacons included with the
rangedBeacons
event will be filtered for duplicates. Defaults to false
.
A beacon is considered a duplicate of another if their UUID, major, and
minor numbers are all the same.
isAdvertising
Boolean
read-only
Whether or not the the module's internal peripheral manager is currently advertising data.
locationManagerAuthorizationStatus
Number
read-only
Authorization status of the Location Manager for this app. Its value is one of the LOCATION_MANAGER_AUTHORIZATION_STATUS_* constants.
monitoredRegions
Array of BeaconRegions
read-only
The beacon regions monitored by all location manager objects. Note that this property will be undefined when the app is restarted into the background. Use the retrieveMonitoredRegions function to retrieve the list of monitored regions in that case.
peripheralManagerState
Number
read-only
State of the module's internal peripheral manager. Its value is one of the PERIPHERAL_MANAGER_STATE_* constants.
rangedRegions
Array of BeaconRegions
read-only
The regions currently being tracked using ranging.
restoredCentralManagerIdentifiers
Array of Strings
read-only
Each string in the array represents the restoration identifier for a central
manager object. This is the same string you assigned to the
restoreIdentifier
parameter of the
{{#crossLink "BluetoothLEModule/initCentralManager:method}}{{/crossLink}}
function.
restoredPeripheralManagerIdentifiers
Array of Strings
read-only
Each string in the array represents the restoration identifier for a
peripheral manager object. This is the same string you assigned to the
restoreIdentifier
parameter of the
{{#crossLink "BluetoothLEModule/initPeripheralManager:method}}{{/crossLink}}
function.
wasLocationLaunch
Boolean
read-only
True
if the application was launched due to a location event.
In the context of this module, a "location event" is an event related to
beacons. Note however that other type of location events might also trigger
the app to be launched.
Constants
ADVERT_DATA_KEY_IS_CONNECTABLE
String
The Bluetooth Low Energy specification defines several fields that may be present in the advertisement data. The ADVERT_DATA_* constants can be used as keys to define the value of these fields when advertising using the startAdvertising method, or to access the values when advertising data is received in the discoveredPeripheral event.
The value associated with this particular key is a Boolean indicating whether or not the advertising event type was connectable. This can be used to determine whether or not a peripheral is connectable in that instant.
Note that iOS version 7.0 only supports the ADVERT_DATA_KEY_SERVICE_UUIDS and ADVERT_DATA_KEY_LOCAL_NAME fields as parameters to the startAdvertising method.
ADVERT_DATA_KEY_LOCAL_NAME
String
The Bluetooth Low Energy specification defines several fields that may be present in the advertisement data. The ADVERT_DATA_* constants can be used as keys to define the value of these fields when advertising using the startAdvertising method, or to access the values when advertising data is received in the discoveredPeripheral event.
The value associated with this particular key is a string, representing the local name of a peripheral.
Note that iOS version 7.0 only supports the ADVERT_DATA_KEY_SERVICE_UUIDS and ADVERT_DATA_KEY_LOCAL_NAME fields as parameters to the startAdvertising method.
ADVERT_DATA_KEY_MANUFACTURER_DATA
String
The Bluetooth Low Energy specification defines several fields that may be present in the advertisement data. The ADVERT_DATA_* constants can be used as keys to define the value of these fields when advertising using the startAdvertising method, or to access the values when advertising data is received in the discoveredPeripheral event.
The value associated with this particular key is a TiBuffer, representing the manufacturing data of the peripheral.
Note that iOS version 7.0 only supports the ADVERT_DATA_KEY_SERVICE_UUIDS and ADVERT_DATA_KEY_LOCAL_NAME fields as parameters to the startAdvertising method.
ADVERT_DATA_KEY_OVERFLOW_SERVICE_UUIDS
String
The Bluetooth Low Energy specification defines several fields that may be present in the advertisement data. The ADVERT_DATA_* constants can be used as keys to define the value of these fields when advertising using the startAdvertising method, or to access the values when advertising data is received in the discoveredPeripheral event.
The value associated with this particular key is an array of strings representing service UUIDs that were found in the "overflow" area of the advertising data. Due to the nature of the data stored in this area, UUIDs listed here are "best effort" and may not always be accurate.
Note that iOS version 7.0 only supports the ADVERT_DATA_KEY_SERVICE_UUIDS and ADVERT_DATA_KEY_LOCAL_NAME fields as parameters to the startAdvertising method.
ADVERT_DATA_KEY_SERVICE_DATA
String
The Bluetooth Low Energy specification defines several fields that may be present in the advertisement data. The ADVERT_DATA_* constants can be used as keys to define the value of these fields when advertising using the startAdvertising method, or to access the values when advertising data is received in the discoveredPeripheral event.
The value associated with this particular key is an object containing service specific advertisement data. The property names of the object are service UUIDs, and the values of the properties are TiBuffer objects.
Note that iOS version 7.0 only supports the ADVERT_DATA_KEY_SERVICE_UUIDS and ADVERT_DATA_KEY_LOCAL_NAME fields as parameters to the startAdvertising method.
ADVERT_DATA_KEY_SERVICE_UUIDS
String
The Bluetooth Low Energy specification defines several fields that may be present in the advertisement data. The ADVERT_DATA_* constants can be used as keys to define the value of these fields when advertising using the startAdvertising method, or to access the values when advertising data is received in the discoveredPeripheral event.
The value associated with this particular key is an array of strings representing service UUIDs.
Note that iOS version 7.0 only supports the ADVERT_DATA_KEY_SERVICE_UUIDS and ADVERT_DATA_KEY_LOCAL_NAME fields as parameters to the startAdvertising method.
ADVERT_DATA_KEY_SOLICITED_SERVICE_UUIDS
String
The Bluetooth Low Energy specification defines several fields that may be present in the advertisement data. The ADVERT_DATA_* constants can be used as keys to define the value of these fields when advertising using the startAdvertising method, or to access the values when advertising data is received in the discoveredPeripheral event.
The value associated with this particular key is a list of one or more
String
s, representing service UUIDs.
Note that iOS version 7.0 only supports the ADVERT_DATA_KEY_SERVICE_UUIDS and ADVERT_DATA_KEY_LOCAL_NAME fields as parameters to the startAdvertising method.
ADVERT_DATA_KEY_TX_POWER_LEVEL
String
The Bluetooth Low Energy specification defines several fields that may be present in the advertisement data. The ADVERT_DATA_* constants can be used as keys to define the value of these fields when advertising using the startAdvertising method, or to access the values when advertising data is received in the discoveredPeripheral event.
The value associated with this particular key is a number, representing the transmit power of a peripheral.
Note that iOS version 7.0 only supports the ADVERT_DATA_KEY_SERVICE_UUIDS and ADVERT_DATA_KEY_LOCAL_NAME fields as parameters to the startAdvertising method.
ALREADY_ADVERTISING_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_ATTRIBUTE_NOT_FOUND_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_ATTRIBUTE_NOT_LONG_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_ERROR_DOMAIN
String
One of the possible values of the errorDomain
property of
an event in case an error occurs.
ATT_INSUFFICIENT_AUTHENTICATION_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_INSUFFICIENT_AUTHORIZATION_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_INSUFFICIENT_ENCRYPTION_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_INSUFFICIENT_ENCRYPTION_KEY_SIZE_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_INSUFFICIENT_RESOURCES_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_INVALID_ATTRIBUTE_VALUE_LENGTH_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_INVALID_HANDLE_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_INVALID_OFFSET_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_INVALID_PDU_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_PREPARE_QUEUE_FULL_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_READ_NOT_PERMITTED_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_REQUEST_NOT_SUPPORTED_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_SUCCESS
Number
Constants to be used for the result
parameter of the
respondToRequest to indicate success.
ATT_UNLIKELY_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_UNSUPPORTED_GROUP_TYPE_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ATT_WRITE_NOT_PERMITTED_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
BACKGROUND_DATA_AUTHORIZATION_STATUS_AUTHORIZED
Number
One of the possible values of the backgroundDataAuthorizationStatus property. User has authorized this application to share data while backgrounded.
BACKGROUND_DATA_AUTHORIZATION_STATUS_DENIED
Number
One of the possible values of the backgroundDataAuthorizationStatus property. User has explicitly denied this application from sharing data while backgrounded.
BACKGROUND_DATA_AUTHORIZATION_STATUS_NOT_DETERMINED
Number
One of the possible values of the backgroundDataAuthorizationStatus property. User has not yet made a choice with regards to this application.
BACKGROUND_DATA_AUTHORIZATION_STATUS_RESTRICTED
Number
One of the possible values of the backgroundDataAuthorizationStatus property. This application is not authorized to share data while backgrounded. The user cannot change this application’s status, possibly due to active restrictions such as parental controls being in place.
CENTRAL_MANAGER_SCAN_OPTION_KEY_ALLOW_DUPLICATES
String
Use this constant as a key in the options
parameter of the
startScan. The value associated with this key is a number,
indicating whether the scan should run without duplicate filtering. By
default, multiple discoveries of the same peripheral are coalesced into a
single discovery event. Disabling this filtering can have an adverse effect
on battery life and should only be used if necessary.
CENTRAL_MANAGER_STATE_RESETTING
Number
The connection with the system service was momentarily lost, update imminent.
CENTRAL_MANAGER_STATE_UNAUTHORIZED
Number
The application is not authorized to use the Bluetooth Low Energy Central role.
CENTRAL_MANAGER_STATE_UNINITIALIZED
Number
This state is reported when the central manager object maintained by the module does not (yet) exist, i.e. before initCentralManager is called or after releaseCentralManager is called.
CENTRAL_MANAGER_STATE_UNSUPPORTED
Number
The platform doesn't support the Bluetooth Low Energy Central role.
CHAR_PROP_BROADCAST
Number
Permits broadcasts of the characteristic value using a characteristic configuration descriptor. Not allowed for local characteristics.
CHAR_PROP_EXTENDED_PROPERTIES
Number
If set, additional characteristic properties are defined in the characteristic extended properties descriptor. Not allowed for local characteristics
CHAR_PROP_INDICATE_ENCRYPTION_REQUIRED
Number
If set, only trusted devices can enable indications of the characteristic value.
CHAR_PROP_NOTIFY_ENCRYPTION_REQUIRED
Number
If set, only trusted devices can enable notifications of the characteristic value.
CHAR_PROP_WRITE_WITHOUT_RESPONSE
Number
Permits writes of the characteristic value, without a response.
CHARACTERISTIC_TYPE_WRITE_WITH_RESPONSE
Number
Use this constant for the type
parameter of the
writeValueForCharacteristic method. It specifies that the write to be performed requires
a response.
CHARACTERISTIC_TYPE_WRITE_WITHOUT_RESPONSE
Number
Use this constant for the type
parameter of the
writeValueForCharacteristic method. It specifies that the write to be performed does not
require a response.
CONNECTION_TIMEOUT_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
ERROR_DOMAIN
String
One of the possible values of the errorDomain
property of
an event in case an error occurs.
INVALID_HANDLE_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
INVALID_PARAMETERS_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
LOCATION_MANAGER_AUTHORIZATION_STATUS_AUTHORIZED
Number
One of the possible values of the locationManagerAuthorizationStatus property. User has authorized this application to share data while backgrounded.
LOCATION_MANAGER_AUTHORIZATION_STATUS_DENIED
Number
One of the possible values of the locationManagerAuthorizationStatus property. The user explicitly denied the use of location services for this application or location services are currently disabled in Settings.
LOCATION_MANAGER_AUTHORIZATION_STATUS_NOT_DETERMINED
Number
One of the possible values of the locationManagerAuthorizationStatus property. The user has not yet made a choice regarding whether this application can use location services.
LOCATION_MANAGER_AUTHORIZATION_STATUS_RESTRICTED
Number
One of the possible values of the locationManagerAuthorizationStatus property. The user cannot change this application’s status, possibly due to active restrictions such as parental controls being in place.
NOT_CONNECTED_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
OPERATION_CANCELLED_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
OUT_OF_SPACE_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
PERIPHERAL_DISCONNECTED_ERROR
Number
One of the possible values of the errorCode
property of
an event in case an error occurs.
PERIPHERAL_MANAGER_CONNECTION_LATENCY_HIGH
Number
Prioritizes extending battery life over rapid communication.
PERIPHERAL_MANAGER_CONNECTION_LATENCY_MEDIUM
Number
A balance between communication frequency and battery life.
PERIPHERAL_MANAGER_STATE_RESETTING
Number
The connection with the system service was momentarily lost, update imminent.
PERIPHERAL_MANAGER_STATE_UNAUTHORIZED
Number
The application is not authorized to use the Bluetooth Low Energy Peripheral role.
PERIPHERAL_MANAGER_STATE_UNINITIALIZED
Number
This state is reported when the peripheral manager object maintained by the module does not (yet) exist, i.e. before initPeripheralManager is called or after releasePeripheralManager is called.
PERIPHERAL_MANAGER_STATE_UNSUPPORTED
Number
The platform doesn't support the Bluetooth Low Energy Peripheral role.
PERIPHERAL_STATE_CONNECTED
Number
One of the possible values of the state
property of
a peripheral object.
PERIPHERAL_STATE_CONNECTING
Number
One of the possible values of the state
property of
a peripheral object.
PERIPHERAL_STATE_DISCONNECTED
Number
One of the possible values of the state
property of
a peripheral object.
REGION_STATE_INSIDE
Number
One of the possible values of the state
property of the
regionStateUpdated event.
REGION_STATE_OUTSIDE
Number
One of the possible values of the state
property of the
regionStateUpdated event.
REGION_STATE_UNKOWN
Number
One of the possible values of the state
property of the
regionStateUpdated event.
Events
addedService
This event returns the result of a
addService call. If advertisement could not be started, the cause will be
detailed in the errorCode
, errorDomain
, and
errorDescription
properties.
Event Payload:
-
service
ServiceAn object representing the service that was added.
-
errorCode
NumberThe error code; only present if an error occurred.
-
errorDomain
StringThe error domain; only present if an error occurred.
-
errorDescription
StringThe error description; only peresent if an
centralManagerStateChange
Fired whenever the state of the module's internal central manager changes.
Event Payload:
-
state
NumberAn integer describing the state of the module's internal central manager. See the CENTRAL_MANAGER_STATE_* constants.
centralSubscribed
This event is fired when a central configures a characteristic to notify or indicate. It should be used as a cue to start sending updates as the characteristic value changes.
Event Payload:
-
central
CentralAn object representing the central that subscribed.
-
characteristic
CharacteristicAn object representintg the characteristic to which the central subscribed.
centralUnsubscribed
This event is fired when a central removes notifications/indications from a characteristic.
Event Payload:
-
central
CentralAn object representing the central that unsubscribed.
-
characteristic
CharacteristicAn object representintg the characteristic from which the central unsubscribed.
centralWillRestoreState
Note: This event is currently not being fired, due to a limitation in Titanium. See the "iOS to iOS" sample app for a potential workaround.
Fired when iOS relaunches the app into the background (after iOS terminated it to free up resources) to complete some Bluetooth-related task. Use this event to synchronize your app's state with the state of the Bluetooth system.
See also the restoreIdentifier
parameter of the
initCentralManager method.
Event Payload:
-
peripherals
Array of PeripheralsAn array of Peripheral objects containing all peripherals that were connected or pending connection at the time the application was terminated by the system. When possible, all known information for each peripheral will be restored, including any discovered services, characteristics and descriptors, as well as characteristic notification states.
-
serviceUUIDs
Array of StringsAn array of strings holding the UUIDs of the service(s) being scanned for at the time the application was terminated by the system.
-
scanOptions
ObjectAn object (dictionary) containing the scan options at the time the application was terminated by the system.
connectedPeripheral
This event is fired when a connection initiated by the connectPeripheral method has succeeded.
Event Payload:
-
peripheral
PeripheralAn object representing the peripheral that connected to the local central manager.
disconnectedPeripheral
Fired when a peripheral disconnects from the local central manager.
Event Payload:
-
peripheral
PeripheralAn object representing the peripheral that disconnected.
-
errorCode
NumberThe error code; only present if an error occurred.
-
errorDomain
StringThe error domain; only present if an error occurred.
-
errorDescription
StringThe error description; only peresent if an
discoveredPeripheral
Fired when a peripheral is discovered.
Event Payload:
-
peripheral
PeripheralAn object representing the peripheral that was discovered by the local central manager.
-
RSSI
NumberThe current RSSI of the peripheral, in dBm. A value of
127
is reserved and indicates the RSSI was not available. -
advertisementData
ObjectAn object holding the advertisement data (see the ADVERT_DATA_KEY_* constants).
enteredRegion
This event is fired when the user enters a monitored region.
Note: In our testing we found this event to be unreliable. This seems to be a problem with the native SDK. We recommend to use the regionStateUpdated event instead.
Event Payload:
-
region
BeaconRegionThe region in question.
exitedRegion
This event is fired when the user exits a monitored region.
Note: In our testing we found this event to be unreliable. This seems to be a problem with the native SDK. We recommend to use the regionStateUpdated event instead.
Event Payload:
-
region
BeaconRegionThe region in question.
failedToConnectPeripheral
This event is fired when a connection initiated by the connectPeripheral method fails.
Event Payload:
-
peripheral
PeripheralAn object representing the peripheral that failed to connect.
-
errorCode
NumberThe error code; only present if an error occurred.
-
errorDomain
StringThe error domain; only present if an error occurred.
-
errorDescription
StringThe error description; only peresent if an
locationManagerAuthorizationChanged
This event is fired when the authorization status of the Location Manager changes.
Event Payload:
-
status
NumberThe status code; one of the LOCATION_MANAGER_AUTHORIZATION_STATUS_* constants.
moduleReady
This event is fired when the module is ready. On iOS, this is a formality; On Android, you need to wait for this event before calling any methods on the module.
peripheralManagerStateChange
Fired whenever the state of the module's internal peripheral manager changes.
Event Payload:
-
state
NumberAn integer describing the state of the module's internal peripheral manager. See the PERIPHERAL_MANAGER_STATE_* constants.
peripheralWillRestoreState
Note: This event is currently not being fired, due to a limitation in Titanium. See the "iOS to iOS" sample app for a potential workaround.
Fired when iOS relaunches the app into the background (after iOS terminated it to free up resources) to complete some Bluetooth-related task. Use this event to synchronize your app's state with the state of the Bluetooth system.
See also the restoreIdentifier
parameter of the
initPeripheralManager method.
Event Payload:
-
services
Array of ServicesAn array of Service objects containing all services that were published to the local database at the time the application was terminated by the system. All the information about a service is restored, including any included services, characteristics, characteristic descriptors, and subscribed centrals.
-
advertisementData
ObjectAn object (dictionary) containing the data being advertised at the time the application was terminated by the system. See the startAdvertising method for more detail.
proximityChange
Use this event to determine which beacons have changed their proximity since the last update. This event is fired whenever the rangedBeacons event is fired, provided that the proximity of any of the ranged beacons has changed since the last rangedBeacons event.
Event Payload:
-
beacons
Array of BeaconsAn array of Beacon objects representing the beacons that changed their proximity since the last update.
rangedBeacons
Use this event to determine which beacons are in range.
See also the filterDuplicateBeacons property.
Event Payload:
-
beacons
Array of BeaconsAn array of Beacon objects representing the beacons currently in range. You can use the information in these objects to determine the range of each beacon and its identifying information.
-
region
BeaconRegionThe region object containing the parameters that were used to locate the beacons.
readyToUpdateSubscribers
This event is fired after a failed call to updateValue, when the module's internal peripheral manager is again ready to send characteristic value updates.
receivedReadRequest
This event is fired when the module's internal peripheral manager receives a read request.
Event Payload:
-
request
RequestAn object representing the request.
receivedWriteRequests
This event is fired when the module's internal peripheral manager receives
a write request for one or more characteristics. For every invocation of this
method,
respondToRequest should be called exactly once. If the requests
parameter contains multiple requests, they must be treated as an atomic unit.
If the execution of one of the requests would cause a failure, the request
and error reason should be provided and none of the requests should be
executed.
Event Payload:
-
requests
Array of Request objectsRequest objects describing the incoming write requests.
regionStateUpdated
This event is fired when the state of a monitored region is updated.
Event Payload:
-
region
BeaconRegionThe region object containing the parameters that were used to locate the beacons.
-
state
NumberOne of the REGION_STATE_* constants.
retrievedConnectedPeripherals
This event returns the result of the retrieveConnectedPeripherals method.
Event Payload:
-
service
ServiceA Service object representing the service that was added.
-
errorCode
NumberThe error code; only present if an error occurred.
-
errorDomain
StringThe error domain; only present if an error occurred.
-
errorDescription
StringThe error description; only peresent if an
retrievedMonitoredRegions
Returns the result of the retrieveMonitoredRegions function.
Event Payload:
-
beaconRegions
Array of BeaconRegionsAn array of BeaconRegion objects, representing the currently monitored beacon regions.
retrievedPeripherals
This event returns the result of the retrievePeripherals method.
Event Payload:
-
peripherals
Array of Peripheral objects
startedAdvertising
This event returns the result of a
startAdvertising call. If advertisement could not be started, the cause will be
detailed in the errorCode
, errorDomain
, and
errorDescription
properties.
Event Payload:
-
errorCode
NumberThe error code; only present if an error occurred.
-
errorDomain
StringThe error domain; only present if an error occurred.
-
errorDescription
StringThe error description; only peresent if an