diff --git a/src/controller/python/chip/ChipCommissionableNodeCtrl.py b/src/controller/python/chip/ChipCommissionableNodeCtrl.py index 21d8a7f238a714..4136b0757bf572 100644 --- a/src/controller/python/chip/ChipCommissionableNodeCtrl.py +++ b/src/controller/python/chip/ChipCommissionableNodeCtrl.py @@ -68,16 +68,18 @@ def __del__(self): self.commissionableNodeCtrl = None def PrintDiscoveredCommissioners(self): - return self._ChipStack.Call( + # void function + self._ChipStack.Call( lambda: self._dmLib.pychip_CommissionableNodeController_PrintDiscoveredCommissioners( self.commissionableNodeCtrl) ) def DiscoverCommissioners(self): - return self._ChipStack.Call( + res = self._ChipStack.Call( lambda: self._dmLib.pychip_CommissionableNodeController_DiscoverCommissioners( self.commissionableNodeCtrl) ) + res.raise_on_error() # ----- Private Members ----- def _InitLib(self): diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 490cc99d95da4d..46327e90590b31 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -177,7 +177,7 @@ def localSessionId(self) -> int: builtins.chipStack.Call( lambda: self._dmLib.pychip_GetLocalSessionId(self._deviceProxy, pointer(localSessionId)) - ) + ).raise_on_error() return localSessionId.value @@ -190,7 +190,7 @@ def numTotalSessions(self) -> int: builtins.chipStack.Call( lambda: self._dmLib.pychip_GetNumSessionsToPeer(self._deviceProxy, pointer(numSessions)) - ) + ).raise_on_error() return numSessions.value @@ -331,7 +331,7 @@ def Shutdown(self): self._ChipStack.Call( lambda: self._dmLib.pychip_DeviceController_DeleteDeviceController( self.devCtrl) - ) + ).raise_on_error() self.devCtrl = None ChipDeviceController.activeList.remove(self) @@ -372,18 +372,6 @@ def IsConnected(self): self.devCtrl) ) - def ConnectBle(self, bleConnection): - self.CheckIsActive() - - self._ChipStack.CallAsync( - lambda: self._dmLib.pychip_DeviceController_ValidateBTP( - self.devCtrl, - bleConnection, - self._ChipStack.cbHandleComplete, - self._ChipStack.cbHandleError, - ) - ) - def ConnectBLE(self, discriminator, setupPinCode, nodeid): self.CheckIsActive() @@ -393,7 +381,7 @@ def ConnectBLE(self, discriminator, setupPinCode, nodeid): self._ChipStack.CallAsync( lambda: self._dmLib.pychip_DeviceController_ConnectBLE( self.devCtrl, discriminator, setupPinCode, nodeid) - ) + ).raise_on_error() if not self._ChipStack.commissioningCompleteEvent.isSet(): # Error 50 is a timeout return False @@ -596,6 +584,7 @@ def GetAddressAndPort(self, nodeid): address = create_string_buffer(64) port = c_uint16(0) + # Intentially return None instead of raising exceptions on error error = self._ChipStack.Call( lambda: self._dmLib.pychip_DeviceController_GetAddressAndPort( self.devCtrl, nodeid, address, 64, pointer(port)) @@ -716,15 +705,6 @@ def HandleDevice(deviceJson, deviceJsonLen): return self._ChipStack.Call(lambda: GetDevices(self)) - def ParseQRCode(self, qrCode, output): - self.CheckIsActive() - - print(output) - return self._ChipStack.Call( - lambda: self._dmLib.pychip_DeviceController_ParseQRCode( - qrCode, output) - ) - def GetIPForDiscoveredDevice(self, idx, addrStr, length): self.CheckIsActive() diff --git a/src/controller/python/chip/ChipStack.py b/src/controller/python/chip/ChipStack.py index f1bbcd57c92d45..3ca313be08214d 100644 --- a/src/controller/python/chip/ChipStack.py +++ b/src/controller/python/chip/ChipStack.py @@ -328,7 +328,7 @@ def setLogFunct(self, logFunct): self._ChipStackLib.pychip_Stack_SetLogFunct(logFunct) def Shutdown(self): - self.Call(lambda: self._ChipStackLib.pychip_DeviceController_StackShutdown()) + self.Call(lambda: self._ChipStackLib.pychip_DeviceController_StackShutdown()).raise_on_error() # # We only shutdown the persistent storage layer AFTER we've shut down the stack,