@@ -230,13 +230,13 @@ class CommissionableNode(discovery.CommissionableNode):
230
230
def SetDeviceController (self , devCtrl : 'ChipDeviceController' ):
231
231
self ._devCtrl = devCtrl
232
232
233
- def Commission (self , nodeId : int , setupPinCode : int ) -> PyChipError :
233
+ def Commission (self , nodeId : int , setupPinCode : int ) -> None :
234
234
''' Commission the device using the device controller discovered this device.
235
235
236
236
nodeId: The nodeId commissioned to the device
237
237
setupPinCode: The setup pin code of the device
238
238
'''
239
- return self ._devCtrl .CommissionOnNetwork (
239
+ self ._devCtrl .CommissionOnNetwork (
240
240
nodeId , setupPinCode , filterType = discovery .FilterType .INSTANCE_NAME , filter = self .instanceName )
241
241
242
242
def __rich_repr__ (self ):
@@ -360,7 +360,10 @@ def HandleCommissioningComplete(nodeId: int, err: PyChipError):
360
360
logging .exception ("HandleCommissioningComplete called unexpectedly" )
361
361
return
362
362
363
- self ._commissioning_complete_future .set_result (err )
363
+ if err .is_success :
364
+ self ._commissioning_complete_future .set_result (None )
365
+ else :
366
+ self ._commissioning_complete_future .set_exception (err .to_exception ())
364
367
365
368
def HandleFabricCheck (nodeId ):
366
369
self .fabricCheckNodeId = nodeId
@@ -533,7 +536,7 @@ def IsConnected(self):
533
536
self .devCtrl )
534
537
)
535
538
536
- def ConnectBLE (self , discriminator , setupPinCode , nodeid ) -> PyChipError :
539
+ def ConnectBLE (self , discriminator , setupPinCode , nodeid ) -> None :
537
540
self .CheckIsActive ()
538
541
539
542
self ._commissioning_complete_future = concurrent .futures .Future ()
@@ -545,11 +548,7 @@ def ConnectBLE(self, discriminator, setupPinCode, nodeid) -> PyChipError:
545
548
self .devCtrl , discriminator , setupPinCode , nodeid )
546
549
).raise_on_error ()
547
550
548
- # TODO: Change return None. Only returning on success is not useful.
549
- # but that is what the previous implementation did.
550
- res = self ._commissioning_complete_future .result ()
551
- res .raise_on_error ()
552
- return res
551
+ return self ._commissioning_complete_future .result ()
553
552
finally :
554
553
self ._commissioning_complete_future = None
555
554
@@ -1856,17 +1855,16 @@ def caIndex(self) -> int:
1856
1855
def fabricAdmin (self ) -> FabricAdmin :
1857
1856
return self ._fabricAdmin
1858
1857
1859
- def Commission (self , nodeid ) -> PyChipError :
1858
+ def Commission (self , nodeid ) -> None :
1860
1859
'''
1861
1860
Start the auto-commissioning process on a node after establishing a PASE connection.
1862
1861
This function is intended to be used in conjunction with `EstablishPASESessionBLE` or
1863
1862
`EstablishPASESessionIP`. It can be called either before or after the DevicePairingDelegate
1864
1863
receives the OnPairingComplete call. Commissioners that want to perform simple
1865
- auto-commissioning should use the supplied "PairDevice" functions above , which will
1864
+ auto-commissioning should use the supplied "CommissionWithCode" function , which will
1866
1865
establish the PASE connection and commission automatically.
1867
1866
1868
- Return:
1869
- bool: True if successful, False otherwise.
1867
+ Raises a ChipStackError on failure.
1870
1868
'''
1871
1869
self .CheckIsActive ()
1872
1870
@@ -1991,7 +1989,7 @@ def GetFabricCheckResult(self) -> int:
1991
1989
return self .fabricCheckNodeId
1992
1990
1993
1991
def CommissionOnNetwork (self , nodeId : int , setupPinCode : int ,
1994
- filterType : DiscoveryFilterType = DiscoveryFilterType .NONE , filter : typing .Any = None , discoveryTimeoutMsec : int = 30000 ) -> PyChipError :
1992
+ filterType : DiscoveryFilterType = DiscoveryFilterType .NONE , filter : typing .Any = None , discoveryTimeoutMsec : int = 30000 ) -> None :
1995
1993
'''
1996
1994
Does the routine for OnNetworkCommissioning, with a filter for mDNS discovery.
1997
1995
Supported filters are:
@@ -2007,6 +2005,8 @@ def CommissionOnNetwork(self, nodeId: int, setupPinCode: int,
2007
2005
DiscoveryFilterType.COMPRESSED_FABRIC_ID
2008
2006
2009
2007
The filter can be an integer, a string or None depending on the actual type of selected filter.
2008
+
2009
+ Raises a ChipStackError on failure.
2010
2010
'''
2011
2011
self .CheckIsActive ()
2012
2012
@@ -2026,9 +2026,11 @@ def CommissionOnNetwork(self, nodeId: int, setupPinCode: int,
2026
2026
finally :
2027
2027
self ._commissioning_complete_future = None
2028
2028
2029
- def CommissionWithCode (self , setupPayload : str , nodeid : int , discoveryType : DiscoveryType = DiscoveryType .DISCOVERY_ALL ) -> PyChipError :
2029
+ def CommissionWithCode (self , setupPayload : str , nodeid : int , discoveryType : DiscoveryType = DiscoveryType .DISCOVERY_ALL ) -> None :
2030
2030
''' Commission with the given nodeid from the setupPayload.
2031
2031
setupPayload may be a QR or manual code.
2032
+
2033
+ Raises a ChipStackError on failure.
2032
2034
'''
2033
2035
self .CheckIsActive ()
2034
2036
@@ -2047,8 +2049,11 @@ def CommissionWithCode(self, setupPayload: str, nodeid: int, discoveryType: Disc
2047
2049
finally :
2048
2050
self ._commissioning_complete_future = None
2049
2051
2050
- def CommissionIP (self , ipaddr : str , setupPinCode : int , nodeid : int ) -> PyChipError :
2051
- """ DEPRECATED, DO NOT USE! Use `CommissionOnNetwork` or `CommissionWithCode` """
2052
+ def CommissionIP (self , ipaddr : str , setupPinCode : int , nodeid : int ) -> None :
2053
+ """ DEPRECATED, DO NOT USE! Use `CommissionOnNetwork` or `CommissionWithCode`
2054
+
2055
+ Raises a ChipStackError on failure.
2056
+ """
2052
2057
self .CheckIsActive ()
2053
2058
2054
2059
self ._commissioning_complete_future = concurrent .futures .Future ()
0 commit comments