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.

Ping

Other Parts Discussed in Thread: Z-STACK

hi all,

Is their any pinging mechanism in zigbee so that devices in the networks can be easily identified..

please help..

regards,

arun...

  • What type of identification you are looking for?

    Do you need specific parameters, or some sort of packet trip time measurement?

  • Hi Sherer,

    I want to use zigbee network for a critical application. In that network all the zigbee devices should be active always. Suppose any one of the device fails i have to peform some other action which is independent of the wireless network. In my application pinging means any logic which ensures all devices in the network or it should identify failure of any device.

    Please help

    thanks in advance

  • You can initiate some periodic message to be sent to a data collector (a PC) through a ZigBee gateway.

    The application (on PC) should be able to detect that some device hasn't sent (even once) its periodic 

    message, thus indicating some sort of failure.

    This kind of message can be a simple ZigBee application message with a specific opcode, shouldn't be

    a very complicated or complex implementation/solution.

  • Hi Sherer,

    It will be an advantage if i can send a periodic message from cordinator to routers and their response to cordinator when any one of the routers fails then the cordinator can report that to PC. But "serialapp" sample application seems to be complex and i could not implement this logic due to its OSAL tasks.

    Thanks

    arun

  • Arun C S said:
    It will be an advantage if i can send a periodic message from cordinator to routers and their response to cordinator

    Broadcasting from a node that can be a potential gateway may create an avalanche. Why instead not using

    the routers to send periodic messages directly to the coordinator, sort of "I'm alive" messages. Coordinator

    will relay those messages directly to a PC (through USB or Serial) and a  PC application will be monitoring

    if one of the router haven't sent its message when it should be.

    Arun C S said:
    But "serialapp" sample application seems to be complex and i could not implement this logic due to its OSAL tasks.

    The OSAL is a perfect solution in this case, go through OSAL API document, there

    you will find several functions for scheduling events, immediately or with a help of

    a software timer.

    You could call for a timer that cen be reloaded automatically, where this timer will

    invoke a very simple event.

    You can learn and benefit by learning other sample applications in Z-stack.

  • I will try to implement this but apart from the ping data i also have to send data packets randomly this will add some complexity of distinguishing ping data and other data packet. 

    also nothing mentioned about creating a new task in OSAL documentation.

    thanks

    arun

  • Hi,

    Arun C S said:
    I will try to implement this but apart from the ping data i also have to send data packets randomly this will add some complexity of distinguishing ping data and other data packet. 

    Sending periodic and random messages in a different way shouldn't be hard for implementation.

    The trick here is to send a periodic messages with OPCODE_1 (as payload sub-header) and a

    random messages with OPCODE_2. On the coordinator side some sort of minimal payload

    inspection (look for the opcode) should be done and then a decision about what have to do with a

    specific message (packet) must be taken.

    Arun C S said:
    also nothing mentioned about creating a new task in OSAL documentation.

    Practically, you may not create a new task, by creating two different events in one task,

    where first event will handle the periodic messages 

  • Hi Sherer,

    you have given a better solution but i have some doubts..Is it possible to define new events? the "serialapp" is bounded for handling messages through UART, i think with it is not possible to send periodic messages without the help of UART. In my application i want to send ping data without the help of UART ie., from the application layer itself. I want to don't know abt packet formation with custimized fields like OPCODE_1,etc, I also want to know more about events.

    thank you

    arun 

  • Hi,

    Arun C S said:
    I want to don't know abt packet formation with custimized fields like OPCODE_1,etc, I also want to know more about events.

    Let's investigate a bit the SerialApp_ProcessEvent, as you can probably observe a very nice

    if( SOME_EVENT ) {
    //some logic
    return ( events ^ SOME_EVENT ); // Actually discard processed event
    }

    structure, so after the SYSTEM_EVENT there are several application specific events like the 

    SERIALAPP_SEND_EVT and SERIALAPP_RESP_EVT. These events defined in serialApp.h

    You can add your own event by initially defining a name for this event

    (i.e. #define MY_PERIODIC_MSG_EVT  0x0004) and then adding an if() structure inside

    the SerialApp_ProcessEvent function that will handle (in some way) your periodic msg.

    Also you can learn a bit the flow of serial application, this described in Z-Stack Sample Applications.pdf,

    section 3.

  • thanks Mr. Sherer,

    i think with the help of a new event and using osal timer, i can send periodic messages..

    regards,

    arun

  • hi Sherer,

    I tried the method suggested by you but not working..may be because of my coding problem...the problem is when to trigger the MY_PING_EVENT using osal_start_timerEx() function only once i can trigger not repeatedly...next problem is where to put the osal_start_timerEx() in the SerialApp application..

    Please help

    thank you

    arun

  • Hi,

    Arun C S said:
    osal_start_timerEx() function only once i can trigger not repeatedly

    osal_start_timerEx() will trigger an event only once, it is a perfect solution for setting

    manual periods (or some other logic on demand).

    For periodic triggering you may try the osal_start_reload_timer() which will trigger an

    event and then reload a timer again, trigger an event... and so on.

    Arun C S said:
    where to put the osal_start_timerEx() in the SerialApp application

    There are no deterministic rules for such things, but in your case a good place might

    be when device joins a network and starts itself as router/end device, in other words,

    when device's state changed from DEV_INIT to DEV_ROUTER/DEV_END_DEV, or

    once device is bound to another device. There is always an option of triggering this

    timer execution by an external event, such as detection of push button press.

  • Hi Sherer,

    Some problem in osal_start_reload_timer() function , am getting error message as "osal_start_reload_timer"declared implictly,also i could not find OSAL API about osal_start_reload_timer().Which is the header file corresponding to osal_start_reload_timer()?

    Please help

    thank you 

    arun

  • Hi,

     

    header: OSAL_timers.h

    source code: OSAL_Timers.c

    You have to include the OSAL_timers.h in serialApp.c (I forgot to mention it before)

  • Hi Sherer,

    I changed the SerialApp code as follows

    UINT16 SerialApp_ProcessEvent( uint8 task_id, UINT16 events )
    {
    (void)task_id; // Intentionally unreferenced parameter

    if ( events & SYS_EVENT_MSG )
    {
    .
    .
    .
    case ZDO_STATE_CHANGE: 
    osal_start_reload_timer (SerialApp_TaskID, PING_EVENT, 50 );
    break;
    .
    .
    .
    .
    .
    if (events & PING_EVENT )// for ping
    {
    ping_send();
    return ( events ^ PING_EVENT);
    }
    ************************************************************
    static void ping_send(void)

    {
    if (afStatus_SUCCESS != AF_DataRequest(&SerialApp_TxAddr,
    (endPointDesc_t *)&SerialApp_epDesc,
    SERIALAPP_CLUSTERID1,
    12, ping_sendbuf,
    &SerialApp_MsgID, 0, AF_DEFAULT_RADIUS))
    {
    osal_set_event(SerialApp_TaskID, PING_EVENT);
    }

    }

    But no ping msg is sending...i couldn't find any mistake in this..
    please help
    Than you
    arun

  • Hi Sherer,

    I changed the SerialApp code as follows,

    UINT16 SerialApp_ProcessEvent( uint8 task_id, UINT16 events )
    {
    (void)task_id; // Intentionally unreferenced parameter

    if ( events & SYS_EVENT_MSG )
    {
    .
    .
    .
    case ZDO_STATE_CHANGE: 
    osal_start_reload_timer (SerialApp_TaskID, PING_EVENT, 50 );
    break;
    .
    .
    if (events & PING_EVENT )// for ping 
    {
    ping_send();
    return ( events ^ PING_EVENT);
    }
    *********************************************************************
    static void ping_send(void)

    {
    if (afStatus_SUCCESS != AF_DataRequest(&SerialApp_TxAddr,
    (endPointDesc_t *)&SerialApp_epDesc,
    SERIALAPP_CLUSTERID1,
    12, ping_sendbuf,
    &SerialApp_MsgID, 0, AF_DEFAULT_RADIUS))
    {
    osal_set_event(SerialApp_TaskID, PING_EVENT);
    }

    }
    I couldn't find any mistake in the code...but it is not sending ping messages.
    please help
    arun
  • Hi,

     

    The code looks right, I have two comments though:

    1. For now increase timer period from 50mSecs to 100mSecs.
    2. You can you a bit different approach to resent messages without
      immediately invoking the osal_set_event(SerialApp_TaskID, PING_EVENT);
      inside ping_send() function.

    Several tips for debugging:

    1. Set a breakpoint at different places in the code. For example, on the ping_send()
      function, in the PING_EVENT. See if your code reach this point. Then you may set
      additional breakpoints to ensure the right flow.
    2. You may rewrite a little bit the pin_send() function, to watch the return value of
      AF_DataRequest().
    3. Additional (and essential) tool to debug these kind of things is the packet sniffer,
      use it to observe the over-the-air traffic.
    4. On the receiving side, set a break point on the place where it should be processing
      your periodic message, it may be so that the message is filtered  out even before
      reaching the processing stage (due to mismatch in endPoint enumeration, different
      cluster ID, etc..)
  • Hi sherer,

    i set breakpoints at different places....i found that the problem with PING_EVENT, that event is not trigerring......it could be either the problem with event or timer....

    thank you

    arun

  • Ok, in this case, have you checked if the start_reload_timer() has been executed during the run?

  • When i did step by step debugging, it reaches start_reload_timer() only once and the timer is not incrementing ie., when it reaches start_reload_timer() ,it doesn't gone to start_reload_timer()  portion in OSAL_timers.c

    than you

    arun


  • thanks a lot for your support Mr.Sherer...now it is working...it was the problem with the timer

    thanks again

    arun

  • You are welcome.

    If this thread can be consider by you as answered, please verify the answer that suits the most.

  • hi Sherer,

    now i am concentrating on the receiver side my receiver is a router(actually 3 routers) i have not included any ping processing function in router. My cordinator is sending ping messages from application layer the router receives the packet and issues acknowlledgement(seen from packet sniffer) but it doesn't write the received packet on the UART. But it writes data to UART which was send from cordinator UART.

    please help

    thank you 

    arun