Skip to content

Commit 3395cd1

Browse files
committed
devices: discovery: do not filter local XBee on node discovery
If 'discover myself' option is enabled, the first 'ND' response comes from the local XBee. Update local XBee data from the response, but do not add a connection to itself. Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
1 parent f067fc4 commit 3395cd1

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

digi/xbee/devices.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9868,11 +9868,6 @@ def discovery_gen_callback(xbee_packet):
98689868
if remote is not None:
98699869
# If remote was successfully created and it is not in the
98709870
# XBee list, add it and notify callbacks.
9871-
9872-
# Do not add a connection to the same node (the local one)
9873-
if remote == self._local_xbee:
9874-
return
9875-
98769871
self._log.debug(" o Discovered neighbor of %s: %s",
98779872
self._local_xbee, remote)
98789873

@@ -9888,17 +9883,19 @@ def discovery_gen_callback(xbee_packet):
98889883
# only the local device performs an 'ND'
98899884
self._log.debug(" - Added to network (scan: %d)", node.scan_counter)
98909885

9891-
# Add connection (there is not RSSI info for a 'ND')
9892-
from digi.xbee.models.zdo import RouteStatus
9893-
if self._add_connection(Connection(
9894-
self._local_xbee, node, LinkQuality.UNKNOWN, LinkQuality.UNKNOWN,
9895-
RouteStatus.ACTIVE, RouteStatus.ACTIVE)):
9896-
self._log.debug(" - Added connection: %s >>> %s",
9897-
self._local_xbee, node)
9898-
else:
9899-
self._log.debug(
9900-
" - CONNECTION already in network in this scan (scan: %d) %s >>> %s",
9901-
self.__scan_counter, self._local_xbee, node)
9886+
# Do not add a connection to the same node (the local one)
9887+
if node != self._local_xbee:
9888+
# Add connection (there is not RSSI info for a 'ND')
9889+
from digi.xbee.models.zdo import RouteStatus
9890+
if self._add_connection(Connection(
9891+
self._local_xbee, node, LinkQuality.UNKNOWN, LinkQuality.UNKNOWN,
9892+
RouteStatus.ACTIVE, RouteStatus.ACTIVE)):
9893+
self._log.debug(" - Added connection: %s >>> %s",
9894+
self._local_xbee, node)
9895+
else:
9896+
self._log.debug(
9897+
" - CONNECTION already in network in this scan (scan: %d) %s >>> %s",
9898+
self.__scan_counter, self._local_xbee, node)
99029899

99039900
# Always add the XBee device to the last discovered devices list:
99049901
self.__last_search_dev_list.append(node)

0 commit comments

Comments
 (0)