Skip to main content
RADS1
Associate II
February 28, 2017
Question

Sensortile BlueNRG-MS Custom Service ACI

  • February 28, 2017
  • 1 reply
  • 2297 views
Posted on February 28, 2017 at 16:19

Hi,

I am working on Sensortile kit with the BlueNRG-MS radio.

As per ST document PM0237 section 3.3, pg 55/99, following commands are used to add custom service to BLE device :

//Add the service with service_uuid 128bits UUID

aci_gatt_add_serv(UUID_TYPE_

128, service_uuid, PRIMARY_SERVICE,

7

,&ServHandle);

//Add the characteristic with charUuid_1 128bits UUID

aci_gatt_add_char(ServHandle, UUID_TYPE_128, charUuid_1, 20,

CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE, 0,16, 1, &CharHandle_1);

//Add the characteristic with charUuid_2 128bits UUID

aci_gatt_add_char(ServHandle, UUID_TYPE_128, charUuid_2, 20,

CHAR_PROP_WRITE|CHAR_PROP_

WRITE_WITHOUT_RESP, ATTR_PERMISSION_NONE,

GATT_NOTIFY_ATTRIBUTE_WRITE,

16, 1, &CharHandle_2);

In above 7 indicates the maximum number of attribute records that can be added to this service. However, as per my understanding BlueNRG-MS always adds 6 mandatory attribute records in any custom service. So for above example, the maximum number of attribute records would be :

6(mandatory attribute records) + 1 (charUuid_1 attribute) + 1 (charUuid_2 attribute) = 8 attribute records

What is incorrect in the above calculated value of 8 as the maximum number of attribute records ? As 7 is used as the maximum number of attribute records in above example.

Any help on above would be appreciated.

#sensortile-bluenrg-ms-custom-service-aci*
    This topic has been closed for replies.

    1 reply

    Antonio Vilei
    ST Employee
    March 3, 2017
    Posted on March 03, 2017 at 10:04

    Dear Rushikesh Suthar,

    the mandatory attribute records you are referring to are probably the Generic Attribute Service and the Generic Access Service (i.e. GATT and GAP) that must be available for each BLE device. Please notice that these attributes are stored in the attributes database only once. This means that when you create your own custom service, there is no need to allocate room for them again.

    If you want to create a new service that includes one characteristic with one value and one descriptor, you need:

    1 attribute for the service + 1 attribute for the characteristic + 1 attribute for the characteristic value + 1 attribute for the characteristic descriptor = 4 attributes

    For more information about the Aci_Gatt_Add_Serv command, please refer to page 79 of the

    BlueNRG-MS Bluetooth LE Stack Application Command Interface (ACI) User Manual (UM1865):

    4.6.2 Aci_Gatt_Add_Serv

    Add a service to GATT Server. When a service is created in the server, the host needs to

    reserve the handle ranges for this service using Max_Attribute_Records parameter. This

    parameter specifies the maximum number of attribute records that can be added to this

    service (including the service attribute, include attribute, characteristic attribute,

    characteristic value attribute and characteristic descriptor attribute). Handle of the created

    service is returned in command complete event.

    Also, you may use the BlueNRG GUI and its 'Service Management...' feature within the 'ACI Utilities' tab if you want to experiment with custom service and characteristics creation. The tool will automatically calculate the number of attributes records that you need.

    Hope that helps,

    Antonio

    RADS1
    RADS1Author
    Associate II
    March 4, 2017
    Posted on March 04, 2017 at 11:38

    Hi Antonio,

    Thanks for your reply pointing out BlueNRG GUI ACI utility.

    If only custom attributes are to be included in the 'Max_Attribute_Records' parameter, then what is the correct interpretation of '7'(breakup in terms of sum of individual attributes) in the following as mentioned in 

    PM0237 section 3.3, pg 55/99

      :

    //Add the service with service_uuid 128bits UUID

    aci_gatt_add_serv(UUID_TYPE_

    128, service_uuid, PRIMARY_SERVICE,

    7

    ,&ServHandle);

    Can you clarify further ?

    Andrea Palmieri
    ST Employee
    March 7, 2017
    Posted on March 07, 2017 at 10:39

    Hi,

    for the example mentioned in PM0237 and according to what

    Vilei.Antonio

    correctly indicated, you should have:

    Max_Attribute_Records:

    1 (attribute for the service) + 1 (attribute for char_uuid1 declaration) + 1 (attribute for char_uuid1 value) + 1 (attribute for char_uuid2 declaration) + 1 (attribute for char_uuid2 value) + 1 (attribute for char_uuid1 CCCD) = 6;

    where CCCD is the Client Configuration Characteristic Descriptor (since char_uuid1 has CHAR_PROP_NOTIFY property).

    In the example, 7 is big enough to also add the CHAR_PROP_NOTIFY property for char_uuid2.

    Hope that clarifies.