Skip to content

Commit

Permalink
Merge branch 'master' into issue/17547
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed May 9, 2022
2 parents facef86 + 11587f5 commit 27b51ae
Show file tree
Hide file tree
Showing 93 changed files with 21,389 additions and 3,309 deletions.
21 changes: 21 additions & 0 deletions docs/guides/chip_tool_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,27 @@ In this command:
- _<test_name\>_ is the name of the particular test.
#### Example: running `TestClusters` test
As an example of running one test suite test:
```
# Clean initialization of state.
rm -fr /tmp/chip_*

# In a shell window, start the DUT device.
./out/debug/standalone/chip-all-clusters-app

# In a second shell window, pair the DUT with chip-tool.
./out/debug/standalone/chip-tool pairing onnetwork 333221 20202021

# Now run the test
./out/debug/standalone/chip-tool tests TestCluster --nodeId 333221
```
Developer details on how the test suite is structured can be found
[here](../../src/app/tests/suites/README.md).
### Parsing the setup payload
The CHIP Tool offers a utility for parsing the Matter onboarding setup payload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3861,8 +3861,8 @@ endpoint 0 {
server cluster GeneralCommissioning {
ram attribute breadcrumb;
callback attribute basicCommissioningInfo;
ram attribute regulatoryConfig;
ram attribute locationCapability;
callback attribute regulatoryConfig;
callback attribute locationCapability;
callback attribute supportsConcurrentConnection default = 1;
ram attribute featureMap default = 6;
ram attribute clusterRevision default = 1;
Expand Down Expand Up @@ -4015,8 +4015,8 @@ endpoint 0 {
server cluster OperationalCredentials {
callback attribute NOCs;
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
callback attribute currentFabricIndex;
ram attribute clusterRevision default = 1;
Expand Down
8 changes: 4 additions & 4 deletions examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1199,8 +1199,8 @@ endpoint 0 {
server cluster GeneralCommissioning {
ram attribute breadcrumb;
callback attribute basicCommissioningInfo;
ram attribute regulatoryConfig;
ram attribute locationCapability;
callback attribute regulatoryConfig;
callback attribute locationCapability;
callback attribute supportsConcurrentConnection default = 1;
ram attribute featureMap default = 6;
ram attribute clusterRevision default = 1;
Expand Down Expand Up @@ -1353,8 +1353,8 @@ endpoint 0 {
server cluster OperationalCredentials {
callback attribute NOCs;
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
callback attribute currentFabricIndex;
ram attribute clusterRevision default = 1;
Expand Down
11 changes: 7 additions & 4 deletions examples/chip-tool-darwin/commands/common/CHIPCommandBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@

#pragma once

constexpr const char kIdentityAlpha[] = "alpha";
constexpr const char kIdentityBeta[] = "beta";
constexpr const char kIdentityGamma[] = "gamma";

class CHIPCommandBridge : public Command
{
public:
CHIPCommandBridge(const char * commandName) : Command(commandName) {}

CHIPCommandBridge(const char * commandName, CredentialIssuerCommands * credIssuerCmds) : CHIPCommandBridge(commandName) {}
CHIPCommandBridge(const char * commandName) : Command(commandName) { AddArgument("commissioner-name", &mCommissionerName); }

/////////// Command Interface /////////
CHIP_ERROR Run() override;
Expand Down Expand Up @@ -58,7 +60,7 @@ class CHIPCommandBridge : public Command
// loop has been stopped.
virtual void Shutdown() {}

void SetIdentity(const char * name);
void SetIdentity(const char * identity);

// This method returns the commissioner instance to be used for running the command.
CHIPDeviceController * CurrentCommissioner();
Expand All @@ -82,5 +84,6 @@ class CHIPCommandBridge : public Command

std::condition_variable cvWaitingForResponse;
std::mutex cvWaitingForResponseMutex;
chip::Optional<char *> mCommissionerName;
bool mWaitingForResponse{ true };
};
17 changes: 13 additions & 4 deletions examples/chip-tool-darwin/commands/common/CHIPCommandBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

ipk = [nocSigner getIPK];

constexpr const char * identities[] = { "alpha", "beta", "gamma" };
constexpr const char * identities[] = { kIdentityAlpha, kIdentityBeta, kIdentityGamma };
for (size_t i = 0; i < ArraySize(identities); ++i) {
auto controllerParams = [[CHIPDeviceControllerStartupParams alloc] initWithKeypair:nocSigner];
controllerParams.vendorId = chip::VendorId::TestVendor1;
Expand All @@ -75,16 +75,25 @@
mControllers[identities[i]] = controller;
}

// Default to alpha.
SetIdentity("alpha");
// If no commissioner name passed in, default to alpha.
SetIdentity(mCommissionerName.HasValue() ? mCommissionerName.Value() : kIdentityAlpha);

ReturnLogErrorOnFailure(RunCommand());
ReturnLogErrorOnFailure(StartWaiting(GetWaitDuration()));

return CHIP_NO_ERROR;
}

void CHIPCommandBridge::SetIdentity(const char * name) { mCurrentController = mControllers[name]; }
void CHIPCommandBridge::SetIdentity(const char * identity)
{
std::string name = std::string(identity);
if (name.compare(kIdentityAlpha) != 0 && name.compare(kIdentityBeta) != 0 && name.compare(kIdentityGamma) != 0) {
ChipLogError(chipTool, "Unknown commissioner name: %s. Supported names are [%s, %s, %s]", name.c_str(), kIdentityAlpha,
kIdentityBeta, kIdentityGamma);
chipDie();
}
mCurrentController = mControllers[name];
}

CHIPDeviceController * CHIPCommandBridge::CurrentCommissioner() { return mCurrentController; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
[CurrentCommissioner() pairDevice:mNodeId
address:[NSString stringWithUTF8String:ipAddress]
port:mRemotePort
discriminator:mDiscriminator
setupPINCode:mSetupPINCode
error:error];
}
34 changes: 25 additions & 9 deletions examples/chip-tool-darwin/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,30 @@ public:
{{#chip_cluster_command_arguments}}
{{#if_chip_complex}}
{{>decodable_value target=(concat "params." (asStructPropertyName label)) source=(concat "mRequest." (asStructPropertyName label)) cluster=parent.clusterName type=type depth=0}}
{{else if (isOctetString type)}}
params.{{asStructPropertyName label}} = [[NSData alloc] initWithBytes:m{{asUpperCamelCase label}}.data() length:m{{asUpperCamelCase label}}.size()];
{{else if (isOctetString type)}}
{{#if isOptional}}
if (m{{asUpperCamelCase label}}.HasValue()) {
{{/if}}
params.{{asStructPropertyName label}} = [[NSData alloc] initWithBytes:m{{asUpperCamelCase label}}{{#if isOptional}}.Value(){{/if}}.data() length:m{{asUpperCamelCase label}}{{#if isOptional}}.Value(){{/if}}.size()];
{{#if isOptional}}
}
{{/if}}
{{else if (isString type)}}
params.{{asStructPropertyName label}} = [[NSString alloc] initWithBytes:m{{asUpperCamelCase label}}.data() length:m{{asUpperCamelCase label}}.size() encoding:NSUTF8StringEncoding];
{{#if isOptional}}
if (m{{asUpperCamelCase label}}.HasValue()) {
{{/if}}
params.{{asStructPropertyName label}} = [[NSString alloc] initWithBytes:m{{asUpperCamelCase label}}{{#if isOptional}}.Value(){{/if}}.data() length:m{{asUpperCamelCase label}}{{#if isOptional}}.Value(){{/if}}.size() encoding:NSUTF8StringEncoding];
{{#if isOptional}}
}
{{/if}}
{{else}}
params.{{asStructPropertyName label}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:m{{asUpperCamelCase label}}];
{{#if isOptional}}
if (m{{asUpperCamelCase label}}.HasValue()) {
{{/if}}
params.{{asStructPropertyName label}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:m{{asUpperCamelCase label}}{{#if isOptional}}.Value(){{/if}}];
{{#if isOptional}}
}
{{/if}}
{{/if_chip_complex}}
{{/chip_cluster_command_arguments}}
uint16_t repeatCount = mRepeatCount.ValueOr(1);
Expand Down Expand Up @@ -92,12 +110,10 @@ private:
{{#if_chip_complex}}
chip::app::Clusters::{{asUpperCamelCase parent.clusterName}}::Commands::{{asUpperCamelCase parent.name}}::Type mRequest;
TypedComplexArgument<{{zapTypeToEncodableClusterObjectType type ns=parent.parent.name}}> mComplex_{{asUpperCamelCase label}};
{{else if (isOctetString type)}}
chip::ByteSpan m{{asUpperCamelCase label}};
{{else if (isCharString type)}}
chip::ByteSpan m{{asUpperCamelCase label}};
{{else if (isString type)}}
{{#if isOptional}}chip::Optional<chip::ByteSpan>{{else}}chip::ByteSpan{{/if}} m{{asUpperCamelCase label}};
{{else}}
{{chipType}} m{{asUpperCamelCase label}};
{{#if isOptional}}chip::Optional<{{chipType}}>{{else}}{{chipType}}{{/if}} m{{asUpperCamelCase label}};
{{/if_chip_complex}}
{{/chip_cluster_command_arguments}}
};
Expand Down
2 changes: 1 addition & 1 deletion examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ class SubscribeEvent : public ReportCommand
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval, 0,
"The requested maximum interval between reports. Sets MaxIntervalCeiling in the Subscribe Request.");
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions,
"0 - Terminate existing subscriptions from initiator.\n 1 - Otherwise.");
"false - Terminate existing subscriptions from initiator.\n true - Leave existing subscriptions in place.");
AddArgument("event-min", 0, UINT64_MAX, &mEventNumber);
ReportCommand::AddArguments();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1729,8 +1729,8 @@ endpoint 0 {
server cluster GeneralCommissioning {
ram attribute breadcrumb;
callback attribute basicCommissioningInfo;
ram attribute regulatoryConfig;
ram attribute locationCapability;
callback attribute regulatoryConfig;
callback attribute locationCapability;
callback attribute supportsConcurrentConnection default = 1;
ram attribute featureMap default = 6;
ram attribute clusterRevision default = 1;
Expand Down Expand Up @@ -1886,8 +1886,8 @@ endpoint 0 {
server cluster OperationalCredentials {
callback attribute NOCs;
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
callback attribute currentFabricIndex;
ram attribute clusterRevision default = 1;
Expand Down
8 changes: 4 additions & 4 deletions examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1717,8 +1717,8 @@ endpoint 0 {
server cluster GeneralCommissioning {
ram attribute breadcrumb;
callback attribute basicCommissioningInfo;
ram attribute regulatoryConfig;
ram attribute locationCapability;
callback attribute regulatoryConfig;
callback attribute locationCapability;
callback attribute supportsConcurrentConnection default = 1;
ram attribute featureMap default = 6;
ram attribute clusterRevision default = 1;
Expand Down Expand Up @@ -1874,8 +1874,8 @@ endpoint 0 {
server cluster OperationalCredentials {
callback attribute NOCs;
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
callback attribute currentFabricIndex;
ram attribute clusterRevision default = 1;
Expand Down
8 changes: 4 additions & 4 deletions examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1884,8 +1884,8 @@ endpoint 0 {
server cluster GeneralCommissioning {
ram attribute breadcrumb;
callback attribute basicCommissioningInfo;
ram attribute regulatoryConfig;
ram attribute locationCapability;
callback attribute regulatoryConfig;
callback attribute locationCapability;
callback attribute supportsConcurrentConnection default = 1;
ram attribute featureMap default = 6;
ram attribute clusterRevision default = 1;
Expand Down Expand Up @@ -2038,8 +2038,8 @@ endpoint 0 {
server cluster OperationalCredentials {
callback attribute NOCs;
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
callback attribute currentFabricIndex;
ram attribute clusterRevision default = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ endpoint 0 {

server cluster OperationalCredentials {
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
ram attribute clusterRevision default = 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ endpoint 0 {
server cluster GeneralCommissioning {
ram attribute breadcrumb;
callback attribute basicCommissioningInfo;
ram attribute regulatoryConfig;
ram attribute locationCapability;
callback attribute regulatoryConfig;
callback attribute locationCapability;
callback attribute supportsConcurrentConnection default = 1;
ram attribute featureMap;
ram attribute clusterRevision default = 1;
Expand All @@ -658,8 +658,8 @@ endpoint 0 {
server cluster OperationalCredentials {
callback attribute NOCs;
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
callback attribute currentFabricIndex;
ram attribute clusterRevision default = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ endpoint 0 {
server cluster GeneralCommissioning {
ram attribute breadcrumb;
callback attribute basicCommissioningInfo;
ram attribute regulatoryConfig;
ram attribute locationCapability;
callback attribute regulatoryConfig;
callback attribute locationCapability;
callback attribute supportsConcurrentConnection default = 1;
ram attribute featureMap;
ram attribute clusterRevision default = 1;
Expand Down Expand Up @@ -719,8 +719,8 @@ endpoint 0 {
server cluster OperationalCredentials {
callback attribute NOCs;
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
callback attribute currentFabricIndex;
ram attribute clusterRevision default = 1;
Expand Down
8 changes: 4 additions & 4 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2632,8 +2632,8 @@ endpoint 0 {
server cluster GeneralCommissioning {
ram attribute breadcrumb;
callback attribute basicCommissioningInfo;
ram attribute regulatoryConfig;
ram attribute locationCapability;
callback attribute regulatoryConfig;
callback attribute locationCapability;
callback attribute supportsConcurrentConnection default = 1;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
Expand Down Expand Up @@ -2728,8 +2728,8 @@ endpoint 0 {

server cluster OperationalCredentials {
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
callback attribute currentFabricIndex;
ram attribute clusterRevision default = 1;
Expand Down
8 changes: 4 additions & 4 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2632,8 +2632,8 @@ endpoint 0 {
server cluster GeneralCommissioning {
ram attribute breadcrumb;
callback attribute basicCommissioningInfo;
ram attribute regulatoryConfig;
ram attribute locationCapability;
callback attribute regulatoryConfig;
callback attribute locationCapability;
callback attribute supportsConcurrentConnection default = 1;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
Expand Down Expand Up @@ -2728,8 +2728,8 @@ endpoint 0 {

server cluster OperationalCredentials {
callback attribute fabrics;
ram attribute supportedFabrics;
ram attribute commissionedFabrics;
callback attribute supportedFabrics;
callback attribute commissionedFabrics;
callback attribute trustedRootCertificates;
callback attribute currentFabricIndex;
ram attribute clusterRevision default = 1;
Expand Down
Loading

0 comments on commit 27b51ae

Please sign in to comment.