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.

cc2538: toggle lock command send in Z-stack

Part Number: CC2538
Other Parts Discussed in Thread: Z-STACK

Dear All,

    I want to practice to send command from end device to the coordinator. I am using the door lock as coordinator and door lock controller as end device to practice.

    The task I am going to do is to send the command from the controller to the door lock to let the LED1 toggle as the button press in door lock controller.

    Best  Regards

      Xian Wang

  • You can refer to SampleLight and SampleSwitch to implement ON/OFF cluster and command to do it.
  • Dear YK Chen,
    Thanks for your reply.
    I have learned the process of the ON/OFF cluster and its logic to control the light between the sample switch and sample light.
    In the learning of Cluster Definition in samplelight_data.c, I found that all the clusters defined the clusterRevision_all in the end of the every one, and it is defined as 0x0001. I am confusing the function of this parameter. If I want to defined one specific cluster for my own application, is it necessary to defined such one revision_all as well?

    Best Regards
    Xian Wang
  • If you define your own cluster ID and attribute, you should create your own attribute variable instead of using clusterRevision_all.
  • Dear YK Chen,
    What do you mean of creating your own attribute variable? Do you mean define one parameter like MyApp_Variable1=0x0002?

    Best Regards
    Xian Wang
  • Yes, that's it.
  • Dear YK Chen,

    I found that the toggle light command is from the coordinator to the end device by the binding table. If I want to send the command from the end device to the coordinator, can I use the clusters defined there? And what should I do since there is no binding table in end device?

    Best Regards
    Xian Wang
  • The short address of coordinator is 0x0000 and if your end device know endpoint of coordinator, it can send command with short address and endpoint directly without binding.
  • Dear YiKai Chen,

        I am doing the communication test between the ZD and ZC using genericapp as sample now. I want to send one integer from ZED to ZC in EVT1, so I add one transmission function in EVT1 and then define it later on.

       In definition, I use AF_DataReqeust function to send the integer stored in *buf.

       I think the short address of ZC is 0x0000, how to define others? Or how to find the afAddrType parameters for the coordinator?

       Besides, unlike the command that has appropriate Cluster ID, is there any Cluster to send data, such as integer or string from one device to another? If so, what is it?

       Best Regards

         Xian Wang

  • You should use afAddr16Bit in afAddrType parameter. Since you use GenericApp which use private cluster, it is OK to send int or string using existing cluster ID defined in GenericApp.
  • Dear YiKai Chen,

        Thank you for the reply.

        So you mean I can use cluster in Genericapp with datatype of unit16 or unit8 to transmit integer and Char to transmit string? such as ZCL_CLUSTER_ID_GEN_IDENTIFY is unit16 datatype and can write.

        Besides, you mentioned about the private cluster which I do not understand. Could you please explain more about private cluster? What is the different between private and public? And how to clarify one cluster is private or not?

        Best Regards

          Xian Wang

  • Dear YK Chen,
    If I want to add callback function to response to my test function, do I need to add the function to the Callback table? If so, which one can I use?

    I am using ZCL_CLUSTER_ID_GEN_IDENTIFY now to send the integer, I think it is OK to callback the function by Identify Trigger Effect command, but it cannot be compiled. Besides, which one can I use to do the callback function?

    Best Regards
    Xian Wang
  • All standard Zigbee application communication should be based on ZCL spec. If you want to transmit data which isn’t defined in zCL spec, you have to define your own for communication.
  • Dear YK Chen,

        Thank you for your reply.

        When I review the code of Samplelight and Sampleswitch for the command send the response, I found that I did not define end point for my point, do I need to define endpoint in header file when I want to send command?

        If so, can I define the endpoint just as the sample code as 8?

        Furthermore, why does the endpoint should define as 8?

       Best Regards

         Xian Wang

  • Yes, you have to define endpoint. I don’t know why Z-Stack examples use 8 as endpoint but you can change it to 1 to 240.
  • Dear YK Chen,
    I try to use zclGeneral_SendOnOff_CmdOn in Genericapp now to send command from one node to the other. But the compiling said that it declared implicitly. What is wrong with that?
    I also tried CmdOff and CmdToggle, they also said declared implicitly.
    I found the zcl_general.h is been declared.

    The same command works good in sampleswitch, and I cannot find any difference between this two samples.

    Best Regards
    Xian Wang
  • Do you include zcl_general.h in your C file which calls zclGeneral_SendOnOff_CmdOnWithTimedOff?

  • Yes, zcl_general.h is included in the beginning.

    Besides, I can use zcl_sendcommand to compile right now. But it seems that the node cannot send the command. I don't know what is wrong with it? Do I need to add something in sampledata.c? like to add the ZCL_CLUSTER_ID_GEN_ON_OFF in that file? But I think it has been defined in zcl.h, does it mean that I can use all the command inside the zcl.h directly in my app?

    Best Regards

      Xian Wang

  • Do you use Ubiqua Protocol Analyzer to check if command is sent? Can you show me how you send the command and what parameters you use?
  • Dear YK Chen,

        Thank you for the reply.

        I do not use Ubiqua Protocol Analyzer, but only use the TI packet sniffer. Does it work to analyze the command? I think the cluster ID is the command I am sending.

        Besides, the function I am using is shown below,

        void RemoteLightOn(uint8 x)
    {
      afAddrType_t RemoteLightOnDst;
      RemoteLightOnDst.addrMode=afAddr16Bit;
      RemoteLightOnDst.addr.shortAddr=0x0000;
      zcl_SendCommand( GENERICAPP_ENDPOINT, &RemoteLightOnDst, ZCL_CLUSTER_ID_GEN_ON_OFF, COMMAND_ON, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR, FALSE, 0, bdb_getZCLFrameCounter(), 0, NULL );
    }

    void RemoteLightOnCB(uint8 Cmd)
    {
      if(Cmd==COMMAND_ON)
      {
        HalLedSet ( HAL_LED_1, HAL_LED_MODE_ON );
      }
      else
      {
        HalLedSet(HAL_LED_2,HAL_LED_MODE_BLINK);
      }
    }

    I am wondering how I can use the command ZCL_CLUSTER_ID_GEN_ON_OFF, do I need to define it in myapp_data.c?

    Best Regards

      Xian Wang

  • TI packet sniffer cannot decrypt Zigbee HA profile messages so it's recommended to use Ubiqua Protocol Analyzer. I think you miss setting endPoint in RemoteLightOnDst.
  • Dear YK Chen,

        I used Ubiqua to analyze the command I want to send between the two nodes, and the default response from one node is shown as below, it seems that the command is unsupported command. How to fix this?

        Best Regards

          Xian Wang

  • If this is your private command not standard ZCL command, you cannot do anything to improve this on Ubiqua. Ubiqua only decrypt standard ZCL messages/commands.
  • This is not my private command, I just want to use the standard command to send the command on/off to turn on the light. So I am confused why the response said my command is not supported.

    Besides, when I looked at the same commend in samplelight and sampleswitch experiment, it response success. So I want to know which part control this part, can I fix this in the code part?

    Best Regards
    Xian Wang
  • What is the code you use to send out the message?
  • void RemoteLightOn(uint8 x)
    {
    afAddrType_t RemoteLightOnDst;
    RemoteLightOnDst.addrMode=afAddr16Bit;
    RemoteLightOnDst.addr.shortAddr=0x0000;
    zcl_SendCommand( GENERICAPP_ENDPOINT, &RemoteLightOnDst, ZCL_CLUSTER_ID_GEN_ON_OFF, COMMAND_ON, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR, FALSE, 0, bdb_getZCLFrameCounter(), 0, NULL );
    }

    and the GENERICAPP_ENDPOINT is been defined. I think this is ZCL cluster.
  • I remember SampleSwitch uses zclGeneral_SendOnOff_CmdToggle not zcl_SendCommand. There must be something wrong in your zcl_SendCommand.