TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2640R2F multi_role怎么接收从机notify

连接成功后,从机每隔一段时间发送notify;使用手机及simple_central接收正常;

static void SimpleBLECentral_processGATTMsg(gattMsgEvent_t *pMsg)//是用这个函数接收吧?调试的时候都没进来

Alvin Chen:

你使能Notify了没?主机需要打开使能:

attWriteReq_t writeReq;writeReq.pValue = GATT_bm_alloc(connHandle, ATT_WRITE_REQ, 2, NULL);if (writeReq.pValue != NULL){writeReq.len = 2;writeReq.pValue[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);writeReq.pValue[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);writeReq.sig = 0;writeReq.cmd = 0;writeReq.handle = charHdl;// Send the read requestif (GATT_WriteCharValue(connHandle, &writeReq,selfEntity) != SUCCESS){GATT_bm_free((gattMsg_t *)&writeReq, ATT_WRITE_REQ);}}
//具体的特征值和句柄要去自己获取。else if (discState == BLE_DISC_STATE_SVC){// Service found, store handlesif (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 completeif (((pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP) &&(pMsg->hdr.status == bleProcedureComplete))||(pMsg->method == ATT_ERROR_RSP)){if (svcStartHdl != 0){attReadByTypeReq_t req;// Discover characteristicdiscState = BLE_DISC_STATE_CHAR;req.startHandle = svcStartHdl;req.endHandle = svcEndHdl;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);VOID GATT_ReadUsingCharUUID(connHandle, &req, selfEntity);}}}

user4997147:

回复 Alvin Chen:

你好,是这个吗?
// Register to receive incoming ATT Indications/Notifications
GATT_RegisterForInd(selfEntity);
这个在初始化的时候就有了
另外也有实现你这一部分的代码

Susan Yang:

回复 user4997147:

请您参考一下 blog.csdn.net/…/52471305 进行修改

user4997147:

回复 Susan Yang:

你好,我是要multi_role这个工程主机接收notify;SimpleBLECentral这个工程我已经实现了

z z46:

回复 user4997147:

你好,我在从机发送nofity的实现上遇到了问题,请问你是利用哪个工程实现的?

赞(0)
未经允许不得转载:TI中文支持网 » CC2640R2F multi_role怎么接收从机notify
分享到: 更多 (0)