From 5c94500156f2b428386fe553d77099d2d7202f8d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 15 Nov 2024 04:39:13 +0000 Subject: [PATCH] Restyled by clang-format --- src/controller/python/OpCredsBinding.cpp | 73 ++++++++++++------------ 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/src/controller/python/OpCredsBinding.cpp b/src/controller/python/OpCredsBinding.cpp index 8f2df1736f6019..667517f23c6753 100644 --- a/src/controller/python/OpCredsBinding.cpp +++ b/src/controller/python/OpCredsBinding.cpp @@ -16,7 +16,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. -*/ + */ #include @@ -45,17 +45,17 @@ #include #include -//Including AutoCommissioner initialization here for getting RootCert +// Including AutoCommissioner initialization here for getting RootCert #include -#include -#include -#include -#include // Added for size_t +#include // Added for size_t #include // Added for std::function #include #include -//#include // Include this for std::this_thread -//#include // Include this for std::chrono::milliseconds +#include +#include +#include +// #include // Include this for std::this_thread +// #include // Include this for std::chrono::milliseconds using namespace chip; @@ -168,7 +168,7 @@ class TestCommissioner : public chip::Controller::AutoCommissioner if (report.Is()) { auto nocChain = report.Get(); - MutableByteSpan rcacSpan(const_cast(nocChain.rcac.data()), nocChain.rcac.size()); + MutableByteSpan rcacSpan(const_cast(nocChain.rcac.data()), nocChain.rcac.size()); chip::ByteSpan rcacByteSpan(rcacSpan.data(), rcacSpan.size()); @@ -337,10 +337,7 @@ class TestCommissioner : public chip::Controller::AutoCommissioner } } - CHIP_ERROR GetCommissioningResultError() const - { - return mCommissioningResultError; - } + CHIP_ERROR GetCommissioningResultError() const { return mCommissioningResultError; } void SetOnRCACReadyCallback(RCACReadyCallback callback) { @@ -351,8 +348,8 @@ class TestCommissioner : public chip::Controller::AutoCommissioner CHIP_ERROR GetCompletionError() { return mCompletionError; } // Getter method to access RCAC data - //const std::vector& GetRCACData() const { return mRCACData; } - const std::vector& GetCHIPRCACData() const { return mCHIPRCACData; } + // const std::vector& GetRCACData() const { return mRCACData; } + const std::vector & GetCHIPRCACData() const { return mCHIPRCACData; } private: void NotifyRCACDataReady() @@ -624,7 +621,8 @@ PyChipError pychip_OpCreds_AllocateController(OpCredsContext * context, chip::Co { initParams.defaultCommissioner = &sTestCommissioner; pairingDelegate->SetCommissioningSuccessCallback(pychip_OnCommissioningSuccess); - //pairingDelegate->SetCommissioningSuccessCallback([](chip::PeerId peerId) { pychip_OnCommissioningSuccess(peerId, sTestCommissioner.GetRCACData().data(), sTestCommissioner.GetRCACData().size()); }); + // pairingDelegate->SetCommissioningSuccessCallback([](chip::PeerId peerId) { pychip_OnCommissioningSuccess(peerId, + // sTestCommissioner.GetRCACData().data(), sTestCommissioner.GetRCACData().size()); }); pairingDelegate->SetCommissioningFailureCallback(pychip_OnCommissioningFailure); pairingDelegate->SetCommissioningStatusUpdateCallback(pychip_OnCommissioningStatusUpdate); } @@ -764,29 +762,28 @@ PyChipError pychip_GetCompletionError() } extern "C" { - // Define a global callback to set the RCAC data callback - using PythonRCACCallback = void (*)(const uint8_t *, size_t); - static PythonRCACCallback gPythonRCACCallback = nullptr; +// Define a global callback to set the RCAC data callback +using PythonRCACCallback = void (*)(const uint8_t *, size_t); +static PythonRCACCallback gPythonRCACCallback = nullptr; +// Function to set the Python callback +void pychip_SetCommissioningRCACCallback(PythonRCACCallback callback) +{ + ChipLogProgress(Controller, "Attempting to set Python RCAC callback in C++"); + gPythonRCACCallback = callback; - // Function to set the Python callback - void pychip_SetCommissioningRCACCallback(PythonRCACCallback callback) - { - ChipLogProgress(Controller, "Attempting to set Python RCAC callback in C++"); - gPythonRCACCallback = callback; - - // Set C++ TestCommissioner callback to notify Python when RCAC data is ready - sTestCommissioner.SetOnRCACReadyCallback([](const std::vector & rcacData) { - if (gPythonRCACCallback) - { - ChipLogProgress(Controller, "RCAC callback in C++ set"); - gPythonRCACCallback(rcacData.data(), rcacData.size()); - } - else - { - ChipLogError(Controller, "Python RCAC callback is not set."); - } - }); + // Set C++ TestCommissioner callback to notify Python when RCAC data is ready + sTestCommissioner.SetOnRCACReadyCallback([](const std::vector & rcacData) { + if (gPythonRCACCallback) + { + ChipLogProgress(Controller, "RCAC callback in C++ set"); + gPythonRCACCallback(rcacData.data(), rcacData.size()); } - } + else + { + ChipLogError(Controller, "Python RCAC callback is not set."); + } + }); +} +} } // extern "C"