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.

Start A Zigbee Network and send messages between coordinator and a router

Other Parts Discussed in Thread: CC2530, Z-STACK

Hi All,

I have 2 cc2530 connected to ccDebugger. And I am trying to establish a Zigbee network. Unfortunately since all sample applications depend on the evaluation board which I do no posess and hence handleKeys event never gets triggered.

Can any1 help me with a sample project to establish a connection and send helloworld messages between coordinator and router without having to depend on HandleKeys event.

Thanks in Advance

  • Let's use GenerricApp as example.

    1. You can remove HOLD_AUTO_START from compile option from both coordinator and end device project.

    2. Add the following red codes in GenericApp_ProcessEvent().

            case ZDO_STATE_CHANGE:
              GenericApp_NwkState = (devStates_t)(MSGpkt->hdr.status);
              if ( (GenericApp_NwkState == DEV_ZB_COORD) ||
                   (GenericApp_NwkState == DEV_ROUTER) ||
                   (GenericApp_NwkState == DEV_END_DEVICE) )
              {

               

                if(GenericApp_NwkState == DEV_ZB_COORD)

                    NLME_PermitJoiningRequest(255); //Enable Permit Join on Current ZC

                if(GenericApp_NwkState == DEV_END_DEVICE){

                    zAddrType_t dstAddr;

                   // Initiate an End Device Bind Request for the mandatory endpoint
                   dstAddr.addrMode = Addr16Bit;
                   dstAddr.addr.shortAddr = 0x0000; // Coordinator
                   ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(),
                                GenericApp_epDesc.endPoint,
                                GENERICAPP_PROFID,
                                GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
                                GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
                                FALSE );

                }

                 // Start sending "the" message in a regular interval.
                osal_start_timerEx( GenericApp_TaskID,
                                    GENERICAPP_SEND_MSG_EVT,
                                    txMsgDelay );
              }
    3. Register Device_annce by adding "ZDO_RegisterForZDOMsg(task_id, Device_annce);" in GenericApp_Init function.

    4. Add "case Device_annce:" in GenericApp_ProcessZDOMsgs() and add sending ZDP_EndDeviceBindReq in "case Device_annce:". Refer to the code in red in the followings:

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

        case Device_annce:

         {

                    zAddrType_t dstAddr;

                   // Initiate an End Device Bind Request for the mandatory endpoint
                   dstAddr.addrMode = Addr16Bit;
                   dstAddr.addr.shortAddr = 0x0000; // Coordinator
                   ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(),
                                GenericApp_epDesc.endPoint,
                                GENERICAPP_PROFID,
                                GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
                                GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
                                FALSE );

         }

         break;


        case End_Device_Bind_rsp:
          if ( ZDO_ParseBindRsp( inMsg ) == ZSuccess )
          {
            // Light LED
            HalLedSet( HAL_LED_4, HAL_LED_MODE_ON );
          }
    #if defined( BLINK_LEDS )
          else
          {
            // Flash LED to show failure
            HalLedSet ( HAL_LED_4, HAL_LED_MODE_FLASH );
          }
    #endif
          break;

        case Match_Desc_rsp:
          {
            ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );
            if ( pRsp )
            {
              if ( pRsp->status == ZSuccess && pRsp->cnt )
              {
                GenericApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
                GenericApp_DstAddr.addr.shortAddr = pRsp->nwkAddr;
                // Take the first endpoint, Can be changed to search through endpoints
                GenericApp_DstAddr.endPoint = pRsp->epList[0];

                // Light LED
                HalLedSet( HAL_LED_4, HAL_LED_MODE_ON );
              }
              osal_mem_free( pRsp );
            }
          }
          break;
      }
    }

    Build coordinator and end device to download two CC2530. Then, turn on coordinator and end device later. They should send "Hello world"

  • Thanks Chen.

    The network establishment is happening fine and AF_DataRequest is returning success on the end device.


    But on the Coordinator where I am recieving the data I am only recieving the event AF_DATA_CONFIRM_CMD with the following data
    Expression Value Location Type
    Atom8_MessageMSGCB Atom8_MessageMSGCB (0x5F929) void (__xdata_reentrant *)(struct __Unnamed_2_1921 *)
    MSGpkt 0x113D (theHeap + 656) R7:R6 struct __Unnamed_2_1921 *
    hdr <struct> XData:0x113D osal_event_hdr_t
    groupId 4104 XData:0x113F uint16
    clusterId 111 XData:0x1141 uint16
    srcAddr <struct> XData:0x1143 afAddrType_t
    macDestAddr 3 XData:0x114F uint16
    endPoint '\0' (0x00) XData:0x1151 uint8
    wasBroadcast '.' (0x0F) XData:0x1152 uint8
    LinkQuality 'k' (0x6B) XData:0x1153 uint8
    correlation '¯' (0xAF) XData:0x1154 uint8
    rssi '\0' (0x00) XData:0x1155 int8
    SecurityUse '\0' (0x00) XData:0x1156 uint8
    timestamp 0 XData:0x1157 uint32
    nwkSeqNum '\0' (0x00) XData:0x115B uint8
    cmd <struct> XData:0x115C afMSGCommandFormat_t
    TransSeqNumber '\0' (0x00) XData:0x115C uint8
    DataLength 0 XData:0x115D uint16
    Data 0xA400 "d.`.Ž‚ƒ££££àd.`..¤¹å\b$.üä5\týt\v.\v³ª‚«ƒ....¤¾.\v³.Ót..\v³t.ðt\b..." XData:0x115F unsigned char *
    'd' (0x64) XData:0xA400 unsigned char
    macSrcAddr 94 XData:0x1161 uint16
    radius '\0' (0x00) XData:0x1163 uint8

    I am not recieving the actual data and event AF_INCOMING_MSG_CMD. Is there anything I am missing here ?
  • Do you trigger SW2 on both coordinator and device to do binding? If you don't do binding, "Hello World" message won't be send in GenericApp example.

  • My Bad. I figured that the zcl_event_loop was handling this event hence was not getting passed to the application

    uint16 zcl_event_loop( uint8 task_id, uint16 events )
    {
    uint8 *msgPtr;

    (void)task_id; // Intentionally unreferenced parameter

    if ( events & SYS_EVENT_MSG )
    {
    msgPtr = osal_msg_receive( zcl_TaskID );
    while ( msgPtr != NULL )
    {
    uint8 dealloc = TRUE;

    if ( *msgPtr == AF_INCOMING_MSG_CMD )
    {
    zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );
    }

    The HelloWorld data being sent from end device is being recieved fine on this device. THanks a lot for the help
  • You are welcome and it's good to know it works now.
  • Hi YK,
    I made small modifications to the system. Instead of the same Temperature sample for coordinator. I used ZNP firmware for coordinator.
    Now with minor modifications the zigbee network is established and router joins the ZNP coordinator. But I am not getting Device_annce event and BindingRequest is not happening. Hence I am not able to transmit messages.

    Could you advice me a bit here?

    Cheers,
    Akash A
  • I suggest you to use Ubiqua Packet Analyzer to see if device announcement is actually sent out.

  • Can you elaborate your question?
  • Hello Sir,
    When I compiled the application as Zigbee Coordinator then everything gets compiled smoothly ,but when I do this for EndDeviceEB then it shows error

    Error[Pe020]: identifier "ZCLSAMPLESW_BINDINGLIST" is undefined
    Error[Pe020]: identifier "bindingOutClusters" is undefined
    etc.

    Whats the probable cause for this?

    Thanks in Advance
  • Which Z-Stack version and example do you see this issue? And, what modification do you make?
  • Hello Sir,
    I am using z-stack example SampleSwitch and I did the modification stated above in the red ,I have achieved the communication between coordinator and end device by pressing the switch on the end device.

    Case:After pressing the switch 2 on coordinator and router ,they are binded ,now when i press switch 6 on end device ,I can see on the debugger coordinator is sending packets .

    Its a good sign that things are working.

    The main task is when I press button on end device the device should send me motion sensor value connected on coordinator

    for e.g motion sensor on the coordinator should send its value to end device on pressing switch on the end device.

    if a value more than specified value is received then glow an LED or buzzer on the end device.

    Thanks!
  • It seems that you don't define define ZCLSAMPLESW_BINDINGLIST and bindingOutClusters in your project.
  • Sir
    I resolved the issue of the above errors.Thanks for the help..
  • You are welcome.
  • Hello Sir,

    I got stucked with this problem:

    Whenever I compile the sample switch program as a router or end device then the interrupt on pin Port 2.0 works fine ,but when I compile the program as coordinator the program doesn`t stops ,it keep running though I clear the interrupt flag to 0

    P2IFG &=~BV(0);
    P2IF=0;

    Can you tell me what is the problem ?

    Thanks and regards!
  • I don't understand your question well. Can you elaborate?
  • Sir,

    I am using the HA SampleSwitch Program,In this for communication between coordinator and end device ,I referred

    e2e.ti.com/.../1860885
    and added the code marked in red ,But when I compiled my code as end device the switch works perfectly ,that is by pressing it I get the LED indication,but same when i compiled my code as Coordinator the the interrupt occurs automatically and doesnt stop??

    Thanks1
  • In hal_key.c, it use P2.0 as interrupt trigger. Do you disable it in hal_key.c.
  • Yes I did....
    P2IFG &=~BV(0);
    P2IF=0;
  • I see no difference when you use those codes on ZC, ZR, or ZED. If this only happens on ZC, I can only suggest you to trace and debug it.
  • this code is for Z-Stack ? how can I do to send frecuency data (I use P 2.0 us frecuency input).
  • What do you mean frequency data?
  • Huumm !! I read 1,83 Mhz data in (P_2.0) from function generator. what I need is send this number to coordinator with ZigBee. i use CC2530 AIR Module BoosterPack.
  • You can use API AF_DataRequest to send message.