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.

how to configure attribute reporting with Z-STACK implemention

Other Parts Discussed in Thread: Z-STACK

I  want to use SampleLight and SampleSwitch with Z-STACK to  implement  the flowing funtions: When the state of light changes,SampleLight will inform SampleSwitch.In the document-ZIGBEE HOME AUTOMATION  PUBLIC APPLICATION PROFILE, I read this:

The ZCL provides a mechanism for clusters to report changes to the value ofvarious attributes. It also provides commands to configure the reporting
parameters.

but i don't know details.

please help 

  • To make SampleLight report on/off attribute when on/off status changes, you can refer to my reply in e2e.ti.com/.../396816
  • I have saw your answer in e2e.ti.com/.../396816, you provide flowing codes:


    rptcmd.numAttr = 1;

    rptcmd.attrList[0].attrID = ATTRID_ON_OFF;

    rptcmd.attrList[0].dataType = ZCL_DATATYPE_UINT8;

    rptcmd.attrList[0].attrData = (uint8*)&zclSampleLight_OnOff;

    zcl_SendReportCmd(SAMPLELIGHT_ENDPOINT, 0,

    ZCL_CLUSTER_ID_GEN_ON_OFF, &rptcmd,

    ZCL_FRAME_CLIENT_SERVER_DIR, false, 0 )


    i have a question:
    whether we should configue rptcmd.attrList[0].direction?
  • No, you don't have to.
  • hi Mr Chen , I modify my codes with your suggestion,but, there are still some problems

    in samlelight.c

    static void zclSampleLight_OnOffCB( uint8 cmd )
    {zclReportCmd_t rptcmd;
      // Turn on the light
      if ( cmd == COMMAND_ON )
        zclSampleLight_OnOff = LIGHT_ON;

      // Turn off the light
      else if ( cmd == COMMAND_OFF )
        zclSampleLight_OnOff = LIGHT_OFF;

     

      // Toggle the light
      else
      {
        if ( zclSampleLight_OnOff == LIGHT_OFF )
          zclSampleLight_OnOff = LIGHT_ON;
        else
          zclSampleLight_OnOff = LIGHT_OFF;
      }

      // In this sample app, we use LED4 to simulate the Light
      if ( zclSampleLight_OnOff == LIGHT_ON )
        HalLedSet( HAL_LED_1, HAL_LED_MODE_ON );
      else
        HalLedSet( HAL_LED_1, HAL_LED_MODE_OFF );
    rptcmd.numAttr = 1;

    rptcmd.attrList[0].attrID = ATTRID_ON_OFF;

    rptcmd.attrList[0].dataType = ZCL_DATATYPE_UINT8;

    rptcmd.attrList[0].attrData = (uint8*)&zclSampleLight_OnOff;

    zcl_SendReportCmd(SAMPLELIGHT_ENDPOINT, 0,

    ZCL_CLUSTER_ID_GEN_ON_OFF, &rptcmd,

    ZCL_FRAME_CLIENT_SERVER_DIR, false, 0 );


    }

    in sampleswtich.c

     

    static void zclSampleSw_ProcessIncomingMsg( zclIncomingMsg_t *pInMsg )
    {
      switch ( pInMsg->zclHdr.commandID )
      {
    #ifdef ZCL_READ
        case ZCL_CMD_READ_RSP:
          zclSampleSw_ProcessInReadRspCmd( pInMsg );
          break;
    #endif
    #ifdef ZCL_WRITE
        case ZCL_CMD_WRITE_RSP:
          zclSampleSw_ProcessInWriteRspCmd( pInMsg );
          break;
    #endif
    #ifdef ZCL_REPORT
        // See ZCL Test Applicaiton (zcl_testapp.c) for sample code on Attribute Reporting
        case ZCL_CMD_CONFIG_REPORT:
          //zclSampleSw_ProcessInConfigReportCmd( pInMsg );
          break;

        case ZCL_CMD_CONFIG_REPORT_RSP:
          //zclSampleSw_ProcessInConfigReportRspCmd( pInMsg );
          break;

        case ZCL_CMD_READ_REPORT_CFG:
          //zclSampleSw_ProcessInReadReportCfgCmd( pInMsg );
          break;

        case ZCL_CMD_READ_REPORT_CFG_RSP:
          //zclSampleSw_ProcessInReadReportCfgRspCmd( pInMsg );
          break;

        case ZCL_CMD_REPORT:
          HalUARTWrite(0,"cor\n",4);
          zclSampleSw_ProcessInReportCmd( pInMsg );
          break;
    #endif
        case ZCL_CMD_DEFAULT_RSP:
          zclSampleSw_ProcessInDefaultRspCmd( pInMsg );
          break;
    #ifdef ZCL_DISCOVER
        case ZCL_CMD_DISCOVER_RSP:
          zclSampleSw_ProcessInDiscRspCmd( pInMsg );
          break;

     

    when the state of light change,the swtich can't print "cor",in other words,the codes can't enter into "ZCL_REPORT" case.

    i have precompiled  ZCL_REPORT in “option”

    i used swtich as coordinator,and light as enddevice

  • Sorry, there is typo in parameter 2 of zcl_SendReportCmd(). It shouldn't set to 0. It should be the destination address in afAddrType_r format.

  • I add the codes like this but now, i even can't control my light!

    void zclSampleLight_Init( byte task_id )
    {
    zclSampleLight_TaskID = task_id;
    zclSampleLight_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
    zclSampleLight_DstAddr.endPoint = SAMPLELIGHT_ENDPOINT;
    zclSampleLight_DstAddr.addr.shortAddr = 0;
    ......
    }
    zcl_SendReportCmd(SAMPLELIGHT_ENDPOINT, &zclSampleLight_DstAddr,

    ZCL_CLUSTER_ID_GEN_ON_OFF, &rptcmd,

    ZCL_FRAME_CLIENT_SERVER_DIR, false, 0 );

    sorry   I can contorl my light now but swtich still can't recieve report from light

  • zclSampleLight_DstAddr.endPoint = //here, it should be the endpoint of sample switch
    zclSampleLight_DstAddr.addr.shortAddr = //here, it should be the short address of sample switch

  • Hi Yikai Sir,

    I was also trying to use zcl_SendReportCmd() to report the attributes.

    While stepwise debugging the code I found that the parameters for the variable of type zclReportCmd_t ( rptcmd ) are not be updating.

    I think because of this I am not seeing any change on Z-Stack Linux Gateway.

    Can you suggest any solution on this problem?

    Regards,

    EG

  • Even if zclReportCmd_t ( rptcmd ) is not updated, the message should be still sent out by device. I don't know if Z-Stack Linux Gateway filters it. You can use Ubiqua Packet Analyzer to check this.