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.

Discover all characteristic by using CC2640 as a central



Hi, I am trying to use the multi-role project (below link) to discover all characteristic of the SimpleProfile service.

http://processors.wiki.ti.com/index.php/Cc2640_MultiRole_Demo_2_1

The original code using GATT_ReadUsingCharUUID can only find one characteristic by UUID. 

I found there is a function GATT_DiscAllChars used to discover all characteristic of the given service.

However, as multi-role connects to the SimpleBLEPeripheral with 5 characteristics in the SimpleProfile service, the number of characteristic found from ATT response is only 3. why does this happen? 

    // 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);
        
        VOID GATT_DiscAllChars(connHandle, svcStartHdl, svcEndHdl, 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))
    {
      LCD_WRITE_STRING_VALUE("numPairs:", pMsg->msg.readByTypeRsp.numPairs, 10, LCD_PAGE7);
      //find index to store handle
      uint8_t connIndex = gapRoleInfo_Find(connHandle);
      charHdl[connIndex] = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0],
                             pMsg->msg.readByTypeRsp.pDataList[1]);

  • Hello Casper,

    Have you checked the handle range used? Is set here:

    svcStartHdl = ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
    svcEndHdl = ATT_GRP_END_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);

    You will receive multiple ATT_READ_BY_TYPE_RSP for all valid handles. Have you waited until your received all of them?

    You could "cheat" and simply use a much larger handle range, for example:

    VOID GATT_DiscAllChars(connHandle, svcStartHdl, 0xFFFF, selfEntity);

    You can also take a look at this thread and follow up with some related questions:

    https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/t/514007