Skip to content

Commit

Permalink
0.20.2 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Adminiuga authored Sep 14, 2020
2 parents 6e647aa + 1ca59ed commit 2aaeb73
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 10 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 = 20
PATCH_VERSION = "1"
PATCH_VERSION = "2"
__short_version__ = "{}.{}".format(MAJOR_VERSION, MINOR_VERSION)
__version__ = "{}.{}".format(__short_version__, PATCH_VERSION)
6 changes: 6 additions & 0 deletions bellows/ezsp/v5/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ def _ezsp_frame_tx(self, name: str) -> bytes:
def _ezsp_frame_rx(self, data: bytes) -> Tuple[int, int, bytes]:
"""Handler for received data frame."""
return data[0], data[4], data[5:]

async def pre_permit(self, time_s: int) -> None:
"""Add pre-shared TC Link key."""
wild_card_ieee = v5_types.EmberEUI64([0xFF] * 8)
tc_link_key = v5_types.EmberKeyData(b"ZigBeeAlliance09")
await self.addTransientLinkKey(wild_card_ieee, tc_link_key)
2 changes: 1 addition & 1 deletion bellows/ezsp/v7/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
#
# The size of the Key Table used for storing individual link keys (if the device
# is a Trust Center) or Application Link Keys (if the device is a normal node)
vol.Optional(EzspConfigId.CONFIG_KEY_TABLE_SIZE.name, default=4): vol.All(
vol.Optional(EzspConfigId.CONFIG_KEY_TABLE_SIZE.name, default=12): vol.All(
int, vol.Range(min=0)
),
#
Expand Down
3 changes: 3 additions & 0 deletions bellows/ezsp/v8/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def _ezsp_frame_rx(self, data: bytes) -> Tuple[int, int, bytes]:

async def pre_permit(self, time_s: int) -> None:
"""Temporarily change TC policy while allowing new joins."""
wild_card_ieee = v8_types.EmberEUI64([0xFF] * 8)
tc_link_key = v8_types.EmberKeyData(b"ZigBeeAlliance09")
await self.addTransientLinkKey(wild_card_ieee, tc_link_key)
await self.setPolicy(
v8_types.EzspPolicyId.TRUST_CENTER_POLICY,
v8_types.EzspDecisionBitmask.ALLOW_JOINS
Expand Down
2 changes: 1 addition & 1 deletion bellows/ezsp/v8/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
#
# The size of the Key Table used for storing individual link keys (if the device
# is a Trust Center) or Application Link Keys (if the device is a normal node)
vol.Optional(EzspConfigId.CONFIG_KEY_TABLE_SIZE.name, default=4): vol.All(
vol.Optional(EzspConfigId.CONFIG_KEY_TABLE_SIZE.name): vol.All(
int, vol.Range(min=0)
),
#
Expand Down
3 changes: 0 additions & 3 deletions bellows/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,6 @@ async def request(

async def permit(self, time_s: int = 60, node: t.EmberNodeId = None) -> None:
"""Permit joining."""
wild_card_ieee = t.EmberEUI64([0xFF] * 8)
tc_link_key = t.EmberKeyData(b"ZigBeeAlliance09")
await self._ezsp.addTransientLinkKey(wild_card_ieee, tc_link_key)
asyncio.create_task(self._ezsp.pre_permit(time_s))
await super().permit(time_s, node)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,11 @@ async def test_cleanup_tc_link_key(app):
@pytest.mark.asyncio
@mock.patch("zigpy.application.ControllerApplication.permit", new=CoroutineMock())
async def test_permit(app):
"""Test permi method."""
"""Test permit method."""
ezsp = app._ezsp
ezsp.addTransientLinkKey = CoroutineMock(return_value=(t.EmberStatus.SUCCESS,))
ezsp.pre_permit = CoroutineMock()
await app.permit(10, None)
await asyncio.sleep(0)
assert ezsp.addTransientLinkKey.await_count == 1
assert ezsp.addTransientLinkKey.await_count == 0
assert ezsp.pre_permit.await_count == 1
11 changes: 10 additions & 1 deletion tests/test_ezsp_v5.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from asynctest import mock
from asynctest import CoroutineMock, mock
import bellows.ezsp.v5
import pytest

Expand All @@ -23,6 +23,15 @@ def test_ezsp_frame_rx(ezsp_f):
assert ezsp_f._handle_callback.call_args[0][1] == [0x01, 0x02, 0x1234]


@pytest.mark.asyncio
async def test_pre_permit(ezsp_f):
"""Test pre permit."""
p2 = mock.patch.object(ezsp_f, "addTransientLinkKey", new=CoroutineMock())
with p2 as tclk_mock:
await ezsp_f.pre_permit(1)
assert tclk_mock.await_count == 1


command_frames = {
"addEndpoint": 0x02,
"addOrUpdateKeyTableEntry": 0x66,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_ezsp_v8.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ async def test_set_source_routing(ezsp_f):
async def test_pre_permit(ezsp_f):
"""Test pre permit."""
p1 = mock.patch.object(ezsp_f, "setPolicy", new=CoroutineMock())
with p1 as pre_permit_mock:
p2 = mock.patch.object(ezsp_f, "addTransientLinkKey", new=CoroutineMock())
with p1 as pre_permit_mock, p2 as tclk_mock:
await ezsp_f.pre_permit(-1.9)
assert pre_permit_mock.await_count == 2
assert tclk_mock.await_count == 1


def test_command_frames(ezsp_f):
Expand Down

0 comments on commit 2aaeb73

Please sign in to comment.