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.

Simple API vs Z-Stack (CC2480)

Other Parts Discussed in Thread: Z-STACK

 Hi all, I'm using CC2480  to develop a zigbee based device locator. It's my first time working with zigbee devices.

I started studying the ZASA example (with EZ430-RF2480 kit). My objective is to make a low powered device send a broadcast message using the AF layer and read the "Link Quality" byte received by the routers and make that byte part of the already implemented report that is sent to the coordinator by SAPI commands (along with temperature and bus voltage readings) . However, I can't make the AF Data Request arrive at the router at all. 

ZASA already makes his register/bind/join using simple api, so i just added along with ZB_APP_REGISTER_REQUEST an AF_REGISTER command (which, i presume, is not part of the simple api) and implemented functions to transmit and receive using AF commands. It didnt work. When using AF to transmit should i have to also bind and join using the z-stack ZDO commands? What commands should i use for that? Simple API is kinda understandable but Z-Stack got me confused. I'm not sure where should i use ZDO_END_DEVICE_BIND_REQ and ZDO_BIND_REQ and which parameters to fill these commands with. also, is it necessary to announce the endpoint if im using SAPI to bind into the network?

If the above explanation is too messed up, does anyone have an example of CC2480 software using Z-stack instead of SAPI?

Hmm lots of questions, bad english, i hope you can understand me.


Thanks,

