Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into non-concurrent-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Apr 1, 2022
2 parents 0cd253e + 1ded008 commit 39971eb
Show file tree
Hide file tree
Showing 63 changed files with 5,752 additions and 2,414 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/examples-esp32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ jobs:
example_binaries/esp32-build/chip-all-clusters-app.elf \
/tmp/bloat_reports/
- name: Build example Pigweed App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh pigweed-app sdkconfig.defaults
- name: Build example Lighting App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh lighting-app sdkconfig.defaults
- name: Build example Lock App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh lock-app sdkconfig.defaults

- name: Uploading Size Reports
Expand Down Expand Up @@ -146,29 +146,29 @@ jobs:
.environment/pigweed-venv/*.log
- name: Build example Bridge App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh bridge-app

- name: Build example Persistent Storage App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh persistent-storage sdkconfig.defaults

- name: Build example Shell App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh shell sdkconfig.defaults

- name: Build example Temperature Measurement App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh temperature-measurement-app sdkconfig.optimize.defaults

- name: Build example IPv6 Only App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh ipv6only-app sdkconfig.defaults

- name: Build example OTA Requestor App
run: scripts/examples/esp_example.sh ota-requestor-app sdkconfig.defaults
timeout-minutes: 10
timeout-minutes: 15

- name: Build example OTA Provider App
run: scripts/examples/esp_example.sh ota-provider-app sdkconfig.defaults
timeout-minutes: 10
timeout-minutes: 15
2 changes: 1 addition & 1 deletion config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ menu "CHIP Core"

config USE_MINIMAL_MDNS
bool "Use the minimal mDNS implementation shipped in the CHIP library"
default y
default n
help
The CHIP library is shipped with a minimal mDNS implementation,
enable this config to use it rather than the mDNS library in IDF.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8038,7 +8038,7 @@
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"storageOption": "NVM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0xFF",
Expand Down Expand Up @@ -10591,7 +10591,7 @@
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"storageOption": "NVM",
"singleton": 0,
"bounded": 0,
"defaultValue": "255",
Expand Down Expand Up @@ -21587,4 +21587,4 @@
}
],
"log": []
}
}
2 changes: 1 addition & 1 deletion examples/all-clusters-app/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y

# Serial Flasher config
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
2 changes: 2 additions & 0 deletions examples/chip-tool-darwin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ assert(chip_build_tools)
executable("chip-tool-darwin") {
sources = [
"${chip_root}/zzz_generated/chip-tool-darwin/zap-generated/cluster/CHIPTestClustersObjc.mm",
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp",
"commands/clusters/ModelCommandBridge.mm",
"commands/common/CHIPCommandBridge.mm",
"commands/common/CHIPCommandStorageDelegate.mm",
Expand All @@ -35,6 +36,7 @@ executable("chip-tool-darwin") {
include_dirs = [
".",
"${chip_root}/zzz_generated/chip-tool-darwin",
"${chip_root}/examples/chip-tool/commands/clusters/ComplexArgument.h",
]

deps = [
Expand Down
87 changes: 39 additions & 48 deletions examples/chip-tool-darwin/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>
#include <type_traits>

#include <commands/clusters/ComplexArgument.h>
#include <app/data-model/DecodableList.h>
#include <commands/clusters/ModelCommandBridge.h>

Expand All @@ -24,17 +25,16 @@
class {{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}: public ModelCommand
{
public:
{{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}(): ModelCommand("{{asDelimitedCommand name}}")
{{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}(): ModelCommand("{{asDelimitedCommand name}}"){{#zcl_command_arguments}}{{#if_chip_complex}}, mComplex_{{asUpperCamelCase label}}(&mRequest.{{asLowerCamelCase label}}){{/if_chip_complex}}{{/zcl_command_arguments}}
{
{{#chip_cluster_command_arguments}}
{{~#*inline "field"}}m{{asUpperCamelCase label}}{{/inline~}}
{{#if isArray}}
{{else if isStruct}}
{{#if_chip_complex}}
AddArgument("{{asUpperCamelCase label}}", &mComplex_{{asUpperCamelCase label}});
{{else if (isString type)}}
AddArgument("{{asUpperCamelCase label}}", &{{>field}});
AddArgument("{{asUpperCamelCase label}}", &m{{asUpperCamelCase label}});
{{else}}
AddArgument("{{asUpperCamelCase label}}", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &{{>field}});
{{/if}}
AddArgument("{{asUpperCamelCase label}}", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &m{{asUpperCamelCase label}});
{{/if_chip_complex}}
{{/chip_cluster_command_arguments}}
ModelCommand::AddArguments();
}
Expand All @@ -45,24 +45,21 @@ public:

dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
CHIP{{asUpperCamelCase clusterName}} * cluster = [[CHIP{{asUpperCamelCase clusterName}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue];
CHIP_ERROR __block err = CHIP_NO_ERROR;
CHIP_ERROR __block chipError = CHIP_NO_ERROR;
{{#chip_cluster_command_arguments}}
{{#first}}
__auto_type * params = [[CHIP{{asUpperCamelCase parent.clusterName}}Cluster{{asUpperCamelCase parent.name}}Params alloc] init];
{{/first}}

{{~#*inline "field"}}m{{asUpperCamelCase label}}{{/inline~}}
{{#if isArray}}
// {{label}} Array parsing is not supported yet
{{else if isStruct}}
// {{label}} Struct parsing is not supported yet
{{#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:{{>field}}.data() length:{{>field}}.size()];
params.{{asStructPropertyName label}} = [[NSData alloc] initWithBytes:m{{asUpperCamelCase label}}.data() length:m{{asUpperCamelCase label}}.size()];
{{else if (isString type)}}
params.{{asStructPropertyName label}} = [[NSString alloc] initWithBytes:{{>field}}.data() length:{{>field}}.size() encoding:NSUTF8StringEncoding];
params.{{asStructPropertyName label}} = [[NSString alloc] initWithBytes:m{{asUpperCamelCase label}}.data() length:m{{asUpperCamelCase label}}.size() encoding:NSUTF8StringEncoding];
{{else}}
params.{{asStructPropertyName label}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:{{>field}}];
{{/if}}
params.{{asStructPropertyName label}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:m{{asUpperCamelCase label}}];
{{/if_chip_complex}}
{{/chip_cluster_command_arguments}}
[cluster {{asLowerCamelCase name}}With{{#if (hasArguments)}}Params:params completionHandler:{{else}}CompletionHandler:{{/if}}
{{#if hasSpecificResponse}}
Expand All @@ -71,24 +68,25 @@ public:
{{else}}
^(NSError * _Nullable error) {
{{/if}}
err = [CHIPError errorToCHIPErrorCode:error];
ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(err));
SetCommandExitStatus(err);
chipError = [CHIPError errorToCHIPErrorCode:error];
ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(chipError));
SetCommandExitStatus(chipError);
}];
return err;
return chipError;
}

private:
{{#chip_cluster_command_arguments}}
{{#if isArray}}
{{else if isStruct}}
{{#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}}
{{chipType}} m{{asUpperCamelCase label}};
{{/if}}
{{/if_chip_complex}}
{{/chip_cluster_command_arguments}}
};

Expand Down Expand Up @@ -144,21 +142,19 @@ public:
{{#if isWritableAttribute}}
{{! No list support for writing yet. Need to figure out how to represent the
values. }}
{{#unless isArray}}
class Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}: public ModelCommand
{
public:
Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(): ModelCommand("write")
Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(): ModelCommand("write"){{#if_chip_complex}}, mComplex(&mValue){{/if_chip_complex}}
{
AddArgument("attr-name", "{{asDelimitedCommand (asUpperCamelCase name)}}");
{{#if isArray}}
// {{label}} Array parsing is not supported yet
{{else if isStruct}}
{{#if_chip_complex}}
AddArgument("attr-value", &mComplex);
{{else if (isString type)}}
AddArgument("attr-value", &mValue);
{{else}}
AddArgument("attr-value", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &mValue);
{{/if}}
{{/if_chip_complex}}
ModelCommand::AddArguments();
}

Expand All @@ -171,41 +167,40 @@ public:
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) WriteAttribute ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
CHIP{{asUpperCamelCase parent.name}} * cluster = [[CHIP{{asUpperCamelCase parent.name}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue];
CHIP_ERROR __block err = CHIP_NO_ERROR;
CHIP_ERROR __block chipError = CHIP_NO_ERROR;

{{#if isArray}}
// {{label}} Array parsing is not supported yet
{{else if isStruct}}
CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase type}} * value = [[CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase type}} alloc] init];
{{#if_chip_complex}}
{{asObjectiveCType type parent.name}} value;
{{>decodable_value target="value" source="mValue" cluster=parent.name errorCode="return err;" depth=0}}
{{else if (isOctetString type)}}
{{asObjectiveCType type parent.name}} value = [[NSData alloc] initWithBytes:mValue.data() length:mValue.size()];
{{else if (isString type)}}
{{asObjectiveCType type parent.name}} value = [[NSString alloc] initWithBytes:mValue.data() length:mValue.size() encoding:NSUTF8StringEncoding];
{{else}}
{{asObjectiveCType type parent.name}} value = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:mValue];
{{/if}}
{{/if_chip_complex}}

[cluster writeAttribute{{asUpperCamelCase name}}WithValue:value completionHandler:^(NSError * _Nullable error) {
err = [CHIPError errorToCHIPErrorCode:error];
ChipLogError(chipTool, "{{asUpperCamelCase parent.name}} {{asUpperCamelCase name}} Error: %s", chip::ErrorStr(err));
SetCommandExitStatus(err);
chipError = [CHIPError errorToCHIPErrorCode:error];
ChipLogError(chipTool, "{{asUpperCamelCase parent.name}} {{asUpperCamelCase name}} Error: %s", chip::ErrorStr(chipError));
SetCommandExitStatus(chipError);
}];
return err;
return chipError;
}

private:
{{#if isArray}}
{{else if isStruct}}
{{#if_chip_complex}}
{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}} mValue;
TypedComplexArgument<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}> mComplex;
{{else if (isOctetString type)}}
chip::ByteSpan mValue;
{{else if (isCharString type)}}
chip::ByteSpan mValue;
{{else}}
{{chipType}} mValue;
{{/if}}
{{/if_chip_complex}}
};

{{/unless}}
{{/if}}
{{#if isReportableAttribute}}
class SubscribeAttribute{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}: public ModelCommand
Expand Down Expand Up @@ -274,11 +269,7 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands)
{{! TODO: Various types (floats, structs) not supported here. }}
make_unique<Read{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{#if isWritableAttribute}}
{{! No list support for writing yet. Need to figure out how to
represent the values. }}
{{#unless isArray}}
make_unique<Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{/unless}}
{{/if}}
{{#if isReportableAttribute}}
make_unique<SubscribeAttribute{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
Expand Down
44 changes: 44 additions & 0 deletions examples/chip-tool-darwin/templates/partials/decodable_value.zapt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{#if isOptional}}
if ({{source}}.HasValue()) {
{{>decodable_value target=target source=(concat source ".Value()") cluster=cluster depth=(incrementDepth depth) isOptional=false}}
} else {
{{target}} = nil;
}
{{else if isNullable}}
if ({{source}}.IsNull()) {
{{target}} = nil;
} else {
{{>decodable_value target=target source=(concat source ".Value()") cluster=cluster depth=(incrementDepth depth) isNullable=false}}
}
{{else if isArray}}
{ // Scope for our temporary variables
auto * array_{{depth}} = [NSMutableArray new];
for (auto & entry_{{depth}} : {{source}}) {
{{asObjectiveCClass type cluster forceNotList=true}} * newElement_{{depth}};
{{>decodable_value target=(concat "newElement_" depth) source=(concat "entry_" depth) cluster=cluster depth=(incrementDepth depth) isArray=false}}
[array_{{depth}} addObject:newElement_{{depth}}];
}
{{target}} = array_{{depth}};
}
{{else}}
{{#if_is_struct type}}
{{target}} = [{{asObjectiveCClass type cluster forceNotList=true}} new];
{{#zcl_struct_items_by_struct_name type}}
{{>decodable_value target=(concat ../target "." (asStructPropertyName label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster depth=(incrementDepth ../depth) }}
{{/zcl_struct_items_by_struct_name}}
{{else}}
{{#if_chip_enum type}}
{{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:chip::to_underlying({{source}})];
{{else}}
{{#if_is_bitmap type}}
{{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:{{source}}.Raw()];
{{else if (isOctetString type)}}
{{target}} = [NSData dataWithBytes:{{source}}.data() length:{{source}}.size()];
{{else if (isCharString type)}}
{{target}} = [[NSString alloc] initWithBytes:{{source}}.data() length:{{source}}.size() encoding:NSUTF8StringEncoding];
{{else}}
{{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:{{source}}];
{{/if_is_bitmap}}
{{/if_chip_enum}}
{{/if_is_struct}}
{{/if}}
4 changes: 4 additions & 0 deletions examples/chip-tool-darwin/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"name": "encode_value",
"path": "../../../src/darwin/Framework/CHIP/templates/partials/encode_value.zapt"
},
{
"name": "decodable_value",
"path": "partials/decodable_value.zapt"
},
{
"name": "decode_value",
"path": "../../../src/darwin/Framework/CHIP/templates/partials/decode_value.zapt"
Expand Down
Loading

0 comments on commit 39971eb

Please sign in to comment.