|
41 | 41 | from chip import ChipDeviceCtrl
|
42 | 42 | from chip.ChipStack import ChipStack
|
43 | 43 | from chip.crypto import p256keypair
|
| 44 | +from chip.exceptions import ChipStackException |
44 | 45 | from chip.utils import CommissioningBuildingBlocks
|
45 | 46 | from cirque_restart_remote_device import restartRemoteDevice
|
46 | 47 | from ecdsa import NIST256p
|
@@ -268,7 +269,9 @@ def TestPaseOnly(self, ip: str, setuppin: int, nodeid: int, devCtrl=None):
|
268 | 269 | def TestCommissionOnly(self, nodeid: int):
|
269 | 270 | self.logger.info(
|
270 | 271 | "Commissioning device with id {}".format(nodeid))
|
271 |
| - if not self.devCtrl.Commission(nodeid): |
| 272 | + try: |
| 273 | + self.devCtrl.Commission(nodeid) |
| 274 | + except ChipStackException: |
272 | 275 | self.logger.info(
|
273 | 276 | "Failed to commission device with id {}".format(str(nodeid)))
|
274 | 277 | return False
|
@@ -311,17 +314,21 @@ def TestCommissionFailureOnReport(self, nodeid: int, failAfter: int):
|
311 | 314 |
|
312 | 315 | def TestCommissioning(self, ip: str, setuppin: int, nodeid: int):
|
313 | 316 | self.logger.info("Commissioning device {}".format(ip))
|
314 |
| - if not self.devCtrl.CommissionIP(ip, setuppin, nodeid): |
315 |
| - self.logger.info( |
| 317 | + try: |
| 318 | + self.devCtrl.CommissionIP(ip, setuppin, nodeid) |
| 319 | + except ChipStackException: |
| 320 | + self.logger.exception( |
316 | 321 | "Failed to finish commissioning device {}".format(ip))
|
317 | 322 | return False
|
318 | 323 | self.logger.info("Commissioning finished.")
|
319 | 324 | return True
|
320 | 325 |
|
321 | 326 | def TestCommissioningWithSetupPayload(self, setupPayload: str, nodeid: int, discoveryType: int = 2):
|
322 | 327 | self.logger.info("Commissioning device with setup payload {}".format(setupPayload))
|
323 |
| - if not self.devCtrl.CommissionWithCode(setupPayload, nodeid, chip.discovery.DiscoveryType(discoveryType)): |
324 |
| - self.logger.info( |
| 328 | + try: |
| 329 | + self.devCtrl.CommissionWithCode(setupPayload, nodeid, chip.discovery.DiscoveryType(discoveryType)) |
| 330 | + except ChipStackException: |
| 331 | + self.logger.exception( |
325 | 332 | "Failed to finish commissioning device {}".format(setupPayload))
|
326 | 333 | return False
|
327 | 334 | self.logger.info("Commissioning finished.")
|
@@ -783,8 +790,10 @@ async def TestMultiFabric(self, ip: str, setuppin: int, nodeid: int):
|
783 | 790 | self.devCtrl2 = self.fabricAdmin2.NewController(
|
784 | 791 | self.controllerNodeId, self.paaTrustStorePath)
|
785 | 792 |
|
786 |
| - if not self.devCtrl2.CommissionIP(ip, setuppin, nodeid): |
787 |
| - self.logger.info( |
| 793 | + try: |
| 794 | + self.devCtrl2.CommissionIP(ip, setuppin, nodeid) |
| 795 | + except ChipStackException: |
| 796 | + self.logger.exception( |
788 | 797 | "Failed to finish key exchange with device {}".format(ip))
|
789 | 798 | return False
|
790 | 799 |
|
|
0 commit comments