<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to Retrieve a List of All Devices Connected in a Zigbee Network Using nRF Connect SDK?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116517/how-to-retrieve-a-list-of-all-devices-connected-in-a-zigbee-network-using-nrf-connect-sdk</link><description>I am working on zigbee network 
 &amp;quot;In a Zigbee network, how can the coordinator retrieve the list of all devices connected to the network?&amp;quot; 
 What is the recommended way to maintain an up-to-date list of all devices in a Zigbee network using the nRF Connect</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 20 Nov 2024 14:40:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116517/how-to-retrieve-a-list-of-all-devices-connected-in-a-zigbee-network-using-nrf-connect-sdk" /><item><title>RE: How to Retrieve a List of All Devices Connected in a Zigbee Network Using nRF Connect SDK?</title><link>https://devzone.nordicsemi.com/thread/511345?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2024 14:40:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92fefaf9-0590-47d5-adf5-039ea22228a8</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]&amp;quot;In a Zigbee network, how can the coordinator retrieve the list of all devices connected to the network?&amp;quot;[/quote]
&lt;p&gt;An answer from our AI helper gives you some generic hints for how to do this&lt;/p&gt;
&lt;p&gt;&lt;em&gt;To retrieve the list of all devices connected to a Zigbee network, the coordinator can use the Management LQI (Link Quality Indicator) request. This request allows the coordinator to obtain information about its neighboring devices, including their network addresses and other details. Here&amp;#39;s how you can do this:&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;1. Use the `zb_zdo_mgmt_lqi_req()` function to send a Management LQI request. This function is part of the ZBOSS Zigbee stack used in Nordic Semiconductor&amp;#39;s Zigbee solutions.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;2. Set the destination address (`dst_addr`) parameter to the coordinator&amp;#39;s own short address. This will retrieve the information about devices directly connected to the coordinator.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;3. Implement a callback function to handle the response from the Management LQI request. This callback will receive the information about the neighboring devices.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;To get a complete list of all devices in the network, you may need to send this request to each router in the network as well, as they might have additional devices connected to them.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;It&amp;#39;s worth noting that executing this request frequently (e.g., every 3-5 seconds) might affect the Zigbee network performance, so it should be used judiciously.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;For more detailed information on using the Management LQI request and handling its response, you can refer to the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/zboss/3.12.1.0/group__zdo__mgmt.html#ga231ec009bd8d5fffa218f30b9e5f089f"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/zboss/3.12.1.0/group__zdo__mgmt.html#ga231ec009bd8d5fffa218f30b9e5f089f&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
[quote user=""]What is the recommended way to maintain an up-to-date list of all devices in a Zigbee network using the nRF Connect SDK?[/quote]
&lt;p&gt;You can for instance&lt;/p&gt;
&lt;p&gt;1. Use the Management LQI request periodically:&lt;br /&gt; As mentioned in the previous answer, you can use the `zb_zdo_mgmt_lqi_req()` function to retrieve information about neighboring devices. However, to get a complete picture of the network, you&amp;#39;ll need to send this request to the coordinator and all routers in the network.&lt;/p&gt;
&lt;p&gt;2. Implement device join and leave callbacks:&lt;br /&gt; The nRF Connect SDK provides callbacks for device joining and leaving events. You can use these to keep your device list up-to-date in real-time.&lt;/p&gt;
&lt;p&gt;- For device joins, implement the `ZB_ZDO_SIGNAL_DEVICE_ANNCE` callback.&lt;br /&gt; - For device leaves, implement the `ZB_ZDO_SIGNAL_LEAVE` callback.&lt;/p&gt;
&lt;p&gt;3. Use the Zigbee Device Object (ZDO) callbacks:&lt;br /&gt; Implement the `ZB_ZCL_REGISTER_DEVICE_CB()` function to register callbacks for various Zigbee events, including device joins and leaves.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an example of how you might implement this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void zboss_signal_handler(zb_bufid_t bufid)
{
    zb_zdo_app_signal_hdr_t *sg_p = NULL;
    zb_zdo_app_signal_type_t sig = zb_get_app_signal(bufid, &amp;amp;sg_p);

    switch (sig) {
        case ZB_ZDO_SIGNAL_DEVICE_ANNCE:
            // Handle new device join
            handle_device_join(sg_p);
            break;
        case ZB_ZDO_SIGNAL_LEAVE:
            // Handle device leave
            handle_device_leave(sg_p);
            break;
        // ... handle other signals as needed
    }

    if (bufid) {
        zb_buf_free(bufid);
    }
}

void device_cb(zb_bufid_t bufid)
{
    zb_zcl_device_callback_param_t *device_cb_param =
        ZB_BUF_GET_PARAM(bufid, zb_zcl_device_callback_param_t);

    switch (device_cb_param-&amp;gt;device_cb_id) {
        case ZB_ZCL_DEVICE_CB_ID_DEVICE_ANNCE:
            // Handle device announce
            break;
        case ZB_ZCL_DEVICE_CB_ID_LEAVE:
            // Handle device leave
            break;
        // ... handle other device callbacks as needed
    }
}

void main(void)
{
    // ... other initialization code

    ZB_ZCL_REGISTER_DEVICE_CB(device_cb);

    // ... start Zigbee network
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This approach allows you to maintain an up-to-date list of devices by:&lt;br /&gt;1. Periodically using the Management LQI request to get a full picture of the network.&lt;br /&gt;2. Updating the list in real-time as devices join or leave the network.&lt;/p&gt;
&lt;p&gt;Remember to handle the responses from the Management LQI requests and update your device list accordingly.&lt;/p&gt;
&lt;p&gt;For more detailed information on implementing these callbacks and handling Zigbee events, refer to the &lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/zigbee/index.html#ug-zigbee"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/zigbee/index.html#ug-zigbee&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/zigbee/qsg.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/zigbee/qsg.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>