Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all table size config for new adapters #629

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions bellows/ezsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import bellows.config as conf
from bellows.exception import EzspError, InvalidCommandError
from bellows.ezsp.config import DEFAULT_CONFIG, RuntimeConfig, ValueConfig
from bellows.ezsp.config import RuntimeConfig, ValueConfig
import bellows.types as t
import bellows.uart

Expand Down Expand Up @@ -543,7 +543,7 @@ async def write_config(self, config: dict) -> None:
ezsp_config = {}
ezsp_values = {}

for cfg in DEFAULT_CONFIG[self._ezsp_version]:
for cfg in self.CONFIG:
if isinstance(cfg, RuntimeConfig):
ezsp_config[cfg.config_id.name] = dataclasses.replace(
cfg, config_id=t.EzspConfigId[cfg.config_id.name]
Expand Down
80 changes: 30 additions & 50 deletions bellows/ezsp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,14 @@ class ValueConfig:
config_id=t.EzspConfigId.CONFIG_STACK_PROFILE,
value=2,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_SUPPORTED_NETWORKS,
value=1,
minimum=True,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_MULTICAST_TABLE_SIZE,
value=16,
minimum=True,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE,
value=2,
minimum=True,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_SECURITY_LEVEL,
value=5,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_ADDRESS_TABLE_SIZE,
value=16,
minimum=True,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_PAN_ID_CONFLICT_REPORT_THRESHOLD,
value=2,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_KEY_TABLE_SIZE,
value=4,
minimum=True,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_MAX_END_DEVICE_CHILDREN,
value=32,
Expand All @@ -73,11 +48,9 @@ class ValueConfig:
| t.EmberZdoConfigurationFlags.APP_HANDLES_UNSUPPORTED_ZDO_REQUESTS
),
),
# Must be set last
RuntimeConfig(t.EzspConfigId.CONFIG_PACKET_BUFFER_COUNT, value=0xFF),
]

DEFAULT_CONFIG_LEGACY = [
DEFAULT_CONFIG_LEGACY = DEFAULT_CONFIG_COMMON + [
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_SOURCE_ROUTE_TABLE_SIZE,
value=16,
Expand All @@ -91,15 +64,37 @@ class ValueConfig:
config_id=t.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT_SHIFT,
value=8,
),
] + DEFAULT_CONFIG_COMMON


DEFAULT_CONFIG_NEW = [
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_SOURCE_ROUTE_TABLE_SIZE,
value=200,
config_id=t.EzspConfigId.CONFIG_SUPPORTED_NETWORKS,
value=1,
minimum=True,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_MULTICAST_TABLE_SIZE,
value=16,
minimum=True,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE,
value=2,
minimum=True,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_ADDRESS_TABLE_SIZE,
value=16,
minimum=True,
),
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_KEY_TABLE_SIZE,
value=4,
minimum=True,
),
# Must be set last
RuntimeConfig(t.EzspConfigId.CONFIG_PACKET_BUFFER_COUNT, value=0xFF),
]


DEFAULT_CONFIG_NEW = DEFAULT_CONFIG_COMMON + [
RuntimeConfig(
config_id=t.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT,
value=8,
Expand All @@ -112,19 +107,4 @@ class ValueConfig:
value_id=t.EzspValueId.VALUE_FORCE_TX_AFTER_FAILED_CCA_ATTEMPTS,
value=t.uint8_t(1),
),
] + DEFAULT_CONFIG_COMMON


DEFAULT_CONFIG = {
4: DEFAULT_CONFIG_LEGACY,
5: DEFAULT_CONFIG_LEGACY,
6: DEFAULT_CONFIG_LEGACY,
7: DEFAULT_CONFIG_NEW,
8: DEFAULT_CONFIG_NEW,
9: DEFAULT_CONFIG_NEW,
10: DEFAULT_CONFIG_NEW,
11: DEFAULT_CONFIG_NEW,
12: DEFAULT_CONFIG_NEW,
13: DEFAULT_CONFIG_NEW,
14: DEFAULT_CONFIG_NEW,
}
]
2 changes: 2 additions & 0 deletions bellows/ezsp/v4/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import zigpy.state

