This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: How to enable mulitple notification

Part Number: CC2340R5

Tool/software:

Hi,

  I understand we can enable notification under : case GATT_CLIENT_CHAR_CFG_UUID:" .in write callback

If i have multiple notification then each notification will go through this same case statement and how to send

notification value to corresponding attribute when notification is enabled.

Ex:: I have notification for ATTR1 & ATTR2, when i enable ATTR2 notification, its value should be sent to ATTR2.

how to programatically identify which notification was enabled?

  • Hi,

    To clarify, you are trying to identify from the central side which attribute a received notification belongs to?

    Best Regards,

    Jan

  • NO. I am talking of peripheral end.When peripheral receives CCCD write to enable notification there is ONE switch case statement in write callback

    case GATT_CLIENT_CHAR_CFG_UUID:. Under this case statement notification will be enabled.

    Please refer to simple_gatt_service.c

    Function : SimpleGattProfile_writeAttrCB

    Snippet of notification enabling code

    case GATT_CLIENT_CHAR_CFG_UUID:
    status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
    offset, GATT_CLIENT_CFG_NOTIFY );
    //notify the App that a change has occurred in Char 4
    notifyApp = SIMPLEGATTPROFILE_CHAR4;
    break;

    If you have ONLY one attribute then we can have the above code, but when we have mutiple ( more than ONE attribute ) how to enable notification

    for each attribute individually?. Or at this point how to identify which attributes CCCD is being enabled by central device?

  • Hi Manjunath, 

    Thanks for the details above!

    For this, it will fall under one case because the UUID (0x2902 which is defined in the Bluetooth specification) is always the same. You only need to add a new characteristic in the GATT table and there's no further code modification to enable this notification. Please refer to our data_stream SLA for more details on attributes and characteristics.

    Regards

    Ivan

  • Hi Ivan,

        Thanks for reply.

    I have added a new characteristics. I want to enable notification. When i enable notification button in SimpleLink app in central ( mobile ) how do i know which attribute notification is enabled?

    Ex: If i have attribute A and B , if central device enables notification for B, how do i know Notification for B is enabled, so that i can send notification immediately 

    Line number 588 simple_gatt_profile.c has following code

    notifyApp = SIMPLEGATTPROFILE_CHAR4;  

    This code send notification immediately on enabling notification on central device.

    In this example there is ONLY ONE attribute so no worry, when i have more than ONE attribute how to decide which attribute notification was enabled

  • Hi Manjunath, 

    The GATT Client needs to write to each CCCD individually so it will enable the notification for a particular characteristic, it simply uses a write request ATT packet to set the corresponding bit to 1. The server will then reply with a write response and start sending the appropriate packets whenever it wants to alert of change in value. Each characteristic requires a CCCD if it needs to support a Notify and/or Indicate. You make the API call based on per-characteristic basis. 

    Please see example below from the User's guide

    Handle 0x002D contains the CCCD. The UUID for the CCCD is always the standard 0x2902 as previously mentioned. The CCCD must always be readable and writable, by writing to this attribute writing 0x0001, a GATT server can configure for notifications. writing 0x0002 for indications or writing 0x0000 disable notifications and indications.

    I hope this helps. 

    Regards

    Ivan

  • No it didn't helped me.

    Looks you didn't got my question.

    I know GATT client writes to each attribute individually and also enable CCCD inidividually by writing 1 to it.

    How do server know which attributes notification is enabled as UUID 0x2902 is used for all attributes.

    Again Iam trying to explain the same example

    Assume i have two attributes A & B, all required things is taken care

    Now when GATT client enable notification below code will get executed in GATT server

    case GATT_CLIENT_CHAR_CFG_UUID:
    status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                                                                  offset, GATT_CLIENT_CFG_NOTIFY );

    whether it is attribute A or B or C or D, you agree?

    Now here how do i know which attributes ( A/B/C/D ) notification is enabled

  • Hi Ivan,

       Did you get chance to look into this?

  • Hi Manjunath,

    case GATT_CLIENT_CHAR_CFG_UUID:
    status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                                                                  offset, GATT_CLIENT_CFG_NOTIFY );

    whether it is attribute A or B or C or D, you agree?

    The parameter gattAttribute_t *pAttr passed to GATTServApp_ProcessCCCWriteReq() will eventually tell whether it is attribute A or B or C or D.

    In general, GATTServApp_ProcessCCCWriteReq() is executed in the GATT write attribute callback function - e.g. in SimpleGattProfile_writeAttrCB()  - and pAttr is passed as argument of this function.

    I hope this will help,

    Best regards,

  • Hi Clement,

      Thanks for reply.

    gattAttribute_t structure is of following type

    typedef struct attAttribute_t
    {
    gattAttrType_t type,           //!< Attribute type (2 or 16 octet UUIDs)
    uint8 permissions;              //!< Attribute permissions
    uint16 handle;                    //!< Attribute handle - assigned internally by attribute server
    uint8* const pValue;             //!< Attribute value - encoding of the octet array is defined in
                                                //!< the applicable profile. The maximum length of an attribute
                                                //!< value shall be 512 octets.
    } gattAttribute_t;

    In the above structure I can take "handle" for identifying the attribute. But i am not able to relate the value in receive in "handle"

    to UUID.

    Could you point to me how UUID is mapped to "handle" ?

    Thanks

  • Hi,

    n the above structure I can take "handle" for identifying the attribute. But i am not able to relate the value in receive in "handle"

     The attribute handle will remain the same as long as the GATT table is not changed. You can then retrieve the attribute handles using BTool as shown by Ivan.

    Note that, as you  have the pointer pValue you can consider using GATTServApp_FindAttr() - and eventually retrieve the handle you want within the gattAttribute_t  structure returned.

    /**
     * @brief       Find the attribute record within a service attribute
     *              table for a given attribute value pointer.
     *
     * @param       pAttrTbl - pointer to attribute table
     * @param       numAttrs - number of attributes in attribute table
     * @param       pValue - pointer to attribute value
     *
     * @return      Pointer to attribute record
     * @return      NULL, if not found
     */
    extern gattAttribute_t *GATTServApp_FindAttr( gattAttribute_t *pAttrTbl,
                                                  uint16 numAttrs, uint8 *pValue );

    I hope this will help,

    Best regards,

  • How can i use BTool in my code?

    Any way i found the way to do.

    Thank you

  • Hi,

    In Ivan's suggestion, BTool is run on a second device. BTool is used to connect the device and discover its GATT table. 

    If needed, you'll find the BTool user's guide here: https://software-dl.ti.com/lprf/simplelink_cc2640r2_sdk/1.30.00.25/exports/docs/blestack/btool_user_guide/BTool_Users_Guide/index.html

    I hope this will help,

    Best regards,

  • Ok, i resolved it. Thank you

  • Awesome! Thank you for confirming.

    Best of luck for the next steps of your project.

    Kind regards,