diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp index 3c0191072923b8..4979da8acdbe35 100644 --- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp +++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -136,7 +137,7 @@ PyChipError pychip_DeviceController_ConnectBLE(chip::Controller::DeviceCommissio PyChipError pychip_DeviceController_ConnectIP(chip::Controller::DeviceCommissioner * devCtrl, const char * peerAddrStr, uint32_t setupPINCode, chip::NodeId nodeid); PyChipError pychip_DeviceController_ConnectWithCode(chip::Controller::DeviceCommissioner * devCtrl, const char * onboardingPayload, - chip::NodeId nodeid); + chip::NodeId nodeid, bool networkOnly); PyChipError pychip_DeviceController_UnpairDevice(chip::Controller::DeviceCommissioner * devCtrl, chip::NodeId remoteDeviceId, DeviceUnpairingCompleteFunct callback); PyChipError pychip_DeviceController_SetThreadOperationalDataset(const char * threadOperationalDataset, uint32_t size); @@ -398,10 +399,13 @@ PyChipError pychip_DeviceController_ConnectIP(chip::Controller::DeviceCommission } PyChipError pychip_DeviceController_ConnectWithCode(chip::Controller::DeviceCommissioner * devCtrl, const char * onboardingPayload, - chip::NodeId nodeid) + chip::NodeId nodeid, bool networkOnly) { + chip::Controller::DiscoveryType discoveryType = chip::Controller::DiscoveryType::kAll; sPairingDelegate.SetExpectingPairingComplete(true); - return ToPyChipError(devCtrl->PairDevice(nodeid, onboardingPayload, sCommissioningParameters)); + if (networkOnly) + discoveryType = chip::Controller::DiscoveryType::kDiscoveryNetworkOnly; + return ToPyChipError(devCtrl->PairDevice(nodeid, onboardingPayload, sCommissioningParameters, discoveryType)); } namespace { diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 8fa20dc75246f3..e67d3759f8bac8 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -1580,7 +1580,7 @@ def _InitLib(self): self._dmLib.pychip_DeviceController_ConnectIP.restype = PyChipError self._dmLib.pychip_DeviceController_ConnectWithCode.argtypes = [ - c_void_p, c_char_p, c_uint64] + c_void_p, c_char_p, c_uint64, c_bool] self._dmLib.pychip_DeviceController_ConnectWithCode.restype = PyChipError self._dmLib.pychip_DeviceController_UnpairDevice.argtypes = [ @@ -1893,7 +1893,7 @@ def CommissionOnNetwork(self, nodeId: int, setupPinCode: int, return PyChipError(CHIP_ERROR_TIMEOUT) return self._ChipStack.commissioningEventRes - def CommissionWithCode(self, setupPayload: str, nodeid: int) -> PyChipError: + def CommissionWithCode(self, setupPayload: str, nodeid: int, network_only: bool = False) -> PyChipError: ''' Commission with the given nodeid from the setupPayload. setupPayload may be a QR or manual code. ''' @@ -1909,7 +1909,7 @@ def CommissionWithCode(self, setupPayload: str, nodeid: int) -> PyChipError: self._ChipStack.CallAsync( lambda: self._dmLib.pychip_DeviceController_ConnectWithCode( - self.devCtrl, setupPayload, nodeid) + self.devCtrl, setupPayload, nodeid, network_only) ) if not self._ChipStack.commissioningCompleteEvent.isSet(): # Error 50 is a timeout