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 UUIDs and handles of a given service

Hi, I am trying to use GATT_DiscAllChars to discover all characteristics for a given service UUID (for later reading and writing of these characteristics).

I can successfully receive responses and store the handles:

if ((pMsg->method == ATT_READ_BY_TYPE_RSP) && (pMsg->msg.readByTypeRsp.numPairs > 0)) {
    Log_info2("Found pairs %d, len %d", pMsg->msg.readByTypeRsp.numPairs, pMsg->msg.readByTypeRsp.numPairs );
    charHdl = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0],
	                   pMsg->msg.readByTypeRsp.pDataList[1]);
    Log_info1("handle %d",charHdl);
}

but how to get the UUIDs?  I believe msg.readByTypeRsp.pDataList to be a list of handle,UUID pairs but I can't find any further documentation.

  • Hi Evan,
    It should be included within the pDataList[] array. You should be able to print out the len of that array and parse out the UUID.
    The Attribute Value contains the characteristic properties, Characteristic Value Handle and characteristic UUID.
    Please let us know your findings, you can also double-check the UUID with BTOOL.

    Best wishes
  • I believe this data is in the form {handle 2 bytes},{0x00},{properties 2 bytes}{0x00}{uuid 2 or 16 bytes}.

    However, I ended up adapting the SPPBleClient code which uses GATT_DiscAllCharDescs and a ATT_FIND_BY_TYPE_VALUE_RSP response. This code makes uses of macros like ATT_PAIR_UUID_IDX(i) and ATT_PAIR_HANDLE which may also work.


    else if (discState == BLE_DISC_STATE_CHAR)
      {      
        // Characteristic descriptors found
        if (pMsg->method == ATT_FIND_INFO_RSP &&
            pMsg->msg.findInfoRsp.numInfo > 0) 
        {
          uint8_t i;]
    \
          
          // For each handle/uuid pair
          for (i = 0; i < pMsg->msg.findInfoRsp.numInfo; i++)
          {
            if(pMsg->msg.findInfoRsp.format == ATT_HANDLE_BT_UUID_TYPE)
            {
              // Look for CCCD
              if (ATT_BT_PAIR_UUID(pMsg->msg.findInfoRsp.pInfo, i) ==
                  GATT_CLIENT_CHAR_CFG_UUID)
              {
                // CCCD found
                DEBUG("CCCD for Data Char Found..."); DEBUG_NEWLINE();
                charCCCDHdl = ATT_PAIR_HANDLE(pMsg->msg.findInfoRsp.pInfo, i);
                ////LCD_WRITE_STRING_VALUE("CCCD Handle:", charCCCDHdl, 10, LCD_PAGE6);
                break;
              }
            }
            else if(pMsg->msg.findInfoRsp.format == ATT_HANDLE_UUID_TYPE)
            {
              // Look for Serial Data Char.
              if (memcmp(&(pMsg->msg.findInfoRsp.pInfo[ATT_PAIR_UUID_IDX(i)]), uuidDataChar, ATT_UUID_SIZE) == 0)
              {
                // CCCD found
                DEBUG("Data Char Found..."); //DEBUG_NEWLINE();
                charDataHdl = ATT_PAIR_HANDLE(pMsg->msg.findInfoRsp.pInfo, i);
                ////LCD_WRITE_STRING_VALUE("Data Char Hdl: ", charDataHdl, 10, LCD_PAGE7);
                break;
              }
            }
          }
        }