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
18 changes: 18 additions & 0 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,24 @@ async def test_startup_connect(zigate_new, app, version_rsp, expected_version):
assert app.version == expected_version


@pytest.mark.asyncio
@pytest.mark.parametrize("version, addr_mode", [
["3.1z", t.AddressMode.NWK_NO_ACK],
["3.1d", t.AddressMode.NWK],
])
async def test_send_unicast_request(app, version, addr_mode):
packet = zigpy_t.ZigbeePacket(src=zigpy_t.AddrModeAddress(addr_mode=zigpy_t.AddrMode.NWK, address=0x0000), src_ep=1, dst=zigpy_t.AddrModeAddress(addr_mode=zigpy_t.AddrMode.NWK, address=0xFA5D), dst_ep=1, source_route=None, extended_timeout=False, tsn=20, profile_id=260, cluster_id=6, data=zigpy_t.SerializableBytes(b'\x01\x14\x00'), tx_options=zigpy_t.TransmitOptions.NONE, radius=0, non_member_radius=0, lqi=None, rssi=None)

app.version = version
app._api.raw_aps_data_request.return_value = ([t.Status.Success, 163, 1328, b'\x00\x00'], 0)
await app.send_packet(packet)

# The packet was sent with ACKs, even though zigpy didn't ask for it
assert app._api.raw_aps_data_request.mock_calls[0].kwargs["addr_mode"] == addr_mode

app._api.raw_aps_data_request.assert_called_once()


@pytest.mark.asyncio
async def test_send_group_request(app):
packet = zigpy_t.ZigbeePacket(src=None, src_ep=1, dst=zigpy_t.AddrModeAddress(addr_mode=zigpy_t.AddrMode.Group, address=0x0002), dst_ep=None, source_route=None, extended_timeout=False, tsn=21, profile_id=260, cluster_id=6, data=zigpy_t.SerializableBytes(b'\x01\x15\x00'), tx_options=zigpy_t.TransmitOptions.NONE, radius=0, non_member_radius=3, lqi=None, rssi=None)
Expand Down
2 changes: 1 addition & 1 deletion zigpy_zigate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MAJOR_VERSION = 0
MINOR_VERSION = 10
PATCH_VERSION = '2'
PATCH_VERSION = '3'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
9 changes: 7 additions & 2 deletions zigpy_zigate/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ def _handle_frame_failure(self, message_tag, status):
async def send_packet(self, packet):
LOGGER.debug("Sending packet %r", packet)

ack = (zigpy.types.TransmitOptions.ACK in packet.tx_options)
# Firmwares 3.1d and below allow a couple of _NO_ACK packets to send but all
# subsequent ones will fail. ACKs must be enabled.
ack = (
zigpy.types.TransmitOptions.ACK in packet.tx_options
or self.version <= "3.1d"
)

try:
(status, tsn, packet_type, _), _ = await self._api.raw_aps_data_request(
Expand All @@ -263,7 +268,7 @@ async def send_packet(self, packet):
if status == t.Status.InvalidParameter and self.version <= "3.1d":
pass
else:
raise zigpy.exceptions.DeliveryError(f"Failed to send packet: {status}", status=status)
raise zigpy.exceptions.DeliveryError(f"Failed to send packet: {status!r}", status=status)

# disabled because of https://github.com/fairecasoimeme/ZiGate/issues/324
# try:
Expand Down