File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -639,7 +639,8 @@ async def write_config(self, config: dict) -> None:
639639 ezsp_config = {}
640640 ezsp_values = {}
641641
642- for cfg in DEFAULT_CONFIG [self ._ezsp_version ]:
642+ # If a protocol version is not explicitly supported, use config for the latest
643+ for cfg in DEFAULT_CONFIG .get (self ._ezsp_version , DEFAULT_CONFIG [EZSP_LATEST ]):
643644 if isinstance (cfg , RuntimeConfig ):
644645 ezsp_config [cfg .config_id .name ] = dataclasses .replace (
645646 cfg , config_id = t .EzspConfigId [cfg .config_id .name ]
Original file line number Diff line number Diff line change @@ -951,6 +951,32 @@ async def test_cfg_initialize_skip():
951951 )
952952
953953
954+ @pytest .mark .parametrize ("unsupported_version" , [15 , 18 , 99 ])
955+ async def test_unsupported_ezsp_version_startup (unsupported_version : int , caplog ):
956+ """Test that startup works with an unsupported EZSP version."""
957+ ezsp = make_ezsp (version = unsupported_version )
958+
959+ with patch ("bellows.uart.connect" ):
960+ await ezsp .connect ()
961+
962+ # The EZSP version should be stored as the unsupported version
963+ assert ezsp ._ezsp_version == unsupported_version
964+
965+ # But the protocol should fall back to the latest
966+ assert ezsp ._protocol .VERSION == EZSP_LATEST
967+
968+ assert f"Protocol version { unsupported_version } is not supported" in caplog .text
969+
970+ ezsp .getConfigurationValue = AsyncMock (return_value = (t .EzspStatus .SUCCESS , 0 ))
971+ ezsp .setConfigurationValue = AsyncMock (return_value = (t .EzspStatus .SUCCESS ,))
972+ ezsp .setValue = AsyncMock (return_value = (t .EzspStatus .SUCCESS ,))
973+ ezsp .getValue = AsyncMock (return_value = (t .EzspStatus .SUCCESS , b"\xFF " ))
974+
975+ # Startup should not fail
976+ await ezsp .write_config ({})
977+ assert len (ezsp .setConfigurationValue .mock_calls ) > 0
978+
979+
954980async def test_reset_custom_eui64 (ezsp_f ):
955981 """Test resetting custom EUI64."""
956982 # No NV3 interface
You can’t perform that action at this time.
0 commit comments