Skip to content

Instantly share code, notes, and snippets.

@marchbold
Last active October 19, 2015 07:33
Show Gist options
  • Save marchbold/027285b36fc34f7871d7 to your computer and use it in GitHub Desktop.
Save marchbold/027285b36fc34f7871d7 to your computer and use it in GitHub Desktop.
Handle the state changed event from Bluetooth LE
BluetoothLE.service.addEventListener( BluetoothLEEvent.STATE_CHANGED, stateChangedHandler );
switch (BluetoothLE.service.state)
{
case BluetoothLEState.STATE_ON:
// We can use the Bluetooth LE functions
break;
case BluetoothLEState.STATE_OFF:
case BluetoothLEState.STATE_RESETTING:
case BluetoothLEState.STATE_UNAUTHORISED:
case BluetoothLEState.STATE_UNSUPPORTED:
case BluetoothLEState.STATE_UNKNOWN:
// All of these indicate the Bluetooth LE is not available
}
...
private function stateChangedHandler( event:BluetoothLEEvent ):void
{
trace( "stateChangedHandler(): "+BluetoothLE.service.state );
}
// com.distriqt.BluetoothLE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment