Skip to content

Commit

Permalink
Fix open commissioning window (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturoGuerra authored May 22, 2023
1 parent 6adac32 commit 2f3341f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions matter_server/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ async def open_commissioning_window(
node_id: int,
timeout: int = 300,
iteration: int = 1000,
option: int = 0,
option: int = 1,
discriminator: Optional[int] = None,
) -> int:
) -> tuple[int, str]:
"""
Open a commissioning window to commission a device present on this controller to another.
Returns code to use as discriminator.
"""
return cast(
int,
tuple[int, str],
await self.send_command(
APICommand.OPEN_COMMISSIONING_WINDOW,
node_id=node_id,
Expand Down
8 changes: 4 additions & 4 deletions matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ async def open_commissioning_window(
node_id: int,
timeout: int = 300,
iteration: int = 1000,
option: int = 0,
option: int = 1,
discriminator: int | None = None,
) -> int:
) -> tuple[int, str]:
"""
Open a commissioning window to commission a device present on this controller to another.
Expand All @@ -254,15 +254,15 @@ async def open_commissioning_window(
if discriminator is None:
discriminator = 3840 # TODO generate random one

await self._call_sdk(
pin, code = await self._call_sdk(
self.chip_controller.OpenCommissioningWindow,
nodeid=node_id,
timeout=timeout,
iteration=iteration,
discriminator=discriminator,
option=option,
)
return discriminator
return pin, code

@api_command(APICommand.DISCOVER)
async def discover_commissionable_nodes(
Expand Down
2 changes: 1 addition & 1 deletion tests/server/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async def test_server_start(
"node_id": 1,
"timeout": 300,
"iteration": 1000,
"option": 0,
"option": 1,
"discriminator": None,
}
assert not (
Expand Down

0 comments on commit 2f3341f

Please sign in to comment.