Skip to content

Commit

Permalink
Merge branch 'master' into bit_mask_class
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Jun 3, 2022
2 parents 5539eba + a00e966 commit a161db6
Show file tree
Hide file tree
Showing 53 changed files with 1,676 additions and 4,578 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3829,8 +3829,8 @@ server cluster WindowCovering = 258 {
command GoToTiltPercentage(GoToTiltPercentageRequest): DefaultSuccess = 8;
}


endpoint 0 {
device type rootdevice = 22;
binding cluster OtaSoftwareUpdateProvider;

server cluster Identify {
Expand Down Expand Up @@ -4148,8 +4148,8 @@ endpoint 0 {
ram attribute clusterRevision default = 3;
}
}

endpoint 1 {
device type onofflight = 256;

server cluster Identify {
ram attribute identifyTime;
Expand Down Expand Up @@ -4740,8 +4740,8 @@ endpoint 1 {
ram attribute clusterRevision default = 3;
}
}

endpoint 2 {
device type onofflight = 256;

server cluster Groups {
ram attribute nameSupport;
Expand Down Expand Up @@ -4787,8 +4787,8 @@ endpoint 2 {
ram attribute clusterRevision default = 3;
}
}

endpoint 65534 {
device type anonymousEndpointType = 61442;

server cluster NetworkCommissioning {
callback attribute maxNetworks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3218,8 +3218,8 @@ server cluster WindowCovering = 258 {
command StopMotion(): DefaultSuccess = 2;
}


endpoint 0 {
device type rootdevice = 22;
binding cluster OtaSoftwareUpdateProvider;

server cluster Identify {
Expand Down Expand Up @@ -3458,8 +3458,8 @@ endpoint 0 {
ram attribute clusterRevision default = 3;
}
}

endpoint 1 {
device type onofflight = 256;

server cluster Identify {
ram attribute identifyTime;
Expand Down Expand Up @@ -3837,8 +3837,8 @@ endpoint 1 {
ram attribute clusterRevision default = 1;
}
}

endpoint 2 {
device type onofflight = 256;

server cluster Groups {
ram attribute nameSupport;
Expand Down Expand Up @@ -3877,8 +3877,8 @@ endpoint 2 {
ram attribute clusterRevision default = 3;
}
}

endpoint 65534 {
device type anonymousEndpointType = 61442;

server cluster NetworkCommissioning {
callback attribute maxNetworks;
Expand Down
4 changes: 2 additions & 2 deletions examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,8 @@ server cluster WiFiNetworkDiagnostics = 54 {
readonly attribute int16u clusterRevision = 65533;
}


endpoint 0 {
device type bridge = 14;
binding cluster AccessControl;

server cluster Descriptor {
Expand Down Expand Up @@ -1405,8 +1405,8 @@ endpoint 0 {
ram attribute clusterRevision default = 1;
}
}

endpoint 1 {
device type dimmablelight = 257;

server cluster OnOff {
ram attribute onOff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@

{{~#if (hasProperty expectedConstraints "maxValue")}}VerifyOrReturn(CheckConstraintMaxValue("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral expectedConstraints.maxValue type}}));{{/if}}

{{~#if (hasProperty expectedConstraints "contains")}}
{{#chip_tests_iterate_expected_list expectedConstraints.contains}}
VerifyOrReturn(CheckConstraintContains("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
{{/if}}

{{~#if (hasProperty expectedConstraints "excludes")}}
{{#chip_tests_iterate_expected_list expectedConstraints.excludes}}
VerifyOrReturn(CheckConstraintExcludes("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
{{/if}}

{{~#if (hasProperty expectedConstraints "notValue")}}
{{#if (isLiteralNull expectedConstraints.notValue)}}
VerifyOrReturn(CheckValueNonNull("{{asPropertyValue}}", {{asPropertyValue}}));
Expand Down
25 changes: 25 additions & 0 deletions examples/darwin-framework-tool/commands/tests/TestCommandBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,31 @@ class TestCommandBridge : public CHIPCommandBridge,
return ConstraintsChecker::CheckConstraintNotValue(itemName, currentValue, expectedValue);
}

template <typename T> bool CheckConstraintContains(const char * _Nonnull itemName, const NSArray * _Nonnull current, T expected)
{
for (id currentElement in current) {
if ([currentElement isEqualToNumber:@(expected)]) {
return true;
}
}

Exit(std::string(itemName) + " expect the value " + std::to_string(expected) + " but the list does not contains it.");
return false;
}

template <typename T> bool CheckConstraintExcludes(const char * _Nonnull itemName, const NSArray * _Nonnull current, T expected)
{
for (id currentElement in current) {
if ([currentElement isEqualToNumber:@(expected)]) {
Exit(std::string(itemName) + " does not expect the value " + std::to_string(expected)
+ " but the list contains it.");
return false;
}
}

return true;
}

bool CheckConstraintNotValue(const char * _Nonnull itemName, const NSData * _Nonnull current, const NSData * _Nonnull expected)
{
const chip::ByteSpan currentValue(static_cast<const uint8_t *>([current bytes]), [current length]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{#if hasExpectedConstraints}}
{{~#*inline "item"}}{{asLowerCamelCase name}}{{/inline}}
{{#if (hasProperty expectedConstraints "type")}}VerifyOrReturn(CheckConstraintType("{{>item}}", "", "{{expectedConstraints.type}}"));{{/if}}

{{~#if (hasProperty expectedConstraints "format")}}VerifyOrReturn(CheckConstraintFormat("{{>item}}", "", "{{expectedConstraints.format}}"));{{/if}}

{{~#if (hasProperty expectedConstraints "startsWith")}}VerifyOrReturn(CheckConstraintStartsWith("{{>item}}", {{>actualValue}}, "{{expectedConstraints.startsWith}}"));{{/if}}

{{~#if (hasProperty expectedConstraints "endsWith")}}VerifyOrReturn(CheckConstraintEndsWith("{{>item}}", {{>actualValue}}, "{{expectedConstraints.endsWith}}"));{{/if}}

{{~#if (hasProperty expectedConstraints "isUpperCase")}}VerifyOrReturn(CheckConstraintIsUpperCase("{{>item}}", {{>actualValue}}, {{expectedConstraints.isUpperCase}}));{{/if}}

{{~#if (hasProperty expectedConstraints "isLowerCase")}}VerifyOrReturn(CheckConstraintIsLowerCase("{{>item}}", {{>actualValue}}, {{expectedConstraints.isLowerCase}}));{{/if}}

{{~#if (hasProperty expectedConstraints "isHexString")}}VerifyOrReturn(CheckConstraintIsHexString("{{>item}}", {{>actualValue}}, {{expectedConstraints.isHexString}}));{{/if}}

{{~#if (hasProperty expectedConstraints "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{>item}}", [{{>actualValue}} length], {{expectedConstraints.minLength}}));{{/if}}

{{~#if (hasProperty expectedConstraints "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{>item}}", [{{>actualValue}} length], {{expectedConstraints.maxLength}}));{{/if}}

{{~#if (hasProperty expectedConstraints "minValue")}}
if ({{>actualValue}} != nil)
{
VerifyOrReturn(CheckConstraintMinValue<{{chipType}}>("{{>item}}", [{{>actualValue}} {{asObjectiveCNumberType "" type true}}Value], {{asTypedLiteral expectedConstraints.minValue type}}));
}
{{/if}}

{{~#if (hasProperty expectedConstraints "maxValue")}}
if ({{>actualValue}} != nil)
{
VerifyOrReturn(CheckConstraintMaxValue<{{chipType}}>("{{>item}}", [{{>actualValue}} {{asObjectiveCNumberType "" type true}}Value], {{asTypedLiteral expectedConstraints.maxValue type}}));
}
{{/if}}

{{~#if (hasProperty expectedConstraints "contains")}}
if ({{>actualValue}} != nil)
{
{{#chip_tests_iterate_expected_list expectedConstraints.contains}}
VerifyOrReturn(CheckConstraintContains("{{asLowerCamelCase name}}", {{>actualValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
}
{{/if}}

{{~#if (hasProperty expectedConstraints "excludes")}}
if ({{>actualValue}} != nil)
{
{{#chip_tests_iterate_expected_list expectedConstraints.excludes}}
VerifyOrReturn(CheckConstraintExcludes("{{asLowerCamelCase name}}", {{>actualValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
}
{{/if}}

{{~#if (hasProperty expectedConstraints "notValue")}}
{{#if (isLiteralNull expectedConstraints.notValue)}}
VerifyOrReturn(CheckValueNonNull("{{>item}}", {{>actualValue}}));
{{else}}
if ({{>actualValue}} != nil)
{
{{#if (isString type)}}
VerifyOrReturn(CheckConstraintNotValue("{{>item}}", {{>actualValue}}, {{asTypedLiteral expectedConstraints.notValue type}}));
{{else}}
VerifyOrReturn(CheckConstraintNotValue("{{>item}}", {{>actualValue}}, {{asTypedLiteral expectedConstraints.notValue type}}));
{{/if}}
}
{{/if}}
{{/if}}
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -209,47 +209,13 @@ class {{filename}}: public TestCommandBridge
{{>check_test_value actual="actualValue" expected=expectedValue cluster=../cluster}}
}
{{/if}}
{{#if hasExpectedConstraints}}
{{~#*inline "item"}}{{asLowerCamelCase name}}{{/inline}}
{{#if (hasProperty expectedConstraints "type")}}VerifyOrReturn(CheckConstraintType("{{>item}}", "", "{{expectedConstraints.type}}"));{{/if}}
{{~#if (hasProperty expectedConstraints "format")}}VerifyOrReturn(CheckConstraintFormat("{{>item}}", "", "{{expectedConstraints.format}}"));{{/if}}
{{~#if (hasProperty expectedConstraints "startsWith")}}VerifyOrReturn(CheckConstraintStartsWith("{{>item}}", {{>actualValue}}, "{{expectedConstraints.startsWith}}"));{{/if}}
{{~#if (hasProperty expectedConstraints "endsWith")}}VerifyOrReturn(CheckConstraintEndsWith("{{>item}}", {{>actualValue}}, "{{expectedConstraints.endsWith}}"));{{/if}}
{{~#if (hasProperty expectedConstraints "isUpperCase")}}VerifyOrReturn(CheckConstraintIsUpperCase("{{>item}}", {{>actualValue}}, {{expectedConstraints.isUpperCase}}));{{/if}}
{{~#if (hasProperty expectedConstraints "isLowerCase")}}VerifyOrReturn(CheckConstraintIsLowerCase("{{>item}}", {{>actualValue}}, {{expectedConstraints.isLowerCase}}));{{/if}}
{{~#if (hasProperty expectedConstraints "isHexString")}}VerifyOrReturn(CheckConstraintIsHexString("{{>item}}", {{>actualValue}}, {{expectedConstraints.isHexString}}));{{/if}}
{{~#if (hasProperty expectedConstraints "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{>item}}", [{{>actualValue}} length], {{expectedConstraints.minLength}}));{{/if}}
{{~#if (hasProperty expectedConstraints "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{>item}}", [{{>actualValue}} length], {{expectedConstraints.maxLength}}));{{/if}}
{{~#if (hasProperty expectedConstraints "minValue")}}
if ({{>actualValue}} != nil) {
VerifyOrReturn(CheckConstraintMinValue<{{chipType}}>("{{>item}}", [{{>actualValue}} {{asObjectiveCNumberType "" type true}}Value], {{asTypedLiteral expectedConstraints.minValue type}}));
}
{{/if}}
{{~#if (hasProperty expectedConstraints "maxValue")}}
if ({{>actualValue}} != nil) {
VerifyOrReturn(CheckConstraintMaxValue<{{chipType}}>("{{>item}}", [{{>actualValue}} {{asObjectiveCNumberType "" type true}}Value], {{asTypedLiteral expectedConstraints.maxValue type}}));
}
{{/if}}
{{~#if (hasProperty expectedConstraints "notValue")}}
{{#if (isLiteralNull expectedConstraints.notValue)}}
VerifyOrReturn(CheckValueNonNull("{{>item}}", {{>actualValue}}));
{{else}}
if ({{>actualValue}} != nil) {
{{#if (isString type)}}
VerifyOrReturn(CheckConstraintNotValue("{{>item}}", {{>actualValue}}, {{asTypedLiteral expectedConstraints.notValue type}}));
{{else}}
VerifyOrReturn(CheckConstraintNotValue("{{>item}}", {{>actualValue}}, {{asTypedLiteral expectedConstraints.notValue type}}));
{{/if}}
}
{{/if}}
{{>maybeCheckExpectedConstraints}}
{{#if saveAs}}
{
{{saveAs}} = {{>actualValue}};
}
{{/if}}
{{/if}}
{{#if saveAs}}
{
{{saveAs}} = {{>actualValue}};
}
{{/if}}
{{/chip_tests_item_response_parameters}}
{{/chip_tests_item_response_parameters}}

{{#unless async}}
NextTest();
Expand Down
4 changes: 4 additions & 0 deletions examples/darwin-framework-tool/templates/tests/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
{
"name": "check_test_value",
"path": "partials/check_test_value.zapt"
},
{
"name": "maybeCheckExpectedConstraints",
"path": "partials/checks/maybeCheckExpectedConstraints.zapt"
}
],
"templates": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1682,8 +1682,8 @@ server cluster WiFiNetworkDiagnostics = 54 {
command ResetCounts(): DefaultSuccess = 0;
}


endpoint 0 {
device type rootdevice = 22;
binding cluster OtaSoftwareUpdateProvider;

server cluster Descriptor {
Expand Down Expand Up @@ -1957,8 +1957,8 @@ endpoint 0 {
ram attribute clusterRevision default = 1;
}
}

endpoint 1 {
device type onofflightswitch = 259;
binding cluster Identify;
binding cluster Scenes;
binding cluster OnOff;
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1664,8 +1664,8 @@ server cluster WiFiNetworkDiagnostics = 54 {
command ResetCounts(): DefaultSuccess = 0;
}


endpoint 0 {
device type rootdevice = 22;
binding cluster OtaSoftwareUpdateProvider;

server cluster Groups {
Expand Down Expand Up @@ -1939,8 +1939,8 @@ endpoint 0 {
ram attribute clusterRevision default = 1;
}
}

endpoint 1 {
device type dimmablelight = 257;

server cluster Identify {
ram attribute identifyTime;
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1840,8 +1840,8 @@ server cluster WiFiNetworkDiagnostics = 54 {
command ResetCounts(): DefaultSuccess = 0;
}


endpoint 0 {
device type rootdevice = 22;
binding cluster OtaSoftwareUpdateProvider;

server cluster Descriptor {
Expand Down Expand Up @@ -2110,8 +2110,8 @@ endpoint 0 {
ram attribute clusterRevision default = 1;
}
}

endpoint 1 {
device type doorlock = 10;

server cluster Identify {
ram attribute identifyTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ server cluster OperationalCredentials = 62 {
command access(invoke: administer) AddTrustedRootCertificate(AddTrustedRootCertificateRequest): DefaultSuccess = 11;
}


endpoint 0 {
binding cluster DiagnosticLogs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ server cluster UserLabel = 65 {
readonly attribute int16u clusterRevision = 65533;
}


endpoint 0 {
device type rootdevice = 22;
binding cluster AccessControl;

server cluster AccessControl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,8 @@ server cluster UserLabel = 65 {
readonly attribute int16u clusterRevision = 65533;
}


endpoint 0 {
device type rootdevice = 22;
binding cluster OtaSoftwareUpdateProvider;

server cluster AccessControl {
Expand Down
4 changes: 2 additions & 2 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2572,8 +2572,8 @@ server cluster WindowCovering = 258 {
command GoToTiltPercentage(GoToTiltPercentageRequest): DefaultSuccess = 8;
}


endpoint 0 {
device type anonymousEndpointType = 65280;
binding cluster OnOff;
binding cluster GeneralCommissioning;
binding cluster Switch;
Expand Down Expand Up @@ -2990,8 +2990,8 @@ endpoint 0 {
ram attribute clusterRevision default = 1;
}
}

endpoint 1 {
device type anonymousEndpointType = 258;
binding cluster OnOff;

server cluster Identify {
Expand Down
Loading

0 comments on commit a161db6

Please sign in to comment.