8
8
from __future__ import annotations
9
9
10
10
import asyncio
11
- from concurrent .futures import ThreadPoolExecutor
12
11
from functools import partial
13
12
import logging
14
13
import time
25
24
26
25
if TYPE_CHECKING :
27
26
from collections .abc import Callable
27
+ from concurrent .futures import ThreadPoolExecutor
28
28
from pathlib import Path
29
29
30
30
from chip .ChipDeviceCtrl import (
@@ -59,7 +59,6 @@ def __init__(self, server: MatterServer, paa_root_cert_dir: Path):
59
59
60
60
self ._node_lock : dict [int , asyncio .Lock ] = {}
61
61
self ._subscriptions : dict [int , Attribute .SubscriptionTransaction ] = {}
62
- self ._sdk_non_entrant_executor = ThreadPoolExecutor (max_workers = 1 )
63
62
64
63
# Instantiate the underlying ChipDeviceController instance on the Fabric
65
64
self ._chip_controller = self .server .stack .fabric_admin .NewController (
@@ -100,16 +99,6 @@ async def _call_sdk(
100
99
) -> _T :
101
100
return await self ._call_sdk_executor (None , target , * args , ** kwargs )
102
101
103
- async def _call_sdk_non_reentrant (
104
- self ,
105
- target : Callable [..., _T ],
106
- * args : Any ,
107
- ** kwargs : Any ,
108
- ) -> _T :
109
- return await self ._call_sdk_executor (
110
- self ._sdk_non_entrant_executor , target , * args , ** kwargs
111
- )
112
-
113
102
async def get_compressed_fabric_id (self ) -> int :
114
103
"""Get the compressed fabric id."""
115
104
return await self ._call_sdk (self ._chip_controller .GetCompressedFabricId )
@@ -128,10 +117,9 @@ async def commission_with_code(
128
117
node_id : int ,
129
118
setup_payload : str ,
130
119
discovery_type : DiscoveryType ,
131
- ) -> PyChipError :
120
+ ) -> int :
132
121
"""Commission a device using a QR Code or Manual Pairing Code."""
133
- return await self ._call_sdk_non_reentrant (
134
- self ._chip_controller .CommissionWithCode ,
122
+ return await self ._chip_controller .CommissionWithCode (
135
123
setupPayload = setup_payload ,
136
124
nodeid = node_id ,
137
125
discoveryType = discovery_type ,
@@ -143,10 +131,9 @@ async def commission_on_network(
143
131
setup_pin_code : int ,
144
132
disc_filter_type : FilterType = FilterType .NONE ,
145
133
disc_filter : Any = None ,
146
- ) -> PyChipError :
134
+ ) -> int :
147
135
"""Commission a device on the network."""
148
- return await self ._call_sdk_non_reentrant (
149
- self ._chip_controller .CommissionOnNetwork ,
136
+ return await self ._chip_controller .CommissionOnNetwork (
150
137
nodeId = node_id ,
151
138
setupPinCode = setup_pin_code ,
152
139
filterType = disc_filter_type ,
@@ -155,10 +142,9 @@ async def commission_on_network(
155
142
156
143
async def commission_ip (
157
144
self , node_id : int , setup_pin_code : int , ip_addr : str
158
- ) -> PyChipError :
145
+ ) -> int :
159
146
"""Commission a device using an IP address."""
160
- return await self ._call_sdk_non_reentrant (
161
- self ._chip_controller .CommissionIP ,
147
+ return await self ._chip_controller .CommissionIP (
162
148
nodeid = node_id ,
163
149
setupPinCode = setup_pin_code ,
164
150
ipaddr = ip_addr ,
@@ -185,9 +171,7 @@ async def unpair_device(self, node_id: int) -> PyChipError:
185
171
Tries to look up the device attached to our controller with the given
186
172
remote node id and ask it to remove Fabric.
187
173
"""
188
- return await self ._call_sdk_non_reentrant (
189
- self ._chip_controller .UnpairDevice , nodeid = node_id
190
- )
174
+ return await self ._chip_controller .UnpairDevice (nodeid = node_id )
191
175
192
176
async def open_commissioning_window (
193
177
self ,
@@ -199,8 +183,7 @@ async def open_commissioning_window(
199
183
) -> CommissioningParameters :
200
184
"""Open a commissioning window to commission a device present on this controller to another."""
201
185
async with self ._get_node_lock (node_id ):
202
- return await self ._call_sdk_non_reentrant (
203
- self ._chip_controller .OpenCommissioningWindow ,
186
+ return await self ._chip_controller .OpenCommissioningWindow (
204
187
nodeid = node_id ,
205
188
timeout = timeout ,
206
189
iteration = iteration ,
0 commit comments