Part Number: CC2640
Hi all,
This is Anil. I am working on the CC2640 Central part. In this one i want to check the data which is sent by peripheral by using the characteristics.
Here i am getting the particular peripheral Service UUID, Characteristics handle, Service handle.
Now i need a data which is sent by Peripheral.
Central Code:
static void SimpleBLECentral_processGATTDiscEvent(gattMsgEvent_t *pMsg)
{
static char c=0;
static char j=0;
if (discState == BLE_DISC_STATE_MTU)
{
// MTU size response received, discover simple service
if (pMsg->method == ATT_EXCHANGE_MTU_RSP)
{
uint8_t uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_SERV_UUID),
HI_UINT16(SIMPLEPROFILE_SERV_UUID) };
// Just in case we're using the default MTU size (23 octets)
Display_print1(dispHandle, 4, 0, "MTU Size: %d", ATT_MTU_SIZE);
discState = BLE_DISC_STATE_SVC;
// Discovery simple service
VOID GATT_DiscPrimaryServiceByUUID(connHandle, uuid, ATT_BT_UUID_SIZE,
selfEntity);
memcpy( UUID_TEMP , uuid, 2); // Getting Service UUID Here
}
}
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)
{
start = svcStartHdl = ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0); //Service Handle
end = 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;
TEMP[c++] = req.startHandle = svcStartHdl;
TEMP[c++] = req.endHandle = svcEndHdl;
TEMP[c++] = req.type.len = ATT_BT_UUID_SIZE;
// TEMP[3] = req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR1_UUID);
// TEMP[4] = req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR1_UUID);
TEMP[c++] = req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR5_UUID);
TEMP[c++] = req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR5_UUID); //Characteristics ID here
VOID GATT_ReadUsingCharUUID(connHandle, &req, selfEntity);
// GATT_ReadCharValue(connHandle, &req, selfEntity);
// memcpy(GAP_DATA,pMsg->msg.readRsp.pValue,pMsg->msg.readRsp.len);
}
}
}
else if (discState == BLE_DISC_STATE_CHAR)
{
// Characteristic found, store handle
if ((pMsg->method == ATT_READ_BY_TYPE_RSP) &&
(pMsg->msg.readByTypeRsp.numPairs > 0))
{
temp[j] = charHdl = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0],
pMsg->msg.readByTypeRsp.pDataList[1]); //Characteristics Handle
Display_print0(dispHandle, 2, 0, "Simple Svc Found");
procedureInProgress = FALSE;
By this one i am getting all the details whichever i mentioned above. now i am trying to read or write data using CC2640 Central.
How to do it.?
Thanks
Anil D.