BleDeviceHandler

abstract class BleDeviceHandler

BleDeviceHandler

Description :

This class represent the interface to adding new BLE device to the list of supported device.

Note that : to support any new BLE Device you must extend this class.

Example of use :

  • Implementation :
    
       class NewSupportedDevice extends BleDeviceHandler {
     public UUID getCharacteristicsUUID() {
     // return characteristicUUID;
     }
    
     public UUID getServiceUUID() {
     //return serviceUUID;
     }
    
     public void onCharacteristicUpdated(BluetoothGattCharacteristic characteristic) {
     // calculate action method
     // you must use {IBleEventCallBack} to handle event(you must implement it in your mainManager) then register to it.
     // more detail in {com.streamwide.smartms.lib.hardware.api.bluetooth.ble.STWBLEManager}
     }
     }
     
  • Add your new Device to Supported device list:
    
    
                 STWBLEManager.getInstance().addServiceUUID(serviceUUId, new NewSupportedDevice());
    
            

NOTE That :

Functions

Link copied to clipboard
abstract fun getAccessoriesName(): String
Same Bluetooth accessories can't appear in Scan operation when we use only the Service UUID, so we add scan by Accessories name to handle these case.
Link copied to clipboard
abstract fun getCharacteristicsUUID(): UUID
    Abstract method, must be implement to return the characteristic UUID
    for your device button, otherwise your device does not work.Note that : characteristicUUID is used to check if button is supported( after discovering GATT service we check if
    there is a supported button, else we consider device not supported.
Link copied to clipboard
abstract fun getServiceUUID(): UUID
Abstract method, must be implement to return the service UUID for your device, otherwise your device does not work.
Link copied to clipboard
abstract fun onCharacteristicUpdated(@NonNull characteristic: BluetoothGattCharacteristic)
Callback triggered as a result of a remote characteristic notification.
Link copied to clipboard
open fun registerButtonActions(@Nullable callbacks: Set<IBleEventCallBack>)
Register the specified listener to be notified by any Device event.
Link copied to clipboard
open fun unRegisterButtonActions(@Nullable callback: Set<IBleEventCallBack>)
Unregister the specified listener to not be notified by any Device event.
Link copied to clipboard
abstract fun writeCharacteristic(characteristicValue: Int)

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard