Skip to content

Commit

Permalink
[chip-tool] Maintains multiple commissioners alive at the same time i…
Browse files Browse the repository at this point in the history
…n chip-tool
  • Loading branch information
vivien-apple committed Dec 15, 2021
1 parent c52bc7b commit e92c465
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions examples/chip-tool/commands/common/CHIPCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ CHIP_ERROR CHIPCommand::Run()
factoryInitParams.listenPort = static_cast<uint16_t>(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<intptr_t>(this));
ReturnLogErrorOnFailure(StartWaiting(GetWaitDuration()));
Expand All @@ -60,7 +62,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));

return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -159,6 +163,7 @@ CHIP_ERROR CHIPCommand::InitializeCommissioner(std::string key, chip::FabricId f
std::unique_ptr<ChipDeviceCommissioner> commissioner = std::make_unique<ChipDeviceCommissioner>();
chip::Controller::SetupParams commissionerParams;
commissionerParams.storageDelegate = &mCommissionerStorage;
commissionerParams.fabricIndex = static_cast<chip::FabricIndex>(fabricId);
commissionerParams.operationalCredentialsDelegate = &mOpCredsIssuer;
commissionerParams.ephemeralKeypair = &ephemeralKey;
commissionerParams.controllerRCAC = rcacSpan;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -2737,7 +2737,7 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
* @brief Defines the max number of SessionCreationDelegates
*/
#ifndef CHIP_CONFIG_MAX_SESSION_CREATION_DELEGATES
#define CHIP_CONFIG_MAX_SESSION_CREATION_DELEGATES 2
#define CHIP_CONFIG_MAX_SESSION_CREATION_DELEGATES 4
#endif

/**
Expand All @@ -2746,7 +2746,7 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
* @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

/**
Expand All @@ -2755,7 +2755,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

/**
Expand Down

0 comments on commit e92c465

Please sign in to comment.