请教:Z-Stack3.0.2 ZNP的应用

芯片型号:CC2530F256

协议栈:Z-Stack3.0.2

测试:通过Z-TOOL2.0

Start Time: 2019/9/4 2:16:49

*** WARNING ***
Expected Z-Stack version (2.7.1) does not match with actual Z-Stack version (2.7.2). Z-Tool may not work properly.

<TX>02:18:31.78 COM1 SYS_OSAL_NV_WRITE (0x2109)
Id: 0x0003
Offset: 0x00
Len: 0x01
Value: . (0x03)

<RX>02:18:31.81 COM1 SYS_OSAL_NV_WRITE_SRSP (0x6109)
Status: SUCCESS (0x0)

<TX>02:18:57.53 COM1 SYS_RESET (0x4100)
Type: 0x00 (HARD RESET) (0x0)

<RX>02:19:00.64 COM1 SYS_RESET_RESPONSE (0x4180)
Reason: 0x02
TransportRev: 0x02
Product: 0x00
MajorRel: 0x02
MinorRel: 0x07
HwRev: 0x02

<TX>02:21:17.02 COM1 SYS_OSAL_NV_WRITE (0x2109)
Id: 0x0057
Offset: 0x00
Len: 0x01
Value: . (0x00)

<RX>02:21:17.06 COM1 SYS_OSAL_NV_WRITE_SRSP (0x6109)
Status: INVALID_PARAMETER (0x2)

<TX>02:35:40.69 COM1 SYS_OSAL_NV_WRITE (0x2109)
Id: 0x0057
Offset: 0x00
Len: 0x01
Value: . (0x00)

<RX>02:35:40.73 COM1 SYS_OSAL_NV_WRITE_SRSP (0x6109)
Status: INVALID_PARAMETER (0x2)

<TX>02:39:32.9 COM1 APP_CNF_BDB_START_COMMISSIONING (0x2F05)
CommissioningMode: (0x04) Network Formation (0x4)

<RX>02:39:39.26 COM1 APP_CNF_BDB_START_COMMISSIONING_SRSP (0x6F05)
Status: SUCCESS (0x0)

<RX>02:39:39.26 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)

<RX>02:39:39.27 COM1 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
Status: 1 (0x1)
Commissioning Mode: 0x02 (Formation) (0x2)
Commissioning Mode: 0x04 (Network Formation) (0x4)

<RX>02:39:39.53 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)

<RX>02:39:39.79 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)

<RX>02:39:40.06 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)

<RX>02:39:40.32 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)

<RX>02:39:40.59 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)

<RX>02:39:41.15 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 9 (0x9)

<RX>02:39:41.15 COM1 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
Status: 0x00 (Success) (0x0)
Commissioning Mode: 0x02 (Formation) (0x2)
Commissioning Mode: 0 (0x0)

<TX>02:40:35.8 COM1 UTIL_GET_DEVICE_INFO (0x2700)

<RX>02:40:35.81 COM1 UTIL_GET_DEVICE_INFO_RESPONSE (0x6700)
Status: SUCCESS (0x0)
IEEEAddr: 0x00124B0007665581
ShortAddress: 0x0000
DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
DeviceState: DEV_ZB_COORD (0x9)
NumAssocDevices: 0x00
AssocDevicesList

做了以上操作,也可以获取设备信息

看论坛帖子说下来该注册端点和发送数据。问题如下:

1、端点注册AF_REGISTER

EndPoint: 
AppProfID: 
AppDeviceId: 
AppDevVer: 
LatencyReq: 
AppNumInClusters:
AppInClusterList: 
AppNumOutClusters: 
AppOutClusterList: 

2、AF_DATA_REQUEST (0x2401)

DstAddr: 
DestEndpoint: 
SrcEndpoint: 
ClusterID: 
TransID: 
Options: 
Radius: 
Len: 
Data: 

以上参数怎么获取?该怎么填,有那些资料可以参考?

3、终端用的是Z-Stack 3.0.2  SampleLight例程,把控制回路增加到三路,目前用SampleSwitch作协调器

可以控制其中的一路,若用ZNP协调器控制是不是要注册三个端点?谢谢!

