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.

LAUNCHXL-CC2640R2: trying to find handle of CCCD with API GATT_ReadUsingCharUUID

Part Number: LAUNCHXL-CC2640R2

Hi there,

I am working on CC2640R2 launchpad with SDK 1.50.0.58 simple_central_cc2640r2lp_app.

I am trying to find CCCD of CHAR5(UUID FFF5). CHAR4(UUID FFF4).

What I did:

1. I noticed the procedure to find CHAR1 value handle is like this from sample code:

 first, issue a read request with GATT_ReadUsingCharUUID:

      if (svcStartHdl != 0)
      {
        attReadByTypeReq_t req;

        // Discover characteristic
        discState = BLE_DISC_STATE_CHAR;

        req.startHandle = svcStartHdl;
        req.endHandle = svcEndHdl;
        req.type.len = ATT_BT_UUID_SIZE;
        req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR1_UUID);
        req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR1_UUID);

        VOID GATT_ReadUsingCharUUID(connHandle, &req, selfEntity);
      }

then, get the handle of CHAR1 value from ATT response like this:

    // Characteristic found, store handle
    if ((pMsg->method == ATT_READ_BY_TYPE_RSP) &&
        (pMsg->msg.readByTypeRsp.numPairs > 0))
    {
      charHdl = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0],
                             pMsg->msg.readByTypeRsp.pDataList[1]);

      Display_print0(dispHandle, 2, 0, "Simple Svc Found");
    }

2. So I follow this process and add my code after the example process:

same as example code, issue a read request with  GATT_ReadUsingCharUUID

    attReadByTypeReq_t req;
    req.startHandle = svcStartHdl;
    req.endHandle = svcEndHdl;
    req.type.len = ATT_BT_UUID_SIZE;
    req.type.uuid[0] = LO_UINT16(GATT_CLIENT_CHAR_CFG_UUID);
    req.type.uuid[1] = HI_UINT16(GATT_CLIENT_CHAR_CFG_UUID);

    VOID GATT_ReadUsingCharUUID(connHandle, &req, selfEntity);

3. the weird result is that the ble stack still send a read request with UUID of CHAR1(0xFFF1), what I expect is send a read request with UUID of CCCD(0x2902)

here I attached sniffer result:

you can see that:

#870 is sample code send a read request with UUID 0xfff1

#878 is slave response

#885 is my code to send a read request with UUID(should be 0x2902), but it send a request with same UUID of 0xfff1

Finally, I attached my project(it's portable), you can import to your ccs easily.

simple_central.zip

  • Hello,

      Are you also using simple_peripheral? Because CHAR5 (OoB) does not have a characteristic configuration (GATT_CLIENT_CHAR_CFG_UUID).

    With the OoB examples and only changing (in simple_central):

          if (svcStartHdl != 0)
          {
            attReadByTypeReq_t req;
    
            // Discover characteristic
            discState = BLE_DISC_STATE_CHAR;
    
            req.startHandle = svcStartHdl;
            req.endHandle = svcEndHdl;
            req.type.len = ATT_BT_UUID_SIZE;
    //        req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR1_UUID);
    //        req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR1_UUID);
    
    //        req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR5_UUID);
    //        req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR5_UUID);
    
            req.type.uuid[0] = LO_UINT16(GATT_CLIENT_CHAR_CFG_UUID);
            req.type.uuid[1] = HI_UINT16(GATT_CLIENT_CHAR_CFG_UUID);
    
            VOID GATT_ReadUsingCharUUID(connHandle, &req, selfEntity);

    I got the correct handle (0x28), please see below:

     Could you please try with the OoB examples and let me know if you see the same behavior.

       Thanks,

        David

  • Hi David,

    I am not so sure about oob example you mentioned about. I am only using simple central example from the 1.50.0.58 SDK.

    And sorry for confusing you that I mean CCCD of CHAR4(I corrected my original post from CHAR5 to CHAR4).

    1. and yes, I can get 0x28 if I modify code (right on the original code, replace CCCD UUID). This is right.

    if (svcStartHdl != 0)
          {
            attReadByTypeReq_t req;
    
            // Discover characteristic
            discState = BLE_DISC_STATE_CHAR;
    
            req.startHandle = svcStartHdl;
            req.endHandle = svcEndHdl;
            req.type.len = ATT_BT_UUID_SIZE;
            //req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR1_UUID);
            //req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR1_UUID);
            req.type.uuid[0] = LO_UINT16(GATT_CLIENT_CHAR_CFG_UUID);
            req.type.uuid[1] = HI_UINT16(GATT_CLIENT_CHAR_CFG_UUID);
    
            VOID GATT_ReadUsingCharUUID(connHandle, &req, selfEntity);
          }

    2.  but when I add a routine right after origial code like this(after read CHAR1 with UUID, read CCCD UUID another time),

    I can not get a right reply. It goes to "cccd Found error\n".

    else if (discState == BLE_DISC_STATE_SVC)
      {
        // Service found, store handles
        if (pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
            pMsg->msg.findByTypeValueRsp.numInfo > 0)
        {
          svcStartHdl = ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
          svcEndHdl = ATT_GRP_END_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
        }
    
        // If procedure complete
        if (((pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP) &&
             (pMsg->hdr.status == bleProcedureComplete))  ||
            (pMsg->method == ATT_ERROR_RSP))
        {
          if (svcStartHdl != 0)
          {
            attReadByTypeReq_t req;
    
            // Discover characteristic
            discState = BLE_DISC_STATE_CHAR;
    
            req.startHandle = svcStartHdl;
            req.endHandle = svcEndHdl;
            req.type.len = ATT_BT_UUID_SIZE;
            req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR1_UUID);
            req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR1_UUID);
    
            VOID GATT_ReadUsingCharUUID(connHandle, &req, selfEntity);
          }
        }
      }
      else if (discState == BLE_DISC_STATE_CHAR)
      {
        // Characteristic found, store handle
        if ((pMsg->method == ATT_READ_BY_TYPE_RSP) &&
            (pMsg->msg.readByTypeRsp.numPairs > 0))
        {
          charHdl = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0],
                                 pMsg->msg.readByTypeRsp.pDataList[1]);
    
          Display_print0(dispHandle, 2, 0, "Simple Svc Found");
        }
    
        attReadByTypeReq_t req;
        req.startHandle = svcStartHdl;
        req.endHandle = svcEndHdl;
        req.type.len = ATT_BT_UUID_SIZE;
        req.type.uuid[0] = LO_UINT16(GATT_CLIENT_CHAR_CFG_UUID);
        req.type.uuid[1] = HI_UINT16(GATT_CLIENT_CHAR_CFG_UUID);
    
        VOID GATT_ReadUsingCharUUID(connHandle, &req, selfEntity);
    
        discState = BLE_DISC_STATE_CCCD;
      }
    
      else if (discState == BLE_DISC_STATE_CCCD)
      {
        // Characteristic found, store handle
        if ((pMsg->method == ATT_READ_BY_TYPE_RSP) &&
            (pMsg->msg.readByTypeRsp.numPairs > 0))
        {
          charHdl = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0],
                                 pMsg->msg.readByTypeRsp.pDataList[1]);
    
          Display_print0(dispHandle, 2, 0, "cccd Found\n");
          procedureInProgress = FALSE;
        }
    
        Display_print0(dispHandle, 2, 0, "cccd Found error\n");
        discState = BLE_DISC_STATE_IDLE;
      }

    You can check my code if I described it not clear enough. Thank you very much.

    B.R

    Leo