Skip to content

Commit

Permalink
Followup for #6599. discover/clusters/reporting commands of chip-tool…
Browse files Browse the repository at this point in the history
… fails during commissioner init (#6644)
  • Loading branch information
vivien-apple authored and pull[bot] committed Aug 3, 2021
1 parent 3283cb7 commit ff81e85
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 8 deletions.
8 changes: 6 additions & 2 deletions examples/chip-tool/commands/clusters/ModelCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "ModelCommand.h"

#include <app/InteractionModelEngine.h>
#include <inttypes.h>

using namespace ::chip;
Expand All @@ -29,9 +30,12 @@ constexpr uint16_t kWaitDurationInSeconds = 10;
CHIP_ERROR ModelCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId)
{
CHIP_ERROR err = CHIP_NO_ERROR;
chip::Controller::CommissionerInitParams initParams;

initParams.storageDelegate = &storage;
mOpCredsIssuer.Initialize();

chip::Controller::CommissionerInitParams initParams;
initParams.storageDelegate = &storage;
initParams.operationalCredentialsDelegate = &mOpCredsIssuer;

err = mCommissioner.SetUdpListenPort(storage.GetListenPort());
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Commissioner: %s", ErrorStr(err)));
Expand Down
2 changes: 2 additions & 0 deletions examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "../../config/PersistentStorage.h"
#include "../common/Command.h"
#include <app/chip-zcl-zpro-codec.h>
#include <controller/ExampleOperationalCredentialsIssuer.h>
#include <core/CHIPEncoding.h>

// Limits on endpoint values.
Expand All @@ -42,5 +43,6 @@ class ModelCommand : public Command
private:
ChipDeviceCommissioner mCommissioner;
ChipDevice * mDevice;
chip::Controller::ExampleOperationalCredentialsIssuer mOpCredsIssuer;
uint8_t mEndPointId;
};
5 changes: 3 additions & 2 deletions examples/chip-tool/commands/discover/DiscoverCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ CHIP_ERROR DiscoverCommand::Run(PersistentStorage & storage, NodeId localId, Nod
{
chip::Controller::CommissionerInitParams params;

params.storageDelegate = &storage;
params.mDeviceAddressUpdateDelegate = this;
params.storageDelegate = &storage;
params.mDeviceAddressUpdateDelegate = this;
params.operationalCredentialsDelegate = &mOpCredsIssuer;

ReturnErrorOnFailure(mCommissioner.SetUdpListenPort(storage.GetListenPort()));
ReturnErrorOnFailure(mCommissioner.Init(localId, params));
Expand Down
2 changes: 2 additions & 0 deletions examples/chip-tool/commands/discover/DiscoverCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "../../config/PersistentStorage.h"
#include "../common/Command.h"
#include <controller/ExampleOperationalCredentialsIssuer.h>

class DiscoverCommand : public Command, public chip::Controller::DeviceAddressUpdateDelegate
{
Expand All @@ -44,4 +45,5 @@ class DiscoverCommand : public Command, public chip::Controller::DeviceAddressUp
private:
chip::NodeId mNodeId;
uint64_t mFabricId;
chip::Controller::ExampleOperationalCredentialsIssuer mOpCredsIssuer;
};
3 changes: 2 additions & 1 deletion examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ CHIP_ERROR PairingCommand::Run(PersistentStorage & storage, NodeId localId, Node
{
CHIP_ERROR err = CHIP_NO_ERROR;

chip::Controller::CommissionerInitParams params;
mOpCredsIssuer.Initialize();

chip::Controller::CommissionerInitParams params;
params.storageDelegate = &storage;
params.mDeviceAddressUpdateDelegate = this;
params.pairingDelegate = this;
Expand Down
6 changes: 5 additions & 1 deletion examples/chip-tool/commands/reporting/ReportingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ constexpr uint16_t kWaitDurationInSeconds = UINT16_MAX;
CHIP_ERROR ReportingCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId)
{
CHIP_ERROR err = CHIP_NO_ERROR;

mOpCredsIssuer.Initialize();

chip::Controller::BasicCluster cluster;
chip::Controller::CommissionerInitParams initParams;

initParams.storageDelegate = &storage;
initParams.storageDelegate = &storage;
initParams.operationalCredentialsDelegate = &mOpCredsIssuer;

err = mCommissioner.SetUdpListenPort(storage.GetListenPort());
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Commissioner: %s", ErrorStr(err)));
Expand Down
3 changes: 3 additions & 0 deletions examples/chip-tool/commands/reporting/ReportingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "../../config/PersistentStorage.h"
#include "../common/Command.h"

#include <controller/ExampleOperationalCredentialsIssuer.h>

// Limits on endpoint values.
#define CHIP_ZCL_ENDPOINT_MIN 0x00
#define CHIP_ZCL_ENDPOINT_MAX 0xF0
Expand All @@ -43,4 +45,5 @@ class ReportingCommand : public Command

ChipDeviceCommissioner mCommissioner;
ChipDevice * mDevice;
chip::Controller::ExampleOperationalCredentialsIssuer mOpCredsIssuer;
};
3 changes: 3 additions & 0 deletions src/darwin/Framework/CHIP/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static_library("framework") {
"CHIPManualSetupPayloadParser.h",
"CHIPManualSetupPayloadParser.mm",
"CHIPOnboardingPayloadParser.m",
"CHIPOperationalCredentialsDelegate.mm",
"CHIPPersistentStorageDelegate.h",
"CHIPPersistentStorageDelegateBridge.h",
"CHIPPersistentStorageDelegateBridge.mm",
Expand All @@ -64,6 +65,8 @@ static_library("framework") {
"${chip_root}/src/lib/support",
]

frameworks = [ "Security.framework" ]

public_configs = [ ":darwin_config" ]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ static BOOL isRunningTests(void)
NSCalendar * calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents * components = [calendar components:units fromDate:date];

return chip::CalendarToChipEpochTime([components year], [components month], [components day], [components hour],
[components minute], [components second], epoch);
uint16_t year = static_cast<uint16_t>([components year]);
uint8_t month = static_cast<uint8_t>([components month]);
uint8_t day = static_cast<uint8_t>([components day]);
uint8_t hour = static_cast<uint8_t>([components hour]);
uint8_t minute = static_cast<uint8_t>([components minute]);
uint8_t second = static_cast<uint8_t>([components second]);
return chip::CalendarToChipEpochTime(year, month, day, hour, minute, second, epoch);
}

0 comments on commit ff81e85

Please sign in to comment.