Skip to content

Commit

Permalink
discover new devices from ZDO NWK_addr_rsp and IEEE_addr_rsp
Browse files Browse the repository at this point in the history
  • Loading branch information
Shulyaka committed Sep 30, 2023
1 parent f85233f commit fdfcf83
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions zigpy_xbee/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def handle_rx(
LOGGER.info("handle_rx self addressed")

ember_ieee = zigpy.types.EUI64(src_ieee)
# Interpret useful global ZDO responses and notifications
if dst_ep == 0 and cluster_id == zdo_t.ZDOCmd.Device_annce:
# ZDO Device announce request
nwk, rest = zigpy.types.NWK.deserialize(data[1:])
Expand All @@ -320,6 +321,18 @@ def handle_rx(
src_nwk,
)
self.handle_join(nwk, ieee, 0)
elif dst_ep == 0 and cluster_id in (
zdo_t.ZDOCmd.NWK_addr_rsp,
zdo_t.ZDOCmd.IEEE_addr_rsp,
):
# ZDO IEEE Address Response or Network Address Response
status, rest = zdo_t.Status.deserialize(data[1:])
ieee, rest = zigpy.types.EUI64.deserialize(rest)
nwk, rest = zigpy.types.NWK.deserialize(rest)

if status == zdo_t.Status.SUCCESS:
LOGGER.debug("Discovered IEEE address for NWK=%s: %s", nwk, ieee)
self.handle_join(nwk, ieee, 0, handle_rejoin=False)

try:
self._device.last_seen = time.time()
Expand Down

0 comments on commit fdfcf83

Please sign in to comment.