From 40331da55f6db1b1985c48bd7cd648c8538cf997 Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Thu, 27 Jan 2022 13:43:33 -0500 Subject: [PATCH 1/9] Update code PairDevice calls to work with network params. --- .../chip-tool/commands/pairing/Commands.h | 36 ++++++++ .../commands/pairing/PairingCommand.cpp | 6 +- src/controller/AutoCommissioner.cpp | 82 +++++++++++++++---- src/controller/AutoCommissioner.h | 7 +- src/controller/CHIPDeviceController.cpp | 17 ++-- src/controller/CHIPDeviceController.h | 1 + src/controller/CommissioningDelegate.h | 6 +- src/controller/SetUpCodePairer.cpp | 4 +- 8 files changed, 129 insertions(+), 30 deletions(-) diff --git a/examples/chip-tool/commands/pairing/Commands.h b/examples/chip-tool/commands/pairing/Commands.h index 20e3077a7919cf..6907315fa4c4c1 100644 --- a/examples/chip-tool/commands/pairing/Commands.h +++ b/examples/chip-tool/commands/pairing/Commands.h @@ -42,6 +42,22 @@ class PairQRCode : public PairingCommand {} }; +class PairQRCodeWifi : public PairingCommand +{ +public: + PairQRCodeWifi(CredentialIssuerCommands * credsIssuerConfig) : + PairingCommand("qrcode-wifi", PairingMode::QRCode, PairingNetworkType::WiFi, credsIssuerConfig) + {} +}; + +class PairQRCodeThread : public PairingCommand +{ +public: + PairQRCodeThread(CredentialIssuerCommands * credsIssuerConfig) : + PairingCommand("qrcode-thread", PairingMode::QRCode, PairingNetworkType::Thread, credsIssuerConfig) + {} +}; + class PairManualCode : public PairingCommand { public: @@ -50,6 +66,22 @@ class PairManualCode : public PairingCommand {} }; +class PairManualCodeWifi : public PairingCommand +{ +public: + PairManualCodeWifi(CredentialIssuerCommands * credsIssuerConfig) : + PairingCommand("manualcode-wifi", PairingMode::ManualCode, PairingNetworkType::WiFi, credsIssuerConfig) + {} +}; + +class PairManualCodeThread : public PairingCommand +{ +public: + PairManualCodeThread(CredentialIssuerCommands * credsIssuerConfig) : + PairingCommand("manualcode-thread", PairingMode::ManualCode, PairingNetworkType::Thread, credsIssuerConfig) + {} +}; + class PairOnNetwork : public PairingCommand { public: @@ -182,7 +214,11 @@ void registerCommandsPairing(Commands & commands, CredentialIssuerCommands * cre commands_list clusterCommands = { make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index c568bf45f5d08f..e7732f7b0170f1 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -85,12 +85,14 @@ CommissioningParameters PairingCommand::GetCommissioningParameters() CHIP_ERROR PairingCommand::PairWithQRCode(NodeId remoteId) { - return CurrentCommissioner().PairDevice(remoteId, mOnboardingPayload); + CommissioningParameters commissioningParams = GetCommissioningParameters(); + return CurrentCommissioner().PairDevice(remoteId, mOnboardingPayload, commissioningParams); } CHIP_ERROR PairingCommand::PairWithManualCode(NodeId remoteId) { - return CurrentCommissioner().PairDevice(remoteId, mOnboardingPayload); + CommissioningParameters commissioningParams = GetCommissioningParameters(); + return CurrentCommissioner().PairDevice(remoteId, mOnboardingPayload, commissioningParams); } CHIP_ERROR PairingCommand::Pair(NodeId remoteId, PeerAddress address) diff --git a/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index 423c77a005a110..9489e5e1947f6e 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -25,6 +25,16 @@ namespace chip { namespace Controller { +AutoCommissioner::AutoCommissioner(DeviceCommissioner * commissioner) : mCommissioner(commissioner) +{ + ChipLogProgress(Controller, "Setting attestation nonce to random value"); + Crypto::DRBG_get_bytes(mAttestationNonce, sizeof(mAttestationNonce)); + mParams.SetAttestationNonce(ByteSpan(mAttestationNonce, sizeof(mAttestationNonce))); + ChipLogProgress(Controller, "Setting CSR nonce to random value"); + Crypto::DRBG_get_bytes(mCSRNonce, sizeof(mCSRNonce)); + mParams.SetCSRNonce(ByteSpan(mCSRNonce, sizeof(mCSRNonce))); +} + AutoCommissioner::~AutoCommissioner() { ReleaseDAC(); @@ -39,6 +49,62 @@ void AutoCommissioner::SetOperationalCredentialsDelegate(OperationalCredentialsD CHIP_ERROR AutoCommissioner::SetCommissioningParameters(const CommissioningParameters & params) { mParams = params; + // Call AddCommissioningParameters to swap bytespans to internal memory. + return AddCommissioningParameters(params); +} + +CHIP_ERROR AutoCommissioner::AddCommissioningParameters(const CommissioningParameters & params) +{ + if (params.GetFailsafeTimerSeconds().HasValue()) + { + mParams.SetFailsafeTimerSeconds(params.GetFailsafeTimerSeconds().Value()); + } + if (params.GetNOCChainGenerationParameters().HasValue()) + { + mParams.SetNOCChainGenerationParameters(params.GetNOCChainGenerationParameters().Value()); + } + if (params.GetRootCert().HasValue()) + { + mParams.SetRootCert(params.GetRootCert().Value()); + } + if (params.GetNoc().HasValue()) + { + mParams.SetNoc(params.GetNoc().Value()); + } + if (params.GetIcac().HasValue()) + { + mParams.SetIcac(params.GetIcac().Value()); + } + if (params.GetIpk().HasValue()) + { + mParams.SetIpk(params.GetIpk().Value()); + } + if (params.GetAdminSubject().HasValue()) + { + mParams.SetAdminSubject(params.GetAdminSubject().Value()); + } + if (params.GetAdminSubject().HasValue()) + { + mParams.SetAdminSubject(params.GetAdminSubject().Value()); + } + if (params.GetAttestationElements().HasValue()) + { + mParams.SetAttestationElements(params.GetAttestationElements().Value()); + } + if (params.GetAttestationSignature().HasValue()) + { + mParams.SetAttestationSignature(params.GetAttestationSignature().Value()); + } + if (params.GetPAI().HasValue()) + { + ReleasePAI(); + SetPAI(params.GetPAI().Value()); + } + if (params.GetDAC().HasValue()) + { + ReleaseDAC(); + SetDAC(params.GetDAC().Value()); + } if (params.GetThreadOperationalDataset().HasValue()) { ByteSpan dataset = params.GetThreadOperationalDataset().Value(); @@ -66,32 +132,20 @@ CHIP_ERROR AutoCommissioner::SetCommissioningParameters(const CommissioningParam mParams.SetWiFiCredentials( WiFiCredentials(ByteSpan(mSsid, creds.ssid.size()), ByteSpan(mCredentials, creds.credentials.size()))); } - // If the AttestationNonce is passed in, using that else using a random one.. if (params.GetAttestationNonce().HasValue()) { ChipLogProgress(Controller, "Setting attestation nonce from parameters"); VerifyOrReturnError(params.GetAttestationNonce().Value().size() == sizeof(mAttestationNonce), CHIP_ERROR_INVALID_ARGUMENT); memcpy(mAttestationNonce, params.GetAttestationNonce().Value().data(), params.GetAttestationNonce().Value().size()); + mParams.SetAttestationNonce(ByteSpan(mAttestationNonce, sizeof(mAttestationNonce))); } - else - { - ChipLogProgress(Controller, "Setting attestation nonce to random value"); - Crypto::DRBG_get_bytes(mAttestationNonce, sizeof(mAttestationNonce)); - } - mParams.SetAttestationNonce(ByteSpan(mAttestationNonce, sizeof(mAttestationNonce))); - if (params.GetCSRNonce().HasValue()) { ChipLogProgress(Controller, "Setting CSR nonce from parameters"); VerifyOrReturnError(params.GetCSRNonce().Value().size() == sizeof(mCSRNonce), CHIP_ERROR_INVALID_ARGUMENT); memcpy(mCSRNonce, params.GetCSRNonce().Value().data(), params.GetCSRNonce().Value().size()); + mParams.SetCSRNonce(ByteSpan(mCSRNonce, sizeof(mCSRNonce))); } - else - { - ChipLogProgress(Controller, "Setting CSR nonce to random value"); - Crypto::DRBG_get_bytes(mCSRNonce, sizeof(mCSRNonce)); - } - mParams.SetCSRNonce(ByteSpan(mCSRNonce, sizeof(mCSRNonce))); return CHIP_NO_ERROR; } diff --git a/src/controller/AutoCommissioner.h b/src/controller/AutoCommissioner.h index c2c0f04837252d..7d21625c4bfe44 100644 --- a/src/controller/AutoCommissioner.h +++ b/src/controller/AutoCommissioner.h @@ -28,9 +28,14 @@ class DeviceCommissioner; class AutoCommissioner : public CommissioningDelegate { public: - AutoCommissioner(DeviceCommissioner * commissioner) : mCommissioner(commissioner) {} + AutoCommissioner(DeviceCommissioner * commissioner); ~AutoCommissioner(); + CHIP_ERROR SetCommissioningParameters(const CommissioningParameters & params); + + // Overwrites only the given commissioning parameters. + CHIP_ERROR AddCommissioningParameters(const CommissioningParameters & params); + void SetOperationalCredentialsDelegate(OperationalCredentialsDelegate * operationalCredentialsDelegate); void StartCommissioning(CommissioneeDeviceProxy * proxy); diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 675ce4d7dea3fe..b2f4698d06e360 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -744,6 +744,12 @@ CHIP_ERROR DeviceCommissioner::GetConnectedDevice(NodeId deviceId, Callback::Cal return DeviceController::GetConnectedDevice(deviceId, onConnection, onFailure); } +CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, const char * setUpCode, const CommissioningParameters & params) +{ + ReturnErrorOnFailure(mAutoCommissioner.AddCommissioningParameters(params)); + return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode); +} + CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, const char * setUpCode) { return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode); @@ -890,18 +896,13 @@ CHIP_ERROR DeviceCommissioner::Commission(NodeId remoteDeviceId, CommissioningPa ChipLogError(Controller, "Commissioning already in progress - not restarting"); return CHIP_ERROR_INCORRECT_STATE; } - if (!params.GetWiFiCredentials().HasValue() && !params.GetThreadOperationalDataset().HasValue() && !mIsIPRendezvous) - { - ChipLogError(Controller, "Network commissioning parameters are required for BLE auto commissioning."); - return CHIP_ERROR_INVALID_ARGUMENT; - } ChipLogProgress(Controller, "Commission called for node ID 0x" ChipLogFormatX64, ChipLogValueX64(remoteDeviceId)); mSystemState->SystemLayer()->StartTimer(chip::System::Clock::Milliseconds32(kSessionEstablishmentTimeout), OnSessionEstablishmentTimeoutCallback, this); mAutoCommissioner.SetOperationalCredentialsDelegate(mOperationalCredentialsDelegate); - ReturnErrorOnFailure(mAutoCommissioner.SetCommissioningParameters(params)); + ReturnErrorOnFailure(mAutoCommissioner.AddCommissioningParameters(params)); if (device->IsSecureConnected()) { mAutoCommissioner.StartCommissioning(device); @@ -1608,7 +1609,9 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio GeneralCommissioningCluster genCom; // TODO: should get the endpoint information from the descriptor cluster. SetupCluster(genCom, proxy, endpoint, timeout); - genCom.ArmFailSafe(mSuccess.Cancel(), mFailure.Cancel(), params.GetFailsafeTimerSeconds(), breadcrumb, kCommandTimeoutMs); + constexpr uint16_t kDefaultFailsafeSeconds = 60; + genCom.ArmFailSafe(mSuccess.Cancel(), mFailure.Cancel(), params.GetFailsafeTimerSeconds().ValueOr(kDefaultFailsafeSeconds), + breadcrumb, kCommandTimeoutMs); } break; case CommissioningStage::kConfigRegulatory: { diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 323c3f81426279..1d3ca1ea5cfeb3 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -477,6 +477,7 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, * @param[in] setUpCode The setup code for connecting to the device */ CHIP_ERROR PairDevice(NodeId remoteDeviceId, const char * setUpCode); + CHIP_ERROR PairDevice(NodeId remoteDeviceId, const char * setUpCode, const CommissioningParameters & CommissioningParameters); /** * @brief diff --git a/src/controller/CommissioningDelegate.h b/src/controller/CommissioningDelegate.h index 12bda4f6fb6ab9..36b65ea78b27aa 100644 --- a/src/controller/CommissioningDelegate.h +++ b/src/controller/CommissioningDelegate.h @@ -73,7 +73,7 @@ class CommissioningParameters static constexpr size_t kMaxThreadDatasetLen = 254; static constexpr size_t kMaxSsidLen = 32; static constexpr size_t kMaxCredentialsLen = 64; - uint16_t GetFailsafeTimerSeconds() const { return mFailsafeTimerSeconds; } + const Optional GetFailsafeTimerSeconds() const { return mFailsafeTimerSeconds; } const Optional GetCSRNonce() const { return mCSRNonce; } const Optional GetAttestationNonce() const { return mAttestationNonce; } const Optional GetWiFiCredentials() const { return mWiFiCreds; } @@ -95,7 +95,7 @@ class CommissioningParameters CommissioningParameters & SetFailsafeTimerSeconds(uint16_t seconds) { - mFailsafeTimerSeconds = seconds; + mFailsafeTimerSeconds.SetValue(seconds); return *this; } @@ -182,7 +182,7 @@ class CommissioningParameters void SetCompletionStatus(CHIP_ERROR err) { completionStatus = err; } private: - uint16_t mFailsafeTimerSeconds = 60; + Optional mFailsafeTimerSeconds; Optional mCSRNonce; ///< CSR Nonce passed by the commissioner Optional mAttestationNonce; ///< Attestation Nonce passed by the commissioner Optional mWiFiCreds; diff --git a/src/controller/SetUpCodePairer.cpp b/src/controller/SetUpCodePairer.cpp index 75d710308f54bb..31392429561896 100644 --- a/src/controller/SetUpCodePairer.cpp +++ b/src/controller/SetUpCodePairer.cpp @@ -147,9 +147,7 @@ void SetUpCodePairer::OnDiscoveredDeviceOverBle(BLE_CONNECTION_OBJECT connObj) Transport::PeerAddress peerAddress = Transport::PeerAddress::BLE(); RendezvousParameters params = RendezvousParameters().SetPeerAddress(peerAddress).SetConnectionObject(connObj); - // We don't have network credentials, so can't do the entire pairing flow. Just establish a PASE session to the - // device and let our consumer deal with the rest. - LogErrorOnFailure(mCommissioner->EstablishPASEConnection(mRemoteId, params.SetSetupPINCode(mSetUpPINCode))); + OnDeviceDiscovered(params); } void SetUpCodePairer::OnDiscoveredDeviceOverBleSuccess(void * appState, BLE_CONNECTION_OBJECT connObj) From f165a51696e3961f7fe92b624e76760b06b276fa Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Thu, 27 Jan 2022 15:09:47 -0500 Subject: [PATCH 2/9] Better way to do commissioning parameters That whole "Add" thing was terrible. --- src/controller/AutoCommissioner.cpp | 82 +++++-------------------- src/controller/AutoCommissioner.h | 7 +-- src/controller/CHIPDeviceController.cpp | 17 ++--- src/controller/CHIPDeviceController.h | 1 + src/controller/CommissioningDelegate.h | 6 +- 5 files changed, 29 insertions(+), 84 deletions(-) diff --git a/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index 9489e5e1947f6e..423c77a005a110 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -25,16 +25,6 @@ namespace chip { namespace Controller { -AutoCommissioner::AutoCommissioner(DeviceCommissioner * commissioner) : mCommissioner(commissioner) -{ - ChipLogProgress(Controller, "Setting attestation nonce to random value"); - Crypto::DRBG_get_bytes(mAttestationNonce, sizeof(mAttestationNonce)); - mParams.SetAttestationNonce(ByteSpan(mAttestationNonce, sizeof(mAttestationNonce))); - ChipLogProgress(Controller, "Setting CSR nonce to random value"); - Crypto::DRBG_get_bytes(mCSRNonce, sizeof(mCSRNonce)); - mParams.SetCSRNonce(ByteSpan(mCSRNonce, sizeof(mCSRNonce))); -} - AutoCommissioner::~AutoCommissioner() { ReleaseDAC(); @@ -49,62 +39,6 @@ void AutoCommissioner::SetOperationalCredentialsDelegate(OperationalCredentialsD CHIP_ERROR AutoCommissioner::SetCommissioningParameters(const CommissioningParameters & params) { mParams = params; - // Call AddCommissioningParameters to swap bytespans to internal memory. - return AddCommissioningParameters(params); -} - -CHIP_ERROR AutoCommissioner::AddCommissioningParameters(const CommissioningParameters & params) -{ - if (params.GetFailsafeTimerSeconds().HasValue()) - { - mParams.SetFailsafeTimerSeconds(params.GetFailsafeTimerSeconds().Value()); - } - if (params.GetNOCChainGenerationParameters().HasValue()) - { - mParams.SetNOCChainGenerationParameters(params.GetNOCChainGenerationParameters().Value()); - } - if (params.GetRootCert().HasValue()) - { - mParams.SetRootCert(params.GetRootCert().Value()); - } - if (params.GetNoc().HasValue()) - { - mParams.SetNoc(params.GetNoc().Value()); - } - if (params.GetIcac().HasValue()) - { - mParams.SetIcac(params.GetIcac().Value()); - } - if (params.GetIpk().HasValue()) - { - mParams.SetIpk(params.GetIpk().Value()); - } - if (params.GetAdminSubject().HasValue()) - { - mParams.SetAdminSubject(params.GetAdminSubject().Value()); - } - if (params.GetAdminSubject().HasValue()) - { - mParams.SetAdminSubject(params.GetAdminSubject().Value()); - } - if (params.GetAttestationElements().HasValue()) - { - mParams.SetAttestationElements(params.GetAttestationElements().Value()); - } - if (params.GetAttestationSignature().HasValue()) - { - mParams.SetAttestationSignature(params.GetAttestationSignature().Value()); - } - if (params.GetPAI().HasValue()) - { - ReleasePAI(); - SetPAI(params.GetPAI().Value()); - } - if (params.GetDAC().HasValue()) - { - ReleaseDAC(); - SetDAC(params.GetDAC().Value()); - } if (params.GetThreadOperationalDataset().HasValue()) { ByteSpan dataset = params.GetThreadOperationalDataset().Value(); @@ -132,20 +66,32 @@ CHIP_ERROR AutoCommissioner::AddCommissioningParameters(const CommissioningParam mParams.SetWiFiCredentials( WiFiCredentials(ByteSpan(mSsid, creds.ssid.size()), ByteSpan(mCredentials, creds.credentials.size()))); } + // If the AttestationNonce is passed in, using that else using a random one.. if (params.GetAttestationNonce().HasValue()) { ChipLogProgress(Controller, "Setting attestation nonce from parameters"); VerifyOrReturnError(params.GetAttestationNonce().Value().size() == sizeof(mAttestationNonce), CHIP_ERROR_INVALID_ARGUMENT); memcpy(mAttestationNonce, params.GetAttestationNonce().Value().data(), params.GetAttestationNonce().Value().size()); - mParams.SetAttestationNonce(ByteSpan(mAttestationNonce, sizeof(mAttestationNonce))); } + else + { + ChipLogProgress(Controller, "Setting attestation nonce to random value"); + Crypto::DRBG_get_bytes(mAttestationNonce, sizeof(mAttestationNonce)); + } + mParams.SetAttestationNonce(ByteSpan(mAttestationNonce, sizeof(mAttestationNonce))); + if (params.GetCSRNonce().HasValue()) { ChipLogProgress(Controller, "Setting CSR nonce from parameters"); VerifyOrReturnError(params.GetCSRNonce().Value().size() == sizeof(mCSRNonce), CHIP_ERROR_INVALID_ARGUMENT); memcpy(mCSRNonce, params.GetCSRNonce().Value().data(), params.GetCSRNonce().Value().size()); - mParams.SetCSRNonce(ByteSpan(mCSRNonce, sizeof(mCSRNonce))); } + else + { + ChipLogProgress(Controller, "Setting CSR nonce to random value"); + Crypto::DRBG_get_bytes(mCSRNonce, sizeof(mCSRNonce)); + } + mParams.SetCSRNonce(ByteSpan(mCSRNonce, sizeof(mCSRNonce))); return CHIP_NO_ERROR; } diff --git a/src/controller/AutoCommissioner.h b/src/controller/AutoCommissioner.h index 7d21625c4bfe44..c2c0f04837252d 100644 --- a/src/controller/AutoCommissioner.h +++ b/src/controller/AutoCommissioner.h @@ -28,14 +28,9 @@ class DeviceCommissioner; class AutoCommissioner : public CommissioningDelegate { public: - AutoCommissioner(DeviceCommissioner * commissioner); + AutoCommissioner(DeviceCommissioner * commissioner) : mCommissioner(commissioner) {} ~AutoCommissioner(); - CHIP_ERROR SetCommissioningParameters(const CommissioningParameters & params); - - // Overwrites only the given commissioning parameters. - CHIP_ERROR AddCommissioningParameters(const CommissioningParameters & params); - void SetOperationalCredentialsDelegate(OperationalCredentialsDelegate * operationalCredentialsDelegate); void StartCommissioning(CommissioneeDeviceProxy * proxy); diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index b2f4698d06e360..5d85f644d1f880 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -746,7 +746,7 @@ CHIP_ERROR DeviceCommissioner::GetConnectedDevice(NodeId deviceId, Callback::Cal CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, const char * setUpCode, const CommissioningParameters & params) { - ReturnErrorOnFailure(mAutoCommissioner.AddCommissioningParameters(params)); + ReturnErrorOnFailure(mAutoCommissioner.SetCommissioningParameters(params)); return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode); } @@ -757,8 +757,8 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, const char * se CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParameters & params) { - CommissioningParameters commissioningParams; - return PairDevice(remoteDeviceId, params, commissioningParams); + ReturnErrorOnFailure(EstablishPASEConnection(remoteDeviceId, params)); + return Commission(remoteDeviceId); } CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParameters & rendezvousParams, @@ -881,6 +881,12 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re } CHIP_ERROR DeviceCommissioner::Commission(NodeId remoteDeviceId, CommissioningParameters & params) +{ + ReturnErrorOnFailure(mAutoCommissioner.SetCommissioningParameters(params)); + return Commission(remoteDeviceId); +} + +CHIP_ERROR DeviceCommissioner::Commission(NodeId remoteDeviceId) { // TODO(cecille): Can we get rid of mDeviceBeingCommissioned and use the remote id instead? Would require storing the // commissioning stage in the device. @@ -902,7 +908,6 @@ CHIP_ERROR DeviceCommissioner::Commission(NodeId remoteDeviceId, CommissioningPa OnSessionEstablishmentTimeoutCallback, this); mAutoCommissioner.SetOperationalCredentialsDelegate(mOperationalCredentialsDelegate); - ReturnErrorOnFailure(mAutoCommissioner.AddCommissioningParameters(params)); if (device->IsSecureConnected()) { mAutoCommissioner.StartCommissioning(device); @@ -1609,9 +1614,7 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio GeneralCommissioningCluster genCom; // TODO: should get the endpoint information from the descriptor cluster. SetupCluster(genCom, proxy, endpoint, timeout); - constexpr uint16_t kDefaultFailsafeSeconds = 60; - genCom.ArmFailSafe(mSuccess.Cancel(), mFailure.Cancel(), params.GetFailsafeTimerSeconds().ValueOr(kDefaultFailsafeSeconds), - breadcrumb, kCommandTimeoutMs); + genCom.ArmFailSafe(mSuccess.Cancel(), mFailure.Cancel(), params.GetFailsafeTimerSeconds(), breadcrumb, kCommandTimeoutMs); } break; case CommissioningStage::kConfigRegulatory: { diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 1d3ca1ea5cfeb3..82532eaf4418cf 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -533,6 +533,7 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, * @param[in] remoteDeviceId The remote device Id. * @param[in] params The commissioning parameters */ + CHIP_ERROR Commission(NodeId remoteDeviceId); CHIP_ERROR Commission(NodeId remoteDeviceId, CommissioningParameters & params); CHIP_ERROR GetDeviceBeingCommissioned(NodeId deviceId, CommissioneeDeviceProxy ** device); diff --git a/src/controller/CommissioningDelegate.h b/src/controller/CommissioningDelegate.h index 36b65ea78b27aa..12bda4f6fb6ab9 100644 --- a/src/controller/CommissioningDelegate.h +++ b/src/controller/CommissioningDelegate.h @@ -73,7 +73,7 @@ class CommissioningParameters static constexpr size_t kMaxThreadDatasetLen = 254; static constexpr size_t kMaxSsidLen = 32; static constexpr size_t kMaxCredentialsLen = 64; - const Optional GetFailsafeTimerSeconds() const { return mFailsafeTimerSeconds; } + uint16_t GetFailsafeTimerSeconds() const { return mFailsafeTimerSeconds; } const Optional GetCSRNonce() const { return mCSRNonce; } const Optional GetAttestationNonce() const { return mAttestationNonce; } const Optional GetWiFiCredentials() const { return mWiFiCreds; } @@ -95,7 +95,7 @@ class CommissioningParameters CommissioningParameters & SetFailsafeTimerSeconds(uint16_t seconds) { - mFailsafeTimerSeconds.SetValue(seconds); + mFailsafeTimerSeconds = seconds; return *this; } @@ -182,7 +182,7 @@ class CommissioningParameters void SetCompletionStatus(CHIP_ERROR err) { completionStatus = err; } private: - Optional mFailsafeTimerSeconds; + uint16_t mFailsafeTimerSeconds = 60; Optional mCSRNonce; ///< CSR Nonce passed by the commissioner Optional mAttestationNonce; ///< Attestation Nonce passed by the commissioner Optional mWiFiCreds; From 9e137c39edd81b84f8d407967070e753e2bf74d4 Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Thu, 27 Jan 2022 15:55:18 -0500 Subject: [PATCH 3/9] Add pase only option to setup code pairer --- .../commands/pairing/PairingCommand.cpp | 23 ++++++++++--------- .../commands/pairing/PairingCommand.h | 4 +--- src/controller/CHIPDeviceController.cpp | 9 ++++++-- src/controller/CHIPDeviceController.h | 20 ++++++++++++++++ src/controller/SetUpCodePairer.cpp | 12 ++++++++-- src/controller/SetUpCodePairer.h | 11 +++++++-- 6 files changed, 59 insertions(+), 20 deletions(-) diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index e7732f7b0170f1..ba2bed2cca4ba6 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -46,10 +46,10 @@ CHIP_ERROR PairingCommand::RunInternal(NodeId remoteId) err = Unpair(remoteId); break; case PairingMode::QRCode: - err = PairWithQRCode(remoteId); + err = PairWithCode(remoteId); break; case PairingMode::ManualCode: - err = PairWithManualCode(remoteId); + err = PairWithCode(remoteId); break; case PairingMode::Ble: err = Pair(remoteId, PeerAddress::BLE()); @@ -83,16 +83,17 @@ CommissioningParameters PairingCommand::GetCommissioningParameters() return CommissioningParameters(); } -CHIP_ERROR PairingCommand::PairWithQRCode(NodeId remoteId) +CHIP_ERROR PairingCommand::PairWithCode(NodeId remoteId) { - CommissioningParameters commissioningParams = GetCommissioningParameters(); - return CurrentCommissioner().PairDevice(remoteId, mOnboardingPayload, commissioningParams); -} - -CHIP_ERROR PairingCommand::PairWithManualCode(NodeId remoteId) -{ - CommissioningParameters commissioningParams = GetCommissioningParameters(); - return CurrentCommissioner().PairDevice(remoteId, mOnboardingPayload, commissioningParams); + if (mNetworkType == PairingNetworkType::None) + { + return CurrentCommissioner().EstablishPASEConnection(remoteId, mOnboardingPayload); + } + else + { + CommissioningParameters commissioningParams = GetCommissioningParameters(); + return CurrentCommissioner().PairDevice(remoteId, mOnboardingPayload, commissioningParams); + } } CHIP_ERROR PairingCommand::Pair(NodeId remoteId, PeerAddress address) diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index 6d2e98fb36636a..fcc24d5ac58e48 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -148,9 +148,7 @@ class PairingCommand : public CHIPCommand, CHIP_ERROR RunInternal(NodeId remoteId); CHIP_ERROR Pair(NodeId remoteId, PeerAddress address); CHIP_ERROR PairWithMdns(NodeId remoteId); - CHIP_ERROR PairWithQRCode(NodeId remoteId); - CHIP_ERROR PairWithManualCode(NodeId remoteId); - CHIP_ERROR PairWithCode(NodeId remoteId, chip::SetupPayload payload); + CHIP_ERROR PairWithCode(NodeId remoteId); CHIP_ERROR Unpair(NodeId remoteId); chip::Controller::CommissioningParameters GetCommissioningParameters(); diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 5d85f644d1f880..a674437c8bd154 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -747,12 +747,12 @@ CHIP_ERROR DeviceCommissioner::GetConnectedDevice(NodeId deviceId, Callback::Cal CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, const char * setUpCode, const CommissioningParameters & params) { ReturnErrorOnFailure(mAutoCommissioner.SetCommissioningParameters(params)); - return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode); + return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode, SetupCodePairerBehaviour::kCommission); } CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, const char * setUpCode) { - return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode); + return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode, SetupCodePairerBehaviour::kCommission); } CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParameters & params) @@ -768,6 +768,11 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam return Commission(remoteDeviceId, commissioningParams); } +CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, const char * setUpCode) +{ + return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode, SetupCodePairerBehaviour::kPaseOnly); +} + CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, RendezvousParameters & params) { CHIP_ERROR err = CHIP_NO_ERROR; diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 82532eaf4418cf..587fab4ae69d82 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -521,6 +521,26 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, */ CHIP_ERROR EstablishPASEConnection(NodeId remoteDeviceId, RendezvousParameters & params); + /** + * @brief + * Start establishing a PASE connection with a node for the purposes of commissioning. + * Commissioners that wish to use the auto-commissioning functions should use the + * supplied "PairDevice" functions above to automatically establish a connection then + * perform commissioning. This function is intended to be use by commissioners that + * are not using the supplied auto-commissioner. + * + * This function is non-blocking. PASE is established once the DevicePairingDelegate + * receives the OnPairingComplete call. + * + * PASE connections can only be established with nodes that have their commissioning + * window open. The PASE connection will fail if this window is not open and the + * OnPairingComplete will be called with an error. + * + * @param[in] remoteDeviceId The remote device Id. + * @param[in] setUpCode The setup code for connecting to the device + */ + CHIP_ERROR EstablishPASEConnection(NodeId remoteDeviceId, const char * setUpCode); + /** * @brief * Start the auto-commissioning process on a node after establishing a PASE connection. diff --git a/src/controller/SetUpCodePairer.cpp b/src/controller/SetUpCodePairer.cpp index 31392429561896..3262697d506eb1 100644 --- a/src/controller/SetUpCodePairer.cpp +++ b/src/controller/SetUpCodePairer.cpp @@ -33,9 +33,10 @@ namespace chip { namespace Controller { -CHIP_ERROR SetUpCodePairer::PairDevice(NodeId remoteId, const char * setUpCode) +CHIP_ERROR SetUpCodePairer::PairDevice(NodeId remoteId, const char * setUpCode, SetupCodePairerBehaviour commission) { SetupPayload payload; + mConnectionType = commission; bool isQRCode = strncmp(setUpCode, kQRCodePrefix, strlen(kQRCodePrefix)) == 0; ReturnErrorOnFailure(isQRCode ? QRCodeSetupPayloadParser(setUpCode).populatePayload(payload) @@ -136,7 +137,14 @@ CHIP_ERROR SetUpCodePairer::StopConnectOverSoftAP() void SetUpCodePairer::OnDeviceDiscovered(RendezvousParameters & params) { - LogErrorOnFailure(mCommissioner->PairDevice(mRemoteId, params.SetSetupPINCode(mSetUpPINCode))); + if (mConnectionType == SetupCodePairerBehaviour::kCommission) + { + LogErrorOnFailure(mCommissioner->PairDevice(mRemoteId, params.SetSetupPINCode(mSetUpPINCode))); + } + else + { + LogErrorOnFailure(mCommissioner->EstablishPASEConnection(mRemoteId, params.SetSetupPINCode(mSetUpPINCode))); + } } #if CONFIG_NETWORK_LAYER_BLE diff --git a/src/controller/SetUpCodePairer.h b/src/controller/SetUpCodePairer.h index 0ecd41c96b0597..08a21d105f0eb6 100644 --- a/src/controller/SetUpCodePairer.h +++ b/src/controller/SetUpCodePairer.h @@ -47,13 +47,19 @@ namespace Controller { class DeviceCommissioner; +enum class SetupCodePairerBehaviour : uint8_t +{ + kCommission, + kPaseOnly, +}; class DLL_EXPORT SetUpCodePairer { public: SetUpCodePairer(DeviceCommissioner * commissioner) : mCommissioner(commissioner) {} virtual ~SetUpCodePairer() {} - CHIP_ERROR PairDevice(chip::NodeId remoteId, const char * setUpCode); + CHIP_ERROR PairDevice(chip::NodeId remoteId, const char * setUpCode, + SetupCodePairerBehaviour connectionType = SetupCodePairerBehaviour::kCommission); // Called by the DeviceCommissioner to notify that we have discovered a new device. #if CHIP_DEVICE_CONFIG_ENABLE_DNSSD @@ -90,7 +96,8 @@ class DLL_EXPORT SetUpCodePairer DeviceCommissioner * mCommissioner = nullptr; chip::NodeId mRemoteId; - uint32_t mSetUpPINCode = 0; + uint32_t mSetUpPINCode = 0; + SetupCodePairerBehaviour mConnectionType = SetupCodePairerBehaviour::kCommission; }; } // namespace Controller From 1615e1e84d826e53b2e56cd19ad08e800a4dd043 Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Fri, 28 Jan 2022 00:27:12 -0500 Subject: [PATCH 4/9] New pairing commands for pase only I broke the test assumptions. --- .../chip-tool/commands/pairing/Commands.h | 18 ++++++++++++++ .../commands/pairing/PairingCommand.cpp | 24 ++++++++++++------- .../commands/pairing/PairingCommand.h | 8 ++++--- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/examples/chip-tool/commands/pairing/Commands.h b/examples/chip-tool/commands/pairing/Commands.h index 6907315fa4c4c1..7c3b6e80a413b9 100644 --- a/examples/chip-tool/commands/pairing/Commands.h +++ b/examples/chip-tool/commands/pairing/Commands.h @@ -42,6 +42,14 @@ class PairQRCode : public PairingCommand {} }; +class PairQRCodePase : public PairingCommand +{ +public: + PairQRCodePase(CredentialIssuerCommands * credsIssuerConfig) : + PairingCommand("qrcode-paseonly", PairingMode::QRCodePaseOnly, PairingNetworkType::None, credsIssuerConfig) + {} +}; + class PairQRCodeWifi : public PairingCommand { public: @@ -66,6 +74,14 @@ class PairManualCode : public PairingCommand {} }; +class PairManualCodePase : public PairingCommand +{ +public: + PairManualCodePase(CredentialIssuerCommands * credsIssuerConfig) : + PairingCommand("manualcode-paseonly", PairingMode::ManualCodePaseOnly, PairingNetworkType::None, credsIssuerConfig) + {} +}; + class PairManualCodeWifi : public PairingCommand { public: @@ -214,9 +230,11 @@ void registerCommandsPairing(Commands & commands, CredentialIssuerCommands * cre commands_list clusterCommands = { make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index ba2bed2cca4ba6..ec7def9c22f723 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -51,6 +51,10 @@ CHIP_ERROR PairingCommand::RunInternal(NodeId remoteId) case PairingMode::ManualCode: err = PairWithCode(remoteId); break; + case PairingMode::QRCodePaseOnly: + case PairingMode::ManualCodePaseOnly: + err = PaseWithCode(remoteId); + break; case PairingMode::Ble: err = Pair(remoteId, PeerAddress::BLE()); break; @@ -83,17 +87,15 @@ CommissioningParameters PairingCommand::GetCommissioningParameters() return CommissioningParameters(); } +CHIP_ERROR PairingCommand::PaseWithCode(NodeId remoteId) +{ + return CurrentCommissioner().EstablishPASEConnection(remoteId, mOnboardingPayload); +} + CHIP_ERROR PairingCommand::PairWithCode(NodeId remoteId) { - if (mNetworkType == PairingNetworkType::None) - { - return CurrentCommissioner().EstablishPASEConnection(remoteId, mOnboardingPayload); - } - else - { - CommissioningParameters commissioningParams = GetCommissioningParameters(); - return CurrentCommissioner().PairDevice(remoteId, mOnboardingPayload, commissioningParams); - } + CommissioningParameters commissioningParams = GetCommissioningParameters(); + return CurrentCommissioner().PairDevice(remoteId, mOnboardingPayload, commissioningParams); } CHIP_ERROR PairingCommand::Pair(NodeId remoteId, PeerAddress address) @@ -158,6 +160,10 @@ void PairingCommand::OnPairingComplete(CHIP_ERROR err) if (err == CHIP_NO_ERROR) { ChipLogProgress(chipTool, "Pairing Success"); + if (mPairingMode == PairingMode::QRCodePaseOnly || mPairingMode == PairingMode::ManualCodePaseOnly) + { + SetCommandExitStatus(err); + } } else { diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index fcc24d5ac58e48..bc3b74388dfa3b 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -32,6 +32,8 @@ enum class PairingMode None, QRCode, ManualCode, + QRCodePaseOnly, + ManualCodePaseOnly, Ble, SoftAP, Ethernet, @@ -80,6 +82,8 @@ class PairingCommand : public CHIPCommand, break; case PairingMode::QRCode: case PairingMode::ManualCode: + case PairingMode::QRCodePaseOnly: + case PairingMode::ManualCodePaseOnly: AddArgument("payload", &mOnboardingPayload); break; case PairingMode::Ble: @@ -149,6 +153,7 @@ class PairingCommand : public CHIPCommand, CHIP_ERROR Pair(NodeId remoteId, PeerAddress address); CHIP_ERROR PairWithMdns(NodeId remoteId); CHIP_ERROR PairWithCode(NodeId remoteId); + CHIP_ERROR PaseWithCode(NodeId remoteId); CHIP_ERROR Unpair(NodeId remoteId); chip::Controller::CommissioningParameters GetCommissioningParameters(); @@ -166,7 +171,4 @@ class PairingCommand : public CHIPCommand, char * mOnboardingPayload; uint64_t mDiscoveryFilterCode; char * mDiscoveryFilterInstanceName; - - chip::CommissioneeDeviceProxy * mDevice; - chip::EndpointId mEndpointId = 0; }; From e6de938848a50628a9fa7e13c8684abdf6174d3b Mon Sep 17 00:00:00 2001 From: C Freeman Date: Fri, 28 Jan 2022 02:42:19 -0500 Subject: [PATCH 5/9] Update src/controller/CHIPDeviceController.h Co-authored-by: Boris Zbarsky --- src/controller/CHIPDeviceController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 4b12ba8add1977..ec83a16da7a7a4 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -543,7 +543,7 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, * Start establishing a PASE connection with a node for the purposes of commissioning. * Commissioners that wish to use the auto-commissioning functions should use the * supplied "PairDevice" functions above to automatically establish a connection then - * perform commissioning. This function is intended to be use by commissioners that + * perform commissioning. This function is intended to be used by commissioners that * are not using the supplied auto-commissioner. * * This function is non-blocking. PASE is established once the DevicePairingDelegate From 3c54dca831e5d5761184dbb65d3662f3354800d6 Mon Sep 17 00:00:00 2001 From: C Freeman Date: Fri, 28 Jan 2022 02:42:24 -0500 Subject: [PATCH 6/9] Update src/controller/CHIPDeviceController.h Co-authored-by: Boris Zbarsky --- src/controller/CHIPDeviceController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index ec83a16da7a7a4..189be5d87f76b4 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -550,7 +550,7 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, * receives the OnPairingComplete call. * * PASE connections can only be established with nodes that have their commissioning - * window open. The PASE connection will fail if this window is not open and the + * window open. The PASE connection will fail if this window is not open and in that case * OnPairingComplete will be called with an error. * * @param[in] remoteDeviceId The remote device Id. From 02da59381ffa26bda67fff619bd7ab375929f20d Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Fri, 28 Jan 2022 15:04:42 -0500 Subject: [PATCH 7/9] Bootstrap the nonces in the auto commissioner. --- src/controller/AutoCommissioner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index 423c77a005a110..f261bb319f1f62 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -29,6 +29,7 @@ AutoCommissioner::~AutoCommissioner() { ReleaseDAC(); ReleasePAI(); + SetCommissioningParameters(CommissioningParameters()); } void AutoCommissioner::SetOperationalCredentialsDelegate(OperationalCredentialsDelegate * operationalCredentialsDelegate) From 0196c04c023af2d78413dc9b1f8ca716de279646 Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Tue, 8 Mar 2022 14:26:29 -0500 Subject: [PATCH 8/9] Fix initialization Something somewhere got messed becuase the initialization happens in the destructor which is not correct for obvious reasons. --- src/controller/AutoCommissioner.cpp | 6 +++++- src/controller/AutoCommissioner.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index 46f68122eab605..56fd26caf7ac10 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -25,11 +25,15 @@ namespace chip { namespace Controller { +AutoCommissioner::AutoCommissioner() +{ + SetCommissioningParameters(CommissioningParameters()); +} + AutoCommissioner::~AutoCommissioner() { ReleaseDAC(); ReleasePAI(); - SetCommissioningParameters(CommissioningParameters()); } void AutoCommissioner::SetOperationalCredentialsDelegate(OperationalCredentialsDelegate * operationalCredentialsDelegate) diff --git a/src/controller/AutoCommissioner.h b/src/controller/AutoCommissioner.h index 199f201d0e2701..15a765fa17adf6 100644 --- a/src/controller/AutoCommissioner.h +++ b/src/controller/AutoCommissioner.h @@ -28,7 +28,7 @@ class DeviceCommissioner; class AutoCommissioner : public CommissioningDelegate { public: - AutoCommissioner() {} + AutoCommissioner(); virtual ~AutoCommissioner(); CHIP_ERROR SetCommissioningParameters(const CommissioningParameters & params) override; void SetOperationalCredentialsDelegate(OperationalCredentialsDelegate * operationalCredentialsDelegate) override; From 39a5c4ad616b0f07885a136448b59773ff699121 Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Tue, 8 Mar 2022 16:01:09 -0500 Subject: [PATCH 9/9] Fix auto documentation. Functions order was confusing the documentation. --- src/controller/CHIPDeviceController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 3e69f8bcb7588a..22117cafaa8b2d 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -543,8 +543,8 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, * @param[in] remoteDeviceId The remote device Id. * @param[in] params The commissioning parameters */ - CHIP_ERROR Commission(NodeId remoteDeviceId); CHIP_ERROR Commission(NodeId remoteDeviceId, CommissioningParameters & params); + CHIP_ERROR Commission(NodeId remoteDeviceId); CHIP_ERROR GetDeviceBeingCommissioned(NodeId deviceId, CommissioneeDeviceProxy ** device);