Skip to content

Commit

Permalink
Merge branch 'master' into unit_localization_cluster_constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Jul 21, 2022
2 parents be78e1f + 6d54807 commit becce7f
Show file tree
Hide file tree
Showing 193 changed files with 17,377 additions and 17,758 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/examples-linux-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ jobs:
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-arm64-all-clusters \
--target linux-arm64-chip-tool-ipv6only \
--target linux-arm64-lock \
--target linux-arm64-minmdns \
--target linux-arm64-thermostat-no-ble \
--target linux-arm64-clang-all-clusters \
--target linux-arm64-clang-chip-tool-ipv6only \
--target linux-arm64-clang-lock \
--target linux-arm64-clang-minmdns \
--target linux-arm64-clang-thermostat-no-ble \
build \
"
- name: Bloat report - chip-tool
timeout-minutes: 5
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
linux arm64 chip-tool-ipv6only \
out/linux-arm64-chip-tool-ipv6only/chip-tool \
out/linux-arm64-clang-chip-tool-ipv6only/chip-tool \
/tmp/bloat_reports/
- name: Bloat report - thermostat
timeout-minutes: 5
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
linux arm64 thermostat-no-ble \
out/linux-arm64-thermostat-no-ble/thermostat-app \
out/linux-arm64-clang-thermostat-no-ble/thermostat-app \
/tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
Expand Down
15 changes: 15 additions & 0 deletions examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::DeviceLayer;

void AllClustersCommandDelegate::OnEventCommandReceived(const char * command)
Expand Down Expand Up @@ -228,30 +229,44 @@ void AllClustersCommandDelegate::OnSwitchEventHandler(uint32_t eventId)

