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.

CC2642R: Get handle for multiple characteristics handle in Simle central code

Part Number: CC2642R

Hi ,

In simple Central code we are able to read and write on characteristic 1 by using GATTread or GATTwrite API but along with the characteristic 1 If we need to do data transaction with one more characteristic like  characteristic 2 also then how we need to do?

and what is the procedure to select the characteristic before doing GATTread or GATTwrite ? If handle we have to pass the handle then how to the get the handle for specific characteristic?

  • Hey Mohan,

    If we need to do data transaction with one more characteristic like  characteristic 2 also then how we need to do?

    You will have to know the characteristic handle for the characteristic you want to write to or read from.

    and what is the procedure to select the characteristic before doing GATTread or GATTwrite ? If handle we have to pass the handle then how to the get the handle for specific characteristic?

    This process is called service discovery. In simple_central, this processed is kicked off by a call to SimpleCentral_startSvcDiscovery(). Here, the application triggers and MTU exchange. When the peer responds, the simple_central device enters SimpleCentral_processGATTDiscEvent() and the event is processed from the stack. You'll see a simple state machine implemented where we check for discState before parsing the data from the stack. If you follow this code, you will see the discovery process in action.

    First, the services are discovered by calling GATT_DiscPrimaryServiceByUUID(). Once this procedure is complete, we call GATT_DiscCharsByUUID() to discover characteristic one since we know the UUID of the first characteristic in the profile beforehand. If you do not know this before hand, you should use GATT_DiscAllChars(). The stack will receive the response from the peripheral and return inside SimpleCentral_processGATTDiscEvent() with ATT_READ_BY_TYPE_RSP passed inside pMsg. You'll find the complete list of characteristics passed in to pMsg->msg.readByTypeRsp.pDataList . Taking a step back, you can also look at the number of attribute pairs found inside pMsg->msg.readByTypeRsp.numPairs.

    You'll find alot of this logic already inside SimpleCentral_processGATTDiscEvent(). You'll need to modify this code to discover new characteristics and services using the GATT API's (see gatt.h for the complete list).