Skip to main content
aj.sk
Associate III
October 18, 2021
Question

Elaborate correct number for max_attr_records in aci_gatt_add_serv

  • October 18, 2021
  • 12 replies
  • 2643 views

I'm struggling to get some detailed information on how to determine the correct number for the max_attr_records value of the aci_gatt_add_serv() function.

I know that you need 1 for the service itself and then at least 2 for each characteristic, but what else requires an attribute record?

Let say I have the following characteristic

aci_gatt_add_char(hServiceConfiguration, UUID_TYPE_128, uuid, 6,

                                          CHAR_PROP_NOTIFY|CHAR_PROP_READ|CHAR_PROP_WRITE, ATTR_PERMISSION_ENCRY_WRITE,

                                          GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP,

                                          16, 0 , &hCharTripConf);

What would be the resulting number of attribute records? I came up with 4, but I'm not sure if that's correct.

Further, there seems to be a limit for the total attribute records as I can only add a quite limited amount of services. How is this limit defined?

    This topic has been closed for replies.

    12 replies

    Sebastien DENOUAL
    ST Employee
    October 18, 2021

    Hi @aj.sk​ ,

    I suppose you are using BlueNRG-1 or BlueNRG-2.

    FYI, together with SDK, there is a specific and useful tool named "BlueNRG-X Radio Init Wizzard".

    I advise to use this tool to help configure and optimize memory usage regarding number of service, characteristics,... this tool will also compute for you max_attr_records used by  the aci_gatt_add_serv()

    Once you installed BlueNRG-1/-2 SDK, you should get access from your Windows menu to this "BlueNRG-X Radio Init Wizzard"

    Hope it helps,

    Regards,

    Sebastien.

    aj.sk
    aj.skAuthor
    Associate III
    October 18, 2021

    Hi @Sebastien DENOUAL​ 

    I'm using BlueNRG-MS, but I assume the tool will be the same?

    Sebastien DENOUAL
    ST Employee
    October 18, 2021

    Hi,

    Yes : sure you can use this tool also with BlueNRG-MS.

    Now, if you don't need a very high optimization (RAM impact) , you can also increase this number with some margins to not be disturbed during your dev.

    Regards,

    Sebastien.

    aj.sk
    aj.skAuthor
    Associate III
    October 18, 2021

    @Sebastien DENOUAL​ 

    Could you may tell me what's the definition of "Extended Properties" for a characteristic?

    It seems like I run into some limitations as I cannot add another service, I currently have a total attribute record count of 57 from 4 services.

    Sebastien DENOUAL
    ST Employee
    October 19, 2021

    Hi @aj.sk​ ,

    FYI, Attached is the release note of BlueNRG-MS BLE stack (extracted from BlueNRG-MS SDK documentation).

    According to selected BlueNRG-MS stack mode (mode1,2,3 or 4), the max number of attributes records is different.

    Default is mode3.

    Regards,

    Sebastien.

    aj.sk
    aj.skAuthor
    Associate III
    October 21, 2021

    @Sebastien DENOUAL​ 

    Thank you very much! What does the following sentence imply

    "The total number of attribute records for services is 8(2 resvered for the default GAP and GATT services)"

    Does that mean that I can have a maximum of 6 services? And could you may still explain to me how to calculate the required max attribute records for the characteristic in the original post? My guess of 4 is based on the assumption that I need 2 for the characteristic (value and description), 1 because I have the notify attribute and 1 because I have the ATTR_PERMISSION_ENCRY_WRITE - is that correct?

    Winfred LU
    ST Employee
    October 22, 2021

    4 is correct: 1 for the service itself. and 3 for the attribute.

    In the 3 records for the attribute:

    • 1 is used for characteristic declaration
    • 1 is used for the characteristic value
    • 1 is used for CCC descriptor for notification configuration

    ENCRY_WRITE would be a security permission configuring the encryption need to write, that does not occupy a record.

    aj.sk
    aj.skAuthor
    Associate III
    October 22, 2021

    Hi @Winfred LU​ 

    Thanks for your response

    I didn't include the service itself in my calculation, so I probably can drastically reduce the amount of used attributes... so a characteristic (not including the service it belongs to) can never use more than 3 attribute records?

    Winfred LU
    ST Employee
    October 22, 2021

    You are welcome.

    A characteristic can consume more than 3 records, in case more descriptors are needed, such as extended properties.

    aj.sk
    aj.skAuthor
    Associate III
    October 22, 2021

    @Winfred LU​ That's where I have a problem, what are "extended properties"?