Hi All,
I'm trying to discover two characteristic handles, one after the other using the below code -
static void simpleBLEGATTDiscoveryEvent( gattMsgEvent_t *pMsg )
{
attReadByTypeReq_t req;
if ( simpleBLEDiscState == BLE_DISC_STATE_SVC )
{
// Service found, store handles
if ( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
pMsg->msg.findByTypeValueRsp.numInfo > 0 )
{
simpleBLESvcStartHdl = pMsg->msg.findByTypeValueRsp.handlesInfo[0].handle;
simpleBLESvcEndHdl = pMsg->msg.findByTypeValueRsp.handlesInfo[0].grpEndHandle;
}
// If procedure complete
if ( ( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
pMsg->hdr.status == bleProcedureComplete ) ||
( pMsg->method == ATT_ERROR_RSP ) )
{
if ( simpleBLESvcStartHdl != 0 )
{
// Discover characteristic
simpleBLEDiscState = BLE_DISC_STATE_CHAR;
req.startHandle = simpleBLESvcStartHdl;
req.endHandle = simpleBLESvcEndHdl;
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);
// GATT_ReadUsingCharUUID( simpleBLEConnHandle, &req, simpleBLETaskId );
GATT_DiscCharsByUUID( simpleBLEConnHandle, &req, simpleBLETaskId );
}
}
}
else if ( simpleBLEDiscState == BLE_DISC_STATE_CHAR )
{
if (simpleBLECharHdl == 0)
{
// Characteristic-1 found, store handle
if ( pMsg->method == ATT_READ_BY_TYPE_RSP &&
pMsg->msg.readByTypeRsp.numPairs > 0 )
{
// simpleBLECharHdl = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[0],
// pMsg->msg.readByTypeRsp.dataList[1] );
simpleBLECharHdl = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[(pMsg->msg.readByTypeRsp.len-4)],
pMsg->msg.readByTypeRsp.dataList[(pMsg->msg.readByTypeRsp.len-3)] );
LCD_WRITE_STRING( "Char-1 Svc Found", HAL_LCD_LINE_1 );
simpleBLEDiscState = BLE_DISC_STATE_AUTH;
req.startHandle = simpleBLESvcStartHdl;
req.endHandle = simpleBLESvcEndHdl;
req.type.len = ATT_BT_UUID_SIZE;
req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR2_UUID);
req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR2_UUID);
GATT_DiscCharsByUUID( simpleBLEConnHandle, &req, simpleBLETaskId );
}
}
}
else if ( simpleBLEDiscState == BLE_DISC_STATE_AUTH )
{
if (simpleBLEAuthHdl == 0)
{
// Characteristic-6 found, store handle
if ( pMsg->method == ATT_READ_BY_TYPE_RSP &&
pMsg->msg.readByTypeRsp.numPairs > 0 )
{
simpleBLEAuthHdl = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[(pMsg->msg.readByTypeRsp.len-4)],
pMsg->msg.readByTypeRsp.dataList[(pMsg->msg.readByTypeRsp.len-3)] );
LCD_WRITE_STRING( "Auth Svc Found", HAL_LCD_LINE_1 );
simpleBLEProcedureInProgress = FALSE;
simpleBLEDiscState = BLE_DISC_STATE_IDLE;
}
}
}
}
If I discover only one handle - either it is "SIMPLEPROFILE_CHAR1_UUID" or "SIMPLEPROFILE_CHAR2_UUID" but if I try to discover "SIMPLEPROFILE_CHAR2_UUID" after "SIMPLEPROFILE_CHAR1_UUID" then I always get "pMsg->msg.readByTypeRsp.numPairs == 0" for the second handle.
Can anyone help me with my problem. Is there any way to discover multiple characteristic handles one after the other?
I'm fighting with this issue from long time and I couldn't figure out any solution.
Arjun