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.

  • 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