Packagecom.distriqt.extension.bluetoothle
Interfacepublic interface CentralManager extends flash.events.IEventDispatcher



Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
Events
 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
Property Detail
isScanningproperty
isScanning:Boolean  [read-only]

Whether the device is currently scanning for peripheral services.


Implementation
    public function get isScanning():Boolean
peripheralsproperty 
peripherals:Vector.<Peripheral>  [read-only]

The list of currently connected peripherals


Implementation
    public function get peripherals():Vector.<Peripheral>
stateproperty 
state:String  [read-only]

The current state of the bluetooth device hardware


Implementation
    public function get state():String

See also

Method Detail
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

Returns
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

Returns
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

Returns
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

Returns
Boolean — true if the scanning was taking place and has been stopped, false if the device was not scanning
Event Detail
peripheral:connect Event
Event Object Type: com.distriqt.extension.bluetoothle.events.PeripheralEvent
PeripheralEvent.type property = com.distriqt.extension.bluetoothle.events.PeripheralEvent.CONNECT

peripheral:connect:fail Event  
Event Object Type: com.distriqt.extension.bluetoothle.events.PeripheralEvent
PeripheralEvent.type property = com.distriqt.extension.bluetoothle.events.PeripheralEvent.CONNECT_FAIL

peripheral:disconnect Event  
Event Object Type: com.distriqt.extension.bluetoothle.events.PeripheralEvent
PeripheralEvent.type property = com.distriqt.extension.bluetoothle.events.PeripheralEvent.DISCONNECT

peripheral:discovered Event  
Event Object Type: com.distriqt.extension.bluetoothle.events.PeripheralEvent
PeripheralEvent.type property = 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  
Event Object Type: com.distriqt.extension.bluetoothle.events.PeripheralManagerEvent
PeripheralManagerEvent.type property = 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.