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.

Acknowledgement for the Command message from ZC

Other Parts Discussed in Thread: Z-STACK

Can anybody please let me know how to get confirmation from the ZED for the following command sent from Coordinator?

status = zclGeneral_SendOnOff_CmdOff(SAMPLEHCUNIT_ENDPOINT, &zclHCUnit_DstThermostatAddr, false, 0 );

I am getting the status as 0 even the concerned ZED is switched off after the ZED joined the network first time with the ZC.
When it joined first time also I am getting the status as 0 as return value of the above function call.

Thanks

  • The return value of zclGeneral_SendOnOff_CmdOff only shows if the command is issued by coordinator successfully. In my application, I use zcl_SendReportCmd to report ON/OFF status if the receiver side does a ON/OFF command. With this report, I can confirm if the ON/OFF command is executed remotely.

  • YiKai,

    As per your suggestion I did the following changes in the zclSampleLight_OnOffCB() in the SampleLight node.

    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_4, HAL_LED_MODE_ON );
    else
    HalLedSet( HAL_LED_4, 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 );
    }

    will this work?

    Where I will process the message in the Coordinator?

    Is it in zclSampleHCUnit_ProcessInReportCmd() function?

    Thanks

  • Yes, your code looks good. And, the message should be processed in zclSampleHCUnit_ProcessInReportCmd if you use SampleHCUnit as your coordinator.

  • YiKai,

    Still I am not getting the report from Sample light to the HCUnit..

    I have added the following code in the zclSampleHCUnit_ProcessInReportCmd() function in the HCUnit...

    if (pReportCmd->attrList[0].attrID == ATTRID_ON_OFF)
    {
    light_onoff = *(int16*)(pReportCmd->attrList[0].attrData);

    data[0] = light_onoff;

    /* Send the Light on/off status on UART to PC */
    zclSampleHCUnit_BuildAndSendZToolResponse(0x01, 0x02, 2, data);
    }

    I still I have not received the report from SampleLight. What else I am missing?

    The direction I have to set is ZCL_FRAME_CLIENT_SERVER_DIR or ZCL_FRAME_SERVER_CLIENT_DIR on the sample light side?

    I have set the direction as ZCL_FRAME_CLIENT_SERVER_DIR from the HCUnit side.

    The following is the code in HCUnit to enable the report from SampleLight...

    cfgRptCmd.numAttr = 1;

    cfgRptCmd.attrList[0].direction = 0;
    cfgRptCmd.attrList[0].attrID = ATTRID_ON_OFF;
    cfgRptCmd.attrList[0].dataType = ZCL_DATATYPE_UINT8;
    cfgRptCmd.attrList[0].minReportInt = 20;
    cfgRptCmd.attrList[0].maxReportInt = 50;
    cfgRptCmd.attrList[0].timeoutPeriod = 0;
    cfgRptCmd.attrList[0].reportableChange = NULL;

    zcl_SendConfigReportCmd(SAMPLEHCUNIT_ENDPOINT,
    &zclHCUnit_DstThermostatAddr,
    ZCL_CLUSTER_ID_GEN_ON_OFF,
    &cfgRptCmd,
    ZCL_FRAME_CLIENT_SERVER_DIR,
    0, 1);

    Am I correct or confusing you?

    Thanks

  • It should be set to ZCL_FRAME_SERVER_CLIENT_DIR.

  • I found that I am receiving command number as 0x0B instead of 0x0a. Please find attached the screenshot of the sniffer log. But I am wondering why it is happening as I am not filling the command myself in the code. It is the existing code only.

    Thanks

  • Can you attach your sniffer log file not snapshot of it?

  • Dear YiKai,

    Please find the sniffer log file attached saved when SampleLight node connected.

    Thanks

    SnifferLogSampleLight.psd
  • The command 0x0B is default response of ON/OFF on command. I don't see there is any on/off report.

    I take a detail look at your previous code and find the problem might be the parameter 2 of zcl_SendReportCmd. It should be afAddrType_t *dstAddr. Why do you put 0 on it??

    zcl_SendReportCmd(SAMPLELIGHT_ENDPOINT, 0,
    ZCL_CLUSTER_ID_GEN_ON_OFF, &rptcmd,
    ZCL_FRAME_CLIENT_SERVER_DIR, false, 0 );

  • When I put the breakpoint and see the status output of the SendReport function says a 0x00 only, I am not sure why it is not transmitted?

  • The parameter 2 of zcl_SendReportCmd must be a pointer of afAddrType_t. You can't put 0 to it. You need do something like:

      afAddrType_t DstAddr;

      DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
      DstAddr.endPoint = your dst device endpoint;
      DstAddr.addr.shortAddr = your dst device short address;

    zcl_SendReportCmd(SAMPLELIGHT_ENDPOINT, &DstAddr, ...);

  • Do I need to filled the 64-bit extended address of the coordinator in DstAddr structure? How will I get the Coordinator extended address?

    Thanks

  • Now I am able see the report message in my Docklight. Please find the sniffer log attached.

    SamplelightLog.psd
  • To send message to coordinator, I recommend to use short address. The short address of coordinator is always 0x0000. If you want extended address of coordinator, you can use ZDP_IEEEAddrReq.

  • I don't see on/off attribute report in your attached sniffer log. Anyway, it is good to know you received the on/off status finally.

  • How exactly can I implement the same functionality for level control of light? I am unable to understand how can I extract the coordinator address . Please Help.
  • The coordinator short address is fixed to 0x0000.
  • Thanks for the prompt response. Should i assume that following code would work fine(on end point side)?

    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, 0x0000,ZCL_CLUSTER_ID_GEN_ON_OFF, &rptcmd,ZCL_FRAME_CLIENT_SERVER_DIR, false, 0 );

    // update the display
    // zclSampleLight_LcdDisplayUpdate( );
    zclSampleLight_DisplayLight();
    }

    Please help me understand whichch part of the code on coordinator side (sampleswitch) needs to be modified?

    Thanks.

  • afAddrType_t DstAddr;

    DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
    DstAddr.endPoint = your dst device endpoint;
    DstAddr.addr.shortAddr = your dst device short address;

    zcl_SendReportCmd(SAMPLELIGHT_ENDPOINT, &DstAddr, ...);

    When coordinators short address is always 0x000 then why do we need to do this for second argument ? Second argument cant be 0???
    I am getting lost now. :-)
  • If you don't set short address, z-stack doesn't know where to send message.