Skip to content

Commit 3332de3

Browse files
committed
Use new commissioning API
1 parent 8717c0b commit 3332de3

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

matter_server/server/ota/provider.py

+14-21
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
if TYPE_CHECKING:
2929
from asyncio.subprocess import Process
3030

31-
from chip.native import PyChipError
32-
3331
from matter_server.server.sdk import ChipDeviceControllerWrapper
3432

3533
LOGGER = logging.getLogger(__name__)
@@ -96,27 +94,22 @@ async def _commission_ota_provider(
9694
) -> None:
9795
"""Commissions the OTA Provider, returns node ID of the commissioned provider."""
9896

99-
res: PyChipError = await chip_device_controller.commission_on_network(
100-
ota_provider_node_id,
101-
passcode,
102-
# TODO: Filtering by long discriminator seems broken
103-
disc_filter_type=FilterType.LONG_DISCRIMINATOR,
104-
disc_filter=discriminator,
105-
)
106-
if not res.is_success:
107-
await self.stop()
108-
raise UpdateError(
109-
f"Failed to commission OTA Provider App: SDK Error {res.code}"
110-
)
111-
112-
LOGGER.info(
113-
"OTA Provider App commissioned with node id %d.",
114-
ota_provider_node_id,
115-
)
116-
11797
# Adjust ACL of OTA Requestor such that Node peer-to-peer communication
11898
# is allowed.
11999
try:
100+
commissioned_node_id = await chip_device_controller.commission_on_network(
101+
ota_provider_node_id,
102+
passcode,
103+
disc_filter_type=FilterType.LONG_DISCRIMINATOR,
104+
disc_filter=discriminator,
105+
)
106+
assert commissioned_node_id == ota_provider_node_id
107+
108+
LOGGER.info(
109+
"OTA Provider App commissioned with node id %d.",
110+
ota_provider_node_id,
111+
)
112+
120113
read_result = cast(
121114
Attribute.AsyncReadTransaction.ReadResponse,
122115
await chip_device_controller.read_attribute(
@@ -163,7 +156,7 @@ async def _commission_ota_provider(
163156
)
164157
raise UpdateError("Error while setting up OTA Provider.")
165158
except ChipStackError as ex:
166-
logging.exception("Failed adjusting OTA Provider App ACL.", exc_info=ex)
159+
logging.exception("Failed setting up OTA Provider.", exc_info=ex)
167160
raise UpdateError("Error while setting up OTA Provider.") from ex
168161

169162
async def start_update(

0 commit comments

Comments
 (0)