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

What is a 'system attribute'

I see this in the documentation for this method

uint32_t sd_ble_gatts_value_set ( uint16_t  conn_handle,
uint16_t  handle,
ble_gatts_value_t  p_value 
)

with this note:

Values other than system attributes can be set at any time, regardless of whether any active connections exist.

But what is a system attribute? Why is one attribute have preference over another? They are, after all, attributes. Is a system attribute any attribute that has no characteristic value, for example, a characteristic declaration? How about a descriptor?

  • So the bottom line is this: I do save the stuff myself. But when I read in that the measurement descriptor has been enabled, can I set the descriptor to the appropriate notify/indicate setting using the write method as when the client does it?  And do it before I start advertising?

  • Hi,

    While you are in a connection, the SoftDevice will handle the CCCD as appropriate. When the peer writes to CCCD, that will be handled by SoftDevice.

    The only thing related to the CCCD that you have to do from the application, is to store the data you get from sd_ble_gatts_sys_attr_get() on disconnection, and provide it back to the SoftDevice with sd_ble_gatts_sys_attr_set() on the BLE_GATTS_EVT_SYS_ATTR_MISSING event. You should treat the data as a blob of data of unknown format, i.e. you should store it as is and provide it back as is, without changing it. You should not try to write to the CCCD directly from the application.

    Regards,
    Terje

  • Now that I am trying to use these methods there are two flags

    #define BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS (1 << 0) /**< Restrict system attributes to system services only. */
    #define BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS (1 << 1) /**< Restrict system attributes to user services only. */

    I think I now understand the system services. But what is a user service?

    If I do this procedure, will I get the

    BLE_GAP_EVT_SEC_INFO_REQUEST

    any more?

    Right now I save the security keys myself and restore them on that event. The documentation for the sd_ble_gatts_sys_attr_set() method does not specifically mention security keys and I get the idea that it is only CCCDs and the like, and no security keys.

    To add to the problem, @ref BLE_GATTS_SYS_ATTRS_FORMAT described in the call to the *_get() method does not exist. I need to know what state the collector left the CCCDs in on a reconnect.

  • Why would I get this 

      BLE_ERROR_GATTS_SYS_ATTR_MISSING

    when trying to invoke a service changed sd_ble_gatts_service_changed() method?

    It is clear that the peer has enabled the characteristic for indications.

    Then the docs say to use these functions

    uint8_t* p_sys_attr_data;
    uint16_t p_len = 0;
    sd_ble_gatts_sys_attr_get(m_adapter, m_connection_handle, NULL, &p_len, BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
    p_sys_attr_data = calloc(1, p_len);
    sd_ble_gatts_sys_attr_get(m_adapter, m_connection_handle, p_sys_attr_data, &p_len, BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
    sd_ble_gatts_sys_attr_set(m_adapter, m_connection_handle, p_sys_attr_data, p_len, BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);

    to set them to a known value??? Then I look at the table in p_sys_attr_data and it is 8 bytes. I have no idea which attribute it is talking about. There is no UUID. I get handle 13, two bytes length, value 0, and a checksum.

    • What am I supposed to do with that and how does it pertain to the 'set' function?
    • Do I pick what I want out of thin air?
    • What's wrong with the value already there?
    • How is that even related to the service table that I am changing? (In this case the DIS is being removed).
  • I do as you say. But I have one major issue. On the bonded re-connect, the  BLE_GATTS_EVT_SYS_ATTR_MISSING is never signaled. Why?

    I suppose that is causing the headaches I am having with invoking a service-changed indication?

    Since the central re-writes the CCCDs I still get the measurements but the central should not have to do that. It does because there are too many bad devices out there that don't bond correctly when it comes to CCCDs.

Related