STWBLEManager
STWBLEManager
Description :
This class represent the API for all actions/event related to BLE(Bluetooth Low Energy)
This class offers several possible operations defined in the following list :
- Start Scan : to receive list of available BLE device BleDevice
- Stop Scan : to stop scan
- Connect : to Connect to specific device BluetoothDevice
- Disconnect : to disconnect from current connected device.
This class offers also the possibility to listen for any events related to BLE.
Example of use :
To add the Support of "swhardware" module to your project, include the following line in the dependencies block of your build.gradle file:dependencies { implementation project(':swhardware') }Content copied to clipboardContent copied to clipboardSTWBLEManager.getInstance().registerBluetoothConnexionStatusChanged(getContext(), new IBluetoothLEConnectionStatusChanged() { public void onConnectionStatusChanged() { //Code... } public void onIterateGattServices() { //Code... } public void onBLEConnectionStopped() { //Code... } public void onBLEConnectionSuccess() { //Code... } });Content copied to clipboardSTWBLEManager.getInstance().unregisterBluetoothLEStatusChanged(context);Content copied to clipboardSTWBLEManager.getInstance().registerBleEventChanged(context, new IBleEventCallBack() { public boolean shouldHandleActions() { //Code... } public void onButtonPressed() { //Code... } public void onButtonReleased() { //Code... } public void onPressPTT1() { //Code... } public void onReleasePTT1() { //Code... } public void onPressPTT2() { //Code... } public void onReleasePTT2() { //Code... } public void onSwitchNext() { //Code... } public void onSwitchPrevious() { //Code... } public void onPressMBF() { //Code... } public void onLongClickMBF() { //Code... } public void onPressSOS() { //Code... } public void onReleaseSOS() { //Code... } });Content copied to clipboardSTWBLEManager.getInstance().unregisterBleEventChanged(IBleEventCallBack);Content copied to clipboard
Properties
Functions
Link copied to clipboard
Abort current scan, the disconnects an established connection.
Link copied to clipboard
open fun addAccessoriesName(@NonNull accessoriesName: String, @NonNull bleDeviceHandler: BleDeviceHandler)
Content copied to clipboard
Link copied to clipboard
open fun addServiceUUID(@NonNull serviceUUId: UUID, @NonNull bleDeviceHandler: BleDeviceHandler)
Content copied to clipboard
Called to add New BLE Device.
Link copied to clipboard
At first login check if there is a connected Bluetooth device to update local connected device to automatically redirect Audio to connected device
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Call this method to retrieve the battery level
Link copied to clipboard
open fun getBluetoothAdapter(@NonNull context: Context): BluetoothAdapter
Content copied to clipboard
Call this method to retreive the Bluetooth adapter instance
Link copied to clipboard
Called to get the connected BleDeviceHandler
Link copied to clipboard
Called to get the connected BluetoothDevice
Link copied to clipboard
Link copied to clipboard
Called to check if connected device is Aina.
Link copied to clipboard
open fun isBLEDeviceType(@NonNull bluetoothDevice: BluetoothDevice): Boolean
Content copied to clipboard
Check the type of device if is BLE type.
Link copied to clipboard
Check if BLE is supported.
Link copied to clipboard
Call this method to check if the bluetooth adapter is enabled
Link copied to clipboard
Called to check if Bluetooth Scan is allowed.
Link copied to clipboard
Called to check if current connection status is STATE_CONNECTED.
Link copied to clipboard
Called to check if current connection status is STATE_CONNECTING.
Link copied to clipboard
Content copied to clipboard
Called to check if there is a connected headset or Bluetooth.
Link copied to clipboard
Called to check if there is a current scan.
Link copied to clipboard
Called to check if current connected device is supported.
Link copied to clipboard
open fun registerBatteryLevel(@NonNull batteryLevelChanged: IBatteryLevelChanged)
Content copied to clipboard
Call this method to be notifiyed when the aina battery level is changed
Link copied to clipboard
open fun registerBleEventChanged(@NonNull bleEventCallBack: IBleEventCallBack)
Content copied to clipboard
Register the specified callback to be notified by BLE events
Link copied to clipboard
open fun registerBluetoothConnexionStatusChanged(@NonNull bluetoothLEConnexionStatusChanged: IBluetoothLEConnectionStatusChanged)
Content copied to clipboard
Register the specified callback to be notified by BLE connection status.
Link copied to clipboard
open fun scanLeDevices( @NonNull context: Context, scanPeriod: Int, @NonNull swLeScanCallback: ISWLeScanCallback)
Content copied to clipboard
Start scan for Ble Devices BleDevice.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun unRegisterBatteryLevel(@NonNull batteryLevelChanged: IBatteryLevelChanged)
Content copied to clipboard
Call this method to unregister from battery level
Link copied to clipboard
open fun unregisterBleEventChanged(@NonNull bleEventCallBack: IBleEventCallBack)
Content copied to clipboard
Unregister the specified callback to not receive any more the BLE events.
Link copied to clipboard
open fun unregisterBluetoothLEStatusChanged(@NonNull bluetoothLEConnectionStatusChanged: IBluetoothLEConnectionStatusChanged)
Content copied to clipboard
Unregister the specified callback to not receive BLE connection status event again.