diff --git a/0004-Python-Support-commissioning-with-code-on-network-on.patch b/0004-Python-Support-commissioning-with-code-on-network-on.patch new file mode 100644 index 0000000..ba5a222 --- /dev/null +++ b/0004-Python-Support-commissioning-with-code-on-network-on.patch @@ -0,0 +1,90 @@ +From e34fbf7b58908fa777335cbc4da4a0d6b26fe6d7 Mon Sep 17 00:00:00 2001 +Message-ID: +From: Stefan Agner +Date: Thu, 14 Dec 2023 13:33:05 +0100 +Subject: [PATCH] [Python] Support commissioning with code on network only + (#31000) + +* [Python] Support commissioning with code on network only + +Add an additional parameter to support commissioning on network only. +This is useful when a manual pairing code is given and we know the +device is on the network already. + +* Use consistent casing for newly added parameter +--- + .../python/ChipDeviceController-ScriptBinding.cpp | 10 +++++++--- + src/controller/python/chip/ChipDeviceCtrl.py | 6 +++--- + 2 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp +index a7732a4836..c4b12570fd 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 +@@ -135,7 +136,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); +@@ -397,10 +398,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 22ae11cda6..de6f1fff03 100644 +--- a/src/controller/python/chip/ChipDeviceCtrl.py ++++ b/src/controller/python/chip/ChipDeviceCtrl.py +@@ -1422,7 +1422,7 @@ class ChipDeviceControllerBase(): + 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 = [ +@@ -1726,7 +1726,7 @@ class ChipDeviceController(ChipDeviceControllerBase): + return PyChipError(CHIP_ERROR_TIMEOUT) + return self._ChipStack.commissioningEventRes + +- def CommissionWithCode(self, setupPayload: str, nodeid: int) -> PyChipError: ++ def CommissionWithCode(self, setupPayload: str, nodeid: int, networkOnly: bool = False) -> PyChipError: + self.CheckIsActive() + + setupPayload = setupPayload.encode() + b'\0' +@@ -1739,7 +1739,7 @@ class ChipDeviceController(ChipDeviceControllerBase): + + self._ChipStack.CallAsync( + lambda: self._dmLib.pychip_DeviceController_ConnectWithCode( +- self.devCtrl, setupPayload, nodeid) ++ self.devCtrl, setupPayload, nodeid, networkOnly) + ) + if not self._ChipStack.commissioningCompleteEvent.isSet(): + # Error 50 is a timeout +-- +2.43.0 +