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.

CC2640R2F multi_role怎么接收从机notify

连接成功后,从机每隔一段时间发送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);
          }
        }
      }
    

  • 你好,是这个吗?
    // Register to receive incoming ATT Indications/Notifications
    GATT_RegisterForInd(selfEntity);
    这个在初始化的时候就有了
    另外也有实现你这一部分的代码
  • 你好,我是要multi_role这个工程主机接收notify;SimpleBLECentral这个工程我已经实现了
  • 你好,我在从机发送nofity的实现上遇到了问题,请问你是利用哪个工程实现的?