Hi,
I am running Multi-role project on CC2640R2 LaunchPad which is running as Central.
I am trying to figure out how to find the service after connected to the Peripheral.
These were what I did:
1. Use 'Light Blue' application on iPad to create a 'Find Me' immediately alert service (UUID: 0x1802)
2. In 'static void multi_role_processGATTDiscEvent(gattMsgEvent_t *pMsg)' function, I modified the code to look for UUID 0x1802, as followings:
VOID GATT_DiscPrimaryServiceByUUID(pMsg->connHandle, 0x1802, ATT_BT_UUID_SIZE, selfEntity);
3. I used BTN to trigger 'Scan' and saw the 'Immediately Alert Service' found (UUID: 0x1802), as the following message (I added this message):
UUID: 1802, Name: Find Me 1, Addr: 0x7921F3A6726D
4. In 'static void multi_role_processGATTDiscEvent(gattMsgEvent_t *pMsg)' function, I did see the 'ATT_EXCHANGE_MTU_RSP' event (method). In other words, 'if (pMsg->method == ATT_EXCHANGE_MTU_RSP)' was TRUE.
But, in the next state: 'BLE_DISC_STATE_SVC', the 'pMsg->method' was getting: ATT_ERROR_RSP. The 'discInfo[connIndex].svcStartHdl' = 0 too.
In other words, LaunchPad did not find the service.
Don't know why. I think I already put the correct UUID 0x1802 and the service should have been found. Indeed, I also modified code to try other service, like: Health Thermometer (UUID: 0x1809). But, I got the same problem.
What were my problems for this issue?
I looked the following link and did not get enough information for my problem.
Here is the part of code:
{
// MTU size response received, discover simple service
if (pMsg->method == ATT_EXCHANGE_MTU_RSP)
{
discInfo[connIndex].discState= BLE_DISC_STATE_SVC;
VOID GATT_DiscPrimaryServiceByUUID(pMsg->connHandle, 0x1802, ATT_BT_UUID_SIZE, selfEntity);
}
}
// If we're performing service discovery
else if (discInfo[connIndex].discState == BLE_DISC_STATE_SVC)
{
// Service found, store handles
if (pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP &&
pMsg->msg.findByTypeValueRsp.numInfo > 0)
{
discInfo[connIndex].svcStartHdl = ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
discInfo[connIndex].svcEndHdl = ATT_GRP_END_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0);
}
if (((pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP) &&
(pMsg->hdr.status == bleProcedureComplete)) ||
(pMsg->method == ATT_ERROR_RSP))
{
// If we've discovered the service
if (discInfo[connIndex].svcStartHdl != 0)
{
attReadByTypeReq_t req;
discInfo[connIndex].discState = BLE_DISC_STATE_CHAR;
req.startHandle = discInfo[connIndex].svcStartHdl;
req.endHandle = discInfo[connIndex].svcEndHdl;
// Steven Cao, 2/11/2019
req.type.len = sizeof(iNxCmdChar.charValueUUID);
memcpy((void *)req.type.uuid, (const void *)iNxCmdChar.charValueUUID, sizeof(iNxCmdChar.charValueUUID));
VOID GATT_DiscCharsByUUID(pMsg->connHandle, &req, selfEntity);
}
}
}
Thanks,
Steven