zigbee 52840

I want to know if I call the following function, which condition should I meet to determine that the coordinator is not connected to any terminal devices.  For example, I now think that IF my ZigBee Dongle is not connected to any terminal device, I will take a zigBee Dongle light operation, but now I call the following function and I don't know what conditions are satisfied to achieve this goal.  The "sig" value in this function determines that ZigBee Dongle is not connected to any terminal devices  

  • My apologies, I was out of office last week. 

    The nRF5 SDK does not have this and users are expected to implement this themselves. Our expert respondes:

    The neighbors of the device are stored in a neighbor table, gc_neighbor. By iterating through this table you get all of the device's neighbors. If the device does not have any neighbors in the neighbor table, then there are no other devices on the network that are in range of the device. If it has neighbors, but their state is stale, then they were on the network and in range, but are not anymore.
    This is very simple and may not be exactly what you want, but it shows how to use the neighbor table to see if there are other devices on the network (in range of the device), and they can use this as a starting point.
    Calling this function will simply print the entries in the neighbor table.
    For end devices you have something called end device timeout. This is something the end device itself sets (with zb_set_ed_timeout in nRF5 SDK), and the end device informs its parent of this timeout, such that the parent will delete the child entry from the neighbor table if the end device has not communicated with the parent in the amount of time specified by the end device timeout. When it has timed out, the end device will be removed from the neighbor table.
    Routers and coordinators are not removed from the neighbor table, but you can find that the entry is stale by looking at the outgoing cost of the entry in the neighbor table. Normally, the cost of an outgoing link is 1-7. However, if a neighbor entry is considered stale, then this cost will be set to 0. Since the entries are not removed, you will have to handle stale entries in some way.
    /* Get neighbor table */
    static zb_void_t get_neighbors()
    {
        uint32_t i;
        zb_uint16_t addr;
        for (i = 0; i < gc_neighbor_table_size; i++)
        {
            /* If gc_neighbor[i].used is 0, the entry is not used */
            /* If gc_neighbor[i].ext_neighbor is 1, this is ext neighbor record, else base neighbor */
            if ((gc_neighbor[i].used == 0) ||
                (gc_neighbor[i].ext_neighbor != 0))
            {
                continue;
            }
            
            zb_address_short_by_ref(&addr, gc_neighbor[i].u.base.addr_ref);
            NRF_LOG_INFO("short_addr: 0x%04x", addr);
            switch (gc_neighbor[i].device_type) {
                case ZB_NWK_DEVICE_TYPE_COORDINATOR:
                    NRF_LOG_INFO("device type: ZC ");
                    break;
     
                case ZB_NWK_DEVICE_TYPE_ROUTER:
                    NRF_LOG_INFO("device type: ZR  ");
                    break;
     
                case ZB_NWK_DEVICE_TYPE_ED:
                    NRF_LOG_INFO("device type: ZED ");
                    break;
     
                default:
                    NRF_LOG_INFO("device type: ??? ");
                    break;
            }
            if (gc_neighbor[i].device_type != ZB_NWK_DEVICE_TYPE_ED)
            {
                /* The number of nwkLinkStatusPeriod intervals since a link status command was received */
                NRF_LOG_INFO("age: %03u ", gc_neighbor[i].u.base.age);
            }
            else
            {
                /* Time left of ED timeout */
                zb_time_t exp_time = ZB_TIME_SUBTRACT(gc_neighbor[i].u.base.time_to_expire, ZB_TIMER_GET());
                NRF_LOG_INFO("timeout: %07u", ZB_TIME_BEACON_INTERVAL_TO_MSEC(exp_time) / 1000);
            }
            if ((gc_neighbor[i].device_type != ZB_NWK_DEVICE_TYPE_ED) &&
                (gc_neighbor[i].u.base.outgoing_cost == 0))
            {   /* Outgoing cost of router or coordinator neighbor entry being 0 means the entry is stale */
                NRF_LOG_INFO("[STALE]");
            }
        }
    }
    Kind regards,
    Øyvind
Related