aws / amazon-freertos-ble-android-sdk

Android SDK for FreeRTOS Bluetooth Devices.
Apache License 2.0
49 stars 41 forks source link

Unable to customise gatt characteristics operation #26

Closed purvagevaria closed 4 years ago

purvagevaria commented 4 years ago

Hi , I am developing an application and using this freetos sdk for it. I want to apply some security features before sending the data over cloud. And for that I need to apply some customized code before sending the data . But for that I need some call back on app side about characteristics scan or read or modify in app side. So how to perfrom any code in gatt profile ?

ravibhagavandas commented 4 years ago

@purvagevaria

For a demo on creating a custom GATT service and sending data over to cloud, you can take a look at the GATT server demo: https://docs.aws.amazon.com/freertos/latest/userguide/ble-demo.html#ble-demo-server But please note that currently the GATT client part of the demo is only supported on IOS SDK. For android SDK you can closely look into how the MQTT proxy GATT service is implemented here: https://github.com/aws/amazon-freertos-ble-android-sdk/blob/master/amazonfreertossdk/src/main/java/software/amazon/freertos/amazonfreertossdk/AmazonFreeRTOSDevice.java#L833

purvagevaria commented 4 years ago

I want to get call backs and modification on gatt services but unfortunately I am not able to receive any call backs on app side about gatt characteristics change or received.

ravibhagavandas commented 4 years ago

Hi,

The callbacks for GATT characteristic read/write is implemented within BluetoothGattCallback object. For adding custom gatt service and characteristics you can add the service and characteristic uuid constants in this file and then implement the corresponding UUID handling logic of yours in onCharacteristicRead, onCharacteristicWrite , onCharacteristicChanged methods. For processing descriptor written notifications you can write your implementation for onDescriptorWrite method.