if (eventId == Clusters::Switch::Events::SwitchLatched::Id)
{
EmberAfStatus status = Switch::Attributes::CurrentPosition::Set(endpoint, newPosition);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to set CurrentPosition attribute"));
Clusters::SwitchServer::Instance().OnSwitchLatch(endpoint, newPosition);
}
else if (eventId == Clusters::Switch::Events::InitialPress::Id)
{
EmberAfStatus status = Switch::Attributes::CurrentPosition::Set(endpoint, newPosition);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to set CurrentPosition attribute"));
Clusters::SwitchServer::Instance().OnInitialPress(endpoint, newPosition);
}
else if (eventId == Clusters::Switch::Events::LongPress::Id)
{
EmberAfStatus status = Switch::Attributes::CurrentPosition::Set(endpoint, newPosition);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to set CurrentPosition attribute"));
Clusters::SwitchServer::Instance().OnLongPress(endpoint, newPosition);
}
else if (eventId == Clusters::Switch::Events::ShortRelease::Id)
{
EmberAfStatus status = Switch::Attributes::CurrentPosition::Set(endpoint, 0);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to reset CurrentPosition attribute"));
Clusters::SwitchServer::Instance().OnShortRelease(endpoint, previousPosition);
}
else if (eventId == Clusters::Switch::Events::LongRelease::Id)
{
EmberAfStatus status = Switch::Attributes::CurrentPosition::Set(endpoint, 0);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to reset CurrentPosition attribute"));
Clusters::SwitchServer::Instance().OnLongRelease(endpoint, previousPosition);
}
else if (eventId == Clusters::Switch::Events::MultiPressOngoing::Id)
{
EmberAfStatus status = Switch::Attributes::CurrentPosition::Set(endpoint, newPosition);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to set CurrentPosition attribute"));
Clusters::SwitchServer::Instance().OnMultiPressOngoing(endpoint, newPosition, count);
}
else if (eventId == Clusters::Switch::Events::MultiPressComplete::Id)
{
EmberAfStatus status = Switch::Attributes::CurrentPosition::Set(endpoint, newPosition);
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(NotSpecified, "Failed to set CurrentPosition attribute"));
Clusters::SwitchServer::Instance().OnMultiPressComplete(endpoint, newPosition, count);
}
else
Expand Down
8 changes: 5 additions & 3 deletions examples/chip-tool/templates/tests/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ function asPropertyValue(options)
{
let rootObject = 'value';

let context = options.hash.context || this;

// The decodable type for commands is a struct by default, even if the
// command just returns a single value.
if (this.parent.isCommand) {
rootObject += '.' + asLowerCamelCase(this.name);
if (context.parent.isCommand) {
rootObject += '.' + asLowerCamelCase(context.name);
}

if (this.isOptional && !options.hash.dontUnwrapValue) {
if (context.isOptional && !options.hash.dontUnwrapValue) {
rootObject += '.Value()';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,65 @@
{{/if}}
{{/if}}

{{~#if (hasProperty expectedConstraints "type")}}VerifyOrReturn(CheckConstraintType("{{asPropertyValue}}", "", "{{expectedConstraints.type}}"));{{/if}}
{{~#chip_tests_iterate_constraints expectedConstraints}}
{{~#if (isStrEqual constraint "hasValue")}}
{{~! Already handled above~}}
{{~else if (isStrEqual constraint "type")}}VerifyOrReturn(CheckConstraintType("{{asPropertyValue context=..}}", "", "{{value}}"));

{{~#if (hasProperty expectedConstraints "format")}}VerifyOrReturn(CheckConstraintFormat("{{asPropertyValue}}", "", "{{expectedConstraints.format}}"));{{/if}}
{{~else if (isStrEqual constraint "format")}}VerifyOrReturn(CheckConstraintFormat("{{asPropertyValue context=..}}", "", "{{value}}"));

{{~#if (hasProperty expectedConstraints "startsWith")}}VerifyOrReturn(CheckConstraintStartsWith("{{asPropertyValue}}", {{asPropertyValue}}, "{{expectedConstraints.startsWith}}"));{{/if}}
{{~else if (isStrEqual constraint "startsWith")}}VerifyOrReturn(CheckConstraintStartsWith("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, "{{value}}"));

{{~#if (hasProperty expectedConstraints "endsWith")}}VerifyOrReturn(CheckConstraintEndsWith("{{asPropertyValue}}", {{asPropertyValue}}, "{{expectedConstraints.endsWith}}"));{{/if}}
{{~else if (isStrEqual constraint "endsWith")}}VerifyOrReturn(CheckConstraintEndsWith("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, "{{value}}"));

{{~#if (hasProperty expectedConstraints "isUpperCase")}}VerifyOrReturn(CheckConstraintIsUpperCase("{{asPropertyValue}}", {{asPropertyValue}}, {{expectedConstraints.isUpperCase}}));{{/if}}
{{~else if (isStrEqual constraint "isUpperCase")}}VerifyOrReturn(CheckConstraintIsUpperCase("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "isLowerCase")}}VerifyOrReturn(CheckConstraintIsLowerCase("{{asPropertyValue}}", {{asPropertyValue}}, {{expectedConstraints.isLowerCase}}));{{/if}}
{{~else if (isStrEqual constraint "isLowerCase")}}VerifyOrReturn(CheckConstraintIsLowerCase("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "isHexString")}}VerifyOrReturn(CheckConstraintIsHexString("{{asPropertyValue}}", {{asPropertyValue}}, {{expectedConstraints.isHexString}}));{{/if}}
{{~else if (isStrEqual constraint "isHexString")}}VerifyOrReturn(CheckConstraintIsHexString("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{asPropertyValue}}", {{asPropertyValue}}.size(), {{expectedConstraints.minLength}}));{{/if}}
{{~else if (isStrEqual constraint "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{asPropertyValue}}", {{asPropertyValue}}.size(), {{expectedConstraints.maxLength}}));{{/if}}
{{~else if (isStrEqual constraint "maxLength")}}VerifyOrReturn(CheckConstraintMaxLength("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{value}}));

{{~#if (hasProperty expectedConstraints "minValue")}}VerifyOrReturn(CheckConstraintMinValue("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral expectedConstraints.minValue type}}));{{/if}}
{{~else if (isStrEqual constraint "minValue")}}VerifyOrReturn(CheckConstraintMinValue("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{asTypedLiteral value ../type}}));

{{~#if (hasProperty expectedConstraints "maxValue")}}VerifyOrReturn(CheckConstraintMaxValue("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral expectedConstraints.maxValue type}}));{{/if}}
{{~else if (isStrEqual constraint "maxValue")}}VerifyOrReturn(CheckConstraintMaxValue("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{asTypedLiteral value ../type}}));

{{~#if (hasProperty expectedConstraints "contains")}}
{{#chip_tests_iterate_expected_list expectedConstraints.contains}}
VerifyOrReturn(CheckConstraintContains("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{~else if (isStrEqual constraint "contains")}}
{{#chip_tests_iterate_expected_list value context=..}}
VerifyOrReturn(CheckConstraintContains("{{asPropertyValue context=..}}", {{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}}));
{{~else if (isStrEqual constraint "excludes")}}
{{#chip_tests_iterate_expected_list value context=..}}
VerifyOrReturn(CheckConstraintExcludes("{{asPropertyValue context=..}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
{{/if}}

{{~#if (hasProperty expectedConstraints "hasMasksSet")}}
{{#chip_tests_iterate_expected_list expectedConstraints.hasMasksSet}}
VerifyOrReturn(CheckConstraintHasMasksSet("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{~else if (isStrEqual constraint "hasMasksSet")}}
{{#chip_tests_iterate_expected_list value context=..}}
VerifyOrReturn(CheckConstraintHasMasksSet("{{asPropertyValue context=..}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
{{/if}}

{{~#if (hasProperty expectedConstraints "hasMasksClear")}}
{{#chip_tests_iterate_expected_list expectedConstraints.hasMasksClear}}
VerifyOrReturn(CheckConstraintHasMasksClear("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{~else if (isStrEqual constraint "hasMasksClear")}}
{{#chip_tests_iterate_expected_list value context=..}}
VerifyOrReturn(CheckConstraintHasMasksClear("{{asPropertyValue context=..}}", {{asPropertyValue}}, {{asTypedLiteral value type}}));
{{/chip_tests_iterate_expected_list}}
{{/if}}

{{~#if (hasProperty expectedConstraints "notValue")}}
{{#if (isLiteralNull expectedConstraints.notValue)}}
VerifyOrReturn(CheckValueNonNull("{{asPropertyValue}}", {{asPropertyValue}}));
{{~else if (isStrEqual constraint "notValue")}}
{{#if (isLiteralNull value)}}
VerifyOrReturn(CheckValueNonNull("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}));
{{else}}
VerifyOrReturn(CheckConstraintNotValue("{{asPropertyValue}}", {{asPropertyValue}}, {{asTypedLiteral expectedConstraints.notValue type}}));
VerifyOrReturn(CheckConstraintNotValue("{{asPropertyValue context=..}}", {{asPropertyValue context=..}}, {{asTypedLiteral value ../type}}));
{{/if}}

{{~else}}
{{! Ensure there's a line-break before the #error }}
#error "Unknown constraint {{constraint}}";
{{! Ensure there's a line-break after the #error }}
{{/if}}
{{/chip_tests_iterate_constraints}}

{{~#if isOptional}}
{{~#unless (hasProperty expectedConstraints "hasValue")}}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class SubscribeAttribute : public ModelCommand {
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("wait", 0, 1, &mWait);
ModelCommand::AddArguments();
}

Expand All @@ -107,7 +106,6 @@ class SubscribeAttribute : public ModelCommand {
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("wait", 0, 1, &mWait);
ModelCommand::AddArguments();
}

Expand All @@ -119,7 +117,6 @@ class SubscribeAttribute : public ModelCommand {
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("fabric-filtered", 0, 1, &mFabricFiltered);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("wait", 0, 1, &mWait);
ModelCommand::AddArguments();
}

Expand All @@ -144,9 +141,7 @@ class SubscribeAttribute : public ModelCommand {
NSLog(@"Response Item: %@", [item description]);
}
}
if (error || !mWait) {
SetCommandExitStatus(error);
}
SetCommandExitStatus(error);
}
subscriptionEstablished:^() {
mSubscriptionEstablished = YES;
Expand All @@ -155,18 +150,14 @@ class SubscribeAttribute : public ModelCommand {
return CHIP_NO_ERROR;
}

chip::System::Clock::Timeout GetWaitDuration() const override
{
return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10);
}
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); }

protected:
chip::Optional<bool> mKeepSubscriptions;
chip::Optional<bool> mFabricFiltered;
bool mSubscriptionEstablished = NO;
uint16_t mMinInterval;
uint16_t mMaxInterval;
bool mWait;

void Shutdown() override
{
Expand All @@ -189,7 +180,6 @@ class SubscribeEvent : public ModelCommand {
AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval);
AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval);
AddArgument("keepSubscriptions", 0, 1, &mKeepSubscriptions);
AddArgument("wait", 0, 1, &mWait);
ModelCommand::AddArguments();
}

Expand All @@ -208,22 +198,16 @@ class SubscribeEvent : public ModelCommand {
params:params
cacheContainer:nil
attributeReportHandler:^(NSArray * value) {
if (!mWait) {
SetCommandExitStatus(CHIP_NO_ERROR);
}
SetCommandExitStatus(CHIP_NO_ERROR);
}
eventReportHandler:^(NSArray * value) {
for (id item in value) {
NSLog(@"Response Item: %@", [item description]);
}
if (!mWait) {
SetCommandExitStatus(CHIP_NO_ERROR);
}
SetCommandExitStatus(CHIP_NO_ERROR);
}
errorHandler:^(NSError * error) {
if (error && !mWait) {
SetCommandExitStatus(error);
}
SetCommandExitStatus(error);
}
subscriptionEstablished:^() {
mSubscriptionEstablished = YES;
Expand All @@ -232,16 +216,12 @@ class SubscribeEvent : public ModelCommand {
return CHIP_NO_ERROR;
}

chip::System::Clock::Timeout GetWaitDuration() const override
{
return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10);
}
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); }

protected:
chip::Optional<bool> mKeepSubscriptions;
chip::Optional<chip::EventNumber> mEventNumber;
bool mSubscriptionEstablished = NO;
uint16_t mMinInterval;
uint16_t mMaxInterval;
bool mWait;
};
24 changes: 24 additions & 0 deletions examples/darwin-framework-tool/commands/tests/TestCommandBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,30 @@ class TestCommandBridge : public CHIPCommandBridge,
return CheckConstraintNotValue(itemName, currentValue, @(expected));
}

using ConstraintsChecker::CheckConstraintMinLength;

bool CheckConstraintMinLength(const char * _Nonnull itemName, NSString * _Nonnull current, uint64_t expected)
{
return CheckConstraintMinLength(itemName, [current length], expected);
}

bool CheckConstraintMinLength(const char * _Nonnull itemName, NSArray * _Nonnull current, uint64_t expected)
{
return CheckConstraintMinLength(itemName, [current count], expected);
}

using ConstraintsChecker::CheckConstraintMaxLength;

bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSString * _Nonnull current, uint64_t expected)
{
return CheckConstraintMaxLength(itemName, [current length], expected);
}

bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSArray * _Nonnull current, uint64_t expected)
{
return CheckConstraintMaxLength(itemName, [current count], expected);
}

using ConstraintsChecker::CheckConstraintMinValue;

// Used when the minValue is a saved variable, since ConstraintsChecker does
Expand Down
4 changes: 1 addition & 3 deletions examples/darwin-framework-tool/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ public:
subscriptionEstablished:^(){ mSubscriptionEstablished=YES; }
reportHandler:^({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error) {
NSLog(@"{{asUpperCamelCase parent.name}}.{{asUpperCamelCase name}} response %@", [value description]);
if (error || !mWait){
SetCommandExitStatus(error);
}
SetCommandExitStatus(error);
}];

return CHIP_NO_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

{{~#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 "minLength")}}VerifyOrReturn(CheckConstraintMinLength("{{>item}}", {{>actualValue}}, {{expectedConstraints.minLength}}));{{/if}}

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

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

0 comments on commit becce7f

Please sign in to comment.