Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover new devices from ZDO NWK_addr_rsp and IEEE_addr_rsp #156

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading