-
Notifications
You must be signed in to change notification settings - Fork 504
Bluetooth Adapter State
Łukasz Rejman edited this page Feb 1, 2018
·
2 revisions
Interacting with BLE devices needs specific conditions under which it will possible. To find out what is the current state of the Bluetooth Adapter two functions are available:
bleManager.state(): Promise<$Keys<typeof State>>
The above function returns a Promise which will resolve with current, global State
of a BleManager
. All APIs are working only when active state is PoweredOn
.
onStateChange(
listener: (newState: $Keys<typeof State>) => void,
emitCurrentState: boolean = false,
): Subscription
The listener
registered will be notified about State
changes of a BleManager
. When observing is no longer needed one must call subscription.remove()
to unsubscribe.
/**
* Device Bluetooth Low Energy state. It's keys are used to check {@link #blemanagerstate} values
* received by {@link BleManager}
*/
export const State = {
/**
* The current state of the manager is unknown; an update is imminent.
*/
Unknown: 'Unknown',
/**
* The connection with the system service was momentarily lost; an update is imminent.
*/
Resetting: 'Resetting',
/**
* The platform does not support Bluetooth low energy.
*/
Unsupported: 'Unsupported',
/**
* The app is not authorized to use Bluetooth low energy.
*/
Unauthorized: 'Unauthorized',
/**
* Bluetooth is currently powered off.
*/
PoweredOff: 'PoweredOff',
/**
* Bluetooth is currently powered on and available to use.
*/
PoweredOn: 'PoweredOn'
}