MrGuga

 

  •  Hi MrGuga,

    I'm not sure whether u clearly know the difference between Joining and binding.

    i jst made this conclusion from ur post, sorry if i'm wrong.

    Joining is related to network layer and MAC layer. We can just control a device to Permit other devices to join with it or not.

    tat's wat happens wen u press the button on the Z-Accel kit wen the device is in appRunning state. actually, pressing he key toggles "Permit Joining".

    A device has to definitely join a network to communicate.

    Binding is something tat happens in application level. It's an optional feature. It helps u to send data to any device on the network without knowing it's actual address. When u start binding with other devices, the devices with matching cluster list(InClusterList, OutClusterList) bind to each other. so u can jst mention the cluster to which the data is destined. Actual address s derived from the binding table. of course, the data is sent to all devices tat r having the specified cluster id.

    Binding is achieved using the either API  ZB_BIND_DEVICE or ZDO_BIND_REQ. both are the commands for source binding. and i think tat the ZDO API ZDO_END_DEVICE_BIND_REQ is for indirect binding where the end device requests binding with another device through coordinator. later on, all the msgs will be forwarded to the bound device through coordinator.

    and it s important to have ur application registered with CC2480 either using ZB_APP_REGISTER_REQUEST or AF_REGISTER  before using ZB_BIND_DEVICE since it doesn't hv any field for srce endpoint, dest endpoint, cluster lists whereas  ZDO_BIND_REQ.

    and according to CC2480 Interface specification, u can send data either using ZB_SEND_DATA_REQ or AF_SEND_DATA_REQ without using binding feature.

    there are some addressing types tat u need to know abt.

    0xFFFC - Group of all routers and coordinator
    0xFFFD - Group of all devices with the radio receiver turned on

    0xFFFE -  indicate to the CC2480 that a binding table lookup should be perfomed

    0xFFFF - Broadcast group of all devices in the network

     

     u can use actual 16-bit network address or any one of these address modes. In this oxfffe must be used to tell CC2480 to add the address from binding table entry and before using this binding must hv been created.

    nd sorry tat if  my reply s lengthy...

    i suggest u to go through the following docs if u hvn't yet.

    1.CC2480 Developer's  guide

    2.CC2480 Interface specification.

    nd also pls refer to the following posts of mine.

    https://community.ti.com/forums/p/337/1337.aspx#1337

    https://community.ti.com/forums/t/106.aspx

     

    with regards,

    vairaX

  •  Actually, there is also some simpler code examples for CC2480 that is also available to show the basics in setting it up and looking at the response using the CC2480 VCP UART. This can also be of hielp and a good start. 

    • CC2480 Software Examples(swru169.zip, 256 KB )
                 30 Apr 2008 zip

     LPRF_Rocks 

  •  Hello again.

     Thanks to the replies I could understand a bit more about the joining and binding process.

    My project already works with the AF broadcasts, or at least part of it. When I use the coordinator and some end device,

    the broadcast messages are received , but any router added doesn't receive a thing. I used different end points for AF and SAPI

    registers, as follows:

    #define ZASA_PROFILE_ID                   0x0F10
    #define ZASA_PROFILE_ID_LSB               0x10
    #define ZASA_PROFILE_ID_MSB               0x0F

    #define SRCE_REPORT_ID_LSB                1
    #define SRCE_REPORT_ID_MSB                0
    #define SRCE_REPORT_ID                    0x0001
    #define SRCE_REPORT_SZ                    5
    #define SRCE_REPORT_ADDR_LSB              1
    #define SRCE_REPORT_ADDR_MSB              0
    #define SRCE_REPORT_BUSV                  2
    #define SRCE_REPORT_RSSI                  3
    #define SRCE_REPORT_SEQ                   4

    #define SINK_ENDPOINT_ID                  2
    #define SINK_DEVICE_ID_LSB                4
    #define SINK_DEVICE_ID_MSB                0
    #define SINK_DEVICE_VERSION               1
    #define SINK_LATENCY                      0
    #define SINK_CLUSTER_IN_CNT               1
    #define SINK_CLUSTER_OUT_CNT              0

    #define SRCE_ENDPOINT_ID                  1
    #define SRCE_DEVICE_ID_LSB                3
    #define SRCE_DEVICE_ID_MSB                0
    #define SRCE_DEVICE_VERSION               1
    #define SRCE_LATENCY                      0
    #define SRCE_CLUSTER_IN_CNT               0
    #define SRCE_CLUSTER_OUT_CNT              1

    #define AF_ZASA_PROFILE_ID                   0x0F10
    #define AF_ZASA_PROFILE_ID_LSB               0x10
    #define AF_ZASA_PROFILE_ID_MSB               0x0F

    #define AF_SRCE_REPORT_ID_LSB                2    //Comando ou ClusterID
    #define AF_SRCE_REPORT_ID_MSB                0
    #define AF_SRCE_REPORT_ID                    0x0002
    #define AF_SRCE_REPORT_SZ                    2
    #define AF_SRCE_REPORT_BUSV                  0
    #define AF_SRCE_REPORT_SEQ                   1

    #define AF_SINK_ENDPOINT_ID                  3
    #define AF_SINK_DEVICE_ID_LSB                0
    #define AF_SINK_DEVICE_ID_MSB                0
    #define AF_SINK_DEVICE_VERSION               1
    #define AF_SINK_LATENCY                      0
    #define AF_SINK_CLUSTER_IN_CNT               0
    #define AF_SINK_CLUSTER_OUT_CNT              0

    #define AF_SRCE_ENDPOINT_ID                  4
    #define AF_SRCE_DEVICE_ID_LSB                5
    #define AF_SRCE_DEVICE_ID_MSB                0
    #define AF_SRCE_DEVICE_VERSION               1
    #define AF_SRCE_LATENCY                      0
    #define AF_SRCE_CLUSTER_IN_CNT               0
    #define AF_SRCE_CLUSTER_OUT_CNT              0

     

    I register the af end points like this, right after registering the SAPI end points:

    if (appFlags & appLowPwrF)
      {
        zb_AfAppRegister(afsrceEP);
      }
      else
      {
        zb_AfAppRegister(afsinkEP);
      } 

    The broadcast function is as follows:

    void af_DataBroadcast( uint16 commandId, uint8 srceEndpoint, uint8 sinkEndpoint, uint8 handle, uint8 txOptions,
                          uint8 radius, uint8 len, uint8 *pData)
    {
        uint8 *pBuf = zaccelMsgBuf;

      *(pBuf+MT_RPC_POS_LEN) = 10 + len;
      *(pBuf+MT_RPC_POS_CMD0) = MT_RPC_SYS_AF | (uint8)(MT_RPC_CMD_SREQ);
      *(pBuf+MT_RPC_POS_CMD1) = MT_AF_DATA_REQUEST;

      *(pBuf+MT_RPC_POS_DAT0) = 0xFC; //Dest Address LSB
      *(pBuf+MT_RPC_POS_DAT0+1) = 0xFF; // Dest Address MSB
      *(pBuf+MT_RPC_POS_DAT0+2) = sinkEndpoint; //Dest Endpoint
      *(pBuf+MT_RPC_POS_DAT0+3) = srceEndpoint; //Src Endpoint
      *(pBuf+MT_RPC_POS_DAT0+4) = (uint8)commandId; //ClusterID LSB
      *(pBuf+MT_RPC_POS_DAT0+5) = (uint8)(commandId >> 8); //ClusterID MSB (
      *(pBuf+MT_RPC_POS_DAT0+6) = handle;
      *(pBuf+MT_RPC_POS_DAT0+7) = txOptions;
      *(pBuf+MT_RPC_POS_DAT0+8) = radius;
      *(pBuf+MT_RPC_POS_DAT0+9) = len;
      if (pData)
      {
        memcpy((pBuf+MT_RPC_POS_DAT0+10), pData, len);
      }

      zaccelRPC(pBuf);
    }

     And this is how I call it:

     af_DataBroadcast(AF_SRCE_REPORT_ID, AF_SRCE_ENDPOINT_ID, AF_SINK_ENDPOINT_ID, appMsgHandle++,
                           AF_DISCV_ROUTE, 1, AF_SRCE_REPORT_SZ, afsrceReport);

     

    Could anyone tell what's wrong? 

    I'd appreciate any help on this matter and apologize for the huge post.

     MrGuga

  • Hi vairaX,

    Firstly, thank you for your post, it's quite comprehensive.

    I'm doing a project which I'm suffering some problems with the binding and address of end-device. Using binding, as you stated, we can send a packet to a device without knowing its short address because the address will be obtained from binding table. The concept about binding is like that but is there any way that we can see what really happen inside the binding process because I want to fix the address of the end-divice.

    Another way to fix the address is using the 64-bit Extended Address but it's really troublesome if we use this address, so if you know how to fix the 16-short address by modifying the binding process or binding table or whatever, could you please give me some guide?

    Thank you.

    Best Regards

    Long Ngo

  • You can find detailed information on the binding table structure and APIs to access that structure from code here (http://tiexpressdsp.com/images/8/8a/08_-_ZigBee_Stack.pdf ). Look about 3/4 of the way through the material.

    Scott

  • Ok, thank you Scott.