|
17 | 17 | from bellows.exception import ControllerError, EzspError |
18 | 18 | import bellows.ezsp as ezsp |
19 | 19 | from bellows.ezsp.v9.commands import GetTokenDataRsp |
20 | | -from bellows.ezsp.xncp import FirmwareFeatures, FlowControlType |
| 20 | +from bellows.ezsp.xncp import FirmwareFeatures, FlowControlType, GetChipInfoRsp |
21 | 21 | import bellows.types |
22 | 22 | import bellows.types as t |
23 | 23 | import bellows.types.struct |
@@ -1786,6 +1786,36 @@ async def test_startup_new_coordinator_no_groups_joined(app, ieee): |
1786 | 1786 | assert app._ezsp._protocol.setMulticastTableEntry.mock_calls == [] |
1787 | 1787 |
|
1788 | 1788 |
|
| 1789 | +@pytest.mark.parametrize( |
| 1790 | + ("concurrency_config", "chip_concurrency", "expected_concurrency"), |
| 1791 | + [ |
| 1792 | + (None, 32, 32), # Default config (None) uses chip |
| 1793 | + (8, 16, 16), # Default fallback (8) uses chip |
| 1794 | + (16, 32, 16), # Explicit config overrides chip |
| 1795 | + (12, 32, 12), # Low explicit config overrides chip |
| 1796 | + ], |
| 1797 | +) |
| 1798 | +async def test_startup_concurrency_setting( |
| 1799 | + app, ieee, concurrency_config, chip_concurrency, expected_concurrency |
| 1800 | +): |
| 1801 | + """Test that adapter concurrency is set correctly based on configuration.""" |
| 1802 | + app._config[zigpy.config.CONF_MAX_CONCURRENT_REQUESTS] = concurrency_config |
| 1803 | + |
| 1804 | + with mock_for_startup(app, ieee) as ezsp: |
| 1805 | + ezsp._xncp_features |= FirmwareFeatures.CHIP_INFO |
| 1806 | + ezsp.get_default_adapter_concurrency = AsyncMock(return_value=chip_concurrency) |
| 1807 | + ezsp.xncp_get_chip_info = AsyncMock( |
| 1808 | + return_value=GetChipInfoRsp(ram_size=0, part_number="") |
| 1809 | + ) |
| 1810 | + |
| 1811 | + await app.connect() |
| 1812 | + await app.start_network() |
| 1813 | + |
| 1814 | + assert ( |
| 1815 | + app._concurrent_requests_semaphore.max_concurrency == expected_concurrency |
| 1816 | + ) |
| 1817 | + |
| 1818 | + |
1789 | 1819 | @pytest.mark.parametrize( |
1790 | 1820 | "scan_results", |
1791 | 1821 | [ |
@@ -1964,6 +1994,7 @@ def zigpy_backup() -> zigpy.backups.NetworkBackup: |
1964 | 1994 | "flow_control": "hardware", |
1965 | 1995 | "can_burn_userdata_custom_eui64": True, |
1966 | 1996 | "can_rewrite_custom_eui64": True, |
| 1997 | + "chip_info": None, |
1967 | 1998 | } |
1968 | 1999 | }, |
1969 | 2000 | ), |
@@ -1999,6 +2030,26 @@ async def test_load_network_info_xncp_flow_control( |
1999 | 2030 | assert app.state.network_info == zigpy_backup.network_info |
2000 | 2031 |
|
2001 | 2032 |
|
| 2033 | +async def test_load_network_info_chip_info( |
| 2034 | + app: ControllerApplication, |
| 2035 | + ieee: zigpy_t.EUI64, |
| 2036 | +) -> None: |
| 2037 | + """Test that chip info is included in network metadata when available.""" |
| 2038 | + app._ezsp._xncp_features |= FirmwareFeatures.CHIP_INFO |
| 2039 | + expected_chip_info = GetChipInfoRsp( |
| 2040 | + ram_size=262144, part_number="EFR32MG24A020F1536IM48" |
| 2041 | + ) |
| 2042 | + app._ezsp.xncp_get_chip_info = AsyncMock(return_value=expected_chip_info) |
| 2043 | + |
| 2044 | + await app.load_network_info(load_devices=True) |
| 2045 | + |
| 2046 | + # Check that chip info is included in the metadata |
| 2047 | + assert app.state.network_info.metadata["ezsp"]["chip_info"] == { |
| 2048 | + "ram_size": 262144, |
| 2049 | + "part_number": "EFR32MG24A020F1536IM48", |
| 2050 | + } |
| 2051 | + |
| 2052 | + |
2002 | 2053 | async def test_write_network_info( |
2003 | 2054 | app: ControllerApplication, |
2004 | 2055 | ieee: zigpy_t.EUI64, |
|
0 commit comments