This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Distinguishing between Zigbee pairing states?

To provide feedback to the user through the LED state, I would like the behavior to be something like this:

  • If the nRF52840 Zigbee device is unpaired and ready for a ZC to add it, flash the blue LED
  • If it is paired but it's still searching for its parent node (or if it has lost connectivity after previously talking to other nodes), flash the red LED
  • If it is paired and it is successfully connected to the network, keep the green LED on solid

I have been looking at the messages arriving through zboss_signal_handler() but I don't understand how to differentiate between these cases.  What should I watch for, and is there an example that demonstrates it?

My app implements a Zigbee on/off switch and it is set up to be a router node.

Parents
  • Hi,

    Something similar to this is already done in both the light bulb and light switch samples, where LED 3 is used to indicate that the device has joined a network. This is done by calling the function zigbee_led_status_update() inside the Zigbee signal handler:

    void zboss_signal_handler(zb_bufid_t bufid)
    {
        /* Update network status LED. */
        zigbee_led_status_update(bufid, ZIGBEE_NETWORK_STATE_LED);

    The function will turn the LED on if the status of the signal ZB_BDB_SIGNAL_STEERING is equal to RET_OK, which means that the device has successfully joined a network. If the status of this signal is something else or the device leaves the network (ZB_ZDO_SIGNAL_LEAVE) the LED will turn off.

    Zigbee router devices do not have parent devices, so the second condition where the device has joined the network but does not have a parent is not relevant. I suggest checking out our Zigbee quick start guide to get more familiar with how Zigbee works, and the different roles.

    Best regards,

    Marte

  • I saw this code and have tested it with a simple two node network, just the ZC and my router/lightbulb on nRF52840.  If I start up the nRF52 board when the ZC is completely powered off, it's still claiming that it joined the network and it's illuminating the ZIGBEE_NETWORK_STATE_LED:

    I: ZBOSS Light Bulb example started
    I: Production configuration is not present or invalid (status: -1)
    I: Zigbee stack initialized
    I: Unimplemented signal (signal: 54, status: 0)
    I: Joined network successfully on reboot signal (Extended PAN ID: XXX, PAN ID: YYY)
    W: Parent is unreachable
    W: Parent is unreachable
    W: Parent is unreachable
    W: Parent is unreachable

    I do not want this.  I want it to be clear to the user whether the nRF52 board has successfully established communication with other Zigbee nodes.  In the case where I power up a paired node and it can't find any other Zigbee devices on the PAN, I'd like to flash red rather than green to alert the user to the connectivity issue.

    Zigbee router devices do not have parent devices

    Perhaps I'm using the wrong terminology to refer to "the peer(s) my router talks to", but the documentation at your link and the error message output seems to state otherwise?

  • Hi,

    mytzyiay said:
    If I start up the nRF52 board when the ZC is completely powered off, it's still claiming that it joined the network and it's illuminating the ZIGBEE_NETWORK_STATE_LED

    This is actually correct. In this case the router has previously been commissioned to and joined the network, and it has the network data stored in NVRAM. When it restarts it does not need to be commissioned again, since it will use the stored network data to rejoin the network.

    The coordinator is not necessary for a Zigbee network to work. In typical Zigbee networks where the coordinator is the Trust Center, the coordinator is responsible for creating a network and for commissioning new devices. However, if the coordinator is turned off or not reachable for some reason, the network will not stop working. You will be unable to commission new devices without a Trust Center, but the devices that have already been commissioned will keep working and can keep communicating.

    mytzyiay said:
    W: Parent is unreachable

    This is printed when the signal ZB_NWK_SIGNAL_NO_ACTIVE_LINKS_LEFT is generated, which happens when a device is unable to reach any router or coordinator. If you have one coordinator and multiple routers in your network, and the coordinator is turned off this signal will not be generated, since the routers will still be able to find other routers.

    mytzyiay said:
    I want it to be clear to the user whether the nRF52 board has successfully established communication with other Zigbee nodes.  In the case where I power up a paired node and it can't find any other Zigbee devices on the PAN, I'd like to flash red rather than green to alert the user to the connectivity issue.

    You can use ZB_NWK_SIGNAL_NO_ACTIVE_LINKS_LEFT in zboss_signal_handler() for this.

    Best regards,

    Marte

Reply
  • Hi,

    mytzyiay said:
    If I start up the nRF52 board when the ZC is completely powered off, it's still claiming that it joined the network and it's illuminating the ZIGBEE_NETWORK_STATE_LED

    This is actually correct. In this case the router has previously been commissioned to and joined the network, and it has the network data stored in NVRAM. When it restarts it does not need to be commissioned again, since it will use the stored network data to rejoin the network.

    The coordinator is not necessary for a Zigbee network to work. In typical Zigbee networks where the coordinator is the Trust Center, the coordinator is responsible for creating a network and for commissioning new devices. However, if the coordinator is turned off or not reachable for some reason, the network will not stop working. You will be unable to commission new devices without a Trust Center, but the devices that have already been commissioned will keep working and can keep communicating.

    mytzyiay said:
    W: Parent is unreachable

    This is printed when the signal ZB_NWK_SIGNAL_NO_ACTIVE_LINKS_LEFT is generated, which happens when a device is unable to reach any router or coordinator. If you have one coordinator and multiple routers in your network, and the coordinator is turned off this signal will not be generated, since the routers will still be able to find other routers.

    mytzyiay said:
    I want it to be clear to the user whether the nRF52 board has successfully established communication with other Zigbee nodes.  In the case where I power up a paired node and it can't find any other Zigbee devices on the PAN, I'd like to flash red rather than green to alert the user to the connectivity issue.

    You can use ZB_NWK_SIGNAL_NO_ACTIVE_LINKS_LEFT in zboss_signal_handler() for this.

    Best regards,

    Marte

Children
  • OK.  Which signal should I watch for to determine that the router has reconnected with other devices (i.e. the number of active links is >0) and so I can turn the LED green again?

  • Hi,

    There is no signal generated for this, but what you can do is to check the neighbor table. The signal ZB_NWK_SIGNAL_NO_ACTIVE_LINKS_LEFT is generated when all entries in the devices neighbor table have aged out, except for the entries for end devices that the device itself is the parent of. Using the function zb_nwk_nbr_iterator_next() you can get entries in the neighbor table, so you can check whether there are any entries that are not a child of the device, and if so, you know that the router is able to communicate with other devices again. As of now, there are no examples showing how to use this function in the latest tag of nRF Connect SDK, but it is used in this pull request: https://github.com/nrfconnect/sdk-nrf/pull/6961/files/ce1cd4337ce0de6de9cc14b26ea740e17d8cccf7, specifically in the function refresh_active_nbt_table().

    Best regards,

    Marte

  • This seems to work for me so far.  What logic do I need to add in order to keep it from counting children of my router node?

    static bool has_active_neighbors = false;

    static void check_neighbors(zb_uint8_t bufid);

    static void neighbor_check_cb(zb_uint8_t bufid)
    {
    zb_nwk_nbr_iterator_params_t *args = ZB_BUF_GET_PARAM(bufid, zb_nwk_nbr_iterator_params_t);
    has_active_neighbors = args->index != ZB_NWK_NBR_ITERATOR_INDEX_EOT;

    ZB_SCHEDULE_APP_ALARM(check_neighbors, bufid, ZB_MILLISECONDS_TO_BEACON_INTERVAL(1000));
    }

    static void check_neighbors(zb_uint8_t bufid)
    {
    zb_ret_t error_code;

    if (bufid == ZB_BUF_INVALID) {
    error_code = zb_buf_get_out_delayed_func(check_neighbors);
    ZB_ASSERT(error_code == RET_OK);
    return;
    }

    zb_nwk_nbr_iterator_params_t *args = ZB_BUF_GET_PARAM(bufid, zb_nwk_nbr_iterator_params_t);
    args->update_count = 0;
    args->index = 0;

    error_code = zb_nwk_nbr_iterator_next(bufid, neighbor_check_cb);
    ZB_ASSERT(error_code == RET_OK);
    }

    static void schedule_neighbor_check(void)
    {
    ZB_SCHEDULE_APP_CALLBACK(check_neighbors, ZB_BUF_INVALID);
    }
  • Hi,

    That is good to hear!

    mytzyiay said:
    What logic do I need to add in order to keep it from counting children of my router node

    You can use either the device_type field of zb_nwk_nbr_iterator_entry_t to check if the device is an end device, or the relationship field to check if it is a child. 

    Device type The type of the neighbor device:
    0x00 = ZigBee coordinator
    0x01 = ZigBee router
    0x02 = ZigBee end device
    0x03 = Unknown
    Relationship The relationship between the neighbor and
    the current device:
    0x00 = neighbor is the parent
    0x01 = neighbor is a child
    0x02 = neighbor is a sibling
    0x03 = None of the above
    0x04 = previous child

    Best regards,

    Marte

Related