From 36755830db4372efba8fa1cc8de58740f2d2568c Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 16 Dec 2021 13:19:14 +0100 Subject: [PATCH] [chip-tool] Maintains multiple commissioners alive at the same time in chip-tool (#13033) --- examples/chip-tool/commands/common/CHIPCommand.cpp | 9 +++++++-- src/lib/core/CHIPConfig.h | 13 ++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/examples/chip-tool/commands/common/CHIPCommand.cpp b/examples/chip-tool/commands/common/CHIPCommand.cpp index 8d64fd7b454154..aa52f1e84e4d8d 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.cpp +++ b/examples/chip-tool/commands/common/CHIPCommand.cpp @@ -55,7 +55,9 @@ CHIP_ERROR CHIPCommand::Run() factoryInitParams.listenPort = static_cast(mDefaultStorage.GetListenPort() + CurrentCommissionerIndex()); ReturnLogErrorOnFailure(DeviceControllerFactory::GetInstance().Init(factoryInitParams)); - ReturnLogErrorOnFailure(InitializeCommissioner(GetIdentity(), CurrentCommissionerIndex())); + ReturnLogErrorOnFailure(InitializeCommissioner(kIdentityAlpha, kIdentityAlphaFabricId)); + ReturnLogErrorOnFailure(InitializeCommissioner(kIdentityBeta, kIdentityBetaFabricId)); + ReturnLogErrorOnFailure(InitializeCommissioner(kIdentityGamma, kIdentityGammaFabricId)); chip::DeviceLayer::PlatformMgr().ScheduleWork(RunQueuedCommand, reinterpret_cast(this)); ReturnLogErrorOnFailure(StartWaiting(GetWaitDuration())); @@ -67,7 +69,9 @@ CHIP_ERROR CHIPCommand::Run() // since the CHIP thread and event queue have been stopped, preventing any thread // races. // - ReturnLogErrorOnFailure(ShutdownCommissioner(GetIdentity())); + ReturnLogErrorOnFailure(ShutdownCommissioner(kIdentityAlpha)); + ReturnLogErrorOnFailure(ShutdownCommissioner(kIdentityBeta)); + ReturnLogErrorOnFailure(ShutdownCommissioner(kIdentityGamma)); StopTracing(); return CHIP_NO_ERROR; @@ -190,6 +194,7 @@ CHIP_ERROR CHIPCommand::InitializeCommissioner(std::string key, chip::FabricId f std::unique_ptr commissioner = std::make_unique(); chip::Controller::SetupParams commissionerParams; commissionerParams.storageDelegate = &mCommissionerStorage; + commissionerParams.fabricIndex = static_cast(fabricId); commissionerParams.operationalCredentialsDelegate = &mOpCredsIssuer; commissionerParams.ephemeralKeypair = &ephemeralKey; commissionerParams.controllerRCAC = rcacSpan; diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index 38bd1152d1c9e4..3905ca16f5e5b0 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -2722,22 +2722,13 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; "Please enable at least one of CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_FAST_COPY_SUPPORT or CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_FLEXIBLE_COPY_SUPPORT" #endif -/** - * @def CHIP_CONFIG_MAX_SESSION_CREATION_DELEGATES - * - * @brief Defines the max number of SessionCreationDelegates - */ -#ifndef CHIP_CONFIG_MAX_SESSION_CREATION_DELEGATES -#define CHIP_CONFIG_MAX_SESSION_CREATION_DELEGATES 2 -#endif - /** * @def CHIP_CONFIG_MAX_SESSION_RELEASE_DELEGATES * * @brief Defines the max number of SessionReleaseDelegate */ #ifndef CHIP_CONFIG_MAX_SESSION_RELEASE_DELEGATES -#define CHIP_CONFIG_MAX_SESSION_RELEASE_DELEGATES 2 +#define CHIP_CONFIG_MAX_SESSION_RELEASE_DELEGATES 4 #endif /** @@ -2746,7 +2737,7 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; * @brief Defines the max number of SessionRecoveryDelegate */ #ifndef CHIP_CONFIG_MAX_SESSION_RECOVERY_DELEGATES -#define CHIP_CONFIG_MAX_SESSION_RECOVERY_DELEGATES 3 +#define CHIP_CONFIG_MAX_SESSION_RECOVERY_DELEGATES 4 #endif /**