diff --git a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h index 2280f71e141a28..3a3a6d8d64efdd 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h +++ b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h @@ -38,6 +38,10 @@ class CHIPCommandBridge : public Command { : Command(commandName) { AddArgument("commissioner-name", &mCommissionerName); + AddArgument("commissioner-nodeId", 0, UINT64_MAX, &mCommissionerNodeId, + "Sets the commisser node ID of the given " + "commissioner-name. Interactive mode will only set a single commissioner on the inital command. " + "The commissioner node ID will be persisted until a different one is specified."); AddArgument("paa-trust-store-path", &mPaaTrustStorePath, "Path to directory holding PAA certificate information. Can be absolute or relative to the current working " "directory."); @@ -134,6 +138,7 @@ class CHIPCommandBridge : public Command { std::condition_variable cvWaitingForResponse; std::mutex cvWaitingForResponseMutex; chip::Optional mCommissionerName; + chip::Optional mCommissionerNodeId; bool mWaitingForResponse { true }; static dispatch_queue_t mOTAProviderCallbackQueue; chip::Optional mPaaTrustStorePath; diff --git a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm index 6c1cd92a32ed48..55f429caeca981 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm +++ b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm @@ -137,9 +137,13 @@ ipk = [gNocSigner getIPK]; constexpr const char * identities[] = { kIdentityAlpha, kIdentityBeta, kIdentityGamma }; + std::string commissionerName = mCommissionerName.HasValue() ? mCommissionerName.Value() : kIdentityAlpha; for (size_t i = 0; i < ArraySize(identities); ++i) { auto controllerParams = [[MTRDeviceControllerStartupParams alloc] initWithIPK:ipk fabricID:@(i + 1) nocSigner:gNocSigner]; + if (commissionerName.compare(identities[i]) == 0 && mCommissionerNodeId.HasValue()) { + controllerParams.nodeId = @(mCommissionerNodeId.Value()); + } // We're not sure whether we're creating a new fabric or using an // existing one, so just try both. auto controller = [factory createControllerOnExistingFabric:controllerParams error:&error];