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.

Z-Stack 3.0.1 AF_DataRequest数据收发不能进入afBuildMSGIncoming函数,怎么修改呢?修改afIncomingData函数吗?

Other Parts Discussed in Thread: Z-STACK

想在Z-Stack 3.0.1协议栈中使用AF_DataRequest函数,数据由router发送到coordinator,但是调试的时候发现不能进入SYS_EVENT_MSG中的AF_INCOMING_MSG_CMD事件。单步调试发现在AF.c文件中能进入afIncomingData函数,但是在该函数内不会进入afBuildMSGIncoming调用的if语句判断中,如下:

能正常建立连接,数据也能成功发送,但是就收不到数据。

自己在zcl_genericapp.c中定义的clusterID:

#define GROUP_ID                21      
#define CLUSTER_P2P             0
#define CLUSTER_BROADCAST       1
#define CLUSTER_GROUPCAST       2

端点描述符:

static endPointDesc_t appTransTest =
{
  GENERICAPP_ENDPOINT,                  // endpoint
  0,
  &zclGenericApp_TaskID,
  (SimpleDescriptionFormat_t *)NULL,
  //(SimpleDescriptionFormat_t *)&zclGenericApp_SimpleDesc,  // No Simple description for this test endpoint
  (afNetworkLatencyReq_t)0            // No Network Latency req
};

建立连接和初始化发送事件:

void zodDeviceInit(void)
{
#ifdef ZDO_COORDINATOR // if this device is coordinator
  bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_FORMATION |    // creat network
                         BDB_COMMISSIONING_MODE_FINDING_BINDING);
  
  printf("this is coordinator\r\n");
  
  NLME_PermitJoiningRequest(0xff); // network will always open for router
  
#else
  bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_STEERING |          // join network
                         BDB_COMMISSIONING_MODE_FINDING_BINDING);
  
  // - AF -
  aps_Group_t group = {
    .ID = GROUP_ID,
    .name = "",
  };
  aps_AddGroup(GENERICAPP_ENDPOINT, &group);
  
  // - p2p -
  osal_start_timerEx(zclGenericApp_TaskID, APP_AF_P2P_EVENT, 
                     27000);
  
  
  printf("this is router\r\n");
#endif
  
  HalLedSet(HAL_LED_1, HAL_LED_MODE_OFF);
}

router发送数据函数:

void zclApp_AF_P2P(uint16 destNwkAddr, uint16 cid, uint8 len, uint8 *data)
{
  afAddrType_t dstAddr;
  static uint8 transferID = 0;
  
  // - destination -
  dstAddr.addrMode = afAddr16Bit;       // destination device ID
  dstAddr.addr.shortAddr = destNwkAddr; // net serial
  dstAddr.endPoint = GENERICAPP_ENDPOINT; // port number
  
  transferID++;

  AF_DataRequest(&dstAddr, &appTransTest, cid, len, data, &transferID, 
                 AF_DISCV_ROUTE, AF_DEFAULT_RADIUS);
}

router数据发送函数的调用方式:

  if(events & APP_AF_P2P_EVENT)
  {
    zclApp_AF_P2P(0x0000, CLUSTER_P2P, 3, "p2p");
    printf("transmit data - p2p\r\n");
    osal_start_timerEx(zclGenericApp_TaskID, APP_AF_P2P_EVENT, 
                     APP_AF_P2P_PERIOD);
    return (events ^ APP_AF_P2P_EVENT);
  }

求大佬们能够帮忙分析分析,谢谢!