Skip to content

Commit

Permalink
Fix sdk command return code error handling (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinHjelmare authored Jan 25, 2023
1 parent f6ef17a commit 8a7b682
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
4 changes: 0 additions & 4 deletions matter_server/common/models/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,3 @@ class NodeNotExists(MatterError):

class VersionMismatch(MatterError):
"""Issue raised when SDK version mismatches."""


class SDKCommandFailed(MatterError):
"""Raised when command on the CHIP SDK Failed."""
9 changes: 2 additions & 7 deletions matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
NodeInterviewFailed,
NodeNotExists,
NodeNotResolving,
SDKCommandFailed,
)
from ..common.models.events import EventType
from ..common.models.node import MatterAttribute, MatterNode
Expand Down Expand Up @@ -173,26 +172,22 @@ async def commission_on_network(
@api_command(APICommand.SET_WIFI_CREDENTIALS)
async def set_wifi_credentials(self, ssid: str, credentials: str) -> None:
"""Set WiFi credentials for commissioning to a (new) device."""
error_code = await self._call_sdk(
await self._call_sdk(
self.chip_controller.SetWiFiCredentials,
ssid=ssid,
credentials=credentials,
)

if error_code != 0:
raise SDKCommandFailed("Set WiFi credentials failed.")
self.wifi_credentials_set = True

@api_command(APICommand.SET_THREAD_DATASET)
async def set_thread_operational_dataset(self, dataset: str) -> None:
"""Set Thread Operational dataset in the stack."""
error_code = await self._call_sdk(
await self._call_sdk(
self.chip_controller.SetThreadOperationalDataset,
threadOperationalDataset=bytes.fromhex(dataset),
)

if error_code != 0:
raise SDKCommandFailed("Set Thread credentials failed.")
self.thread_credentials_set = True

@api_command(APICommand.OPEN_COMMISSIONING_WINDOW)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "python-matter-server"
version = "2.0.0"
version = "2.0.1"
license = {text = "Apache-2.0"}
description = "Python Matter WebSocket Server"
readme = "README.md"
Expand Down

0 comments on commit 8a7b682

Please sign in to comment.