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.

CC2650DK: How to send data using ZCL API

Part Number: CC2650DK

Hi All,

I'm using SampleSwitch from zstack_home_1_02_02a_44539 as a base for my project.

now i want to send a data from end point to coordinator, to send the data I'm using 

AF_DataRequest( destAddr, epDesc, clusterID, msgLen, pBuf, &zcl_TransID, options, AF_DEFAULT_RADIUS );

with the data in "pBuf".

but when i see in the sniffer using wireshark, I cannot see the data that i send.

do you know where i'm wrong ? or maybe I'm using incorrect API for the process

Please help me with this.

i set the Source Endpoint to 27 to identified the message.

this is the sniff data

Frame 163: 30 bytes on wire (240 bits), 28 bytes captured (224 bits) on interface 0
Interface id: 0 (\\.\pipe\ws_socket)
Encapsulation type: IEEE 802.15.4 Wireless PAN (104)
Arrival Time: Apr 22, 2017 16:31:49.000140000 SE Asia Standard Time
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1492853509.000140000 seconds
[Time delta from previous captured frame: 1.999952000 seconds]
[Time delta from previous displayed frame: 1.999952000 seconds]
[Time since reference or first frame: 123.999705000 seconds]
Frame Number: 163
Frame Length: 30 bytes (240 bits)
Capture Length: 28 bytes (224 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: wpan:zbee_nwk:zbee_aps:zbee_zcl]
IEEE 802.15.4 Data, Dst: 0x0000, Src: 0x5fe9
Frame Control Field: 0x8861, Frame Type: Data, Acknowledge Request, PAN ID Compression, Destination Addressing Mode: Short/16-bit, Frame Version: IEEE Std 802.15.4-2003, Source Addressing Mode: Short/16-bit
Sequence Number: 244
Destination PAN: 0x6b43
Destination: 0x0000
Source: 0x5fe9
ZigBee Network Layer Data, Dst: Broadcast, Src: 0x5fe9
Frame Control Field: 0x0008, Frame Type: Data, Discover Route: Suppress Data
Destination: 0xffff
Source: 0x5fe9
Radius: 30
Sequence Number: 255
ZigBee Application Support Layer Data, Dst Endpt: 255, Src Endpt: 27
Frame Control Field: Data (0x08)
Destination Endpoint: 255
Cluster: Identify (0x0003)
Profile: Home Automation (0x0104)
Source Endpoint: 27
Counter: 92
ZigBee Cluster Library Frame, Command: Read Attributes, Seq: 4
Frame Control Field: Profile-wide (0x00)
.... ..00 = Frame Type: Profile-wide (0x0)
.... .0.. = Manufacturer Specific: False
.... 0... = Direction: Server
...0 .... = Disable Default Response: False
Sequence Number: 4
Command: Read Attributes (0x00)

  • Your destination endpoint is set to 255 which is incorrect.
  • Hi YK,

    I though endpoint 255 is the broadcast endpoint, is that an issue if i want to send data ?
    i haven't manage the endpoint, only want to send the data out correctly first.

    thx for your reply
    regards
    Tonny
  • Yes, that is an issue. You have to use a correct endpoint otherwise it won't work.
  • Hi YK,

    if my endpoint is coordinator, can i set endpoint value using ztool ?

    thx for your reply
    regards
    Tonny
  • Hi YK,

    if i use znp-bringup.zjs is this the endpoint config ?
    private var endPoint : Byte = 0x07;

    i still cannot change the destination endpoint in the end node,
    is the sample for SampleSwitch can connect with ZAP-ZNP Coordinator without trouble ? or need modification ?
    maybe i need to reinstall the ZStack Home again if by default the sample should work

    thx for your reply
    regards
    Tonny
  • Yes, SampleSwitch can connect with ZAP-ZNP coordinator without problem. I suggest you to use ZDP_ACTIVE_EP_REQ MT command to request endpoint from coordinator to your SampleSwitch.
  • Hi YK,

    still need to read some more about endpoint because still fail to set one.

    but if i snif the data using cc2530 and wireshark, the message is encrypted.
    do you know how to send plain message so i can see what data is being sent ?

    thx for your reply
    regards
    Tonny
  • Since Zigbee HA use TC link key to transport network key, you have to input your TC link key to make wireshark can decrypt Zigbee HA message.
  • Hi YK,

    ah thx for the key info, now i can see the data.

    but i loop AF_DataRequest function, but why no data that being send out ?

    status = AF_DataRequest( destAddr, epDesc, clusterID, msgLen, msgBuf,
    &zcl_TransID, options, AF_DEFAULT_RADIUS );

    I trace step by step and no error occur.
    do you know what is possibly wrong with my coding, what is the function that supposed to send message out ?

    I modify the basic the default "static void Switch_sendToggle(void)" into this

    static void Switch_sendToggle(void)
    {
    zclReportCmd_t *pReportCmd;

    // Build and send a ZCL temperature reading to the matched device
    pReportCmd = ICall_malloc(sizeof(zclReportCmd_t) + sizeof(zclReport_t));
    if(pReportCmd != NULL)
    {
    afAddrType_t dstAddr;

    // Fill in the destination address
    dstAddr.addrMode = (afAddrMode_t)zswDstAddr.addrMode;
    dstAddr.addr.shortAddr = zswDstAddr.addr.shortAddr;
    dstAddr.endPoint = zswDstAddr.endpoint;
    dstAddr.panId = zswDstAddr.panID;

    // Fill in the single attribute information for the temperature reading
    pReportCmd->numAttr = 1;
    pReportCmd->attrList[0].attrID = ATTRID_MS_TEMPERATURE_MEASURED_VALUE;
    pReportCmd->attrList[0].dataType = ZCL_DATATYPE_INT16;
    pReportCmd->attrList[0].attrData = "Hallo"; //(void *) (&staTempMeasuredValue);

    // Call ZCL function to send the report
    zcl_SendReportCmd(SWITCH_EP, &dstAddr,
    ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT, pReportCmd,
    ZCL_FRAME_SERVER_CLIENT_DIR, true, staTransID++);

    ICall_free(pReportCmd);

    thx for your reply
    regards
    Tonny
  • Hi YK,

    btw my setup only like this :
    CC2650DK (ZED) (SampleSwitch SOC) connect to CC2650DK (ZC) + Ztool ( using znp-bringup.zjs)
    do you have any concern about my setup related to my question

    thx for your reply
    regards
    Tonny
  • No, I see no problem on your configuration.
  • Hi YK,

    after see "zclGeneral_SendIdentifyQuery" function, i see some prerequisite so "zcl_SendCommand" can send a message.
    maybe because of that the Switch_sendToggle failed to send the message, beside the Dest Endpoint is not 255, do you know what is the pre req for "zcl_SendCommand" so it can send the message ?

    like maybe need on certain state or event ?
    certain condition ?

    thx for your reply
    regards
    Tonny
  • Hi YK,

    is it correct that i need to successfully mapping a switch to light, before i can successfully send the data using "zclGeneral_SendOnOff_CmdToggle" in the SampleSwitch from "C:\ti\simplelink\zstack_home_1_02_02a_44539\Projects\zstack\HomeAutomation\SampleSwitch" ?

    thx for your reply
    regards
    Tonny
  • Hi All,

    where is this message below come from ? is it Zstack Core because i cannot trace the source from the sample application,
    when i try to open ZStackCore code there always message pop up say "changing active configuration will terminate the debug session"

    i see you can put breakpoint on ZstackCore, how you do it ?

    Frame 10799: 12 bytes on wire (96 bits), 10 bytes captured (80 bits) on interface 0
    Interface id: 0 (\\.\pipe\ws_socket)
    Encapsulation type: IEEE 802.15.4 Wireless PAN (104)
    Arrival Time: Apr 24, 2017 23:35:24.000311000 SE Asia Standard Time
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1493051724.000311000 seconds
    [Time delta from previous captured frame: 2.000002000 seconds]
    [Time delta from previous displayed frame: 2.000002000 seconds]
    [Time since reference or first frame: 11257.999429000 seconds]
    Frame Number: 10799
    Frame Length: 12 bytes (96 bits)
    Capture Length: 10 bytes (80 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: wpan]
    IEEE 802.15.4 Command, Dst: 0x0000, Src: 0xc35e
    Frame Control Field: 0x8863, Frame Type: Command, Acknowledge Request, PAN ID Compression, Destination Addressing Mode: Short/16-bit, Frame Version: IEEE Std 802.15.4-2003, Source Addressing Mode: Short/16-bit
    Sequence Number: 214
    Destination PAN: 0x8213
    Destination: 0x0000
    Source: 0xc35e
    [Extended Source: TexasIns_00:06:8b:4e:07 (00:12:4b:00:06:8b:4e:07)]
    [Origin: 20]
    Command Identifier: Data Request (0x04)

    thx for your reply
    regards
    Tonny
  • 1. You have to do binding or know destination short address/endpoint before you can send message from SampleSwitch to SampleLight.
    2. Yes, you can set a breakpoint in ZStackCore but you should debug from application.
  • Hi YK,

    yes you are correct previously, the issue is in the endpoint value, it has to be valid value,

    my question now, how we know what is the list of correct EndPoint value, and how to define one if you want to create specific endpoint value ?

    could you refer a document about this 

    this is my sniff with my data broadcast ed, the data is in the payload

    Frame 11777: 53 bytes on wire (424 bits), 51 bytes captured (408 bits) on interface 0
    IEEE 802.15.4 Data, Dst: Broadcast, Src: 0x0000
    Frame Control Field: 0x8841, Frame Type: Data, PAN ID Compression, Destination Addressing Mode: Short/16-bit, Frame Version: IEEE Std 802.15.4-2003, Source Addressing Mode: Short/16-bit
    Sequence Number: 50
    Destination PAN: 0x2bde
    Destination: 0xffff
    Source: 0x0000
    [Extended Source: TexasIns_00:06:8b:0e:0a (00:12:4b:00:06:8b:0e:0a)]
    [Origin: 7013]
    ZigBee Network Layer Data, Dst: Broadcast, Src: 0x83ce
    Frame Control Field: 0x0208, Frame Type: Data, Discover Route: Suppress, Security Data
    Destination: 0xffff
    Source: 0x83ce
    Radius: 29
    Sequence Number: 178
    [Extended Source: TexasIns_00:06:8b:4e:07 (00:12:4b:00:06:8b:4e:07)]
    [Origin: 7009]
    ZigBee Security Header
    ZigBee Application Support Layer Data, Dst Endpt: 39, Src Endpt: 8
    Frame Control Field: Data (0x08)
    Destination Endpoint: 39
    Cluster: Identify (0x0003)
    Profile: Home Automation (0x0104)
    Source Endpoint: 8
    Counter: 63
    ZigBee Cluster Library Frame
    Frame Control Field: Cluster-specific (0x11)
    Sequence Number: 29
    Command: Identify Query (0x01)
    Payload

    Thx for your reply

    Regards

    Tonny S

  • When a device joins Zigbee network, it would broadcast end node announcement which would contains short and IEEE address of device. You can use the short address to request endpoint. If you use ZNP, you can use ZDO_ACTIVE_EP_REQ to request endpoint.
  • Hi YK,

    yes I'm using ZNP for the coordinator.
    and after get the endpoint value from ZED i need to register it on the coordinator endpoint table something ?

    Thx for your reply
    Regards
    Tonny S
  • No, you should store the endpoint and short address for sending messages using AF_DataRequest.