35 个回复

  • 回复 YiKai Chen:

    您好!非常感谢您的耐心指导和帮助!刚才试了下,按您给的数据格式目前端点7可以控制,端点8

    和9不行,现端点7的数据会自动变成5位,我设置时是一样的端点8和9显示的是3位,截图及数据包

    如下:

    端点7:

    端点8:

    端点9:

    抓包文件:0907_Test_3.rar

    再次感谢您的支持和帮助!谢谢!

  • 回复 user5228474:

    你要控制的SampleLight 例程端点是?

    YK Chen

  • 回复 YiKai Chen:

    您好!非常感谢您的帮助和支持!我用Z-Stack 3.0.2  SampleLight的例程添加了两个回路后作为协调器内存不足报错

    我就把SampleLight设置为终端,源代码端点是8,新添加的端点是7和9,截图如下:

    谢谢!

  • 回复 user5228474:

    你的0907_Test_3.rar抓包檔沒有入網過程,我沒有辦法解碼,感覺上是你的SampleLight有問題,你再重做一次包含重新入網過程的抓包讓我看看

    YK Chen

  • 回复 YiKai Chen:

    您好!十分感谢您的帮助和支持!我刚刚看了下SampleLight的代码感觉是有点问题,我先把代码检查一遍然后再试下看还有什么问题再抓包,然后回帖请教您!再次致以由衷的感谢!谢谢!
  • 回复 YiKai Chen:

    您好!首先感谢您的帮助和支持!现在的问题是这样;端点7开关没问题,端点8和9只能开,不能关。

    我昨晚和今天上午查了几遍代码没发现明显错误,还要麻烦您帮分析下是什么问题,Z-Tool截图如下,

    抓包档:0908_Test_1.rar

    设备信息:

    端点7开关操作:

    端点8开关操作:

    端点9开关操作:

    再次致以由衷的感谢!谢谢!

  • 回复 user5228474:

    抓包看來送給端点8和9的toggle命令是正確的,應該還是你端点8和9處理toggle命令的應用程序有問題,建議你調適看看

    YK Chen

  • 回复 YiKai Chen:

    您好!谢谢您的帮助和支持!我回头按您的建议再查下代码,现在仿真器出了点问题,我到时调试下看看。再次致以由衷的感谢!谢谢!
  • 回复 YiKai Chen:

    您好!首先感谢您的帮助和支持!现在端点7、8、9都可以控制了,我想让开关状态回馈给协调器

    并且在端点7的代码上做了如下添加:

    static void zclSampleLight_OnOffCB( uint8 cmd )
    {
    afIncomingMSGPacket_t *pPtr = zcl_getRawAFMsg();
    uint8 OnOff;
    zclSampleLight_DstAddr.addr.shortAddr=pPtr->srcAddr.addr.shortAddr;
    //////////////////////////////////////////////////////////////////////////////
    zclReportCmd_t rptcmd;//
    //////////////////////////////////////////////////////////////////////
    // Turn on the light
    if ( cmd == COMMAND_ON )
    {
    OnOff = LIGHT_ON;
    }
    // Turn off the light
    else if ( cmd == COMMAND_OFF )
    {
    OnOff = LIGHT_OFF;
    }
    // Toggle the light
    else if ( cmd == COMMAND_TOGGLE )
    {
    #ifdef ZCL_LEVEL_CTRL
    if (zclSampleLight_LevelRemainingTime > 0)
    {
    if (zclSampleLight_NewLevelUp)
    {
    OnOff = LIGHT_OFF;

    }
    else
    {
    OnOff = LIGHT_ON;
    }
    }
    else
    {
    if (zclSampleLight_OnOff == LIGHT_ON)
    {
    OnOff = LIGHT_OFF;
    }
    else
    {
    OnOff = LIGHT_ON;
    }
    }
    #else
    if (zclSampleLight_OnOff == LIGHT_ON)
    {
    OnOff = LIGHT_OFF;
    }
    else
    {
    OnOff = LIGHT_ON;
    }
    #endif
    }
    #ifdef ZCL_LEVEL_CTRL
    zclSampleLight_LevelChangeCmd = (OnOff == LIGHT_ON ? LEVEL_CHANGED_BY_ON_CMD : LEVEL_CHANGED_BY_OFF_CMD);
    zclSampleLight_DefaultMove(OnOff);
    #else
    zclSampleLight_OnOff = OnOff;
    #endif
    //////////////////////////////////回馈/////////////////////////////////////// 

    rptcmd.numAttr = 1;
    rptcmd.attrList[0].attrID = ATTRID_ON_OFF;
    rptcmd.attrList[0].dataType = ZCL_DATATYPE_BOOLEAN;
    rptcmd.attrList[0].attrData = (uint8*)&zclSampleLight_OnOff;
    zcl_SendReportCmd(SAMPLELIGHT_ENDPOINT,&zclSampleLight_DstAddr,ZCL_CLUSTER_ID_GEN_ON_OFF,
    &rptcmd,ZCL_FRAME_CLIENT_SERVER_DIR, false, 0 );
    zclSampleLight_UpdateLedState();

    //////////////////////////////////////////////////////////////////////////
    }

    但是在Z-Tool客户端看不到变化,客户端截图如下,端点9是没加回馈的,请帮忙分析下是什么原因,附抓包档:0909_Test_1.rar

    再次致以由衷的感谢!谢谢!

  • 回复 user5228474:

    你的抓包檔沒有入網過程,我沒辦法解碼,你可以用下面的範例程序報on/off 狀態

    zclReportCmd_t *pReportCmd;
    
      pReportCmd = osal_mem_alloc( sizeof(zclReportCmd_t) + sizeof(zclReport_t) );
      if ( pReportCmd != NULL )
      {
        pReportCmd->numAttr = 1;
        pReportCmd->attrList[0].attrID = ATTRID_ON_OFF;
        pReportCmd->attrList[0].dataType = ZCL_DATATYPE_UINT8;
        pReportCmd->attrList[0].attrData = (uint8*)&zclSampleLight_OnOff;
    
        zcl_SendReportCmd(SAMPLELIGHT_ENDPOINT, 0,ZCL_CLUSTER_ID_GEN_ON_OFF,
                                         pReportCmd, ZCL_FRAME_SERVER_CLIENT_DIR, TRUE, SeqNum++ );
      }
    
      osal_mem_free( pReportCmd );

    YK Chen