Package | com.distriqt.extension.bluetoothle |
Interface | public interface CentralManager extends flash.events.IEventDispatcher |
Property | Defined By | ||
---|---|---|---|
isScanning : Boolean [read-only]
Whether the device is currently scanning for peripheral services. | CentralManager | ||
peripherals : Vector.<Peripheral> [read-only]
The list of currently connected peripherals
| CentralManager | ||
state : String [read-only]
The current state of the bluetooth device hardware
| CentralManager |
Method | Defined By | ||
---|---|---|---|
connect(peripheral:Peripheral):Boolean
Attempt to connect to the specified Peripheral. | CentralManager | ||
disconnect(peripheral:Peripheral):Boolean
Attempt to disconnect from the specified Peripheral. | CentralManager | ||
scanForPeripherals(uuids:Vector.<String> = null, options:PeripheralScanningOptions = null):Boolean
Starts a scan to discover peripheral devices that available for this
device to connect to. | CentralManager | ||
stopScan():Boolean
Stops scanning for peripherals
| CentralManager |
Event | Summary | Defined By | ||
---|---|---|---|---|
CentralManager | ||||
CentralManager | ||||
CentralManager | ||||
Dispatched when the central manager scan discovers a peripheral. | CentralManager | |||
Dispatched when the state of the Bluetooth adpater changes. | CentralManager |
isScanning | property |
isScanning:Boolean
[read-only]
Whether the device is currently scanning for peripheral services.
public function get isScanning():Boolean
peripherals | property |
peripherals:Vector.<Peripheral>
[read-only]
The list of currently connected peripherals
public function get peripherals():Vector.<Peripheral>
state | property |
state:String
[read-only]
The current state of the bluetooth device hardware
public function get state():String
See also
connect | () | method |
public function connect(peripheral:Peripheral):Boolean
Attempt to connect to the specified Peripheral. This peripheral must be an object
returned in a PeripheralEvent.DISCOVERED
event.
Parameters
peripheral:Peripheral — The Peripheral to initiate a connection
|
Boolean — true if the connection attempt was successfully started
and false if the peripheral was invalid
or the bluetooth hardware is in an invalid state.
|
disconnect | () | method |
public function disconnect(peripheral:Peripheral):Boolean
Attempt to disconnect from the specified Peripheral.
Parameters
peripheral:Peripheral — The Peripheral to disconnect
|
Boolean — true if the disconnection was successfully started
and false if the peripheral was invalid
or the bluetooth hardware is in an invalid state.
|
scanForPeripherals | () | method |
public function scanForPeripherals(uuids:Vector.<String> = null, options:PeripheralScanningOptions = null):Boolean
Starts a scan to discover peripheral devices that available for this device to connect to.
Each UUID string represents the UUID of a service that a peripheral is advertising
Because scanning is battery-intensive, you should observe the following guidelines:
Note Under Android it is not common practice to filter by uuids, so you may find this will actually return all the detected devices and not just the specified uuids. It seems to operate slightly differently on different hardware so just be aware that you may get peripherals discovered that were not in your uuids.
Parameters
uuids:Vector.<String> (default = null ) — An array of peripheral service UUIDs to scan for. If null the central manager returns all discovered peripherals.
| |
options:PeripheralScanningOptions (default = null ) — An optional parameter specifying options to customize the scan
|
Boolean — true if the scan started successfully and false if BLE is not available or turned off
|
stopScan | () | method |
public function stopScan():Boolean
Stops scanning for peripherals
ReturnsBoolean — true if the scanning was taking place and has been stopped, false if the device was not scanning
|
peripheral:connect | Event |
com.distriqt.extension.bluetoothle.events.PeripheralEvent
com.distriqt.extension.bluetoothle.events.PeripheralEvent.CONNECT
peripheral:connect:fail | Event |
com.distriqt.extension.bluetoothle.events.PeripheralEvent
com.distriqt.extension.bluetoothle.events.PeripheralEvent.CONNECT_FAIL
peripheral:disconnect | Event |
com.distriqt.extension.bluetoothle.events.PeripheralEvent
com.distriqt.extension.bluetoothle.events.PeripheralEvent.DISCONNECT
peripheral:discovered | Event |
com.distriqt.extension.bluetoothle.events.PeripheralEvent
com.distriqt.extension.bluetoothle.events.PeripheralEvent.DISCOVERED
Dispatched when the central manager scan discovers a peripheral. This may be dispatched multiple times for the same device.
peripheralManager:state:changed | Event |
com.distriqt.extension.bluetoothle.events.PeripheralManagerEvent
com.distriqt.extension.bluetoothle.events.PeripheralManagerEvent.STATE_CHANGED
Dispatched when the state of the Bluetooth adpater changes. For example, the user has turned off Bluetooth on their device.
You should listen for this event and make sure you re-start any services when the adapter is turned on again.