请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:LP-CC1352P7工具/软件:
您好、
如何获取 ns_br 应用程序上已连接设备的列表?
我知道这是通过 SPINEL 上的连接器件完成的、但如何通过 ns-br 代码完成的?
我有 ns_br 和 ns_node、我想了解新节点何时加入组。
此致、
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具/软件:
您好、
如何获取 ns_br 应用程序上已连接设备的列表?
我知道这是通过 SPINEL 上的连接器件完成的、但如何通过 ns-br 代码完成的?
我有 ns_br 和 ns_node、我想了解新节点何时加入组。
此致、
您好、
您是否查看过上述功能的内部? 这就是检索已连接设备列表的方式。 目前、我们没有这种开箱即用函数。
我基于 NcpBase:HandlePropertyGet 编写了自己的 get_connected_devices (void) 我每 1 秒从 application.c 中调用一次 (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 */
}
节点联接后、将打印地址

希望这能帮助您的问题。
此致、
Daniel