This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Caching BLE Gatt Services

Other Parts Discussed in Thread: CC2540

Hello Everyone,

I have been working on a BLE application with CC2540 (slave) and Nexus 5 (master). On Android application whenever I am done with physical connection, I discover GATT services, then eventually I can read and write data by using 128 bit UUIDs. According to my experiences, I can not read/write/notify information with UUIDs without discovering GATT services from the CC2540 device.

Is there some way to store GATT services once and whenever I connect to the same device, I can restore GATT services back on Android device? Discovering services almost takes 5 second and I would like to shorten this time by restoring stored GATT services.

Thank you so much!

Have a great day to all!

  • Hi Dnz,

    Generally, you'd have to bond (pair) the devices so that a long term relationship is created where data about the peer device is stored locally. This local data would be GATT structure for example. I'm not sure how to enable pairing from Android but I suppose there is an API for that, or you could protect a characteristic with "encryption needed" to automatically trigger pairing process which is how you do it from iOS.

    Best Regards

    Joakim

  • The Android stack already does this for you "under the hood"; i.e. it caches services and characteristic handles the first time you connect to a device.  Subsequent connections and calls to 'discoverServices' use the cached handles.  This behavior can be observed using the TI Sniffer.  This caching does not require bonding and the cache persists even after the app terminates.  AFAIK, the only way to clear the cache is to turn Bluetooth off and back on again.

  • Turning bluetooth on/off does not clear the cache.  The cache is not being able to get cleared by the system on Nexus 5X device.