Skip to content

Commit

Permalink
Merge pull request #531 from puddly/rc
Browse files Browse the repository at this point in the history
0.34.9 Release
  • Loading branch information
puddly authored Feb 22, 2023
2 parents f16288d + ccc641e commit b2e33a8
Show file tree
Hide file tree
Showing 12 changed files with 2,074 additions and 12 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 = 34
PATCH_VERSION = "8"
PATCH_VERSION = "9"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
5 changes: 3 additions & 2 deletions bellows/ezsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import bellows.types as t
import bellows.uart

from . import v4, v5, v6, v7, v8, v9
from . import v4, v5, v6, v7, v8, v9, v10

EZSP_LATEST = v9.EZSP_VERSION
EZSP_LATEST = v10.EZSP_VERSION
PROBE_TIMEOUT = 3
NETWORK_OPS_TIMEOUT = 10
LOGGER = logging.getLogger(__name__)
Expand All @@ -37,6 +37,7 @@ class EZSP:
v7.EZSP_VERSION: v7.EZSPv7,
v8.EZSP_VERSION: v8.EZSPv8,
v9.EZSP_VERSION: v9.EZSPv9,
v10.EZSP_VERSION: v10.EZSPv10,
}

def __init__(self, device_config: Dict):
Expand Down
58 changes: 58 additions & 0 deletions bellows/ezsp/v10/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
""""EZSP Protocol version 10 protocol handler."""
import asyncio
import logging
from typing import Tuple

import voluptuous

import bellows.config

from . import commands, config, types as v10_types
from .. import protocol

EZSP_VERSION = 10
LOGGER = logging.getLogger(__name__)


class EZSPv10(protocol.ProtocolHandler):
"""EZSP Version 10 Protocol version handler."""

COMMANDS = commands.COMMANDS
SCHEMAS = {
bellows.config.CONF_EZSP_CONFIG: voluptuous.Schema(config.EZSP_SCHEMA),
bellows.config.CONF_EZSP_POLICIES: voluptuous.Schema(config.EZSP_POLICIES_SCH),
}
types = v10_types

def _ezsp_frame_tx(self, name: str) -> bytes:
"""Serialize the frame id."""
cmd_id = self.COMMANDS[name][0]
hdr = [self._seq, 0x00, 0x01]
return bytes(hdr) + self.types.uint16_t(cmd_id).serialize()

def _ezsp_frame_rx(self, data: bytes) -> Tuple[int, int, bytes]:
"""Handler for received data frame."""
seq, data = data[0], data[3:]
frame_id, data = self.types.uint16_t.deserialize(data)

return seq, frame_id, data

async def pre_permit(self, time_s: int) -> None:
"""Temporarily change TC policy while allowing new joins."""
wild_card_ieee = v10_types.EmberEUI64([0xFF] * 8)
tc_link_key = v10_types.EmberKeyData(b"ZigBeeAlliance09")
await self.addTransientLinkKey(wild_card_ieee, tc_link_key)
await self.setPolicy(
v10_types.EzspPolicyId.TRUST_CENTER_POLICY,
v10_types.EzspDecisionBitmask.ALLOW_JOINS
| v10_types.EzspDecisionBitmask.ALLOW_UNSECURED_REJOINS,
)
await asyncio.sleep(time_s + 2)
await self.setPolicy(
v10_types.EzspPolicyId.TRUST_CENTER_POLICY,
self.tc_policy,
)

async def set_source_routing(self) -> None:
"""Enable source routing on NCP."""
await self.setSourceRouteDiscoveryMode(1)
Loading

0 comments on commit b2e33a8

Please sign in to comment.