Skip to content

Commit

Permalink
Add ability to set commissioner node ID and update logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
krypton36 committed Jan 11, 2023
1 parent 99a2d8a commit 75afc9e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CHIPCommandBridge : public Command {
: Command(commandName)
{
AddArgument("commissioner-name", &mCommissionerName);
AddArgument("commissioner-nodeId", 0, UINT64_MAX, &mCommissionerNodeId);
AddArgument("paa-trust-store-path", &mPaaTrustStorePath,
"Path to directory holding PAA certificate information. Can be absolute or relative to the current working "
"directory.");
Expand Down Expand Up @@ -131,6 +132,7 @@ class CHIPCommandBridge : public Command {
std::condition_variable cvWaitingForResponse;
std::mutex cvWaitingForResponseMutex;
chip::Optional<char *> mCommissionerName;
chip::Optional<uint64_t> mCommissionerNodeId;
bool mWaitingForResponse { true };
static dispatch_queue_t mOTAProviderCallbackQueue;
chip::Optional<char *> mPaaTrustStorePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ static bool ParseJsonFileAndPopulateCandidates(
CHIP_ERROR error = CHIP_NO_ERROR;
if (userConsentNeeded == 0) {
mOTADelegate.userConsentNeeded = @(0);
ChipLogDetail(chipTool, "Successfully set User Consent to: OTAProviderUserGranted");
ChipLogDetail(chipTool, "Successfully set User Consent Needed to: OTAProviderUserGranted");
} else if (userConsentNeeded == 1) {
mOTADelegate.userConsentNeeded = @(1);
ChipLogDetail(chipTool, "Successfully set User Consent to: OTAProviderUserObtaining");
ChipLogDetail(chipTool, "Successfully set User Consent Needed to: OTAProviderUserObtaining");
} else {
ChipLogError(chipTool, "Only accepts the following: 0 (Not Needed), and 1 (Needed).");
error = CHIP_ERROR_INTERNAL;
Expand Down

0 comments on commit 75afc9e

Please sign in to comment.