import bellows.config
from bellows.ezsp.config import DEFAULT_CONFIG_LEGACY
import bellows.types as t
from bellows.zigbee.util import ezsp_key_to_zigpy_key

Expand All @@ -26,6 +27,7 @@ class EZSPv4(protocol.ProtocolHandler):
bellows.config.CONF_EZSP_CONFIG: vol.Schema(config.EZSP_SCHEMA),
bellows.config.CONF_EZSP_POLICIES: vol.Schema(config.EZSP_POLICIES_SCH),
}
CONFIG = DEFAULT_CONFIG_LEGACY

def _ezsp_frame_tx(self, name: str) -> bytes:
"""Serialize the frame id."""
Expand Down
2 changes: 2 additions & 0 deletions bellows/ezsp/v7/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import voluptuous

import bellows.config
from bellows.ezsp.config import DEFAULT_CONFIG_NEW
import bellows.types as t

from . import commands, config
Expand All @@ -24,6 +25,7 @@ class EZSPv7(EZSPv6):
bellows.config.CONF_EZSP_CONFIG: voluptuous.Schema(config.EZSP_SCHEMA),
bellows.config.CONF_EZSP_POLICIES: voluptuous.Schema(config.EZSP_POLICIES_SCH),
}
CONFIG = DEFAULT_CONFIG_NEW

async def read_child_data(
self,
Expand Down
16 changes: 8 additions & 8 deletions tests/test_ezsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,18 +734,10 @@ async def test_config_initialize_husbzb1(ezsp_f):
ezsp_f.networkState = AsyncMock(return_value=(t.EmberNetworkStatus.JOINED_NETWORK,))

expected_calls = [
call(t.EzspConfigId.CONFIG_SOURCE_ROUTE_TABLE_SIZE, 16),
call(t.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT, 60),
call(t.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT_SHIFT, 8),
call(t.EzspConfigId.CONFIG_INDIRECT_TRANSMISSION_TIMEOUT, 7680),
call(t.EzspConfigId.CONFIG_STACK_PROFILE, 2),
call(t.EzspConfigId.CONFIG_SUPPORTED_NETWORKS, 1),
call(t.EzspConfigId.CONFIG_MULTICAST_TABLE_SIZE, 16),
call(t.EzspConfigId.CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE, 2),
call(t.EzspConfigId.CONFIG_SECURITY_LEVEL, 5),
call(t.EzspConfigId.CONFIG_ADDRESS_TABLE_SIZE, 16),
call(t.EzspConfigId.CONFIG_PAN_ID_CONFLICT_REPORT_THRESHOLD, 2),
call(t.EzspConfigId.CONFIG_KEY_TABLE_SIZE, 4),
call(t.EzspConfigId.CONFIG_MAX_END_DEVICE_CHILDREN, 32),
call(
t.EzspConfigId.CONFIG_APPLICATION_ZDO_FLAGS,
Expand All @@ -754,6 +746,14 @@ async def test_config_initialize_husbzb1(ezsp_f):
| t.EmberZdoConfigurationFlags.APP_RECEIVES_SUPPORTED_ZDO_REQUESTS
),
),
call(t.EzspConfigId.CONFIG_SOURCE_ROUTE_TABLE_SIZE, 16),
call(t.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT, 60),
call(t.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT_SHIFT, 8),
call(t.EzspConfigId.CONFIG_SUPPORTED_NETWORKS, 1),
call(t.EzspConfigId.CONFIG_MULTICAST_TABLE_SIZE, 16),
call(t.EzspConfigId.CONFIG_TRUST_CENTER_ADDRESS_CACHE_SIZE, 2),
call(t.EzspConfigId.CONFIG_ADDRESS_TABLE_SIZE, 16),
call(t.EzspConfigId.CONFIG_KEY_TABLE_SIZE, 4),
call(t.EzspConfigId.CONFIG_PACKET_BUFFER_COUNT, 255),
]

Expand Down
Loading