Skip to content

Commit

Permalink
Merge pull request #130 from puddly/rc
Browse files Browse the repository at this point in the history
0.16.1 Release
  • Loading branch information
puddly authored Oct 8, 2022
2 parents b2e2b9d + 0fba87c commit ea308a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
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

0 comments on commit ea308a5

Please sign in to comment.