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.

toggle on/off ZPLUG with ZTOOL

Other Parts Discussed in Thread: Z-STACK, CC2531, CC2530

Hi,

i Have a Zplug as ZigBee device that i can communicate with and send commands using ZTOOL, the only problem is that i didn't find how to toggle on/off the ZPLUG using AF_DATA_REQUEST.

i know that my destination address is correct, the destination endpoint is 1,  and the cluster for the switch on/off is 6.

<TX>10:36:00.69 COM4 AF_DATA_REQUEST (0x2401)
    DstAddr: 0xE71A
    DestEndpoint: 0x01
    SrcEndpoint: 0x00
    ClusterID: 0x0006
    TransID: 0x00
    Options: 0x00
    Radius: 0x00
    Len: 0x01
    Data: . (0x02)

<RX>10:36:00.69 COM4 AF_DATA_REQUEST_SRSP (0x6401)
    Status: afStatus_SUCCESS (0x0)

but it didn't work. Can you help me ?

Thanks

  • The data should be length 3. The first byte is for frame control, second is for transaction sequence number, and the 3rd is for off(0x00)/on(0x01)/toggle(0x02).

  • i understand you Chen, but can you tell me what data do i have to use for the frame control and the transaction sequence number ?

    i don't really understand how the data fields work ! ? can you explain me ?

  • For frame control byte, you can use 0x01 and the detail of frame control byte is listed in the followings and you can find explanation in spec.

    // ZCL header - frame control field
    typedef struct
    {
      unsigned int type:2;
      unsigned int manuSpecific:1;
      unsigned int direction:1;
      unsigned int disableDefaultRsp:1;
      unsigned int reserved:3;
    } zclFrameControl_t;

    For transaction sequence number, you can use a random number for unify transaction and you can use 0x01 here.

  • i've already done that but with no success, the ZPLUG don't toggle on/off when i try the command. as you see when i try to get the active endpoints, the ZPLUG answer but when i try to toggle on/off with the AF DATA REQUEST the ZPLUG dont switch on/off :

    Active end point command :

    <TX>09:50:20.38 COM4 ZDO_ACTIVE_EP_REQ (0x2505)
        DstAddr: 0xE71A
        NWKAddrOfInterest: 0xE71A

    <RX>09:50:20.42 COM4 ZDO_ACTIVE_EP_REQ_SRSP (0x6505)
        Status: afStatus_SUCCESS (0x0)

    <RX>09:50:20.42 COM4 ZDO_ACTIVE_EP_RSP (0x4585)
        SrcAddr: 0xE71A
        Status: ZDP_SUCCESS (0x0)
        NwkAddr: 0xE71A
        ActiveEPCount: 0x01
        ActiveEPList: . (0x01)

    Data Request Command :

    <TX>09:50:34.49 COM4 AF_DATA_REQUEST (0x2401)
        DstAddr: 0xE71A
        DestEndpoint: 0x01
        SrcEndpoint: 0x00
        ClusterID: 0x0006
        TransID: 0x00
        Options: 0x00
        Radius: 0x00
        Len: 0x03
        Data: ... (0x01, 0x01, 0x02)

    <RX>09:50:34.51 COM4 AF_DATA_REQUEST_SRSP (0x6401)
        Status: afStatus_SUCCESS (0x0)

  • Try to change SrcEndpoint: to 0x01.

  • aldready done that but it said invalid parameter.

    <TX>10:28:39.1 COM4 AF_DATA_REQUEST (0x2401)
        DstAddr: 0xE71A
        DestEndpoint: 0x01
        SrcEndpoint: 0x01
        ClusterID: 0x0006
        TransID: 0x00
        Options: 0x00
        Radius: 0x00
        Len: 0x03
        Data: ... (0x01, 0x01, 0x02)

    <RX>10:28:39.11 COM4 AF_DATA_REQUEST_SRSP (0x6401)
        Status: afStatus_INVALID_PARAMETER (0x2)

  • Could you check what end point you use on your coordinator application? You need that to fill in SrcEndpoint.

  • Thanks Chen for the help !

    in fact the active endpoint on my coordinator was 0x0A !

    i use it and now it work ! thanks !

    Active endpoin of coordinator :

    <TX>10:50:05.71 COM4 ZDO_ACTIVE_EP_REQ (0x2505)
        DstAddr: 0x0000
        NWKAddrOfInterest: 0x0000

    <RX>10:50:05.72 COM4 ZDO_ACTIVE_EP_REQ_SRSP (0x6505)
        Status: afStatus_SUCCESS (0x0)

    <RX>10:50:05.72 COM4 ZDO_ACTIVE_EP_RSP (0x4585)
        SrcAddr: 0x0000
        Status: ZDP_SUCCESS (0x0)
        NwkAddr: 0x0000
        ActiveEPCount: 0x01
        ActiveEPList: . (0x0A)

    AF DATA REQUEST :

    <TX>10:50:43.78 COM4 AF_DATA_REQUEST (0x2401)
        DstAddr: 0xE71A
        DestEndpoint: 0x01
        SrcEndpoint: 0x0A
        ClusterID: 0x0006
        TransID: 0x00
        Options: 0x00
        Radius: 0x00
        Len: 0x03
        Data: ... (0x01, 0x01, 0x02)

    <RX>10:50:43.79 COM4 AF_DATA_REQUEST_SRSP (0x6401)
        Status: afStatus_SUCCESS (0x0)

    <RX>10:50:43.83 COM4 AF_INCOMING_MSG (0x4481)
        GroupID: 0x0000
        ClusterID: 0x0006
        SrcAddr: 0xE71A
        SrcEndpoint: 0x01
        DstEndpoint: 0x0A
        WasBroadcast: 0x00
        LinkQuality: 0xAF
        SecurityUse: 0x00
        Timestamp: 0x0001AFF9
        TransSeqNumber: 0x00
        Len: 0x05
        Data: ..... (0x18, 0x01, 0x0B, 0x02, 0x00)

    Zerhouni Adam

  • Hey, 

    I have approximately the same problem. I want to turn on/off a device (Phillips Hue if it matters) the same way it is described here. But for some reason it wont work like Zerhouni Adam described. But i fail already one step earlier, once i try to send 

    <TX>10:50:05.71 COM11 ZDO_ACTIVE_EP_REQ (0x2505)
    DstAddr: 0x0000
    NWKAddrOfInterest: 0x0000

    i get no response at all. Not from the coordinator nor the end device (0x6C0F) i get any response to this command. In the startup procedure of the ZNP software is written at the last point

    7. The host processor should then wait for the ZDO_STATE_CHANGE_IND command with a status of DEV_ZB_COORD, DEV_ROUTER, or DEV_END_DEVICE before performing any other API operations.

    I don't get any of this commands once i try to start the device, am i maybe making a mistake starting the device itself? But i can see in the sniffer that there is a device with the short address 0x0000 on my specified PAN-ID (this should be my coordinator) and a second device 0x6C0F which should be my lamp.

    thanks for any help :)

    Thomas

  • Hello,

       At first time, thanks a lot to Zerhouni Adam and Chen, you resolve some of my problems with this. In another side, Zerhouni Adam I have a Zplug too and I would like obtain the simple metering (value of power) with Ztools, you know how can I do it? 

    Thanks for the help, I really need it

    Juan.

  • Hi Juan,


      unfortuntly i don't have time right now to explain you very well the procedure to follow, but you can try to use the ZDO_POWER_DESC_REQ to send request to your node, this will answer with a ZDO_POWER_DESC_RSP wich contain CurrentPowerMode/AvailablePowerSources CurrentPowerSource/CurrentPowerSourceLevel values.

      You can refer to the zigbee_api_R16 to more information.

      Hope that will help you.

      Adam.

  • Hi Adam,

       ok no problem, at the next days I try to prove your indications! 

    Thanks for your help,

    Juan.

  • Hi Juan,

    Try to post your steps and where you get stuck. Maybe I can help.

    YK

  • Hi YK,

      At the moment I haven´t got any step, I only want to know how I get the consume of ZPlug and I don´t use the indications of Adam yet. If you know how get this value, please tell me.

    Thanks for you interest! 

    Juan

    PD: Sorry about my english, I know it´s not very good.

  • Hi Juan,

    I had replied to some related topic before. You can refer to http://e2e.ti.com/support/wireless_connectivity/f/158/p/345530/1212150.aspx#1212150

  • Hi Yikai Chen,

       Thanks for the information. I try with ZDO_POWER_DESC_REQ and I get the information. If someone need more information, I give the information.

    I have some questions for you Yikai, how you know the information of data field? I mean, in which document you search for know the information necesary for fix this field of AF_DATA_REQUEST command? And, how could "translate" the information of data field response of the same command?

    Thanks,

    Juan.

  • I get these information from Zigbee ZCL spec, TI monitor and test command document, lots of source  codes reading , testing and tracing.

  • Hi again,

       Now i'm trying send the frame on serial port directly without use Z-Tools for toggle Zplug, someone know how do it or give some information for to start?

    Thanks a lot,

    Juan.

  • Hi Juan,

    You can refer to monitor and test command.pdf under Z-Stack document.

  • Hi Yikai,

       Yes, I know it, with this document I can know the hexadecimal value of commands, but my question is about the send of data in serial port without use Z-Tool, I mean, if I want send the SYS_PING command and I know the hexadecimal value of this frame (FE00210120), how can I do it? You have experience about this topic?

    Best regards,

    Juan.

  • You can use other terminal tool like Comm Operator (http://www.serialporttool.com/CommOpInfo.htm) to try these MT commands on PC. 

  • Do you want to send commands from a terminal or make your own program to do this. If you want to send this from an MCU (like MSP430) you will find ZAP project in ZStack-Home on www.ti.com/tool/z-stack. If you want to make a Linux program (on beaglebone embedded Linux machine) you can refer to ZSTACK-LINUX-GATEWAY. Regards, TC.
  • Hi again!

       At first, I apologize for no response to your messages, I haven´t got any time. Yikai I try use your recomendation and it´s very useful but I´d like try to send the AF_DATA_REQUEST command in hexadecimal with Comm Operator but the Zplug not toggle. I think that my error is in some hexadecimal value (in special, the FCS value). I put all of values of frame:

    SOF: 0xFE

    Length: 0x0D

    CMD0: 0x24

    CMD1: 0x01

    DstAddr: 0x29A5

    DstEndpoint: 0x01

    SrcEndpoint: 0x0A

    ClusterID: 0x06

    TransID: 0x00

    Options: 0x00

    Radius: 0x00

    Len: 0x03

    Data: 0x01, 0x01, 0x02

    FCS: 0x2981 (I know this value has only 1 byte, but I don´t know how do the XOR operation the another form)

    Can you detect my error? Thanks again!

    Juan.

  • Ok...I detect my error, I didn´t do correctly the XOR operation for FCS value. The correct value is "A8" and now I receive the frame of SRSP of AF_DATA_REQUEST but I not receive the AF_INCOMING_MSG and ZPLUG not toggle. I will try to investigate but someone know how solve this new problem?

    Thanks,

    Juan.

  • Do you use packet sniffer to check if the command is sent out from coordinator?

  • No, I haven´t  used packet sniffer. I tried to use it,  but  I don´t get information of any frame. I read the user manual of packet snnifer and I think my problem is I need to programme the firmware of my coordinator for use the packet sniffer, what do you think?

  • If you want to use packet sniffer, you need to make sure the FW on your cc2531 USB dongle is for this purpose. If you aren't sure about that, you can program sniffer_fw_cc2531.hex to it first. sniffer_fw_cc2531.hex is located at C:\Program Files\Texas Instruments\SmartRF Tools\Packet Sniffer\bin\general\firmware after you install packet sniffer.

  • Ok Yikai, but when you say "program" you refer to use SmartRF Flash Programmer, and mount to CC2531 the sniffer_fw_cc2531, right?

  • Yes, you need to use SmartRF flash programmer to download sniffer FW hex file to CC2531 usb dongle.

  • Yikai I try to program with SmartRF flash programmer but this tool no detect my device and I can´t dowload the hex file to CC2531 usb dongle. Any idea?

  • Would you show me how you connect flash programmer to your cc2531?

  • ok, this is my problem:

  • Do you give power to SmartRF05?

  • I not sure to understand your question, I haven´t got the SmartRF05 board, It is necesary for use this tool?

  • You need to use SmartRF05EB or CC debugger to download FW to CC2531/CC2530. You can refer to http://www.ti.com/lit/ug/swru197h/swru197h.pdf

  • Thanks for the reference Yikai, but I haven´t got the CCdebugger available. I will try to get one but is not sure. You know another way to solve the problem of the frame? Meanwhile I look forward get the ccdebuger.

  • What is  the problem of the frame?

  • My problem is when I send the AF_DATA_REQUEST with Comm Operator tool, I receive the frame of SRSP (and for this reason, the frame arrive correctly) but I not receive the AF_INCOMING_MSG (this frame arrive when send AF_DATA_REQUEST command with Z-Tools) and ZPLUG no toggle. I not sure if is necesary receive the AF_INCOMING_MSG command but Z-Plug not toggle anyway.

  • ok, I can solve this problem and now I will try to send the frame by means of java, someone has sent a Zigbee frame with Java in some moment?

  • Hi Juan,

    Would you share how you solve the problem this time?

  • Hi,

       The solution of the problem is strange but it works, only is necessary change the position of bytes when the attribute of the frame has two bytes or more, for example the attribute "Cluster ID" has two bytes and the value is 0006, however when you send the frame this attribute should have the 0600 value. I hope I have explain it well, if you have some question, tell me.

       On the other hand Yikai, you know some about my question?

  • Hi Juan,

    What's you question? Java? If so, I am afraid that I can't help. I don't have experience using Java to control Zigbee coordinator, router and end device.

  • hi i think that the solution is not strange, i already used java to send request to router and end device such as the Zplug. For your remarque you need to send 06 00 ==>  in the frame because when the end device receive it and want to read the frame, he read it from the right to left <== 00 06. ( i think ).


    But if you want to use java, you need to use the RXTX library !


    anyway in my case when in wanted to send frames from java, i had create an xml file that contain every command such as for the "toggle on " this is the command in the xml file :

    <command name="TOGGLE_ON">
                
                
                    <databyte id="sof">254</databyte>
                    <databyte id="lenght">13</databyte>
                    <databyte id="cmd0">36</databyte>
                    <databyte id="cmd1">01</databyte>
                    <databyte id="shaddr1"></databyte>
                    <databyte id="shaddr2"></databyte>
                    <databyte id="dstendpoint">01</databyte>
                    <databyte id="srcendpoint">10</databyte>
                    <databyte id="clusterid_1">06</databyte>
                    <databyte id="clusterid_2">00</databyte>
                    <databyte id="transid">00</databyte>
                    <databyte id="option">00</databyte>
                    <databyte id="radius">00</databyte>
                    <databyte id="len">03</databyte>
                    <databyte id="data1">01</databyte>
                    <databyte id="data2">01</databyte>
                    <databyte id="data3">01</databyte>
                
                
            </command>

    and in java, i used the jaxb library to use my xml file in java. 

    Ttry to find how to convert the information in your xml file to a byte frame to send, and you also need  not to miss calculate the FCS when you want to send the frame !

     

  • Hi,

       It´s a good hypothesis Zerhouni . About Java problem, I use the RXTX library and I will try work with your idea about xml file, but when you use the "write" function for send information on serial port Java finds an error. I need to send this frame in hexadecimal "fe0d2401a529010a060000000003010101ab" and Java finds an error and this error says: the  integer number is too large. I hope you can understand me. Another question is: when you use the xml file, how you send that file through serial port?

    PD: I need the toggle_on command too.

  • You need to put an array of byte [] that have the right length, every case handle 1 byte for exemple on[0]=fe, on[1]=0d etc...
    try using arrays.


    for the second question, i said to you that i dont send the xml file, but i load it in my java code and use the information in it ! try to see tutorials about the jaxb library !

    Zerhouni Adam.

  • It works! Thanks Zerhouni Adam for the suggestion. I try with an array and casting all attributes of the frame. Now I need receive the response frame but I think is easy with rxtx library.

    Juan 

  • Happy that i helped ! good luck for your project !


    Zerhouni Adam.

  • Adam,

        Do you know the End Point used by the ZPLUG application? You need to set  DestEndpoint correctly or the message will not be processed by the application on the ZPLUG. Also I notice that you are using SrcEndpoint: 0x00, this is incorrect, only the ZDO Endpoint can use 0, please use something different (maybe 1).

    To find the application end points used by the ZPLUG you can use ActiveEpReq, you can then find the EP that supports the on/off cluster by sending a SimpleDescReq to all EP's.

    Regards, TC. 

     

  • Hi TopCat,


    Dont worry about me, i solved all my problems long time ago, and the program that i wrote in Java to manipulate the Dongle and differents other devices ( Zplug/Zlum/Zmove...) worked fine ^^.

    My subject is already solved.

    Regards.

    Adam.

  • Hi again,

       I try to send a command for use the simple metering cluster in ZPlug device. I try with ZDO_POWER_DESC_REQ command but with this command I can´t obtain the value of the current demand of Energy in Kw. I use the AF_DATA_REQUEST but I not sure with the value of "data" attribute and when I send this command I receive the response but I don´t know how interpreted the value of "data" attribute, any idea? I put now the received frame :

    <TX>07:42:50.71 COM4 AF_DATA_REQUEST (0x2401)
    DstAddr: 0x29A5
    DestEndpoint: 0x01
    SrcEndpoint: 0x0A
    ClusterID: 0x0702
    TransID: 0x00
    Options: 0x00
    Radius: 0x00
    Len: 0x03
    Data: ... (0x01, 0x01, 0x01)

    <RX>07:42:50.73 COM4 AF_DATA_REQUEST_SRSP (0x6401)
    Status: afStatus_SUCCESS (0x0)

    <RX>07:42:50.76 COM4 AF_INCOMING_MSG (0x4481)
    GroupID: 0x0000
    ClusterID: 0x0702
    SrcAddr: 0x29A5
    SrcEndpoint: 0x01
    DstEndpoint: 0x0A
    WasBroadcast: 0x00
    LinkQuality: 0xA5
    SecurityUse: 0x00
    Timestamp: 0x0001C2FA
    TransSeqNumber: 0x00
    Len: 0x05
    Data: ..... (0x18, 0x01, 0x0B, 0x01, 0x81)