@@ -186,7 +186,7 @@ def __init__(self, deviceProxy: ctypes.c_void_p, dmLib=None):
186
186
def __del__ (self ):
187
187
if (self ._dmLib is not None and hasattr (builtins , 'chipStack' ) and builtins .chipStack is not None ):
188
188
# This destructor is called from any threading context, including on the Matter threading context.
189
- # So, we cannot call chipStack.Call or chipStack.CallAsync which waits for the posted work to
189
+ # So, we cannot call chipStack.Call or chipStack.CallAsyncWithCompleteCallback which waits for the posted work to
190
190
# actually be executed. Instead, we just post/schedule the work and move on.
191
191
builtins .chipStack .PostTaskOnChipThread (lambda : self ._dmLib .pychip_FreeOperationalDeviceProxy (self ._deviceProxy ))
192
192
@@ -447,7 +447,7 @@ def ConnectBLE(self, discriminator, setupPinCode, nodeid) -> PyChipError:
447
447
448
448
self .state = DCState .COMMISSIONING
449
449
self ._enablePairingCompeleteCallback (True )
450
- self ._ChipStack .CallAsync (
450
+ self ._ChipStack .CallAsyncWithCompleteCallback (
451
451
lambda : self ._dmLib .pychip_DeviceController_ConnectBLE (
452
452
self .devCtrl , discriminator , setupPinCode , nodeid )
453
453
).raise_on_error ()
@@ -459,7 +459,7 @@ def ConnectBLE(self, discriminator, setupPinCode, nodeid) -> PyChipError:
459
459
def UnpairDevice (self , nodeid : int ):
460
460
self .CheckIsActive ()
461
461
462
- return self ._ChipStack .CallAsync (
462
+ return self ._ChipStack .CallAsyncWithCompleteCallback (
463
463
lambda : self ._dmLib .pychip_DeviceController_UnpairDevice (
464
464
self .devCtrl , nodeid , self .cbHandleDeviceUnpairCompleteFunct )
465
465
).raise_on_error ()
@@ -498,7 +498,7 @@ def EstablishPASESessionBLE(self, setupPinCode: int, discriminator: int, nodeid:
498
498
499
499
self .state = DCState .RENDEZVOUS_ONGOING
500
500
self ._enablePairingCompeleteCallback (True )
501
- return self ._ChipStack .CallAsync (
501
+ return self ._ChipStack .CallAsyncWithCompleteCallback (
502
502
lambda : self ._dmLib .pychip_DeviceController_EstablishPASESessionBLE (
503
503
self .devCtrl , setupPinCode , discriminator , nodeid )
504
504
)
@@ -508,7 +508,7 @@ def EstablishPASESessionIP(self, ipaddr: str, setupPinCode: int, nodeid: int, po
508
508
509
509
self .state = DCState .RENDEZVOUS_ONGOING
510
510
self ._enablePairingCompeleteCallback (True )
511
- return self ._ChipStack .CallAsync (
511
+ return self ._ChipStack .CallAsyncWithCompleteCallback (
512
512
lambda : self ._dmLib .pychip_DeviceController_EstablishPASESessionIP (
513
513
self .devCtrl , ipaddr .encode ("utf-8" ), setupPinCode , nodeid , port )
514
514
)
@@ -518,7 +518,7 @@ def EstablishPASESession(self, setUpCode: str, nodeid: int):
518
518
519
519
self .state = DCState .RENDEZVOUS_ONGOING
520
520
self ._enablePairingCompeleteCallback (True )
521
- return self ._ChipStack .CallAsync (
521
+ return self ._ChipStack .CallAsyncWithCompleteCallback (
522
522
lambda : self ._dmLib .pychip_DeviceController_EstablishPASESession (
523
523
self .devCtrl , setUpCode .encode ("utf-8" ), nodeid )
524
524
)
@@ -737,7 +737,7 @@ def OpenCommissioningWindow(self, nodeid: int, timeout: int, iteration: int,
737
737
Returns CommissioningParameters
738
738
'''
739
739
self .CheckIsActive ()
740
- self ._ChipStack .CallAsync (
740
+ self ._ChipStack .CallAsyncWithCompleteCallback (
741
741
lambda : self ._dmLib .pychip_DeviceController_OpenCommissioningWindow (
742
742
self .devCtrl , self .pairingDelegate , nodeid , timeout , iteration , discriminator , option )
743
743
).raise_on_error ()
@@ -858,7 +858,7 @@ async def GetConnectedDevice(self, nodeid, allowPASE: bool = True, timeoutMs: in
858
858
859
859
if allowPASE :
860
860
returnDevice = c_void_p (None )
861
- res = self ._ChipStack .Call (lambda : self ._dmLib .pychip_GetDeviceBeingCommissioned (
861
+ res = await self ._ChipStack .CallAsync (lambda : self ._dmLib .pychip_GetDeviceBeingCommissioned (
862
862
self .devCtrl , nodeid , byref (returnDevice )), timeoutMs )
863
863
if res .is_success :
864
864
logging .info ('Using PASE connection' )
@@ -888,11 +888,12 @@ def deviceAvailable(self, device, err):
888
888
889
889
closure = DeviceAvailableClosure (eventLoop , future )
890
890
ctypes .pythonapi .Py_IncRef (ctypes .py_object (closure ))
891
- self ._ChipStack .Call (lambda : self ._dmLib .pychip_GetConnectedDeviceByNodeId (
891
+ res = await self ._ChipStack .CallAsync (lambda : self ._dmLib .pychip_GetConnectedDeviceByNodeId (
892
892
self .devCtrl , nodeid , ctypes .py_object (closure ), _DeviceAvailableCallback ),
893
- timeoutMs ).raise_on_error ()
893
+ timeoutMs )
894
+ res .raise_on_error ()
894
895
895
- # The callback might have been received synchronously (during self._ChipStack.Call ()).
896
+ # The callback might have been received synchronously (during self._ChipStack.CallAsync ()).
896
897
# In that case the Future has already been set it will return immediately
897
898
if timeoutMs is not None :
898
899
timeout = float (timeoutMs ) / 1000
@@ -1020,13 +1021,14 @@ async def SendCommand(self, nodeid: int, endpoint: int, payload: ClusterObjects.
1020
1021
future = eventLoop .create_future ()
1021
1022
1022
1023
device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs )
1023
- ClusterCommand .SendCommand (
1024
+ res = await ClusterCommand .SendCommand (
1024
1025
future , eventLoop , responseType , device .deviceProxy , ClusterCommand .CommandPath (
1025
1026
EndpointId = endpoint ,
1026
1027
ClusterId = payload .cluster_id ,
1027
1028
CommandId = payload .command_id ,
1028
1029
), payload , timedRequestTimeoutMs = timedRequestTimeoutMs ,
1029
- interactionTimeoutMs = interactionTimeoutMs , busyWaitMs = busyWaitMs , suppressResponse = suppressResponse ).raise_on_error ()
1030
+ interactionTimeoutMs = interactionTimeoutMs , busyWaitMs = busyWaitMs , suppressResponse = suppressResponse )
1031
+ res .raise_on_error ()
1030
1032
return await future
1031
1033
1032
1034
async def SendBatchCommands (self , nodeid : int , commands : typing .List [ClusterCommand .InvokeRequestInfo ],
@@ -1062,10 +1064,11 @@ async def SendBatchCommands(self, nodeid: int, commands: typing.List[ClusterComm
1062
1064
1063
1065
device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs )
1064
1066
1065
- ClusterCommand .SendBatchCommands (
1067
+ res = await ClusterCommand .SendBatchCommands (
1066
1068
future , eventLoop , device .deviceProxy , commands ,
1067
1069
timedRequestTimeoutMs = timedRequestTimeoutMs ,
1068
- interactionTimeoutMs = interactionTimeoutMs , busyWaitMs = busyWaitMs , suppressResponse = suppressResponse ).raise_on_error ()
1070
+ interactionTimeoutMs = interactionTimeoutMs , busyWaitMs = busyWaitMs , suppressResponse = suppressResponse )
1071
+ res .raise_on_error ()
1069
1072
return await future
1070
1073
1071
1074
def SendGroupCommand (self , groupid : int , payload : ClusterObjects .ClusterCommand , busyWaitMs : typing .Union [None , int ] = None ):
@@ -1895,7 +1898,7 @@ def Commission(self, nodeid) -> PyChipError:
1895
1898
self ._ChipStack .commissioningCompleteEvent .clear ()
1896
1899
self .state = DCState .COMMISSIONING
1897
1900
1898
- self ._ChipStack .CallAsync (
1901
+ self ._ChipStack .CallAsyncWithCompleteCallback (
1899
1902
lambda : self ._dmLib .pychip_DeviceController_Commission (
1900
1903
self .devCtrl , nodeid )
1901
1904
)
@@ -2011,7 +2014,7 @@ def CommissionOnNetwork(self, nodeId: int, setupPinCode: int,
2011
2014
self ._ChipStack .commissioningCompleteEvent .clear ()
2012
2015
2013
2016
self ._enablePairingCompeleteCallback (True )
2014
- self ._ChipStack .CallAsync (
2017
+ self ._ChipStack .CallAsyncWithCompleteCallback (
2015
2018
lambda : self ._dmLib .pychip_DeviceController_OnNetworkCommission (
2016
2019
self .devCtrl , self .pairingDelegate , nodeId , setupPinCode , int (filterType ), str (filter ).encode ("utf-8" ) + b"\x00 " if filter is not None else None , discoveryTimeoutMsec )
2017
2020
)
@@ -2035,7 +2038,7 @@ def CommissionWithCode(self, setupPayload: str, nodeid: int, discoveryType: Disc
2035
2038
self ._ChipStack .commissioningCompleteEvent .clear ()
2036
2039
2037
2040
self ._enablePairingCompeleteCallback (True )
2038
- self ._ChipStack .CallAsync (
2041
+ self ._ChipStack .CallAsyncWithCompleteCallback (
2039
2042
lambda : self ._dmLib .pychip_DeviceController_ConnectWithCode (
2040
2043
self .devCtrl , setupPayload , nodeid , discoveryType .value )
2041
2044
)
@@ -2055,7 +2058,7 @@ def CommissionIP(self, ipaddr: str, setupPinCode: int, nodeid: int) -> PyChipErr
2055
2058
self ._ChipStack .commissioningCompleteEvent .clear ()
2056
2059
2057
2060
self ._enablePairingCompeleteCallback (True )
2058
- self ._ChipStack .CallAsync (
2061
+ self ._ChipStack .CallAsyncWithCompleteCallback (
2059
2062
lambda : self ._dmLib .pychip_DeviceController_ConnectIP (
2060
2063
self .devCtrl , ipaddr .encode ("utf-8" ), setupPinCode , nodeid )
2061
2064
)
@@ -2069,7 +2072,7 @@ def IssueNOCChain(self, csr: Clusters.OperationalCredentials.Commands.CSRRespons
2069
2072
The NOC chain will be provided in TLV cert format."""
2070
2073
self .CheckIsActive ()
2071
2074
2072
- return self ._ChipStack .CallAsync (
2075
+ return self ._ChipStack .CallAsyncWithCompleteCallback (
2073
2076
lambda : self ._dmLib .pychip_DeviceController_IssueNOCChain (
2074
2077
self .devCtrl , py_object (self ), csr .NOCSRElements , len (csr .NOCSRElements ), nodeId )
2075
2078
)
0 commit comments