Home/Support/Support Forum/XBee3, Python: what is the difference between device.discovery of remote device vs instantiating a remote device object?

XBee3, Python: what is the difference between device.discovery of remote device vs instantiating a remote device object?

0 votes
I have an XBee3 ZigBee network here.

I'm using the Python built in library:
https://xbplib.readthedocs.io/en/latest/user_doc/communicating_with_xbee_devices.html

In the relative beginning of my program I of course establish connection with all the reouter devices in my network of many routers and a coordinator. I am wondering what the difference is between instantiating a remote xbee device object like so:
# Instantiate a remote XBee device object.
remote_device = RemoteXBeeDevice(device, XBee64BitAddress.from_hex_string("0013A20040XXXXXX"))
and discovering a remote xbee device via it's Node Identifier (NI) like so:
# Discover the remote device whose node ID is ‘SOME NODE ID’.
remote = xnet.discover_device("SOME NODE ID")

For the duration of my project I've been just discovering the remote devices in the network using the latter NI string identifier. However, now I have new design requirements and so I would like to discover the device by it's MAC address. So, fundamentally I would like a better understanding of the two above things: instantiating via MAC vs discovering via NI.

if I instantiate, does that inherently discover the device behind the scenes? or would I have to discover the device separately...?
asked Aug 10, 2020 in XBee3 ZigBee by edunn106 New to the Community (25 points)

Please log in or register to answer this question.

1 Answer

+1 vote
What is this code to run on? Are you trying to use the Micro Python interface on the XBee 3 or is this code to run on an external processor?
answered Aug 10, 2020 by mvut Veteran of the Digi Community (14,676 points)
this will run on the pc python
The NI does a discovery to a known ASCII value and resolves the 64 bit address off of that ASCII value for you.  It is meant to be a user friendly way of discovering and setting a destination address.
ok cool. and so the instantiation of a router device via specifying its MAC address:

# Instantiate a remote XBee device object.
remote_device = RemoteXBeeDevice(device, XBee64BitAddress.from_hex_string("0013A20040XXXXXX"))

"discovers" or establishes an official network connection.. as does the NI discover.. both, as standalone uses, establishes / discovers the network connection "equally". how do I say, if I use either one, poof connection established right? lol
like in my code here:
-----------------------
remote_2 = RemoteXBeeDevice(local_device, XBee64BitAddress.from_hex_string(jn_device_mac))
print('remote_2 before NI set: ', remote_2)
remote_2.set_node_id('TOWER_2')
print('remote_2 after NI set: ', remote_2)
tower_2 = xnet.discover_device("TOWER_2")
----------------------------

the last line of xnet.discover_device(NI) would be redundant because I established connection via the MAC in the first line and then just gave it a new NI. so, connection established and using the discover via NI would be redundant?
That is correct.
...