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.

Sending PC to ZED through ZC

Other Parts Discussed in Thread: CC2530

Hi,

     i am Using two ZED and one ZC. One ZED is sending a Sensor Data to ZC and ZC will send to PC, From the PC, data will send as a string to ZC, if Sensor goes Abnormal. Then ZC should Receive that and send to other ZED to on and off the device. I have Discussed my project in different thread, But This question is enhancement of that, so opened new thread. So my questions are

1) initUart(halUARTCBack_t pf); i should call from zclSampleLight_Init, what is pf?

2)i need register the callback uartRxCB Function in zclSampleLight_CmdCallbacks or directly i can write a fuction?

3)While sending data through UART HalUARTWrite ( uint8 port, uint8 *pBuffer, uint16 length );. In the Buffer we need to follow any serialization format or we can directly pass raw data . For example i want to send number 20, can i send like this pBuffer = (uint8) 20;?

4)Same thing for Receving also, HalUARTRead ( uint8 port, uint8 *pBuffer, uint16 length ); after calling this function data will store in the pBuffer. Directly can i read a data, for example, PC sends a data as "ON". can i read as uart_data = pBuffer.

  • Hi,

         i am Using two ZED and one ZC. One ZED is sending a Sensor Data to ZC and ZC will send to PC, From the PC, data will send as a string to ZC, if Sensor goes Abnormal. Then ZC should Receive that and send to other ZED to on and off the device. I have Discussed my project in different thread, But This question is enhancement of that, so opened new thread. So my questions are

    1) initUart(halUARTCBack_t pf); i should call from zclSampleLight_Init, what is pf?

    2)i need register the callback uartRxCB Function in zclSampleLight_CmdCallbacks or directly i can write a fuction?

    3)While sending data through UART HalUARTWrite ( uint8 port, uint8 *pBuffer, uint16 length );. In the Buffer we need to follow any serialization format or we can directly pass raw data . For example i want to send number 20, can i send like this pBuffer = (uint8) 20;?

    4)Same thing for Receving also, HalUARTRead ( uint8 port, uint8 *pBuffer, uint16 length ); after calling this function data will store in the pBuffer. Directly can i read a data, for example, PC sends a data as "ON". can i read as uart_data = pBuffer.

    5)Both two ZED i am ZDP_MatchDecReq. I use to send Sensor Data from one ZED to ZC through ZCL_REPORT, as i get a Data "ON" from PC i need to Send on/off cmd attribute to other ZED. How can i Send?

  • 1~4. I had given example codes for uart usage on this forum. Please refer to the discussion at http://e2e.ti.com/support/low_power_rf/f/158/p/236389/827877.aspx#827877.

    5. You can use API zclGeneral_SendOnOff_CmdToggle to send ZCL on/off. 

  • After referring that Post only i asked these questions, In that Post i didn't detail of Point 3 and 4.  

              3)While writing in to that buffer, we need to follow any serialization format. (i.e) first byte for id, Second byte is payload like wise or we can directly write raw thing and send it.

                 4) Same thing for Receiver, after calling HalUARTRead(Port, buff, len); .That buff contains the data which is send by PC. Can i read directly or we need to follow any format for reading.

                  5) zclGeneral_SendOnOff_CmdToggle, how does it work? first time when we call it sending on and second time when will call it off command??

                     i want to control light through relay, so i want to make relay on(i.e light on) when it receives on command, and off when receives off command.

          Thanks.  

  • 3. No, there is no serialization format. But your syntax of bBuf usage is wrong, if you want to put decimal value into first byte of pBuf, it should be "pBuf[0]=20". This is C/C++ programming skill and I suggest you study on it.

    4. The serialization format is defined by yourself so you should know how to parse it inside receiving buffer.

    5. You can use zclGeneral_SendOnOff_CmdOn and zclGeneral_SendOnOff_CmdOff.

  • Thanks once again,

            In both ZED i am using ZDP_MatchDescReq to coordinator, if I am using samplelight as coordinator, what  should use in dstAddr of   zclGeneral_SendOnOff_CmdOn API. Because i am having two ZED. How can i get a particular short address of ZED, where i connect the relay? Then i am using ZCL_SendReportcmd in same ZED to send Acknowledgement to Coordinator. 

  • When a ZED joins ZC, ZED will broadcast end node announcement message and it contains short address inside. You can keep it in your application and use it accordingly.

  • Yes, I know theoretically, But how get it in program. Sorry for Basic Question. Both ZED will Broadcast their Address, How ZC will know where the relay is Connected. Where should i use, if my coordinator is sample light.

  • This is nothing about Zigbee. It is application design. In my application, we will have a devices list to keep all of ZED and ZR that join the network and keep their capability. For example, if ZED A joins and it contains ZCL_CLUSTER_ID_GEN_ON_OFF in Incluster, I will label it to a ON/OFF device. , if ZED B joins and it contains ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL in Incluster, I will label it to a DIMMER device...etc. So, you must know each devices in your application and send control command accordingly.

  • Still i am clear, while sending ZDP_MatchDescReq from ZED B(relay). Which Contain outcluster ZCL_CLUSTER_ID_GEN_ON_OFF and i registered  same in incluster of ZC, which it sends Desc Rsp. Where I should label the ON/OFF Device?. Can you give me small Example, So that i can explore in my Application.

  • After ZED boradcasts end node announcement message, ZC can have the short address of this ZED and uses ZDP_SimpleDescReq to request simple descriptor from ZED. You can know clusters supported by the ZED from its simple descriptor.

  • You mean, i need to call ZDP_SimpleDescReq

    case ZDO_STATE_CHANGE:
    Nwkstate = (devStates_t)(MSGpkt->hdr.status);
    if ( (NWKstate == DEV_ZB_COORD) )
    {
    dstAddr.addrMode = AddrBroadcast;
    dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
    ZDP_SimpleDescReq(&dstAddr, NWK_BROADCAST_SHORTADDR, epIntf, FALSE )

    }

    Is it the correct method? Please suggest me. I am very confused. This also needs dstAddr.


  • 1. You should register Device_annce using ZDO_RegisterForZDOMsg(task_id, Device_annce); in your zclAPP_Init().

    2. Add  the following case in zclAPP_event_loop.

    case ZDO_CB_MSG:
              zclAPP_ProcessZDOMsgs( (zdoIncomingMsg_t *)MSGpkt );
              break;

    3. Create zclAPP_ProcessZDOMsgs function and process

    void GenericApp_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg )
    {
      switch ( inMsg->clusterID )
      {

      case Device_annce:
        {
          //put simple description request here.
        }
          break;
      }
    }

  • Thanks for you kind answer, again i having doubt. 

    dstAddr.addrMode = AddrBroadcast;
    dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR

    ZDP_SimpleDescReq( &dstAddr,  nwkAddr, NWK_BROADCAST_SHORTADDR, ep, 0 );

    what is ep? Endpoint of Coordinator or ZED? 

    if i call this from ZC, then How can i get dst address of ZED.

  • 1. It is ZED's end point.

    2. You can parse short address in Device_annce case using the following example code:

    case Device_annce:
    {

    ZDO_DeviceAnnce_t devAnnce;

    ZDO_ParseDeviceAnnce(inMsg, &devAnnce);
    //devAnnce.nwkAddr is the short address of device announced.

  • Mufiq/YiKai Chen,

    1)            Where did you called ZDP_SimpleDescReq in coordinator, It is like this,

    case ZDO_STATE_CHANGE:
    Nwkstate = (devStates_t)(MSGpkt->hdr.status);
    if ( (NWKstate == DEV_ZB_COORD) )
    {
    dstAddr.addrMode = AddrBroadcast;
    dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
    ZDP_SimpleDescReq(&dstAddr, NWK_BROADCAST_SHORTADDR, epIntf, FALSE )

    as you mentioned in post.

    2) 

    case Device_annce:
    {

    ZDO_DeviceAnnce_t devAnnce;

    ZDO_ParseDeviceAnnce(inMsg, &devAnnce);
    //devAnnce.nwkAddr is the short address of device announced.

    If Simultaneously 3 ZED is announcing or powered up, devAnnce will overwrite, then how we can find out the short address in devAnnce is the short Address what we needed. 

  • Mufiq/YiKai Chen,

    1)            Where did you called ZDP_SimpleDescReq in coordinator, It is like this,

    case ZDO_STATE_CHANGE:
    Nwkstate = (devStates_t)(MSGpkt->hdr.status);
    if ( (NWKstate == DEV_ZB_COORD) )
    {
    dstAddr.addrMode = AddrBroadcast;
    dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
    ZDP_SimpleDescReq(&dstAddr, NWK_BROADCAST_SHORTADDR, coordinator_endpoint, FALSE )

    as you mentioned in post.

    2)dstaddr and coordinator_endpoint is correct?

    3) 

    case Device_annce:
    {

    ZDO_DeviceAnnce_t devAnnce;

    ZDO_ParseDeviceAnnce(inMsg, &devAnnce);
    //devAnnce.nwkAddr is the short address of device announced.

    If Simultaneously 3 ZED is announcing or powered up, devAnnce will overwrite, then how we can find out the short address in devAnnce is the short Address what we needed. here i am sending a on/off status to ZED, i think Mufiq also does same thing. Among you people, can some one help me out. 

  • 1&2. I never send ZDP_SimpleDescReq from coordinator. You code looks reasonable and just try it.

    3. Zigbee protocol avoids collisions when transmitting so it is impossible that 3 ZED announce simultaneously. They must be one by one so you can handle them one by one.

  • 1)So you mean, inorder to get a Short address of ZED from Coordinator, no need to of sending ZDP_SimpleDescReq from Coordinator.

    2)Yes, I know Zigbee protocol avoids collision. My question is for example i am powering up 3 ZED simultaneously. It will announce one by one. i am getting it short address in ZDO_ParseDeviceAnnce(inMsg, &devAnnce);. How can i know the address is in devAnnce is short address of ZED 1/2/3. How can i extract the short address of ZED 2. I hope you understand my question.

  • I would keep a list that records short addresses of ZED1/2/3 when they join ZC one by one. Then, if you turn off them and turn on them all at the same time, I can tell them from short address in end node announcement.

  • You mean, i have to turn on ZED on by one. and keep the short address. and it can turn off and turn on simultaneously. Is this a method of listing the records?, my understanding is correct.

           1)  If this  the method, What could happen, if coordinator restarts?

            2)If this is not, then can you please Specify clearly, how can i store or keep records of 3 ZED.

  • Yes. And you should save the list on NV flash in case of power lost.

  • Thanks,

                 Is there any other method to get short address of particular enddevice from Coordinator?, for example by sending particular enddevice cluster id or endpoints. Because i don't want to use NV_RESTORE. So, Please can you suggest me any other method.

  • If you know the IEEE address of ZED, you can use ZDP_NwkAddrReq to get the short address from ZED.

  • 1)After calling this, where i will get short address.

    2)Is there any other method, that should get short address, without any manual operation, i mean, The software should independent of particular devices and after downloading software to hardware,it should work without any manual operation(on get it and off).

  • 1. You have to register NWK_addr_rsp with ZDO_RegisterForZDOMsg and process it in your zclXXX_ProcessZDOMsgs. It is like what you do to handle Match_Desc_rsp.

    2. No, it need to be handle by your application software.

  • Thanks Yikai, That only i asked. It can't handle by my application software?. The application Software which i am going make, that should be independent of device (i.e) IEEE address could be any thing, This Application Software should fit for all devices(CC2530 only) with out any changes in software.

  • If you don't want enable NV_RESTORE and save the device list, it is no way to know them when they rejoin ZC. This is obvious. Since you have 3 ZED with the same cluster support, you can't tell who is who if you don't have any label on them.

  • No, My three  ZED is having Different Cluster. Then it can possible to get with the cluster id?

  • If so, you can ask for simple descriptor when ZC receives ZED sends out end node announcement. You can tell the difference from simple descriptor sent back from ZED to ZC.

  • Coordinator needs Short address of ZED. So in Coordinator

    case Device_annce:
    {

    dstAddr.addrMode = AddrBroadcast;
    dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;

     ZDP_SimpleDescReq(&dstAddr, NWK_BROADCAST_SHORTADDR, coordinator_endpoint, FALSE )

     dstaddr & endpoint is correct ?

    }

    what should i do in ZED? and again how will i get ZED short address in ZC. 

  • You can use the following code to get short address when receiving device announcement.

    case Device_annce:
    {

    ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );
    pRsp->nwkAddr; //This short address of announced device

  • Mr.Yikai,

      Again it makes me confuse, where should i call SimpleDescReq?.I want to match with Cluster ID of particular Endpoint Device and need to get Short Address of it.

    case Device_annce:
    {

    dstAddr.addrMode = AddrBroadcast;
    dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;

     ZDP_SimpleDescReq(&dstAddr, NWK_BROADCAST_SHORTADDR, coordinator_endpoint, FALSE )

     dstaddr & endpoint is correct ?

    }

  • You should add the following codes in your coordinator.

    1. Add the following two lines in zclCoord_Init to register Device_annce and Simple_Desc_rsp.

      ZDO_RegisterForZDOMsg( zclCoord_TaskID, Device_annce );
      ZDO_RegisterForZDOMsg( zclCoord_TaskID, Simple_Desc_rsp );
    2. Add the following two case to process Device_annce and Simple_Desc_rsp in zclCoord_ProcessZDOMsgs.
    case Device_annce:
    {
        ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );

    dstAddr.addrMode = (afAddrMode_t)Addr16Bit;
    dstAddr.addr.shortAddr = pRsp->nwkAddr; //This is the short address of announced device

     ZDP_SimpleDescReq(&dstAddr, pRsp->nwkAddr, coordinator_endpoint, FALSE ) //Send simple description request to the announced device.
    }
    break;

    case Simple_Desc_rsp:
    {
    ZDO_SimpleDescRsp_t *pSimpleDescRsp
      uint8 *msg;

      msg = inMsg->asdu;
      pSimpleDescRsp->status = *msg++;
      pSimpleDescRsp->nwkAddr = BUILD_UINT16( msg[0], msg[1] );
      msg += sizeof ( uint16 );
      msg++; // Skip past the length field.
      if ( pSimpleDescRsp->status == ZDP_SUCCESS )
      {
        ZDO_ParseSimpleDescBuf( msg, &(pSimpleDescRsp->simpleDesc) ); //Parse simple description and fill data to pSimpleDescRsp
      }

    }

    So, the simple description of the announced device is parsed and kept in pSimpleDescRsp.

  • Thank you very much,

                    So, now pSimpleDescRsp consists of simple Description of the announced device. I need to check the cluster id, if it matches then, i need to store the short address of that device.I will make a try.Correct me if am wrong. Thanks Once again.

  • 1)It is not entering in the case, i have registered   ZDO_RegisterForZDOMsg( zclCoord_TaskID, Simple_Desc_rsp ); in init.

    case Simple_Desc_rsp:
    {
    ZDO_SimpleDescRsp_t *pSimpleDescRsp
      uint8 *msg;

      msg = inMsg->asdu;
      pSimpleDescRsp->status = *msg++;

    2)Giving warning like pSimpleDescRsp is used before set.


  • Try to use packet sniffer to check if the simple description request is sent out correctly and if there is simple description response over the air.

  • Here the Sniffer, 6102.sniff.psd. It Seema that, ZC send Request, but ZED is not Responding.

  • Set a breakpoint in ZDO_ProcessSimpleDescReq function of ZED and check what's happened. If ZED receives Simple Description request, it will be process in ZDO_ProcessSimpleDescReq.

  • I set code break point in ZDO_ProcessSimpleDescReq in ZDObject.c file in ZED. Then i see the Sniffer. I didn't find changes. here the log file 5342.log.psd. Please can you help to work this success ful.

  • I doubt that you use endpoint 0 when you send ZDP_SimpleDescReq. Endpoint 0 is served value. Please change it to another value.

  • No my endpoint is not zero, it is 13. Is need to do any thing in ZED? whether i should register and the process the Simple_desc_Req or it will send response automatically

  • 1. From your sniffer log, you use 0 as endpoint. Make sure you set correct endpoint before you call ZDP_SimpleDescReq().

    dstAddr..endPoint = applcation_endpoint;
    coordinator_endpoint = applcation_endpoint;
    ZDP_SimpleDescReq(&dstAddr, NWK_BROADCAST_SHORTADDR, coordinator_endpoint, FALSE )

    2. If ZED receives simple description request, it should send response automatically.

  • dstAddr..endPoint = applcation_endpoint

    dstAddr of ZDP_SimpleDescReq is zAddrType_t, then how can add endpoint in dstAddr? if is is afAddrType_t then we. 

  • Sorry, it is my mistake. Just ignore dstAddr..endPoint = applcation_endpoint.  Make sure your 3rd parameter is not 0.

  • Yes, SAMPLELIGHT_ENDPOINT is 13. not zero. 

  • Do you check your sniffer log? Do you see that the endpoint of message in sniffer log is 0?

  • Then what should i do? I am giving the Same App Endpoint in the ZDP_SimpleDescReq. Where should be wrong? But one thing is sure, it is Sending to ZED ShortAddress, but why i am not able to get in ZED. Help me to do this

  • Help me out to solve this issue

  • Is any other Method for ZDP_SimpleDescReq. why it is not working for me?I request to suggest me.

  • Would you attach your ZC source code for me to check?