LP-CC1352P7: How to get the Connected devices on ns_br

Part Number: LP-CC1352P7

Tool/software:

Hi,

How to get a list of connected devices on ns_br application?

I know this is done via connecteddevices on spinel but how is it done via the ns-br code please?

I have a ns_br and ns_node and I want to find out when a new node joins the group.

Regards,

  • Hi AliGeda,

    This is the function used by spinel in the embedded side, located in ncp_base_mtd.cpp.

    template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CONNECTED_DEVICES>(void)
    I'll check if there is a callback you could use.
    Best regards,
    Daniel
  • Thanks, but I am more after the equivalent of spinel in Wi-SUN.

  • Hi,

    Have you looked inside the function I described above? That is how the list of connected devices is retrieved. We currently don't have an out of the box function for this.
    I wrote my own get_connected_devices based on NcpBase::HandlePropertyGet<SPINEL_PROP_CONNECTED_DEVICES>(void) which I call every 1 second from application.c of ns_br.

    void get_connected_devices(void)
    {
        /*  GET NUM CONNECTED DEVICES */
        rpl_instance_t *instance;
        rpl_dao_target_list_t *dao_targets;
        uint16_t local_num_dao_targets = 0;
    
        instance = (rpl_instance_t *)get_rpl_instance();
        if (instance == NULL)
        {
            return;
        }
    
        dao_targets = &instance->dao_targets;
        if (dao_targets == NULL)
        {
            return;
        }
    
        local_num_dao_targets = ns_list_count(dao_targets); // Max possible number of dao targets
        if (local_num_dao_targets == 0)
        {
            return;
        }
    
        local_num_dao_targets = 0; // Reuse for calculating actual number of dao targets stored
        ns_list_foreach(rpl_dao_target_t, target, dao_targets) {
            if (target->root)
            {
                tr_info("Device address %d: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", local_num_dao_targets,
                        target->prefix[0],target->prefix[1],target->prefix[2],target->prefix[3],target->prefix[4],target->prefix[5],target->prefix[6],target->prefix[7],
                        target->prefix[8],target->prefix[9],target->prefix[10],target->prefix[11],target->prefix[12],target->prefix[13],target->prefix[14],target->prefix[15]);
                local_num_dao_targets++;
            }
        }
        tr_info("Connected devices %d", local_num_dao_targets);
    
        /* END GET CONNECTED DEVICES */
    }

    Once a node joins, the address is printed

    Hopefully, this helps your question.

    Best regards,

    Daniel