CC2340R5: Invalid response length after calling GATT_DiscAllChars

Part Number: CC2340R5

Tool/software:

Hi,

Chipset: CC2340R5

sdk:

Hi I am currently using one CC2340R5 EVK (Central EVK)for development and I am running the EVK in central role, Basic ble sdk is used as a base project.

I am using another CC2340R5 EVK(Peripheral EVK) in peripheral  mode, the basic ble sdk code is used as a base project.

I have The gatt table of the evk running in peripheral role using nrf connect and it is attached below. After collecting this info, I disconnect the peripheral device from nRF connect.

 

Now, using the "Central EVK" I connect to the "Peripheral EVK". After the connection is successful, I initiate a service discovery call as shown below:

I have used the Log_printf function to print the response for the service discovery, and it is as follows:

I have saved the service discovery response in a queue. 

Later,  I call retrieve the service discovery response from the queue and call the  "GATT_DiscAllChars" APIas shown below.

I get a "ATT_READ_BY_GRP_TYPE_RSP" rsp and after parsing, I have printed the contents of " attReadByGrpTypeRsp_t" below.

as you can see, the dataLen field contains a very huge number. 

What could be the issue here? I am not able to proceed further due to this, Please help me resolve this. 

In addition, I have also added the logic that I have used to parse the "attReadByGrpTypeRsp_t" structure.

  • Hello,

    You shouldn't be getting an ATT_READ_BY_GRP_TYPE_RSP, since GATT_DiscAllChars returns ATT_READ_BY_TYPE_RSP which uses a different structure.

    https://dev.ti.com/tirex/content/simplelink_lowpower_f3_sdk_8_10_01_02/docs/ble5stack/ble_user_guide/doxygen/ble/html/group___a_t_t___g_a_t_t.html#gac824af509fbd28c84ae6a1d1d4a1ba11

    Are you receiving ATT_READ_BY_GRP_TYPE_RSP instead of ATT_READ_BY_TYPE_RSP? Do you mind sending over your handler code so I can review it?

    Best,

    Nima Behmanesh

  • Hi Nima, 

    Thanks for pointing out the mistake. I posted the wrong snippets. Please find my GATT_EvenHandler below.

    static void GATT_EventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData)
    {
      gattMsgEvent_t *gattMsg = ( gattMsgEvent_t * )pMsgData;
      switch ( gattMsg->method )
      {
        case ATT_FLOW_CTRL_VIOLATED_EVENT:
          {
              MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE, 0, "GATT status: ATT flow control is violated");
          }
          break;
    
        case ATT_MTU_UPDATED_EVENT:
          {
              MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE, 0, "GATT status: ATT MTU update to %d",
                                gattMsg->msg.mtuEvt.MTU);
              Log_printf(LogModule_App1, Log_INFO, "MTU updated to: %d", gattMsg->msg.mtuEvt.MTU);
    
          }
          break;
        case ATT_READ_BY_GRP_TYPE_RSP:
        {
    
            MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE, 0, "GATT status: ATT MTU update to %d",
                              gattMsg->msg.mtuEvt.MTU);
    
            attReadByGrpTypeRsp_t *resp = (attReadByGrpTypeRsp_t *)&(gattMsg->msg.readByGrpTypeRsp);
    
            Log_printf(LogModule_App1, Log_INFO, "response len: %d", resp->len);
            Log_printf(LogModule_App1, Log_INFO, "num groups: %d", resp->numGrps);
            if(resp->len)
            {
                sendSvcDiscRsp(resp->pDataList, resp->len); // save data to queue.
            }
    
        }break;
    
        case ATT_READ_BY_TYPE_RSP :
        {
            attReadByTypeRsp_t * resp = (attReadByTypeRsp_t *)&(gattMsg->msg.readByTypeRsp);
    
    
            Log_printf(LogModule_App1, Log_INFO, "response len: %d", resp->len);
            Log_printf(LogModule_App1, Log_INFO, "numPairs: %d", resp->numPairs);
            Log_printf(LogModule_App1, Log_INFO, "dataLen: %d", resp->dataLen);
            for(int i=0; i < resp->len; i++)
            {
                Log_printf(LogModule_App1, Log_INFO, "%d", resp->pDataList[i]);
            }
        }break;
       
        default:
          break;
      }
    }

    I am receiving "ATT_READ_BY_TYPE_RSP" The parsing logic is present in the above code snippet.

    I print the contents of "attReadByTypeRsp_t" structure and get  a very value for the  datalength field. 

    I have also printed the raw data contents of "attReadByTypeRsp_t" below, the below contents are results of a different handle search.

    gattMsg->msg.readByTypeRsp.len = 7;
    gattMsg->msg.readByTypeRsp.numPairs = 0x05;
    gattMsg->msg.readByTypeRsp.pDataList = 0xC3, 0x43, 0x00, 0x20; 
    gattMsg->msg.readByTypeRsp.dataLen = 0xEB11; // Very large

    0x05, 0x00,  0x07, 0x00, 0xC3, 0x43, 0x00, 0x20, 0x11, 0xEB

  • Hi,

    This is definitely, strange by reading the attReadbyTypeRsp_t structure, you may not need this field.

    For instance, here is how I parse it:

            display_index += 1;
            attReadByTypeRsp_t *response = (attReadByTypeRsp_t *)&(gattMsg->msg.readByTypeRsp);
            MenuModule_printf(display_index, 0, "GATT status: Read by type %d", response->numPairs);
    
            for (int i = 0; i < response->numPairs; i++)
            {
                uint16_t attributeHandle = BUILD_UINT16(response->pDataList[i * response->len + 0],
                                                        response->pDataList[i * response->len + 1]);
    
                uint16_t endHandle = BUILD_UINT16(response->pDataList[i * response->len + 2],
                                                  response->pDataList[i * response->len + 3]);
    
                display_index += 1;
                MenuModule_printf(display_index, 0, "GATT status: Read by type: Handle: %x | %x", attributeHandle, endHandle);
            }
            break;

    Can you try this and let me know the results?

    Best,
    Nima Behmanesh

  • Hi Nima, 

    I will be back to office tomorrow, I will try this an keep you posted. But it very strange to get such huge values, Could you check what could be the reason for this?

  • Hi Sandeep,

    I will need to contact R&D and reproduce the issue on my side as well. What SDK version are you using? I believe it was missing from your original post.

    Best,
    Nima Behmanesh

  • Hi Nima, 

    The SDK version that I am currently using is "simplelink_lowpower_f3_sdk_8_10_01_02".

  • Hello,

    Thanks! I'll try it and get back to you.

    Best,
    Nima Behmanesh

  • Hi Sandeep,

    I'm still looking into this, and will get back to you no later than Friday.

    Best,
    Nima Behmanesh

  • Hi Sandeep,

    Do the holidays, my responses will be a little bit delayed. Thank you for your patience in resolving this issue.

    Best,
    Nima Behmanesh

  • Thank you for keeping me posted. I Hope that we can find a solution soon.

  • Hi Sandeep,

    Do you mind testing on the latest SDK to see if the issue still persists?

    Best,
    Nima Behmanesh