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.

how to send data from ED to router then Coordinator in zstack mesh

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

Dear

        I am new to zstack mesh , up till now i have send data from ED to Coordinator , Can you please guide if i want to send data to router from ENd device then from router  coordinator 

ED------------> R1----------------->Coordinator 

Thanks 

  • You can only assign destination but not routing path in Zigbee mesh network.

  • Dear
    can you explain little more ?

    Thanks
  • For example, if your ZED is a child node of ZR and ZED wants to send a message to ZC, it would go to ZR then ZC. If your ZED is a child node of ZC, ZED can send message directly to ZC. Z-Stack would decide the routing path for a message.
  • thanks,
    means i have to just download the code in ZED (cc2530) of end device ,ZR (cc2530) of router , ZC (cc2531) and coordinator hex file , and zstack will manage automatically ?

    Currently i have programmed the ZED(cc2530) and ZC(cc2531), on an external interrupt ZED sends message to ZC and ZC display it on UART.

    My question is how ZR router will forward the message to ZC , is it automatic or we have to insert some code in functions to forward to ZC.

    Thanks
  • It's automatically done by Z-Stack. Application doesn't have to take care of it.
  • thanks, i will check and update you
  • You are welcome.
  • Dear
    i have downloaded router hex file in two cc2530 and place between coordinator and end device

    ED----------> R1------------------> R2--------------------------> Coordinator

    When i ED move to a distance of round 30 to 35 feet it stops sending messages or communication breaked ,
    is it ok ? means that range is ok or it should be greater then that?


    Second issue i have , i can't have any indication to show that my message is moving from routers and reached at co ordinator , can you please tell me in which function in genericapp router receives a message and send it to next router or co ordinator ? because i want to blink light our there to confirm that message is received to router and forward as well .

    Thanks in advance
  • 1. 30 to 35 feet is not good. Is it in line of sight? What HW do you use to test this? cC2530DK or your own PCB design?
    2. The application on router won't know it is forwarding message for other so you won't be able to blink LED when it does that.
  • Thanks Dear

    yes , its line of sight.
    i am using usb dongle cc2531 as a cordinator which i pluged into pc usb port, then smartrf05 DK cc2530 as a Router # 1 , then a smartrf05 battery board as Router # 2 and then a cc2530 as a End device.


    ED cc2530 ------> R1 (smartrf05 battery board) ------> R2(smartrf05 DK)-------> Coordinator(usb dongle cc2531).

    Any solution in your mind how to proceed ?

    thanks,
  • I don't understand your question. Can you elaborate what I can help you?
  • Thanks Dear,

    i have tested , without antennas then what should be range ?
    Can you tell me how to proceed further to increase distance , because its very less. and its line of sight.
    thanks
  • What do you mean without antennas?
  • on zigbee modules i have not attached any antenna
  • If you don't attach antenna, the RF range would be very short. By the way, what do you intend to do to not use antenna?
  • :) , for time being unable to arrange antennas .Do you think that is the reason that it only works for the line of sight communication ?

    Thanks,
  • Most probably that's the reason
  • I suggest you to connect antenna and test again.

  • ok thanks i will and update you , thanks for help Igor Sherer and Yikai Chen
  • Dear

    when i programmed the Router R1 with CC2530 Router .hex file , then it display on LCD " Match Desc Req Rsp Sent"
    and from ED when i send a message by pressing a button it blinks LED1 on smartrf05 means that it is receiving message .
    But Router does not forwarding that message to coordinator.
    when i by pass the router then ED successfully send messages to coordinator.

    Any help?
  • I am not clear about your test steps and what you intend to do. Can you elaborate? By the way, please specify which Z-Stack example you use to test this.

  • Dear,

    i am using genericapp ,these are the steps which i have taken

    1)i have downloaded the ENDdeviceEB in CC2530,with some modification in the code.When i press a button it generate an interrupt and sends a message to Coordinator(CC2531 USB dongle).
    2)i have downloaded the Coordinator code in CC2531 (USB dongle).With little modification ,when it receive message from step # 1 , it display it on COM Port via USB.

    ED CC2530--------> Coordinator (CC2531 USB dongle) -------------> PC Com port Display

    3)Above two steps are working fine.

    4)Now i want to increase the communication range in first step by adding routers in between ED and Coordinator as discussed in step 1&2.

    5)To achieve step # 4 , i have downloaded the RouterEB hex file in CC2530 to make it router.When it receive message from ED as discussed in Step # 1 it take that message and send it to Coordinator (CC2531 usb dongle) as discussed in step # 2 .

    ED CC2530--------------> Router CC2530 ---------------------> Coordinator (CC2531 USB dongle)

    6)when i follow step # 5 , then Router (CC2530) displayed on LCD " Match Desc Req Rsp Sent".And when i pressed button on CC2530 ED , it sends a message to router(CC2530), and led1 blinks on receiving every new message.

    ED CC2530--------------> Router CC2530 // working fine ,led blinks on receiving message

    7) Now router have to forward message to Coordinator

    Router CC2530 ---------------------> Coordinator (CC2531 USB dongle)

    But it didn't because no led blink on Coordinator.

    8)But when i make Router OFF then again sending message as briefed in step 1 & 2.

    ED CC2530--------> Coordinator (CC2531 USB dongle) --------> PC Com port Display // working fine again.


    i have problem in step # 6 and 7

    Thanks,
  • When you do step 5, what is the destination address your ED CC2530 sends message to?
  • i didn't add any address in ED as Router automatically assign address to ED to connect with it. Zstack automatically handle it

    in step number 1 &2 also didnt add any address.

    thanks Dear
  • It seems that your ED CC2530 bind with router so the message only sends to router. I suggest you to use Ubiqua Packet Analyzer to check this.
  • thanks dear , i will use

    Can you suggest me how router sends message to coordinator ? is there any function on which i have to forward received message to coordinator again ?

    Thanks again
  • You described "When i press a button it generate an interrupt and sends a message to Coordinator(CC2531 USB dongle)." in your step 1. Can you tell me how you send message to Coordinator from your ED CC2530?
  • dear mohammed,

    I am using CC2530DK. I am just stuck up in my work.

    can  u pls help me.

    I am not able to use CC2531 (ie i don't know how to configure it as Coordinator)

    Then i want to display the nodes identfier, can u tell me where i can find the line to display the identifier.

  • If you use GenericApp example in Z-Stack Mesh 1.0.0, you can use CC2531 GenericApp example under C:\Texas Instruments\Z-Stack Mesh 1.0.0\Projects\zstack\Samples\GenericApp\CC2531 and select coordinator to test it.
  • Dear Amudha
    Your problem solved or not ? or should i send you the code ?

    Thanks,
  • Dear

    i have used


    if ( events & GENERICAPP_SEND_MSG_EVT )
    {

    osal_start_timerEx( GenericApp_TaskID,
    GENERICAPP_SEND_MSG_EVT,
    txMsgDelay );

    }


    if (HAL_KEY_SW_6_PXIFG & HAL_KEY_SW_6_BIT) /* Interrupt Flag has been set */
    {
    HAL_KEY_SW_6_PXIFG = ~(HAL_KEY_SW_6_BIT); /* Clear Interrupt Flag */

    Message_Send(0,'C'); // this is a function which sends a message to Coordinator on interrupt
    valid = TRUE;
    }
  • It is not solved.
    I will be so thankful if u can consider me as a begginer and send me the details .
  • Dear
    are u able to open Zstack mesh after installation ?
    if yes then from workspace select EndDeviceEB
    then compile the code , it will generate the hex file then you download it into the cc2530
    if you done that then we proceed further ok ?

    thanks
  • What's in Message_Send? By the way, it's not recommended to send message in ISR function.
  • Yes , u r right , i have set a flag and send message in another function , which is called by a event of 500ms .
    Message_send is a function which sends a message to coordinator C-MACaddress-Batteryvoltage .

    thanks,
  • I need to know exactly how you use AF_DataRequest to send message.
  • thanks dear , i will update you in few hours about that , what exactly i am doing .
  • You are welcome.
  • Dear Muhammed,

    I have downloaded Zstack 1.2.1 Home Automaton Program into my kit.
    I have temperature sensor as end device. Can u now help me.
  • If you mean you use SampleTemperatureSensor as end device, you can run SampleThermostat as coordinator and make SampleTemperatureSensor to join it.
  • Dear
    I am using genericapp , i can help you in genericapp ,
    ok i will try to help you if i can
    have you tried , what i told u ?

    thanks
  • Dear

    I havent use home automation before , i am first time using genericapp for my project.Any how i will try my best to help you.

    Have you generated .hex file from the temperature sensor and downloaded into the Enddevice ?
  • Dear here is the code , please go through

    _______________________________________________________________________________________________________________

    For End Device CC2530 in GenericApp.c

    i have made following changes in END device

    case AF_DATA_CONFIRM_CMD:

    // changes made by Me, i have placed the if ( keys & HAL_KEY_SW_4 ) code there
    because before that i have to press joystick for binding ,
    now on power up it automatically bind , and send message on pressing a interrupt button on end device

    dstAddr.addrMode = AddrBroadcast;
    dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
    ZDP_MatchDescReq( &dstAddr, NWK_BROADCAST_SHORTADDR,
    GENERICAPP_PROFID,
    GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
    GENERICAPP_MAX_CLUSTERS, (cId_t *)GenericApp_ClusterList,
    FALSE );
    afDataConfirm = (afDataConfirm_t *)MSGpkt;



    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) )
    {
    // Start sending "the" message in a regular interval of 30 mins
    osal_start_timerEx( GenericApp_TaskID,
    GENERICAPP_SEND_MSG_EVT,
    txMsgDelay );

    // this is a polling timer of 500ms to check a function if/else conditions in " condition.c file" mentioned below
    // GENERICAPP_POLL_WHILE_EVT = 500ms

    osal_start_timerEx( GenericApp_TaskID,
    GENERICAPP_POLL_WHILE_EVT,
    While_Polling);

    Message_Send(0,'P'); // it sends a ping message to coordinator



    if ( events & GENERICAPP_POLL_WHILE_EVT ){

    Check_Conditions(); // if/else check condtions of 500ms , as discussed above

    osal_start_timerEx( GenericApp_TaskID,
    GENERICAPP_POLL_WHILE_EVT,
    While_Polling);

    return (events ^ GENERICAPP_POLL_WHILE_EVT);
    }

    if ( events & GENERICAPP_SEND_MSG_EVT ){


    Message_Send(0,'P'); // ping message send every 30mins

    // Setup to send message again
    osal_start_timerEx(GenericApp_TaskID,
    GENERICAPP_SEND_MSG_EVT,
    txMsgDelay );


    return (events ^ GENERICAPP_SEND_MSG_EVT);
    }


    _______________________________________________________________________________________________________________

    For End Device CC2530 in halkey.c

    if (HAL_KEY_SW_6_PXIFG & HAL_KEY_SW_6_BIT) /* Interrupt Flag has been set */
    {
    HAL_KEY_SW_6_PXIFG = ~(HAL_KEY_SW_6_BIT); /* Clear Interrupt Flag */
    Call_Int=1;
    Sec=0;
    valid = TRUE;
    }


    _______________________________________________________________________________________________________________

    For End Device CC2530 in condition.c

    void Check_Conditions(){
    if(Call_Int==1 ){
    Sec=0;
    Message_Send(Call_Message_Count,'C');
    Timer_Five_Min=1;
    Five_Min_Passed=0;
    Led=0;
    }

    ______________________________________________________________________________________________________________



    For Coordinator CC2531 in GenericApp.c



    static void GenericApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )
    {
    switch ( pkt->clusterId )
    {
    case GENERICAPP_CLUSTERID:
    rxMsgCount += 1; // Count this message
    HalLedSet ( HAL_LED_4, HAL_LED_MODE_BLINK ); // Blink an LED

    #if defined( LCD_SUPPORTED )
    HalLcdWriteString( (char*)pkt->cmd.Data, HAL_LCD_LINE_1 );

    #elif defined( WIN32 )
    WPRINTSTR( pkt->cmd.Data );
    #endif

    HalUARTWrite (1,pkt->cmd.Data,24); // coordinator sends message on COM port via USB
    break;
    }
    }
    _____________________________________________________________________________________________________________

    Dear ABove code is working fine , only issue i am facing is when i add router in between them , as discussed with you in previous comments (7 steps as discussed before)


    Thanks In advance,
  • You still don't show me what's in your Message_Send so I don't know how to help.
  • sorry for that dear ,


    unsigned char new_arr[26]; // global array

    Message_Send(0,'C'); // function call

    void Message_Send(unsigned char Count,unsigned char Type){



    pHidData[18]='-';
    pHidData[19]=(Bat_V/10)+48; // BV
    pHidData[20]=(Bat_V%10)+48;
    pHidData[21]='-';
    pHidData[22]=(Count/10)+48;
    pHidData[23]=(Count%10)+48;
    pHidData[24]=NULL;



    pHidData[1]='-';



    pHidData[2]=LookUpTable[aExtendedAddress[0]&0x0F];
    pHidData[3]=LookUpTable[(aExtendedAddress[0]&0xF0)>>4];

    pHidData[4]=LookUpTable[aExtendedAddress[1]&0x0F];
    pHidData[5]=LookUpTable[(aExtendedAddress[1]&0xF0)>>4];

    pHidData[6]=LookUpTable[aExtendedAddress[2]&0x0F];
    pHidData[7]=LookUpTable[(aExtendedAddress[2]&0xF0)>>4];

    pHidData[8]=LookUpTable[aExtendedAddress[3]&0x0F];
    pHidData[9]=LookUpTable[(aExtendedAddress[3]&0xF0)>>4];

    pHidData[10]=LookUpTable[aExtendedAddress[4]&0x0F];
    pHidData[11]=LookUpTable[(aExtendedAddress[4]&0xF0)>>4];

    pHidData[12]=LookUpTable[aExtendedAddress[5]&0x0F];
    pHidData[13]=LookUpTable[(aExtendedAddress[5]&0xF0)>>4];

    pHidData[14]=LookUpTable[aExtendedAddress[6]&0x0F];
    pHidData[15]=LookUpTable[(aExtendedAddress[6]&0xF0)>>4];

    pHidData[16]=LookUpTable[aExtendedAddress[7]&0x0F];
    pHidData[17]=LookUpTable[(aExtendedAddress[7]&0xF0)>>4];

    if(Type=='P'||Type=='F'||Type=='C'||Type=='M'){

    pHidData[0]=Type;

    }

    Generic_Message_Send((char*)pHidData);




    }

    void Generic_Message_Send(char string []){

    for(int i = 0; i <25; i++) {
    new_arr[i] = string[i];
    }
    GenericApp_SendTheMessage();



    }


    static void GenericApp_SendTheMessage(void)
    {

    if ( AF_DataRequest( &GenericApp_DstAddr, &GenericApp_epDesc,
    GENERICAPP_CLUSTERID,
    (byte)osal_strlen(new_arr) + 1,
    (byte *)&new_arr ,
    &GenericApp_TransID,
    AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
    {
    // Successfully requested to be sent.

    // HalLcdWriteString(string, HAL_LCD_LINE_1 );
    // HalLcdWriteString( "MAC-MT Coord", HAL_LCD_LINE_2 );
    }
    else
    {
    // Error occurred in request to send.
    }
    }


    thanks,
  • You have to check what is in your GenericApp_DstAddr when you do step 5.
  • thanks dear ,

    i will sort out , if not able to solve then i will contact you
  • You are welcome.
  • Dear

    1.Will the ED(cc2530) in genericapp.c automatically transmit to all routers and coordinator with a broadcast message and whoever gets it passes it onto the coordinator? Or does the ED(cc2530) bind with the router as it comes into range?
    2. How do I know if a router is connected to the coordinator and not self configuring it self as a coordinator? I get the sense that is what was happening the router I plugged in didn't connect to the coordinator but instead connected with the ED(cc2530) as the coordinator and messages sent to it didn't get relayed. Can we create a unique LED flashing pattern for router to tell me it is connected to the coordinator and configured as the router?

    thanks for the help so far you did for me .