Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion zigpy_xbee/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MAJOR_VERSION = 0
MINOR_VERSION = 16
PATCH_VERSION = "0"
PATCH_VERSION = "1"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
21 changes: 17 additions & 4 deletions zigpy_xbee/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ async def _get_association_state(self):
async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None:
LOGGER.debug("Sending packet %r", packet)

try:
device = self.get_device_with_address(packet.dst)
except (KeyError, ValueError):
device = None

tx_opts = TXOptions.NONE

if packet.extended_timeout:
Expand All @@ -193,17 +198,25 @@ async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None:
long_addr = UNKNOWN_IEEE
short_addr = UNKNOWN_NWK

if packet.dst.addr_mode == zigpy.types.AddrMode.IEEE:
long_addr = packet.dst.address
elif packet.dst.addr_mode == zigpy.types.AddrMode.Broadcast:
if packet.dst.addr_mode == zigpy.types.AddrMode.Broadcast:
long_addr = EUI64(
[
zigpy.types.uint8_t(b)
for b in packet.dst.address.to_bytes(8, "little")
]
)
else:
short_addr = packet.dst.address
elif packet.dst.addr_mode == zigpy.types.AddrMode.Group:
short_addr = packet.dst.address
elif packet.dst.addr_mode == zigpy.types.AddrMode.IEEE:
long_addr = EUI64(packet.dst.address)
elif device is not None:
long_addr = EUI64(device.ieee)
short_addr = device.nwk
else:
raise zigpy.exceptions.DeliveryError(
"Cannot send a packet to a device without a known IEEE address"
)

send_req = self._api.tx_explicit(
long_addr,
Expand Down