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.

CCS/CC2650EM-7ID-RD: Why GATT_DiscAllChars() can only found 3 handles, but not all handles

Part Number: CC2650EM-7ID-RD

Tool/software: Code Composer Studio

Hi,

I separately used two CC2650EM-7ID as central one and peripheral one. There are 7 Characteristics for the peripheral device.

When the central device connected the peripheral device, only three handles was founded. And pMsg->msg.readByTypeRsp.numPairs was equal to 3. However I can use phone app to find all characteristics.

So there must be some bugs in the MCU program of central device. But I can't solve it.

Could you please tell me how to do with the MCU program of central device. The MCU program can be found in the ble_sdk_2_02_01_18.

Thank you.

Jacob

  • Hi Jacob,

    What parameters are you passing into GATT_DiscAllChars?
    More specifically for the startHandle and endHandle parameter (2nd and 3rd parameter), is this set to the appropriate range to discover all?

    -Sy Su
  • Hi Sy Su,

    Thanks for your reply.

    At first, the svcStartHdl and svcEndHdl were assigned values according to the following code.
    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);
    }

    Then I have tried
    VOID GATT_DiscAllChars(connHandle, svcStartHdl,svcEndHdl, selfEntity);
    and
    VOID GATT_DiscAllChars(connHandle, svcStartHdl, 0xFFFF, selfEntity);

    But both of them didn't work and only found three handles.

    Looking forward to your reply.

    Regards,
    Jacob
  • Hey Jacob,

    What is your scvStartHdl being returned as? Could you try setting it to 0x01 in addition to the svcEndHdl being kept at 0xFFFF?
    A similar thread here might be helpful: e2e.ti.com/.../537724

    -Sy Su
  • Hi Sy Su,

    Thanks for your reply.

    The scvStartHdl is assigned the right value, because the first three characteristics can be found. I also tried setting it to 0x01 and kept svcEndHdl at 0xFFFF, but it didn't work.

    I found the similar question was mentioned in that thread, but I am not sure how to modify code. It said " I think the reason you are only seeing 3 pairs is that you are only displaying the number of pairs in one data packet." But I have no idea how to display in more than one data packet. Could you please give me a detailed explanation?

    Best regards,
    Jacob
  • Hey Jacob,

    The size of a single data packet is determined by the MAX_PDU_SIZE (PDU = Protocol Data Unit). It does look like the default PDU size only allows for 3 pairs.
    You can try increasing the MAX_PDU_SIZE preprocessor symbol in the application settings to allow more pairs come in at a single data packet.

    -Sy Su
  • Hi Sy Su,

    Really sorry to reply you late. I have tried to double the size of PDU, but it still could only find three pairs. Do you think if other reasons can also cause that problem?

    Thank you so much!

    Best regards,
    Jacob
  • Hey Jacob,

    I have it set to MAX_PDU_SIZE=70 and I am able to find the three five pairs.
    Can you try that out?

    -Sy Su

    Edit: Meant to say five not three

  • Hi Sy Su,

    I am able to only find three pairs before and after MAX_PDU_SIZE was changed. However there are five pairs (characteristics) in total. I want to find all 5 pairs at the same time. Are you able to find more than 3 pairs?

    Thanks,
    Jacob
  • Jacob,

    Oh my apologies. I meant to say 5 pairs in my reply.

    With the MAX_PDU_SIZE set to the higher value, yes I am. Here is my relevant code snippet from SimpleBLECentral_processGATTDiscEvent:

     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;
            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))
        {
          uint8_t numPairs = pMsg->msg.readByTypeRsp.numPairs; // this returns 5
          
          Display_print1(dispHandle, 3, 0, "Num Pairs: %d", numPairs);
          
          charHdl = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0],
                                 pMsg->msg.readByTypeRsp.pDataList[1]);
    
          Display_print0(dispHandle, 2, 0, "Simple Svc Found");
          procedureInProgress = FALSE;
        }
    
        discState = BLE_DISC_STATE_IDLE;
      }

    Here's a screenshot of my locals window showing numPairs is 5:

    -Sy Su