@@ -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 (nodeId )
365
+ else :
366
+ self ._commissioning_complete_future .set_exception (err .to_exception ())
364
367
365
368
def HandleFabricCheck (nodeId ):
366
369
self .fabricCheckNodeId = nodeId
@@ -408,7 +411,7 @@ def HandlePASEEstablishmentComplete(err: PyChipError):
408
411
# During Commissioning, HandlePASEEstablishmentComplete will also be called.
409
412
# Only complete the future if PASE session establishment failed.
410
413
if not err .is_success :
411
- self ._commissioning_complete_future .set_result (err )
414
+ self ._commissioning_complete_future .set_exception (err . to_exception () )
412
415
return
413
416
414
417
if self ._pase_establishment_complete_future is None :
@@ -533,7 +536,12 @@ def IsConnected(self):
533
536
self .devCtrl )
534
537
)
535
538
536
- def ConnectBLE (self , discriminator : int , setupPinCode : int , nodeid : int , isShortDiscriminator : bool = False ) -> PyChipError :
539
+ def ConnectBLE (self , discriminator : int , setupPinCode : int , nodeid : int , isShortDiscriminator : bool = False ) -> int :
540
+ """Connect to a BLE device using the given discriminator and setup pin code.
541
+
542
+ Returns:
543
+ - Effective Node ID of the device (as defined by the assigned NOC)
544
+ """
537
545
self .CheckIsActive ()
538
546
539
547
self ._commissioning_complete_future = concurrent .futures .Future ()
@@ -545,11 +553,7 @@ def ConnectBLE(self, discriminator: int, setupPinCode: int, nodeid: int, isShort
545
553
self .devCtrl , discriminator , isShortDiscriminator , setupPinCode , nodeid )
546
554
).raise_on_error ()
547
555
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
556
+ return self ._commissioning_complete_future .result ()
553
557
finally :
554
558
self ._commissioning_complete_future = None
555
559
@@ -1853,17 +1857,19 @@ def caIndex(self) -> int:
1853
1857
def fabricAdmin (self ) -> FabricAdmin :
1854
1858
return self ._fabricAdmin
1855
1859
1856
- def Commission (self , nodeid ) -> PyChipError :
1860
+ def Commission (self , nodeid ) -> None :
1857
1861
'''
1858
1862
Start the auto-commissioning process on a node after establishing a PASE connection.
1859
1863
This function is intended to be used in conjunction with `EstablishPASESessionBLE` or
1860
1864
`EstablishPASESessionIP`. It can be called either before or after the DevicePairingDelegate
1861
1865
receives the OnPairingComplete call. Commissioners that want to perform simple
1862
- auto-commissioning should use the supplied "PairDevice" functions above , which will
1866
+ auto-commissioning should use the supplied "CommissionWithCode" function , which will
1863
1867
establish the PASE connection and commission automatically.
1864
1868
1865
- Return:
1866
- bool: True if successful, False otherwise.
1869
+ Raises a ChipStackError on failure.
1870
+
1871
+ Returns:
1872
+ - Effective Node ID of the device (as defined by the assigned NOC)
1867
1873
'''
1868
1874
self .CheckIsActive ()
1869
1875
@@ -1879,13 +1885,13 @@ def Commission(self, nodeid) -> PyChipError:
1879
1885
finally :
1880
1886
self ._commissioning_complete_future = None
1881
1887
1882
- def CommissionThread (self , discriminator , setupPinCode , nodeId , threadOperationalDataset : bytes , isShortDiscriminator : bool = False ) -> PyChipError :
1888
+ def CommissionThread (self , discriminator , setupPinCode , nodeId , threadOperationalDataset : bytes , isShortDiscriminator : bool = False ) -> int :
1883
1889
''' Commissions a Thread device over BLE
1884
1890
'''
1885
1891
self .SetThreadOperationalDataset (threadOperationalDataset )
1886
1892
return self .ConnectBLE (discriminator , setupPinCode , nodeId , isShortDiscriminator )
1887
1893
1888
- def CommissionWiFi (self , discriminator , setupPinCode , nodeId , ssid : str , credentials : str , isShortDiscriminator : bool = False ) -> PyChipError :
1894
+ def CommissionWiFi (self , discriminator , setupPinCode , nodeId , ssid : str , credentials : str , isShortDiscriminator : bool = False ) -> int :
1889
1895
''' Commissions a Wi-Fi device over BLE.
1890
1896
'''
1891
1897
self .SetWiFiCredentials (ssid , credentials )
@@ -1988,7 +1994,7 @@ def GetFabricCheckResult(self) -> int:
1988
1994
return self .fabricCheckNodeId
1989
1995
1990
1996
def CommissionOnNetwork (self , nodeId : int , setupPinCode : int ,
1991
- filterType : DiscoveryFilterType = DiscoveryFilterType .NONE , filter : typing .Any = None , discoveryTimeoutMsec : int = 30000 ) -> PyChipError :
1997
+ filterType : DiscoveryFilterType = DiscoveryFilterType .NONE , filter : typing .Any = None , discoveryTimeoutMsec : int = 30000 ) -> int :
1992
1998
'''
1993
1999
Does the routine for OnNetworkCommissioning, with a filter for mDNS discovery.
1994
2000
Supported filters are:
@@ -2004,6 +2010,11 @@ def CommissionOnNetwork(self, nodeId: int, setupPinCode: int,
2004
2010
DiscoveryFilterType.COMPRESSED_FABRIC_ID
2005
2011
2006
2012
The filter can be an integer, a string or None depending on the actual type of selected filter.
2013
+
2014
+ Raises a ChipStackError on failure.
2015
+
2016
+ Returns:
2017
+ - Effective Node ID of the device (as defined by the assigned NOC)
2007
2018
'''
2008
2019
self .CheckIsActive ()
2009
2020
@@ -2023,9 +2034,14 @@ def CommissionOnNetwork(self, nodeId: int, setupPinCode: int,
2023
2034
finally :
2024
2035
self ._commissioning_complete_future = None
2025
2036
2026
- def CommissionWithCode (self , setupPayload : str , nodeid : int , discoveryType : DiscoveryType = DiscoveryType .DISCOVERY_ALL ) -> PyChipError :
2037
+ def CommissionWithCode (self , setupPayload : str , nodeid : int , discoveryType : DiscoveryType = DiscoveryType .DISCOVERY_ALL ) -> int :
2027
2038
''' Commission with the given nodeid from the setupPayload.
2028
2039
setupPayload may be a QR or manual code.
2040
+
2041
+ Raises a ChipStackError on failure.
2042
+
2043
+ Returns:
2044
+ - Effective Node ID of the device (as defined by the assigned NOC)
2029
2045
'''
2030
2046
self .CheckIsActive ()
2031
2047
@@ -2042,8 +2058,14 @@ def CommissionWithCode(self, setupPayload: str, nodeid: int, discoveryType: Disc
2042
2058
finally :
2043
2059
self ._commissioning_complete_future = None
2044
2060
2045
- def CommissionIP (self , ipaddr : str , setupPinCode : int , nodeid : int ) -> PyChipError :
2046
- """ DEPRECATED, DO NOT USE! Use `CommissionOnNetwork` or `CommissionWithCode` """
2061
+ def CommissionIP (self , ipaddr : str , setupPinCode : int , nodeid : int ) -> int :
2062
+ """ DEPRECATED, DO NOT USE! Use `CommissionOnNetwork` or `CommissionWithCode`
2063
+
2064
+ Raises a ChipStackError on failure.
2065
+
2066
+ Returns:
2067
+ - Effective Node ID of the device (as defined by the assigned NOC)
2068
+ """
2047
2069
self .CheckIsActive ()
2048
2070
2049
2071
self ._commissioning_complete_future = concurrent .futures .Future ()
0 commit comments