首页 > 解决方案 > 如何使用 python digi-xbee 库从本地 xbee 接收多个 ATCommand 响应数据包,用于“FN”(查找邻居)AT 命令

问题描述

这是适用于除“FN”之外的所有 AT 命令的代码:

from digi.xbee.devices import XBeeDevice

#Initialise a serial port for the local xbee 
local_xbee = XBeeDevice("/dev/tty.usbserial-AH02D9Q4", 9600). 

#Opens serial port for sending commands   
local_xbee.open()

#Sets new timeout for sync command operation 
local.set_sync_ops_timeout(10). 

#Send "FN" AT command to local xbee to receive neighbour list
neighbour_xbee_list = local.get_parameter("FN")

print(neighbour_xbee_list)

local_xbee.close()

笔记:

上面的代码只返回一个邻居,而我在网络中有多个节点。

标签: pythonxbee

解决方案


我相信问题的关键不是如何使用 FN 命令,而是如何发现邻居。

为此,您可以使用此处描述的 start_discovery_process 函数。 http://xbplib.readthedocs.io/en/latest/user_doc/discovering_the_xbee_network.html#discovernetwork


推荐阅读