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.

CC2640R2F: Central connection with peripheral-SDK version 4_20_00_04.

Part Number: CC2640R2F


Hi 

I tried connecting  4857.HCITester Trace Log.htm

I tried connecting with central and peripheral.

when i am discovering with default GATT profile it's working fine.

Now I made custom profile with custom UUID.

In this case although the connection is getting established but out of 5 UUID only 3 UUID and their respective handle are getting discovered.

Then I tried the same using HCI tester then in that case all UUID and their handle are getting discovered.

static void SimpleCentral_processGATTDiscEvent(gattMsgEvent_t *pMsg)
{

if (discState == BLE_DISC_STATE_MTU)
{
// MTU size response received, discover simple service
if (pMsg->method == ATT_EXCHANGE_MTU_RSP)
{
#ifdef UseTestSvcUUID
uint8_t Test_uuid[ ATT_UUID_SIZE ] = {0x66,0x9A,0x0C,0x20,
0x00,0x08,0x96,0x9E,
0xE2,0x11,0x9E,0xB1,
0xE0,0xF2,0x73,0xB9};
#endif

#ifdef UseActualSvcUUID
uint8_t uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_SERV_UUID),
HI_UINT16(SIMPLEPROFILE_SERV_UUID) };
#endif
discState = BLE_DISC_STATE_SVC;

// Discovery simple service
#ifdef UseTestSvcUUID
VOID GATT_DiscPrimaryServiceByUUID(connHandle, Test_uuid, ATT_UUID_SIZE,
selfEntity);
#endif

#ifdef UseActualSvcUUID
VOID GATT_DiscPrimaryServiceByUUID(connHandle, uuid, ATT_BT_UUID_SIZE,
selfEntity);
#endif
}
}
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)
{
// 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 *pairs = &pMsg->msg.readByTypeRsp.pDataList[3];

numPairs = pMsg->msg.readByTypeRsp.numPairs;
uint16_t pairLen = pMsg->msg.readByTypeRsp.len;

if( numPairs <= cMaxNumUUID )
{
for (uint16_t idx = 0; idx < numPairs; idx++,pairs += pairLen)
{
uint16_t handle = *(uint16_t *)&pairs[0];
uint16_t uuid = *(uint16_t *)&pairs[14];

aUUID[handleIdx++] = uuid;
aUUID_Handle[uuidIdx++] = handle;
}
Display_print0(dispHandle, 2, 0, "Simple Svc Found");
procedureInProgress = FALSE;
}
else
{
/* Num of UUID exceeds the valid range - connection break */
SimpleCentral_stopEstablishing( );
}
}
discState = BLE_DISC_STATE_IDLE;
}
}

The above code performs the UUID and their handle discovery. Although it works fine with fresh Simple peripheral.

Regards

Sudhanshu

  • Also num pairs value is coming 3 when device is getting connected and svc start handle and svc end handle are 0x0015 and 0xFFFF.

    Now when i fix the start handle and end handle as 0x0001 and 0xFFFF numpairs value comes 5 but UUID and handle are not getting discovered correctly.  

  • Hey Sudhanshu,

    I've assigned an expert to comment. Have you seen the issue using Host_test? Perhaps there is a setting in HCI tester that limits this. I've never had an issue with Host_test in this regard.

  • Hi Ammar

    Can you please explain how HCI tester limits this as this issue is not getting re created while I'm using HCI tester.

    Regards

    Sudhanshu

  • Hey Sudhanshu,

    I think I misunderstood your original post. I assumed since you wrote, "Although it works fine with fresh Simple peripheral" that it may have been an HCI test related issue, so I'm sorry for that. There isn't a limitation of HCI tester, rather I should have said that HCI tester needs to be configured and used correctly. I see in your post that HCI tester has no issues, so this is good!

    Since the issue does not occur on HCI tester, I also assume that a third party app like Light Blue successfully discovers the custom profile correctly. This would be good to verify as well.

    To summarize, the issue here is that a custom profile (with custom UUID) is not properly discovered using the default simple central example? Please correct me if I misunderstood.

  • Hi Ammar

    You understood it right.

    When I am discovering the custom profile with HCI tester or any third party app it works fine but with simple central only first 3 UUID and their handle get discovered.

    Also the service start handle and end handle arguments that are passed in VOID GATT_DiscAllChars(connHandle,svcStartHdl,svcEndHdl,selfEntity);

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

    Is it liable to fix the values of start and end handle as 0x0001 and 0xFFFF ?

    Regards

    Sudhanshu

  • Hi Sudhanshu,

    Just to verify, are you finding only 3 services, or only 3 characteristics?

    Best Regards,
    Alec

  • Hi

    I'm discovering only 1 service and within that service there are 5 characteristics but I'm able to discover only 3.

    Regards

    Sudhanshu

  • Hi Sudhanshu,

    Would you be able to go through the  else if "(discState == BLE_DISC_STATE_SVC)" case inside of the SimpleCentral_processGATTDiscEvent function and try to find where things begin to become unaligned with what you expect? Since I will not be able to recreate this issue on my end, I will have to rely on whatever debugging you are able to perform. Let me know what you find.

    Best Regards,
    Alec

  • Hi Alec

    static void SimpleCentral_processGATTDiscEvent(gattMsgEvent_t *pMsg)
    {
     
      if (discState == BLE_DISC_STATE_MTU)
      {
        // MTU size response received, discover simple service
        if (pMsg->method == ATT_EXCHANGE_MTU_RSP)
        {
    
          uint8_t Test_uuid[ ATT_UUID_SIZE ] = {0x66,0x9A,0x0C,0x20,
                                                0x00,0x08,0x96,0x9E,
                                                0xE2,0x11,0x9E,0xB1,
                                                0xE0,0xF2,0x73,0xB9};
    
          discState = BLE_DISC_STATE_SVC;
    
          // Discovery simple service
    
          VOID GATT_DiscPrimaryServiceByUUID(connHandle, Test_uuid, ATT_UUID_SIZE,
                                             selfEntity);
          discState = BLE_DISC_STATE_SVC;
    
        }
       
      }
      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)
          {
            // 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 *pairs = &pMsg->msg.readByTypeRsp.pDataList[3];/* Iteration */
         
          numPairs = pMsg->msg.readByTypeRsp.numPairs;
          uint16_t pairLen = pMsg->msg.readByTypeRsp.len;
          
          for (uint16_t idx = 0; idx < numPairs; idx++,pairs += pairLen)
          {
            uint16_t handle = *(uint16_t *)&pairs[0];
            uint16_t uuid = *(uint16_t *)&pairs[14];
            
            aUUID[handleIdx++] = uuid;
            aUUID_Handle[uuidIdx++] = handle;
          }   
          procedureInProgress = FALSE;
        }
        }
        discState = BLE_DISC_STATE_IDLE;
      }
    }

    The above code snippet defines my characteristic discovery with their respective handles.

    1. Num pairs signifies the number of UUID and their respective handles.

    2. When i pass the svc start handle and end handle discovered , then  num pairs value is coming 3 and I am able to discover all those 3 but total there are 5 characteristics within this service.

    3. At the same time when I fix the svc start and end handle as 0x0001 and 0xFFFF then num pairs gets updated to 5 but none of the characteristics gets discovered. In both the cases the connection gets established.

    Regards

    Sudhanshu

  • Hi Sudhanshu,

    If you connect to this device using host_test + BTool, what does your service + characteristic hierarchy look like? Does the discovery function properly? And does it look correct there? Feel free to include a screenshot of that as well.

    Best Regards,
    Alec