diff --git a/examples/chip-tool/commands/pairing/Commands.h b/examples/chip-tool/commands/pairing/Commands.h index cd244b56aded28..41a35bb6bae6ad 100644 --- a/examples/chip-tool/commands/pairing/Commands.h +++ b/examples/chip-tool/commands/pairing/Commands.h @@ -69,6 +69,14 @@ class PairCodeThread : public PairingCommand {} }; +class PairCodeWiFiThread : public PairingCommand +{ +public: + PairCodeWiFiThread(CredentialIssuerCommands * credsIssuerConfig) : + PairingCommand("code-wifi-thread", PairingMode::Code, PairingNetworkType::WiFiOrThread, credsIssuerConfig) + {} +}; + class PairOnNetwork : public PairingCommand { public: @@ -165,14 +173,6 @@ class PairBleThread : public PairingCommand {} }; -class PairBleWiFiOrThread : public PairingCommand -{ -public: - PairBleWiFiOrThread(CredentialIssuerCommands * credsIssuerConfig) : - PairingCommand("ble-wifi-thread", PairingMode::Ble, PairingNetworkType::WiFiOrThread, credsIssuerConfig) - {} -}; - class PairSoftAP : public PairingCommand { public: @@ -239,9 +239,9 @@ void registerCommandsPairing(Commands & commands, CredentialIssuerCommands * cre 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/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index 7f016b6cb5678a..d6bc9f5c79fcac 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -300,7 +300,7 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageNetworkSetup(Commi { if (IsSecondaryNetworkSupported()) { - if (IsTriedSecondaryNetwork()) + if (TryingSecondaryNetwork()) { // Try secondary network interface. return mDeviceCommissioningInfo.network.wifi.endpoint == kRootEndpointId ? CommissioningStage::kThreadNetworkSetup @@ -729,12 +729,12 @@ CHIP_ERROR AutoCommissioner::CommissioningStepFinished(CHIP_ERROR err, Commissio } } - if (err != CHIP_NO_ERROR && IsSecondaryNetworkSupported() && !IsTriedSecondaryNetwork() && + if (err != CHIP_NO_ERROR && IsSecondaryNetworkSupported() && !TryingSecondaryNetwork() && completionStatus.failedStage.HasValue() && completionStatus.failedStage.Value() >= kWiFiNetworkSetup && completionStatus.failedStage.Value() <= kICDSendStayActive) { // Primary network failed, disable primary network interface and try secondary network interface. - SetTrySecondaryNetwork(); + TrySecondaryNetwork(); err = CHIP_NO_ERROR; report.stageCompleted = CommissioningStage::kPrimaryOperationalNetworkFailed; } @@ -856,6 +856,10 @@ CHIP_ERROR AutoCommissioner::CommissioningStepFinished(CHIP_ERROR err, Commissio mOperationalDeviceProxy = report.Get().operationalProxy; break; case CommissioningStage::kCleanup: + if (IsSecondaryNetworkSupported() && TryingSecondaryNetwork()) + { + ResetTryingSecondaryNetwork(); + } ReleasePAI(); ReleaseDAC(); mCommissioneeDeviceProxy = nullptr; diff --git a/src/controller/AutoCommissioner.h b/src/controller/AutoCommissioner.h index 78a01fd6e37fa7..deacda6e3cca31 100644 --- a/src/controller/AutoCommissioner.h +++ b/src/controller/AutoCommissioner.h @@ -105,9 +105,10 @@ class AutoCommissioner : public CommissioningDelegate mDeviceCommissioningInfo.network.thread.endpoint != kInvalidEndpointId); } - void SetTrySecondaryNetwork() { mAttemptedSecondaryNetwork = true; } - bool IsTriedSecondaryNetwork() const { return mAttemptedSecondaryNetwork; } - bool mAttemptedSecondaryNetwork = false; + void TrySecondaryNetwork() { mTryingSecondaryNetwork = true; } + bool TryingSecondaryNetwork() const { return mTryingSecondaryNetwork; } + void ResetTryingSecondaryNetwork() { mTryingSecondaryNetwork = false; } + bool mTryingSecondaryNetwork = false; bool mStopCommissioning = false; diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index c5cdc2ef351ae4..7a345f20bb9829 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -2756,7 +2756,7 @@ CHIP_ERROR DeviceCommissioner::SendCommissioningWriteRequest(DeviceProxy * devic auto onSuccessCb = [this, successCb](const app::ConcreteAttributePath & aPath) { successCb(this); }; auto onFailureCb = [this, failureCb](const app::ConcreteAttributePath * aPath, CHIP_ERROR aError) { failureCb(this, aError); }; return WriteAttribute(device->GetSecureSession().Value(), endpoint, cluster, attribute, requestData, onSuccessCb, onFailureCb, - NullOptional, nullptr, NullOptional); + /* aTimedWriteTimeoutMs = */ NullOptional, /* onDoneCb = */ nullptr, /* aDataVersion = */ NullOptional); } void DeviceCommissioner::SendCommissioningReadRequest(DeviceProxy * proxy, Optional timeout, @@ -3444,16 +3444,15 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio } break; case CommissioningStage::kPrimaryOperationalNetworkFailed: { - // nothing to do. This stage indicates that the primary operation network failed and the network interface should be + // nothing to do. This stage indicates that the primary operational network failed and the network interface should be // disabled later. break; } case CommissioningStage::kDisablePrimaryNetworkInterface: { NetworkCommissioning::Attributes::InterfaceEnabled::TypeInfo::Type request = false; - CHIP_ERROR err = SendCommissioningWriteRequest( - proxy, endpoint, NetworkCommissioning::Attributes::InterfaceEnabled::TypeInfo::GetClusterId(), - NetworkCommissioning::Attributes::InterfaceEnabled::TypeInfo::GetAttributeId(), request, - OnInterfaceEnableWriteSuccessResponse, OnBasicFailure); + CHIP_ERROR err = SendCommissioningWriteRequest(proxy, endpoint, NetworkCommissioning::Id, + NetworkCommissioning::Attributes::InterfaceEnabled::Id, request, + OnInterfaceEnableWriteSuccessResponse, OnBasicFailure); if (err != CHIP_NO_ERROR) { // We won't get any async callbacks here, so just complete our stage. diff --git a/src/controller/CommissioningDelegate.cpp b/src/controller/CommissioningDelegate.cpp index 7afecc8ac2be59..85ea5e86c5e3a6 100644 --- a/src/controller/CommissioningDelegate.cpp +++ b/src/controller/CommissioningDelegate.cpp @@ -137,10 +137,10 @@ const char * StageToString(CommissioningStage stage) return "NeedsNetworkCreds"; case kPrimaryOperationalNetworkFailed: - return "kPrimaryOperationalNetworkFailed"; + return "PrimaryOperationalNetworkFailed"; case kDisablePrimaryNetworkInterface: - return "kDisablePrimaryNetworkInterface"; + return "DisablePrimaryNetworkInterface"; default: return "???";