Ble Device Handler
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} } }Content copied to clipboard - Add your new Device to Supported device list:
STWBLEManager.getInstance().addServiceUUID(serviceUUId, new NewSupportedDevice());Content copied to clipboard
NOTE That :
- getServiceUUID is used when starting scan ( do not scan for service UUID not supported), to more information see startScan
- getCharacteristicsUUID is used to check if Hardware button is supported.
Functions
Link copied to clipboard
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 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.
Content copied to clipboard
Link copied to clipboard
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)
Content copied to clipboard
Callback triggered as a result of a remote characteristic notification.
Link copied to clipboard
open fun registerButtonActions(@Nullable callbacks: Set<IBleEventCallBack>)
Content copied to clipboard
Register the specified listener to be notified by any Device event.
Link copied to clipboard
open fun unRegisterButtonActions(@Nullable callback: Set<IBleEventCallBack>)
Content copied to clipboard
Unregister the specified listener to not be notified by any Device event.
Link copied to clipboard