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.

ZigBee 3.0 AF_DataRequest使用问题

ZigBee 3.0  GenericApp例程,终端发送的时候使用下面的函数

if ( AF_DataRequest( &GenericApp_DstAddr, &GenericApp_epDesc,
GENERICAPP_CLUSTERID,
1,
(uint8 *)&GenericApp_SO,
&GenericApp_TransID,
AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )

其中GenericApp_SO=0x10;

GenericApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
GenericApp_DstAddr.endPoint = GENERICAPP_ENDPOINT;
GenericApp_DstAddr.addr.shortAddr = 0x0000;

// Fill out the endpoint description.
GenericApp_epDesc.endPoint = GENERICAPP_ENDPOINT;
GenericApp_epDesc.task_id = &zclGenericApp_TaskID;
GenericApp_epDesc.simpleDesc = (SimpleDescriptionFormat_t *)&zclGenericApp_SimpleDesc;
GenericApp_epDesc.latencyReq = noLatencyReqs;
// Register the endpoint description with the AF
afRegister( &GenericApp_epDesc );

const SimpleDescriptionFormat_t GenericApp_SimpleDesc =
{
GENERICAPP_ENDPOINT, // int Endpoint;
GENERICAPP_PROFID, // uint16 AppProfId[2];
GENERICAPP_DEVICEID, // uint16 AppDeviceId[2];
GENERICAPP_DEVICE_VERSION, // int AppDevVer:4;
GENERICAPP_FLAGS, // int AppFlags:4;
GENERICAPP_MAX_CLUSTERS, // byte AppNumInClusters;
(cId_t *)GenericApp_ClusterList, // byte *pAppInClusterList;
GENERICAPP_MAX_CLUSTERS, // byte AppNumInClusters;
(cId_t *)GenericApp_ClusterList // byte *pAppInClusterList;
};

发送确实返回是afStatus_SUCCESS ,我用LED闪烁指示发送成功的,

但是接收端进入不了下面的代码:

case AF_INCOMING_MSG_CMD:
GenericApp_MessageMSGCB( MSGpkt );
break;

  • 看看你的地址以及end point对不对,请提供抓包文件看一下。
  • 先設個斷點在afBuildMSGIncoming里面看看有沒有收到
  • 终端给协调器单播发,地址是0没问题

    两边的endpoint都是8 

    #define GENERICAPP_ENDPOINT            8

    抓包如附件,请帮忙分析协调器AF_INCOMING_MSG_CMD收不到的原因

    001.psd

  • 0647.001.psd请帮忙分析抓包文件协调器AF_INCOMING_MSG_CMD收不到的原因

  • 你的GENERICAPP_CLUSTERID是0x0008嗎? GenericApp_SO是不是有時候會是0x10有時候是0x11?

  • GENERICAPP_CLUSTERID是8,GenericApp_SO在终端那边每按一下按键值变一下(0x10和0x11之间切换),
    另外在协调器端afBuildMSGIncoming里面打断点,也没有中断
    但是终端这边确实是返回afStatus_SUCCESS
    if ( AF_DataRequest( &GenericApp_DstAddr, &GenericApp_epDesc,
    GENERICAPP_CLUSTERID,
    (byte)sizeof( GenericApp_SO ) + 1,
    (uint8 *)&GenericApp_SO,
    &GenericApp_TransID,
    AF_SKIP_ROUTING , AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
  • 基于3.0.2的GenericApp例程,协调器2538,终端2530
    你那边能不能测试一下AF_DataRequest相互发,对方能不能收到,
    如果可以,麻烦把这块的代码贴给我,我这边怎么试对方都收不到(不触发AF_INCOMING_MSG_CMD)
  • 這樣看起來你的封包是有送出來的,而且协调器端有mac ack,代表协调器端有收到,你在設置斷點在afIncomingData內看看有沒有收到
  • afIncomingData可以进入,单步调试如下:
    else if ( (epDesc = afFindEndPointDesc( aff->DstEndPoint )) )//进入这里
    {
    pList = afFindEndPointDescList( epDesc->endPoint );//进入这里
    }
    while ( epDesc )
    {
    else if ( epDesc->simpleDesc )//进入这里
    {
    epProfileID = epDesc->simpleDesc->AppProfId;//进入这里
    }
    }
  • afIncomingData可以进入代表有收到了,那你往下调试看看為什麼他不走到afBuildMSGIncoming去
  • if ( (aff->ProfileID == epProfileID) ||
    ((epDesc->endPoint == ZDO_EP) && (aff->ProfileID == ZDO_PROFILE_ID)) ||
    ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) )

    这个判断通不过,
    aff->ProfileID=0x0F04,epProfileID=0x00FE
    epDesc->endPoint=8,ZDO_EP=0,ZDO_PROFILE_ID=0,ZDO_WILDCARD_PROFILE_ID =0xFFFF
    我是不是该改一下发送端的参数?改哪个?
  • 你的GENERICAPP_PROFID定義是?
  • #define GENERICAPP_PROFID 0x0F04
  • 那你應該調試一下為什麼你的epProfileID會是0x00FE
  • 我把#define GENERICAPP_PROFID 0x0F04改为0x00FE,怎么还是进不去
    此时aff->ProfileID == epProfileID成立,还是进不去
    if ( (aff->ProfileID == epProfileID) ||
    ((epDesc->endPoint == ZDO_EP) && (aff->ProfileID == ZDO_PROFILE_ID)) ||
    ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) )
    {
    // Save original endpoint
    uint8 endpoint = aff->DstEndPoint;

    // overwrite with descriptor's endpoint
    aff->DstEndPoint = epDesc->endPoint;

    afBuildMSGIncoming( aff, epDesc, SrcAddress, SrcPanId, sig,
    nwkSeqNum, SecurityUse, timestamp, radius );

    // Restore with original endpoint
    aff->DstEndPoint = endpoint;
    }
  • 你確定把#define GENERICAPP_PROFID 0x0F04改为0x00FE後此时aff->ProfileID == epProfileID就會成立?有沒有調試看看?
  • 修改GENERICAPP_PROFID 为0x0104后可以进入afBuildMSGIncoming
    但是还是不行,下面的MSGpkt == NULL为真,直接返回了,但是发的是有数据的啊
    怎么是空的呢

    static void afBuildMSGIncoming( aps_FrameFormat_t *aff, endPointDesc_t *epDesc,
    zAddrType_t *SrcAddress, uint16 SrcPanId, NLDE_Signal_t *sig,
    uint8 nwkSeqNum, uint8 SecurityUse, uint32 timestamp, uint8 radius )
    {
    afIncomingMSGPacket_t *MSGpkt;
    const uint8 len = sizeof( afIncomingMSGPacket_t ) + aff->asduLength;
    uint8 *asdu = aff->asdu;
    MSGpkt = (afIncomingMSGPacket_t *)osal_msg_allocate( len );

    if ( MSGpkt == NULL )
    {
    return;
    }
    ……
    }
  • MSGpkt == NULL为真的話,你要查一下為什麼osal_msg_allocate會返回空的MSGpkt
  • 我就在官方的例程上加了下面的代码?
    别的也没改什么?按说应该没问题的啊?
    估计是添加的代码的问题,麻烦帮忙看一下是不是代码的问题?
    if ( AF_DataRequest( &GenericApp_DstAddr, &GenericApp_epDesc,
    GENERICAPP_CLUSTERID,
    1,
    (uint8 *)&GenericApp_SO,
    &GenericApp_TransID,
    AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )

    其中GenericApp_SO=0x10;

    GenericApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
    GenericApp_DstAddr.endPoint = GENERICAPP_ENDPOINT;
    GenericApp_DstAddr.addr.shortAddr = 0x0000;

    // Fill out the endpoint description.
    GenericApp_epDesc.endPoint = GENERICAPP_ENDPOINT;
    GenericApp_epDesc.task_id = &zclGenericApp_TaskID;
    GenericApp_epDesc.simpleDesc = (SimpleDescriptionFormat_t *)&zclGenericApp_SimpleDesc;
    GenericApp_epDesc.latencyReq = noLatencyReqs;
    // Register the endpoint description with the AF
    afRegister( &GenericApp_epDesc );

    const SimpleDescriptionFormat_t GenericApp_SimpleDesc =
    {
    GENERICAPP_ENDPOINT, // int Endpoint;
    GENERICAPP_PROFID, // uint16 AppProfId[2];
    GENERICAPP_DEVICEID, // uint16 AppDeviceId[2];
    GENERICAPP_DEVICE_VERSION, // int AppDevVer:4;
    GENERICAPP_FLAGS, // int AppFlags:4;
    GENERICAPP_MAX_CLUSTERS, // byte AppNumInClusters;
    (cId_t *)GenericApp_ClusterList, // byte *pAppInClusterList;
    GENERICAPP_MAX_CLUSTERS, // byte AppNumInClusters;
    (cId_t *)GenericApp_ClusterList // byte *pAppInClusterList;
    };
    #define GENERICAPP_PROFID 0x0F04
    #define GENERICAPP_DEVICEID 0x0001
    #define GENERICAPP_DEVICE_VERSION 0
    #define GENERICAPP_FLAGS 0

    #define GENERICAPP_MAX_CLUSTERS 1
    #define GENERICAPP_CLUSTERID 1
    const cId_t GenericApp_ClusterList[GENERICAPP_MAX_CLUSTERS] =
    {
    GENERICAPP_CLUSTERID
    };
    #define GENERICAPP_ENDPOINT 8
  • 我把AF_INCOMING_MSG_CMD放在下面的函数里是不是不行?
    是不是这个原因导致无法触发AF_INCOMING_MSG_CMD
    下面的函数是不是只处理ZCL的指令?
    另外如果AF_INCOMING_MSG_CMD调不通,能否用ZCL_INCOMING_MSG处理私有数据?
    uint16 zclGenericApp_event_loop( uint8 task_id, uint16 events )
    {
    afIncomingMSGPacket_t *MSGpkt;

    (void)task_id; // Intentionally unreferenced parameter

    if ( events & SYS_EVENT_MSG )
    {
    while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zclGenericApp_TaskID )) )
    {
    switch ( MSGpkt->hdr.event )
    {
    case ZCL_INCOMING_MSG:
    // Incoming ZCL Foundation command/response messages
    zclGenericApp_ProcessIncomingMsg( (zclIncomingMsg_t *)MSGpkt );
    break;

    case CMD_SERIAL_MSG://添加
    SampleApp_SerialCMD((mtOSALSerialData_t *)MSGpkt);
    break;

    case AF_INCOMING_MSG_CMD://添加
    GenericApp_MessageMSGCB( MSGpkt );
    break;
    ……
    }
  • 應該不是这个原因导致无法触发AF_INCOMING_MSG_CMD
  • 你们有在3.0的协议栈上测试AF_DataRequest收发吗?
    或者哪个例程里面有,我借鉴一下,一直不通,不知道是什么原因?
    你们要是有参考例程我直接用就行了!
  • 我們在3.0的协议栈上都是透過ZCL收发,AF_DataRequest收发應該也是要沒問題,你還是調試清楚為什麼進到afBuildMSGIncoming後會有問題吧
  • ZCL能发私有数据吗?比如100个字节的私有数据,
    ZCL收发是哪个函数?
  • ZCL发数据是用zcl_SendReportCmd,可以发私有数据,100个字节的私有数据有點太長,建議分成50-50發送兩次