连接成功后,从机每隔一段时间发送notify;使用手机及simple_central接收正常;
static void SimpleBLECentral_processGATTMsg(gattMsgEvent_t *pMsg)//是用这个函数接收吧?调试的时候都没进来
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.
连接成功后,从机每隔一段时间发送notify;使用手机及simple_central接收正常;
static void SimpleBLECentral_processGATTMsg(gattMsgEvent_t *pMsg)//是用这个函数接收吧?调试的时候都没进来
你使能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 request if (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 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) { attReadByTypeReq_t req; // Discover characteristic discState = 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); } } }