ble.addStateListener(callback [, object])
Registers a Bluetooth® LE state-change listener callback. The registration of multiple listener callbacks at the same time is supported. Registered listener callbacks can be removed by calling removeStateListener
Parameter |
Type |
Description |
---|---|---|
callback |
in function |
Callback to receive unsolicited events |
object |
in any (optional) |
If an object is provided it will be
passed as the first parameter to the specified callback function. |
callback([object,] state)
The callback function provided in addStateListener will be called for unsolicited Bluetooth® LE state changes. This includes switching on/off Bluetooth ® technology or the OS resetting the Bluetooth® stack.
Parameter |
Type |
Description |
---|---|---|
object |
in any (optional) |
If an object was provided as a
parameter to the function addStateListener, |
state |
in ble table constant |
Please see the following section for details. |
The constants described in the following table are part of the ble table, e.g. ble.OFF.
Name |
Description |
---|---|
ON |
Bluetooth® technology is switched on |
OFF |
Bluetooth® technology is switched off. This implies that any ongoing scan has been stopped and connected peripherals lose their connection. |
RESETTING |
The Bluetooth
® stack is resetting. |
UNSUPPORTED |
Bluetooth® technology is not supported on this platform |
Introduced in platform.apiLevel =
'2.5'