Skip to content

Commit 9f002c4

Browse files
authored
Enable force route discovery on retries (#674)
1 parent 857bfe5 commit 9f002c4

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

bellows/zigbee/application.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -836,11 +836,15 @@ async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None:
836836
else:
837837
aps_frame.groupId = t.uint16_t(0x0000)
838838

839-
if not self.config[zigpy.config.CONF_SOURCE_ROUTING]:
840-
aps_frame.options |= t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY
841-
else:
839+
if self.config[zigpy.config.CONF_SOURCE_ROUTING]:
842840
# Source routing uses address discovery to discover routes
843841
aps_frame.options |= t.EmberApsOption.APS_OPTION_ENABLE_ADDRESS_DISCOVERY
842+
elif zigpy.types.TransmitOptions.FORCE_ROUTE_DISCOVERY in packet.tx_options:
843+
# Forcing route discovery requires retrying
844+
aps_frame.options |= t.EmberApsOption.APS_OPTION_FORCE_ROUTE_DISCOVERY
845+
aps_frame.options |= t.EmberApsOption.APS_OPTION_RETRY
846+
else:
847+
aps_frame.options |= t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY
844848

845849
extended_timeout = packet.extended_timeout
846850

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
"click",
1818
"click-log>=0.2.1",
1919
"voluptuous",
20-
"zigpy>=0.78.0",
20+
"zigpy>=0.79.0",
2121
'async-timeout; python_version<"3.11"',
2222
]
2323

tests/test_application.py

+11
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,17 @@ async def test_send_packet_unicast_extended_timeout_without_acks(app, ieee, pack
941941
]
942942

943943

944+
async def test_send_packet_unicast_force_route_discovery(app, packet):
945+
await _test_send_packet_unicast(
946+
app,
947+
packet.replace(tx_options=zigpy.types.TransmitOptions.FORCE_ROUTE_DISCOVERY),
948+
options=(
949+
t.EmberApsOption.APS_OPTION_RETRY
950+
| t.EmberApsOption.APS_OPTION_FORCE_ROUTE_DISCOVERY
951+
),
952+
)
953+
954+
944955
async def test_send_packet_unicast_unexpected_failure(app, packet):
945956
with pytest.raises(zigpy.exceptions.DeliveryError):
946957
await _test_send_packet_unicast(app, packet, status=t.EmberStatus.ERR_FATAL)

0 commit comments

Comments
 (0)