diff --git a/bellows/zigbee/application.py b/bellows/zigbee/application.py index a638cb5d..9fe94ac5 100644 --- a/bellows/zigbee/application.py +++ b/bellows/zigbee/application.py @@ -1159,8 +1159,15 @@ async def send_packet(self, packet: zigpy.types.ZigbeePacket) -> None: aps_frame.groupId = t.uint16_t(0x0000) if self.config[zigpy.config.CONF_SOURCE_ROUTING]: - # Source routing uses address discovery to discover routes - aps_frame.options |= t.EmberApsOption.APS_OPTION_ENABLE_ADDRESS_DISCOVERY + # Concentrator/source-routing uses address discovery; also keep AODV + # route discovery as a fallback for destinations that aren't yet in + # the NCP's source-route table (e.g. immediately after startup, + # before the first MTORR has propagated). Mirrors what + # zigbee-herdsman's ember adapter does for the same reason. + aps_frame.options |= ( + t.EmberApsOption.APS_OPTION_ENABLE_ADDRESS_DISCOVERY + | t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY + ) elif zigpy.types.TransmitOptions.FORCE_ROUTE_DISCOVERY in packet.tx_options: # Forcing route discovery requires retrying aps_frame.options |= t.EmberApsOption.APS_OPTION_FORCE_ROUTE_DISCOVERY diff --git a/tests/test_application.py b/tests/test_application.py index ed5ce537..326ef973 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -927,6 +927,7 @@ async def test_send_packet_unicast_source_route(make_app, packet): options=( t.EmberApsOption.APS_OPTION_RETRY | t.EmberApsOption.APS_OPTION_ENABLE_ADDRESS_DISCOVERY + | t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY ), ) @@ -957,6 +958,7 @@ async def test_send_packet_unicast_manual_source_route(make_app, packet): options=( t.EmberApsOption.APS_OPTION_RETRY | t.EmberApsOption.APS_OPTION_ENABLE_ADDRESS_DISCOVERY + | t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY ), ) @@ -1074,6 +1076,7 @@ async def test_send_packet_unicast_combined_manual_source_route(make_app, packet options=( t.EmberApsOption.APS_OPTION_RETRY | t.EmberApsOption.APS_OPTION_ENABLE_ADDRESS_DISCOVERY + | t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY ), ) @@ -1096,6 +1099,7 @@ async def test_send_packet_unicast_combined_native_source_route_fallback( options=( t.EmberApsOption.APS_OPTION_RETRY | t.EmberApsOption.APS_OPTION_ENABLE_ADDRESS_DISCOVERY + | t.EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY ), )