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

Implement permit_with_link_key #226

Merged
merged 1 commit into from
Sep 27, 2023
Merged
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
30 changes: 20 additions & 10 deletions zigpy_znp/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,22 +343,20 @@ async def force_remove(self, dev: zigpy.device.Device) -> None:

# Z-Stack does not have any way to do this

async def permit_with_key(self, node: t.EUI64, code: bytes, time_s=60):
async def permit_with_link_key(
self, node: t.EUI64, link_key: t.KeyData, time_s: int = 60
) -> None:
"""
Permits a new device to join with the given IEEE and Install Code.
Permits a new device to join with the given IEEE and link key.
"""

key = zigpy.util.convert_install_code(code)
install_code_format = c.app_config.InstallCodeFormat.KeyDerivedFromInstallCode

if key is None:
raise ValueError(f"Invalid install code: {code!r}")

await self._znp.request(
c.AppConfig.BDBAddInstallCode.Req(
InstallCodeFormat=install_code_format,
InstallCodeFormat=(
c.app_config.InstallCodeFormat.KeyDerivedFromInstallCode
),
IEEE=node,
InstallCode=t.Bytes(key),
InstallCode=link_key.serialize(),
),
RspStatus=t.Status.SUCCESS,
)
Expand All @@ -384,6 +382,18 @@ async def permit_with_key(self, node: t.EUI64, code: bytes, time_s=60):
RspStatus=t.Status.SUCCESS,
)

async def permit_with_key(self, node: t.EUI64, code: bytes, time_s=60):
"""
Permits a new device to join with the given IEEE and Install Code.
"""

key = zigpy.util.convert_install_code(code)

if key is None:
raise ValueError(f"Invalid install code: {code!r}")

await self.permit_with_link_key(node=node, link_key=key, time_s=time_s)

async def _move_network_to_channel(
self, new_channel: int, new_nwk_update_id: int
) -> None:
Expand Down