This blog is to describe about the Service Change handling on the BLE GATT. For example, there is a GATT Server at the BLE Peripheral Side. By using the service change indicator approach, it can force the host side to re-do the service discovery.

Flow Diagram on the GATT Server with service discovery

Service Change Indications

Background: Attribute Caching is a mechanism of caching attribute handles which allows clients to avoid the process of rediscovering services upon consecutive connections with paired and bonded devices. This saves power, time and reduces the packet size.

Problem: If the client caches attribute handles and the values change then it can lead to unpredictable values from those handles. This can happen when you add or remove characteristics in run time or between firmware updates. So the question arises of how do we notify the client to rediscover services upon a change in GATT server?

For more details about how Android, iOS behaves and implements this, refer this article.

Solution

The Generic Attribute Service includes a characteristic called Service Changed which can be used by the client to let the server know that the client wants to be indicated for any changes in GATT Server. The Service Changed Indication with UUID 0x2A05 has the range of handles which have been changed. This can help the client to rediscover that range of handles.

If the database has a Generic Attribute Service and Service Changed characteristic, the stack will monitor local database change status and manage service changed indications for a GATT client that has enabled the indication configuration of the Service Changed characteristic.

Nordic SDK for Service Change

GATT Database change : Service Change indicator
Example how to enable the service change inside the generic attribute

For example, if user can notice the host side that the local database has changed,

By the above example, user can press the button 3 for asking the local database changed. The service discovery would be started again.

Welcome to give any message / feedback to me.

Thanks for your interests on my blog. Since 2019, I have created this blog and shared the idea how to do some funny stuffs. I am very pleasure that I get quite a lot of positive feedback. I really hope that this blog helps your own embedded solution development. May I get support from you to keep it in order to maintain the wordpress host service? Your appreciation would be very helpful.


https://jimmywongiot.com/2021/05/26/asking-for-support/