This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use sd_ble_gatts_service_changed?

In our product we have both a DFU profile and an application profile which is confusing Mac OS X 10.9 "Mavericks" since it caches device services unless it receives a service changed indication.

The sd_ble_gatts_service_changed requires a start and end service handle, is there a way to determine what the max used service handle is? Passing 0xFF as max causes the routine to return an error.

Parents
  • Hi Andre,

    As far as I can remember, the OS X and iOS would always check for a Service Changed characteristic and enable this for every connection if you do not bond, and only once if you bond.

    The Service Changed characteristic is added by default in the stack, and you should not have to think about adding it yourself.

    The NRF_ERROR_INVALID_STATE might happen because you respond to a BLE_GATTS_EVT_SYS_ATTR_MISSING (using a sd_ble_gatts_sys_attrs_set with NULL), thus disabling all the CCCD's.

    After the first time you bonded, you should use the sd_ble_gatts_sys_attrs_get function to retrieve all the cccd's that have been set by the peer (Preferable when you receive the disconnected event). This should be stored in flash or any other place where it is retrievable by your application after it has been upgraded.

    When you re-connect again you should call the sd_ble_gatts_sys_attrs_set function with the stored system attributes. This would enable all those CCCD's that the peer had already enabled. (Like the Service Changed CCCD) and you should be able to send a Service Changed to the peer.

Reply
  • Hi Andre,

    As far as I can remember, the OS X and iOS would always check for a Service Changed characteristic and enable this for every connection if you do not bond, and only once if you bond.

    The Service Changed characteristic is added by default in the stack, and you should not have to think about adding it yourself.

    The NRF_ERROR_INVALID_STATE might happen because you respond to a BLE_GATTS_EVT_SYS_ATTR_MISSING (using a sd_ble_gatts_sys_attrs_set with NULL), thus disabling all the CCCD's.

    After the first time you bonded, you should use the sd_ble_gatts_sys_attrs_get function to retrieve all the cccd's that have been set by the peer (Preferable when you receive the disconnected event). This should be stored in flash or any other place where it is retrievable by your application after it has been upgraded.

    When you re-connect again you should call the sd_ble_gatts_sys_attrs_set function with the stored system attributes. This would enable all those CCCD's that the peer had already enabled. (Like the Service Changed CCCD) and you should be able to send a Service Changed to the peer.

Children
No Data
Related