Skip to content

Commit

Permalink
Merge pull request #558 from puddly/rc
Browse files Browse the repository at this point in the history
0.35.4 Release
  • Loading branch information
puddly authored May 12, 2023
2 parents 2acb1c0 + 03f7878 commit 74e61a7
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bellows/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MAJOR_VERSION = 0
MINOR_VERSION = 35
PATCH_VERSION = "3"
PATCH_VERSION = "4"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
71 changes: 57 additions & 14 deletions bellows/ezsp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ class RuntimeConfig:
minimum: bool = False


DEFAULT_CONFIG = [
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_SOURCE_ROUTE_TABLE_SIZE,
value=200,
minimum=True,
),
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT,
value=8,
),
DEFAULT_CONFIG_COMMON = [
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_INDIRECT_TRANSMISSION_TIMEOUT,
value=7680,
Expand Down Expand Up @@ -56,14 +47,20 @@ class RuntimeConfig:
value=16,
minimum=True,
),
RuntimeConfig(
config_id=types_v6.EzspConfigId.CONFIG_TC_REJOINS_USING_WELL_KNOWN_KEY_TIMEOUT_S,
value=90,
),
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_PAN_ID_CONFLICT_REPORT_THRESHOLD,
value=2,
),
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_KEY_TABLE_SIZE,
value=4,
minimum=True,
),
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_MAX_END_DEVICE_CHILDREN,
value=32,
minimum=True,
),
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_APPLICATION_ZDO_FLAGS,
value=(
Expand All @@ -74,3 +71,49 @@ class RuntimeConfig:
# Must be set last
RuntimeConfig(types_v4.EzspConfigId.CONFIG_PACKET_BUFFER_COUNT, value=0xFF),
]

DEFAULT_CONFIG_LEGACY = [
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_SOURCE_ROUTE_TABLE_SIZE,
value=16,
minimum=True,
),
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT,
value=60,
),
RuntimeConfig(
config_id=types_v4.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT_SHIFT,
value=8,
),
] + DEFAULT_CONFIG_COMMON


DEFAULT_CONFIG_NEW = [
RuntimeConfig(
config_id=types_v6.EzspConfigId.CONFIG_SOURCE_ROUTE_TABLE_SIZE,
value=200,
minimum=True,
),
RuntimeConfig(
config_id=types_v6.EzspConfigId.CONFIG_END_DEVICE_POLL_TIMEOUT,
value=8,
),
RuntimeConfig(
config_id=(
types_v6.EzspConfigId.CONFIG_TC_REJOINS_USING_WELL_KNOWN_KEY_TIMEOUT_S
),
value=90,
),
] + 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,
}
14 changes: 5 additions & 9 deletions bellows/ezsp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,11 @@ async def initialize(self, zigpy_config: Dict) -> None:
# Not all config will be present in every EZSP version so only use valid keys
ezsp_config = {}

for cfg in DEFAULT_CONFIG:
try:
config_id = self.types.EzspConfigId[cfg.config_id.name]
except KeyError:
pass
else:
ezsp_config[cfg.config_id.name] = dataclasses.replace(
cfg, config_id=config_id
)
for cfg in DEFAULT_CONFIG[self.EZSP_VERSION]:
config_id = self.types.EzspConfigId[cfg.config_id.name]
ezsp_config[cfg.config_id.name] = dataclasses.replace(
cfg, config_id=config_id
)

# Override the defaults with user-specified values (or `None` for deletions)
for name, value in self.SCHEMAS[CONF_EZSP_CONFIG](
Expand Down
36 changes: 35 additions & 1 deletion tests/test_ezsp_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import bellows.ezsp.v4
import bellows.ezsp.v4.types as t

from .async_mock import ANY, AsyncMock, MagicMock, patch
from .async_mock import ANY, AsyncMock, MagicMock, call, patch


class _DummyProtocolHandler(bellows.ezsp.v4.EZSPv4):
Expand Down Expand Up @@ -93,6 +93,40 @@ async def test_cfg_initialize(prot_hndl, caplog):
assert "Couldn't set" in caplog.text


async def test_config_initialize_husbzb1(prot_hndl):
"""Test timeouts are properly set for HUSBZB-1."""

prot_hndl.getConfigurationValue = AsyncMock(return_value=(t.EzspStatus.SUCCESS, 0))
prot_hndl.setConfigurationValue = AsyncMock(return_value=(t.EzspStatus.SUCCESS,))

await prot_hndl.initialize({"ezsp_config": {}})
prot_hndl.setConfigurationValue.assert_has_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,
(
t.EmberZdoConfigurationFlags.APP_HANDLES_UNSUPPORTED_ZDO_REQUESTS
| t.EmberZdoConfigurationFlags.APP_RECEIVES_SUPPORTED_ZDO_REQUESTS
),
),
call(t.EzspConfigId.CONFIG_PACKET_BUFFER_COUNT, 255),
]
)


async def test_cfg_initialize_skip(prot_hndl):
"""Test initialization."""

Expand Down

0 comments on commit 74e61a7

Please sign in to comment.