From 514cf19c5d8e3b6480f19ad36f522c79439b59b2 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 26 Nov 2021 10:23:02 -0500 Subject: [PATCH 1/8] Re-enable test coverage that the python test suite runner disabled. (#12282) * Re-enable test coverage that the python test suite runner disabled. The pattern for tests is not "test_*"; there are a bunch of tests (e.g. TestCluster) that don't match that. The correct pattern is "Test*" (and "TV_*" for the TV tests). "test*" also does not work right because it includes src/app/tests/suites/certification/tests.yaml which is not a test yaml we want to be running. Summary of changes: 1. Stop lowercasing test names in creating the test definitions, so we can actually match against "Test*" sanely. This also makes the test names match what consumers see in the actual filenames. 2. Change the test name detection to match on "Test*", which fixes the actual regression. 3. Move the lowercasing to the --target and --target-glob matching. 4. Add more useful error output when unrecognized --target values are specified, and exit with a failure in that case instead of silently succeeding. * Update the glob for skipping TV apps in darwin tests * make globs lowercase as well, since we match against lowercase names Co-authored-by: Andrei Litvin --- .github/workflows/tests.yaml | 2 +- scripts/tests/chiptest/__init__.py | 10 ++++------ scripts/tests/run_test_suite.py | 27 ++++++++++++++++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index dbabc1ff3b9763..7770cb5e70c0d0 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -174,7 +174,7 @@ jobs: run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ - --target-skip-glob 'tv-*' \ + --target-skip-glob 'TV_*' \ run \ --iterations 2 \ --chip-tool ./out/debug/standalone/chip-tool \ diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index 0e7223e01d4af9..2d72bc2b43a4da 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -32,17 +32,15 @@ def AllTests(root: str): logging.debug('Found YAML: %s' % path) # grab the name without the extension - name = path.stem.lower() + name = path.stem - if 'simulated' in name: + if 'Simulated' in name: continue - if name.startswith('tv_'): + if name.startswith('TV_'): target = TestTarget.TV - name = 'tv-' + name[3:] - elif name.startswith('test_'): + elif name.startswith('Test'): target = TestTarget.ALL_CLUSTERS - name = 'app-' + name[5:] else: continue diff --git a/scripts/tests/run_test_suite.py b/scripts/tests/run_test_suite.py index 6022d6d50e5dcd..133e9213ba7ca4 100755 --- a/scripts/tests/run_test_suite.py +++ b/scripts/tests/run_test_suite.py @@ -110,18 +110,31 @@ def main(context, log_level, target, target_glob, target_skip_glob, no_log_times coloredlogs.install(level=__LOG_LEVELS__[log_level], fmt=log_fmt) # Figures out selected test that match the given name(s) - tests = [test for test in chiptest.AllTests(root)] + all_tests = [test for test in chiptest.AllTests(root)] + tests = all_tests if 'all' not in target: - target = set([name.lower() for name in target]) - tests = [test for test in tests if test.name in target] + tests = [] + for name in target: + targeted = [test for test in all_tests if test.name.lower() + == name.lower()] + if len(targeted) == 0: + logging.error("Unknown target: %s" % name) + tests.extend(targeted) if target_glob: - matcher = GlobMatcher(target_glob) - tests = [test for test in tests if matcher.matches(test.name)] + matcher = GlobMatcher(target_glob.lower()) + tests = [test for test in tests if matcher.matches(test.name.lower())] + + if len(tests) == 0: + logging.error("No targets match, exiting.") + logging.error("Valid targets are (case-insensitive): %s" % + (", ".join(test.name for test in all_tests))) + exit(1) if target_skip_glob: - matcher = GlobMatcher(target_skip_glob) - tests = [test for test in tests if not matcher.matches(test.name)] + matcher = GlobMatcher(target_skip_glob.lower()) + tests = [test for test in tests if not matcher.matches( + test.name.lower())] tests.sort(key=lambda x: x.name) From 8180456f8852ddf80bc79e8f781bef2ef3baddf2 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Fri, 26 Nov 2021 16:56:53 +0100 Subject: [PATCH 2/8] [YAML] Get simulated clusters related code to merge clusters/commands/attributes for real clusters and simulated clusters to be into a dedicated file (#12288) --- .../common/ClusterTestGeneration.js | 46 +------------- .../simulated-clusters/SimulatedClusters.js | 60 +++++++++++++++++++ 2 files changed, 62 insertions(+), 44 deletions(-) create mode 100644 src/app/zap-templates/common/simulated-clusters/SimulatedClusters.js diff --git a/src/app/zap-templates/common/ClusterTestGeneration.js b/src/app/zap-templates/common/ClusterTestGeneration.js index d159e6a9bf3fc5..1694a291d31a8a 100644 --- a/src/app/zap-templates/common/ClusterTestGeneration.js +++ b/src/app/zap-templates/common/ClusterTestGeneration.js @@ -26,10 +26,8 @@ const path = require('path'); // Import helpers from zap core const templateUtil = require(zapPath + 'dist/src-electron/generator/template-util.js') -const { DelayCommands } = require('./simulated-clusters/TestDelayCommands.js'); -const { LogCommands } = require('./simulated-clusters/TestLogCommands.js'); -const { Clusters, asBlocks, asPromise } = require('./ClustersHelper.js'); -const { asUpperCamelCase } = require(basePath + 'src/app/zap-templates/templates/app/helper.js'); +const { getClusters, getCommands, getAttributes, isTestOnlyCluster } = require('./simulated-clusters/SimulatedClusters.js'); +const { asBlocks } = require('./ClustersHelper.js'); const kClusterName = 'cluster'; const kEndpointName = 'endpoint'; @@ -341,37 +339,6 @@ function printErrorAndExit(context, msg) process.exit(1); } -function getClusters() -{ - // Create a new array to merge the configured clusters list and test - // simulated clusters. - return Clusters.getClusters().then(clusters => clusters.concat(DelayCommands, LogCommands)); -} - -function getCommands(clusterName) -{ - switch (clusterName) { - case DelayCommands.name: - return Promise.resolve(DelayCommands.commands); - case LogCommands.name: - return Promise.resolve(LogCommands.commands); - default: - return Clusters.getClientCommands(clusterName); - } -} - -function getAttributes(clusterName) -{ - switch (clusterName) { - case DelayCommands.name: - return Promise.resolve(DelayCommands.attributes); - case LogCommands.name: - return Promise.resolve(LogCommands.attributes); - default: - return Clusters.getServerAttributes(clusterName); - } -} - function assertCommandOrAttribute(context) { const clusterName = context.cluster; @@ -469,15 +436,6 @@ function chip_tests_items(options) return templateUtil.collectBlocks(this.tests, options, this); } -function isTestOnlyCluster(name) -{ - const testOnlyClusters = [ - DelayCommands.name, - LogCommands.name, - ]; - return testOnlyClusters.includes(name); -} - // test_cluster_command_value and test_cluster_value-equals are recursive partials using #each. At some point the |global| // context is lost and it fails. Make sure to attach the global context as a property of the | value | // that is evaluated. diff --git a/src/app/zap-templates/common/simulated-clusters/SimulatedClusters.js b/src/app/zap-templates/common/simulated-clusters/SimulatedClusters.js new file mode 100644 index 00000000000000..ee7af0c2454238 --- /dev/null +++ b/src/app/zap-templates/common/simulated-clusters/SimulatedClusters.js @@ -0,0 +1,60 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const { Clusters } = require('../ClustersHelper.js'); +const { DelayCommands } = require('./TestDelayCommands.js'); +const { LogCommands } = require('./TestLogCommands.js'); + +const SimulatedClusters = [ + DelayCommands, + LogCommands, +]; + +function getSimulatedCluster(clusterName) +{ + return SimulatedClusters.find(cluster => cluster.name == clusterName); +} + +function getClusters() +{ + return Clusters.getClusters().then(clusters => clusters.concat(SimulatedClusters).flat(1)); +} + +function getCommands(clusterName) +{ + const cluster = getSimulatedCluster(clusterName); + return cluster ? Promise.resolve(cluster.commands) : Clusters.getClientCommands(clusterName); +} + +function getAttributes(clusterName) +{ + const cluster = getSimulatedCluster(clusterName); + return cluster ? Promise.resolve(cluster.attributes) : Clusters.getServerAttributes(clusterName); +} + +function isTestOnlyCluster(clusterName) +{ + return !!getSimulatedCluster(clusterName); +} + +// +// Module exports +// +exports.getClusters = getClusters; +exports.getCommands = getCommands; +exports.getAttributes = getAttributes; +exports.isTestOnlyCluster = isTestOnlyCluster; From 47fca5b82787a7aa483f1ec2d35556a81352d1fe Mon Sep 17 00:00:00 2001 From: Jon Smirl Date: Fri, 26 Nov 2021 10:58:04 -0500 Subject: [PATCH 3/8] Remove Sample Extensions from On-Off cluster (#12198) * Remove Sample Extensions from On-Off cluster * scripts/tools/zap_regen_all.py --- src/app/zap-templates/zcl/zcl.json | 1 - .../python/chip/clusters/Objects.py | 298 -------------- .../zap-generated/CHIPCommandPayloadsObjc.h | 10 - .../zap-generated/CHIPCommandPayloadsObjc.mm | 22 - .../app-common/zap-generated/attribute-id.h | 20 - .../zap-generated/attributes/Accessors.cpp | 246 ----------- .../zap-generated/attributes/Accessors.h | 52 --- .../app-common/zap-generated/callback.h | 266 ------------ .../zap-generated/callbacks/PluginCallbacks.h | 4 - .../app-common/zap-generated/cluster-id.h | 6 - .../zap-generated/cluster-objects.cpp | 236 ----------- .../zap-generated/cluster-objects.h | 383 ------------------ .../app-common/zap-generated/command-id.h | 11 - .../app-common/zap-generated/ids/Attributes.h | 60 --- .../app-common/zap-generated/ids/Clusters.h | 6 - .../app-common/zap-generated/ids/Commands.h | 40 -- .../app-common/zap-generated/print-cluster.h | 17 +- 17 files changed, 1 insertion(+), 1677 deletions(-) diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 4da0010d156f46..ca8ada6228555b 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -61,7 +61,6 @@ "ha-devices.xml", "ha.xml", "lo-devices.xml", - "sample-extensions.xml", "types.xml", "zll-devices.xml", "zll.xml" diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index d3fb94a053361e..afd713c4f205e2 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -2168,18 +2168,6 @@ def descriptor(cls) -> ClusterObjectDescriptor: Fields=[ ]) - @dataclass - class SampleMfgSpecificOffWithTransition(ClusterCommand): - cluster_id: typing.ClassVar[int] = 0x0006 - command_id: typing.ClassVar[int] = 0x0000 - is_client: typing.ClassVar[bool] = True - - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ]) - @dataclass class On(ClusterCommand): cluster_id: typing.ClassVar[int] = 0x0006 @@ -2192,30 +2180,6 @@ def descriptor(cls) -> ClusterObjectDescriptor: Fields=[ ]) - @dataclass - class SampleMfgSpecificOnWithTransition(ClusterCommand): - cluster_id: typing.ClassVar[int] = 0x0006 - command_id: typing.ClassVar[int] = 0x0001 - is_client: typing.ClassVar[bool] = True - - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ]) - - @dataclass - class SampleMfgSpecificOnWithTransition2(ClusterCommand): - cluster_id: typing.ClassVar[int] = 0x0006 - command_id: typing.ClassVar[int] = 0x0001 - is_client: typing.ClassVar[bool] = True - - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ]) - @dataclass class Toggle(ClusterCommand): cluster_id: typing.ClassVar[int] = 0x0006 @@ -2228,30 +2192,6 @@ def descriptor(cls) -> ClusterObjectDescriptor: Fields=[ ]) - @dataclass - class SampleMfgSpecificToggleWithTransition(ClusterCommand): - cluster_id: typing.ClassVar[int] = 0x0006 - command_id: typing.ClassVar[int] = 0x0002 - is_client: typing.ClassVar[bool] = True - - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ]) - - @dataclass - class SampleMfgSpecificToggleWithTransition2(ClusterCommand): - cluster_id: typing.ClassVar[int] = 0x0006 - command_id: typing.ClassVar[int] = 0x0002 - is_client: typing.ClassVar[bool] = True - - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ]) - @dataclass class OffWithEffect(ClusterCommand): cluster_id: typing.ClassVar[int] = 0x0006 @@ -2322,70 +2262,6 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'bool' = None - @dataclass - class SampleMfgSpecificAttribute0x00000x1002(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0x0006 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x0000 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - - @dataclass - class SampleMfgSpecificAttribute0x00000x1049(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0x0006 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x0000 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - - @dataclass - class SampleMfgSpecificAttribute0x00010x1002(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0x0006 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x0001 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - - @dataclass - class SampleMfgSpecificAttribute0x00010x1040(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0x0006 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x0001 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - @dataclass class GlobalSceneControl(ClusterAttributeDescriptor): @ChipUtility.classproperty @@ -29271,177 +29147,3 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: return ClusterObjectFieldDescriptor(Type=uint) value: 'uint' = None - - -@dataclass -class SampleMfgSpecificCluster(Cluster): - id: typing.ClassVar[int] = 0xFC00 - - class Commands: - @dataclass - class CommandOne(ClusterCommand): - cluster_id: typing.ClassVar[int] = 0xFC00 - command_id: typing.ClassVar[int] = 0x0000 - is_client: typing.ClassVar[bool] = True - - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ClusterObjectFieldDescriptor( - Label="argOne", Tag=0, Type=uint), - ]) - - argOne: 'uint' = None - - class Attributes: - @dataclass - class EmberSampleAttribute(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0xFC00 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x0000 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - - @dataclass - class EmberSampleAttribute2(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0xFC00 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x0001 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - - @dataclass - class FeatureMap(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0xFC00 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0xFFFC - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - - @dataclass - class ClusterRevision(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0xFC00 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0xFFFD - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=uint) - - value: 'uint' = None - - -@dataclass -class SampleMfgSpecificCluster2(Cluster): - id: typing.ClassVar[int] = 0xFC00 - - class Commands: - @dataclass - class CommandTwo(ClusterCommand): - cluster_id: typing.ClassVar[int] = 0xFC00 - command_id: typing.ClassVar[int] = 0x0000 - is_client: typing.ClassVar[bool] = True - - @ChipUtility.classproperty - def descriptor(cls) -> ClusterObjectDescriptor: - return ClusterObjectDescriptor( - Fields=[ - ClusterObjectFieldDescriptor( - Label="argOne", Tag=0, Type=uint), - ]) - - argOne: 'uint' = None - - class Attributes: - @dataclass - class EmberSampleAttribute3(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0xFC00 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x0000 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - - @dataclass - class EmberSampleAttribute4(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0xFC00 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0x0001 - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - - @dataclass - class FeatureMap(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0xFC00 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0xFFFC - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) - - value: 'typing.Optional[uint]' = None - - @dataclass - class ClusterRevision(ClusterAttributeDescriptor): - @ChipUtility.classproperty - def cluster_id(cls) -> int: - return 0xFC00 - - @ChipUtility.classproperty - def attribute_id(cls) -> int: - return 0xFFFD - - @ChipUtility.classproperty - def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=uint) - - value: 'uint' = None diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h index b916ca9c0e6845..bc38038467073c 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h @@ -2067,16 +2067,6 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init; @end -@interface CHIPSampleMfgSpecificClusterClusterCommandOneParams : NSObject -@property (strong, nonatomic) NSNumber * _Nonnull argOne; -- (instancetype)init; -@end - -@interface CHIPSampleMfgSpecificCluster2ClusterCommandTwoParams : NSObject -@property (strong, nonatomic) NSNumber * _Nonnull argOne; -- (instancetype)init; -@end - NS_ASSUME_NONNULL_END #endif /* CHIP_COMMAND_PAYLOADS_H */ diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm index 9c8314e88c718d..86f04acf55e03c 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm @@ -4411,26 +4411,4 @@ - (instancetype)init } @end -@implementation CHIPSampleMfgSpecificClusterClusterCommandOneParams -- (instancetype)init -{ - if (self = [super init]) { - - _argOne = @(0); - } - return self; -} -@end - -@implementation CHIPSampleMfgSpecificCluster2ClusterCommandTwoParams -- (instancetype)init -{ - if (self = [super init]) { - - _argOne = @(0); - } - return self; -} -@end - NS_ASSUME_NONNULL_END diff --git a/zzz_generated/app-common/app-common/zap-generated/attribute-id.h b/zzz_generated/app-common/app-common/zap-generated/attribute-id.h index 33ceff68320e10..f79b7e04b4b590 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attribute-id.h +++ b/zzz_generated/app-common/app-common/zap-generated/attribute-id.h @@ -137,10 +137,6 @@ // Server attributes #define ZCL_ON_OFF_ATTRIBUTE_ID (0x0000) -#define ZCL_SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_ATTRIBUTE_ID (0x0000) -#define ZCL_SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_2_ATTRIBUTE_ID (0x0000) -#define ZCL_SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_3_ATTRIBUTE_ID (0x0001) -#define ZCL_SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_4_ATTRIBUTE_ID (0x0001) #define ZCL_GLOBAL_SCENE_CONTROL_ATTRIBUTE_ID (0x4000) #define ZCL_ON_TIME_ATTRIBUTE_ID (0x4001) #define ZCL_OFF_WAIT_TIME_ATTRIBUTE_ID (0x4002) @@ -1645,19 +1641,3 @@ // Server attributes #define ZCL_GROUPS_ATTRIBUTE_ID (0x0000) #define ZCL_GROUPKEYS_ATTRIBUTE_ID (0x0001) - -// Attribute ids for cluster: Sample Mfg Specific Cluster - -// Client attributes - -// Server attributes -#define ZCL_ATTRIBUTE_ONE_ATTRIBUTE_ID (0x0000) -#define ZCL_ATTRIBUTE_TWO_ATTRIBUTE_ID (0x0001) - -// Attribute ids for cluster: Sample Mfg Specific Cluster 2 - -// Client attributes - -// Server attributes -#define ZCL_ATTRIBUTE_THREE_ATTRIBUTE_ID (0x0000) -#define ZCL_ATTRIBUTE_FOUR_ATTRIBUTE_ID (0x0001) diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index 758372a01c0920..75f8126d7ec313 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -2293,122 +2293,6 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) } // namespace OnOff -namespace SampleMfgSpecificAttribute0x00000x1002 { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = NumericAttributeTraits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace SampleMfgSpecificAttribute0x00000x1002 - -namespace SampleMfgSpecificAttribute0x00000x1049 { - -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) -{ - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = NumericAttributeTraits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) -{ - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -} // namespace SampleMfgSpecificAttribute0x00000x1049 - -namespace SampleMfgSpecificAttribute0x00010x1002 { - -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) -{ - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = NumericAttributeTraits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) -{ - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -} // namespace SampleMfgSpecificAttribute0x00010x1002 - -namespace SampleMfgSpecificAttribute0x00010x1040 { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::OnOff::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = NumericAttributeTraits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteServerAttribute(endpoint, Clusters::OnOff::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace SampleMfgSpecificAttribute0x00010x1040 - namespace GlobalSceneControl { EmberAfStatus Get(chip::EndpointId endpoint, bool * value) @@ -28012,136 +27896,6 @@ namespace Attributes { } // namespace Attributes } // namespace GroupKeyManagement -namespace SampleMfgSpecificCluster { -namespace Attributes { - -namespace EmberSampleAttribute { - -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) -{ - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = NumericAttributeTraits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) -{ - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -} // namespace EmberSampleAttribute - -namespace EmberSampleAttribute2 { - -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) -{ - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = NumericAttributeTraits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) -{ - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); -} - -} // namespace EmberSampleAttribute2 - -} // namespace Attributes -} // namespace SampleMfgSpecificCluster - -namespace SampleMfgSpecificCluster2 { -namespace Attributes { - -namespace EmberSampleAttribute3 { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = - emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = NumericAttributeTraits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace EmberSampleAttribute3 - -namespace EmberSampleAttribute4 { - -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) -{ - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); - EmberAfStatus status = - emberAfReadServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, readable, sizeof(temp)); - VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - *value = NumericAttributeTraits::StorageToWorking(temp); - return status; -} -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) -{ - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) - { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; - } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteServerAttribute(endpoint, Clusters::SampleMfgSpecificCluster2::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); -} - -} // namespace EmberSampleAttribute4 - -} // namespace Attributes -} // namespace SampleMfgSpecificCluster2 - } // namespace Clusters } // namespace app } // namespace chip diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index a430425acf484d..a637fc51b37221 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -445,26 +445,6 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); } // namespace OnOff -namespace SampleMfgSpecificAttribute0x00000x1002 { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace SampleMfgSpecificAttribute0x00000x1002 - -namespace SampleMfgSpecificAttribute0x00000x1049 { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -} // namespace SampleMfgSpecificAttribute0x00000x1049 - -namespace SampleMfgSpecificAttribute0x00010x1002 { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -} // namespace SampleMfgSpecificAttribute0x00010x1002 - -namespace SampleMfgSpecificAttribute0x00010x1040 { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace SampleMfgSpecificAttribute0x00010x1040 - namespace GlobalSceneControl { EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); @@ -5219,38 +5199,6 @@ namespace Attributes { } // namespace Attributes } // namespace GroupKeyManagement -namespace SampleMfgSpecificCluster { -namespace Attributes { - -namespace EmberSampleAttribute { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -} // namespace EmberSampleAttribute - -namespace EmberSampleAttribute2 { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // int8u -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); -} // namespace EmberSampleAttribute2 - -} // namespace Attributes -} // namespace SampleMfgSpecificCluster - -namespace SampleMfgSpecificCluster2 { -namespace Attributes { - -namespace EmberSampleAttribute3 { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace EmberSampleAttribute3 - -namespace EmberSampleAttribute4 { -EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value); // int16u -EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); -} // namespace EmberSampleAttribute4 - -} // namespace Attributes -} // namespace SampleMfgSpecificCluster2 - } // namespace Clusters } // namespace app } // namespace chip diff --git a/zzz_generated/app-common/app-common/zap-generated/callback.h b/zzz_generated/app-common/app-common/zap-generated/callback.h index 21b5cd2e03c26c..a8285468ea092b 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -934,22 +934,6 @@ void emberAfBindingClusterInitCallback(chip::EndpointId endpoint); */ void emberAfGroupKeyManagementClusterInitCallback(chip::EndpointId endpoint); -/** @brief Sample Mfg Specific Cluster Cluster Init - * - * Cluster Init - * - * @param endpoint Endpoint that is being initialized - */ -void emberAfSampleMfgSpecificClusterClusterInitCallback(chip::EndpointId endpoint); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Init - * - * Cluster Init - * - * @param endpoint Endpoint that is being initialized - */ -void emberAfSampleMfgSpecificCluster2ClusterInitCallback(chip::EndpointId endpoint); - // Cluster Server/Client Init Functions // @@ -12596,214 +12580,6 @@ void emberAfGroupKeyManagementClusterServerTickCallback(chip::EndpointId endpoin */ void emberAfGroupKeyManagementClusterClientTickCallback(chip::EndpointId endpoint); -// -// Sample Mfg Specific Cluster Cluster -// - -/** @brief Sample Mfg Specific Cluster Cluster Server Init - * - * Server Init - * - * @param endpoint Endpoint that is being initialized - */ -void emberAfSampleMfgSpecificClusterClusterServerInitCallback(chip::EndpointId endpoint); - -/** @brief Sample Mfg Specific Cluster Cluster Client Init - * - * Client Init - * - * @param endpoint Endpoint that is being initialized - */ -void emberAfSampleMfgSpecificClusterClusterClientInitCallback(chip::EndpointId endpoint); - -/** @brief Sample Mfg Specific Cluster Cluster Server Attribute Changed - * - * Server Attribute Changed - * - * @param attributePath Concrete attribute path that changed - */ -void MatterSampleMfgSpecificClusterClusterServerAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath); - -/** @brief Sample Mfg Specific Cluster Cluster Client Attribute Changed - * - * Client Attribute Changed - * - * @param attributePath Concrete attribute path that changed - */ -void MatterSampleMfgSpecificClusterClusterClientAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath); - -/** @brief Sample Mfg Specific Cluster Cluster Server Message Sent - * - * Server Message Sent - * - * @param destination The destination to which the message was sent - * @param apsFrame The APS frame for the message - * @param msgLen The length of the message - * @param message The message that was sent - * @param status The status of the sent message - */ -void emberAfSampleMfgSpecificClusterClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); - -/** @brief Sample Mfg Specific Cluster Cluster Client Message Sent - * - * Client Message Sent - * - * @param destination The destination to which the message was sent - * @param apsFrame The APS frame for the message - * @param msgLen The length of the message - * @param message The message that was sent - * @param status The status of the sent message - */ -void emberAfSampleMfgSpecificClusterClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); - -/** @brief Sample Mfg Specific Cluster Cluster Server Pre Attribute Changed - * - * Server Pre Attribute Changed - * - * @param attributePath Concrete attribute path to be changed - * @param attributeType Attribute type - * @param size Attribute size - * @param value Attribute value - */ -chip::Protocols::InteractionModel::Status MatterSampleMfgSpecificClusterClusterServerPreAttributeChangedCallback( - const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); - -/** @brief Sample Mfg Specific Cluster Cluster Client Pre Attribute Changed - * - * Client Pre Attribute Changed - * - * @param attributePath Concrete attribute path to be changed - * @param attributeType Attribute type - * @param size Attribute size - * @param value Attribute value - */ -chip::Protocols::InteractionModel::Status MatterSampleMfgSpecificClusterClusterClientPreAttributeChangedCallback( - const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); - -/** @brief Sample Mfg Specific Cluster Cluster Server Tick - * - * Server Tick - * - * @param endpoint Endpoint that is being served - */ -void emberAfSampleMfgSpecificClusterClusterServerTickCallback(chip::EndpointId endpoint); - -/** @brief Sample Mfg Specific Cluster Cluster Client Tick - * - * Client Tick - * - * @param endpoint Endpoint that is being served - */ -void emberAfSampleMfgSpecificClusterClusterClientTickCallback(chip::EndpointId endpoint); - -// -// Sample Mfg Specific Cluster 2 Cluster -// - -/** @brief Sample Mfg Specific Cluster 2 Cluster Server Init - * - * Server Init - * - * @param endpoint Endpoint that is being initialized - */ -void emberAfSampleMfgSpecificCluster2ClusterServerInitCallback(chip::EndpointId endpoint); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Client Init - * - * Client Init - * - * @param endpoint Endpoint that is being initialized - */ -void emberAfSampleMfgSpecificCluster2ClusterClientInitCallback(chip::EndpointId endpoint); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Server Attribute Changed - * - * Server Attribute Changed - * - * @param attributePath Concrete attribute path that changed - */ -void MatterSampleMfgSpecificCluster2ClusterServerAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Client Attribute Changed - * - * Client Attribute Changed - * - * @param attributePath Concrete attribute path that changed - */ -void MatterSampleMfgSpecificCluster2ClusterClientAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Server Message Sent - * - * Server Message Sent - * - * @param destination The destination to which the message was sent - * @param apsFrame The APS frame for the message - * @param msgLen The length of the message - * @param message The message that was sent - * @param status The status of the sent message - */ -void emberAfSampleMfgSpecificCluster2ClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Client Message Sent - * - * Client Message Sent - * - * @param destination The destination to which the message was sent - * @param apsFrame The APS frame for the message - * @param msgLen The length of the message - * @param message The message that was sent - * @param status The status of the sent message - */ -void emberAfSampleMfgSpecificCluster2ClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Server Pre Attribute Changed - * - * Server Pre Attribute Changed - * - * @param attributePath Concrete attribute path to be changed - * @param attributeType Attribute type - * @param size Attribute size - * @param value Attribute value - */ -chip::Protocols::InteractionModel::Status MatterSampleMfgSpecificCluster2ClusterServerPreAttributeChangedCallback( - const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Client Pre Attribute Changed - * - * Client Pre Attribute Changed - * - * @param attributePath Concrete attribute path to be changed - * @param attributeType Attribute type - * @param size Attribute size - * @param value Attribute value - */ -chip::Protocols::InteractionModel::Status MatterSampleMfgSpecificCluster2ClusterClientPreAttributeChangedCallback( - const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Server Tick - * - * Server Tick - * - * @param endpoint Endpoint that is being served - */ -void emberAfSampleMfgSpecificCluster2ClusterServerTickCallback(chip::EndpointId endpoint); - -/** @brief Sample Mfg Specific Cluster 2 Cluster Client Tick - * - * Client Tick - * - * @param endpoint Endpoint that is being served - */ -void emberAfSampleMfgSpecificCluster2ClusterClientTickCallback(chip::EndpointId endpoint); - // Cluster Commands Callback /** @@ -13000,46 +12776,16 @@ bool emberAfScenesClusterCopySceneResponseCallback(chip::EndpointId endpoint, ch */ bool emberAfOnOffClusterOffCallback(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::OnOff::Commands::Off::DecodableType & commandData); -/** - * @brief On/Off Cluster SampleMfgSpecificOffWithTransition Command callback (from client) - */ -bool emberAfOnOffClusterSampleMfgSpecificOffWithTransitionCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::OnOff::Commands::SampleMfgSpecificOffWithTransition::DecodableType & commandData); /** * @brief On/Off Cluster On Command callback (from client) */ bool emberAfOnOffClusterOnCallback(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::OnOff::Commands::On::DecodableType & commandData); -/** - * @brief On/Off Cluster SampleMfgSpecificOnWithTransition Command callback (from client) - */ -bool emberAfOnOffClusterSampleMfgSpecificOnWithTransitionCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::OnOff::Commands::SampleMfgSpecificOnWithTransition::DecodableType & commandData); -/** - * @brief On/Off Cluster SampleMfgSpecificOnWithTransition2 Command callback (from client) - */ -bool emberAfOnOffClusterSampleMfgSpecificOnWithTransition2Callback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::OnOff::Commands::SampleMfgSpecificOnWithTransition2::DecodableType & commandData); /** * @brief On/Off Cluster Toggle Command callback (from client) */ bool emberAfOnOffClusterToggleCallback(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::OnOff::Commands::Toggle::DecodableType & commandData); -/** - * @brief On/Off Cluster SampleMfgSpecificToggleWithTransition Command callback (from client) - */ -bool emberAfOnOffClusterSampleMfgSpecificToggleWithTransitionCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::OnOff::Commands::SampleMfgSpecificToggleWithTransition::DecodableType & commandData); -/** - * @brief On/Off Cluster SampleMfgSpecificToggleWithTransition2 Command callback (from client) - */ -bool emberAfOnOffClusterSampleMfgSpecificToggleWithTransition2Callback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::OnOff::Commands::SampleMfgSpecificToggleWithTransition2::DecodableType & commandData); /** * @brief On/Off Cluster OffWithEffect Command callback (from client) */ @@ -14999,18 +14745,6 @@ bool emberAfBindingClusterBindCallback(chip::app::CommandHandler * commandObj, c */ bool emberAfBindingClusterUnbindCallback(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::Binding::Commands::Unbind::DecodableType & commandData); -/** - * @brief Sample Mfg Specific Cluster Cluster CommandOne Command callback (from client) - */ -bool emberAfSampleMfgSpecificClusterClusterCommandOneCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::SampleMfgSpecificCluster::Commands::CommandOne::DecodableType & commandData); -/** - * @brief Sample Mfg Specific Cluster 2 Cluster CommandTwo Command callback (from client) - */ -bool emberAfSampleMfgSpecificCluster2ClusterCommandTwoCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::SampleMfgSpecificCluster2::Commands::CommandTwo::DecodableType & commandData); /** @brief Add To Current App Tasks * diff --git a/zzz_generated/app-common/app-common/zap-generated/callbacks/PluginCallbacks.h b/zzz_generated/app-common/app-common/zap-generated/callbacks/PluginCallbacks.h index ad33416064b5ca..bbcd4fb348cae6 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callbacks/PluginCallbacks.h +++ b/zzz_generated/app-common/app-common/zap-generated/callbacks/PluginCallbacks.h @@ -241,7 +241,3 @@ void __attribute__((weak)) MatterBindingPluginClientInitCallback() {} void MatterBindingPluginServerInitCallback(); void __attribute__((weak)) MatterGroupKeyManagementPluginClientInitCallback() {} void MatterGroupKeyManagementPluginServerInitCallback(); -void __attribute__((weak)) MatterSampleMfgSpecificClusterPluginClientInitCallback() {} -void MatterSampleMfgSpecificClusterPluginServerInitCallback(); -void __attribute__((weak)) MatterSampleMfgSpecificCluster2PluginClientInitCallback() {} -void MatterSampleMfgSpecificCluster2PluginServerInitCallback(); diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-id.h b/zzz_generated/app-common/app-common/zap-generated/cluster-id.h index ff52968f2db772..015366d5dcbab0 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-id.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-id.h @@ -354,9 +354,3 @@ static constexpr chip::ClusterId ZCL_BINDING_CLUSTER_ID = 0xF000; // Definitions for cluster: Group Key Management static constexpr chip::ClusterId ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID = 0xF004; - -// Definitions for cluster: Sample Mfg Specific Cluster -static constexpr chip::ClusterId ZCL_SAMPLE_MFG_SPECIFIC_CLUSTER_ID = 0xFC00; - -// Definitions for cluster: Sample Mfg Specific Cluster 2 -static constexpr chip::ClusterId ZCL_SAMPLE_MFG_SPECIFIC_CLUSTER_2_ID = 0xFC00; diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 7c0406db412e5e..d82e9cfcc5b7b0 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -1468,36 +1468,6 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) return CHIP_NO_ERROR; } } // namespace Off. -namespace SampleMfgSpecificOffWithTransition { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const -{ - TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVType outer; - VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - return CHIP_NO_ERROR; -} -} // namespace SampleMfgSpecificOffWithTransition. namespace On { CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { @@ -1528,66 +1498,6 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) return CHIP_NO_ERROR; } } // namespace On. -namespace SampleMfgSpecificOnWithTransition { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const -{ - TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVType outer; - VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - return CHIP_NO_ERROR; -} -} // namespace SampleMfgSpecificOnWithTransition. -namespace SampleMfgSpecificOnWithTransition2 { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const -{ - TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVType outer; - VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - return CHIP_NO_ERROR; -} -} // namespace SampleMfgSpecificOnWithTransition2. namespace Toggle { CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { @@ -1618,66 +1528,6 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) return CHIP_NO_ERROR; } } // namespace Toggle. -namespace SampleMfgSpecificToggleWithTransition { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const -{ - TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVType outer; - VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - return CHIP_NO_ERROR; -} -} // namespace SampleMfgSpecificToggleWithTransition. -namespace SampleMfgSpecificToggleWithTransition2 { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const -{ - TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVType outer; - VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (TLV::TagNumFromTag(reader.GetTag())) - { - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - return CHIP_NO_ERROR; -} -} // namespace SampleMfgSpecificToggleWithTransition2. namespace OffWithEffect { CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { @@ -19344,92 +19194,6 @@ namespace Events { } // namespace Events } // namespace GroupKeyManagement -namespace SampleMfgSpecificCluster { - -namespace Commands { -namespace CommandOne { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const -{ - TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArgOne)), argOne)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVType outer; - VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (TLV::TagNumFromTag(reader.GetTag())) - { - case to_underlying(Fields::kArgOne): - ReturnErrorOnFailure(DataModel::Decode(reader, argOne)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - return CHIP_NO_ERROR; -} -} // namespace CommandOne. -} // namespace Commands - -namespace Events { -} // namespace Events - -} // namespace SampleMfgSpecificCluster -namespace SampleMfgSpecificCluster2 { - -namespace Commands { -namespace CommandTwo { -CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const -{ - TLV::TLVType outer; - ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArgOne)), argOne)); - ReturnErrorOnFailure(writer.EndContainer(outer)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVType outer; - VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); - ReturnErrorOnFailure(reader.EnterContainer(outer)); - while ((err = reader.Next()) == CHIP_NO_ERROR) - { - VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); - switch (TLV::TagNumFromTag(reader.GetTag())) - { - case to_underlying(Fields::kArgOne): - ReturnErrorOnFailure(DataModel::Decode(reader, argOne)); - break; - default: - break; - } - } - - VerifyOrReturnError(err == CHIP_END_OF_TLV, err); - ReturnErrorOnFailure(reader.ExitContainer(outer)); - return CHIP_NO_ERROR; -} -} // namespace CommandTwo. -} // namespace Commands - -namespace Events { -} // namespace Events - -} // namespace SampleMfgSpecificCluster2 } // namespace Clusters } // namespace app diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 07e18c24881d9f..d7c494ecbb02b1 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -2447,41 +2447,16 @@ struct Type; struct DecodableType; } // namespace Off -namespace SampleMfgSpecificOffWithTransition { -struct Type; -struct DecodableType; -} // namespace SampleMfgSpecificOffWithTransition - namespace On { struct Type; struct DecodableType; } // namespace On -namespace SampleMfgSpecificOnWithTransition { -struct Type; -struct DecodableType; -} // namespace SampleMfgSpecificOnWithTransition - -namespace SampleMfgSpecificOnWithTransition2 { -struct Type; -struct DecodableType; -} // namespace SampleMfgSpecificOnWithTransition2 - namespace Toggle { struct Type; struct DecodableType; } // namespace Toggle -namespace SampleMfgSpecificToggleWithTransition { -struct Type; -struct DecodableType; -} // namespace SampleMfgSpecificToggleWithTransition - -namespace SampleMfgSpecificToggleWithTransition2 { -struct Type; -struct DecodableType; -} // namespace SampleMfgSpecificToggleWithTransition2 - namespace OffWithEffect { struct Type; struct DecodableType; @@ -2526,32 +2501,6 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace Off -namespace SampleMfgSpecificOffWithTransition { -enum class Fields -{ -}; - -struct Type -{ -public: - // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificOffWithTransition::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - - using ResponseType = DataModel::NullObjectType; -}; - -struct DecodableType -{ -public: - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificOffWithTransition::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Decode(TLV::TLVReader & reader); -}; -}; // namespace SampleMfgSpecificOffWithTransition namespace On { enum class Fields { @@ -2578,58 +2527,6 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace On -namespace SampleMfgSpecificOnWithTransition { -enum class Fields -{ -}; - -struct Type -{ -public: - // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificOnWithTransition::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - - using ResponseType = DataModel::NullObjectType; -}; - -struct DecodableType -{ -public: - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificOnWithTransition::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Decode(TLV::TLVReader & reader); -}; -}; // namespace SampleMfgSpecificOnWithTransition -namespace SampleMfgSpecificOnWithTransition2 { -enum class Fields -{ -}; - -struct Type -{ -public: - // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificOnWithTransition2::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - - using ResponseType = DataModel::NullObjectType; -}; - -struct DecodableType -{ -public: - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificOnWithTransition2::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Decode(TLV::TLVReader & reader); -}; -}; // namespace SampleMfgSpecificOnWithTransition2 namespace Toggle { enum class Fields { @@ -2656,58 +2553,6 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace Toggle -namespace SampleMfgSpecificToggleWithTransition { -enum class Fields -{ -}; - -struct Type -{ -public: - // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificToggleWithTransition::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - - using ResponseType = DataModel::NullObjectType; -}; - -struct DecodableType -{ -public: - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificToggleWithTransition::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Decode(TLV::TLVReader & reader); -}; -}; // namespace SampleMfgSpecificToggleWithTransition -namespace SampleMfgSpecificToggleWithTransition2 { -enum class Fields -{ -}; - -struct Type -{ -public: - // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificToggleWithTransition2::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - - using ResponseType = DataModel::NullObjectType; -}; - -struct DecodableType -{ -public: - static constexpr CommandId GetCommandId() { return Commands::SampleMfgSpecificToggleWithTransition2::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - - CHIP_ERROR Decode(TLV::TLVReader & reader); -}; -}; // namespace SampleMfgSpecificToggleWithTransition2 namespace OffWithEffect { enum class Fields { @@ -2817,50 +2662,6 @@ struct TypeInfo static constexpr AttributeId GetAttributeId() { return Attributes::OnOff::Id; } }; } // namespace OnOff -namespace SampleMfgSpecificAttribute0x00000x1002 { -struct TypeInfo -{ - using Type = uint16_t; - using DecodableType = uint16_t; - using DecodableArgType = uint16_t; - - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::SampleMfgSpecificAttribute0x00000x1002::Id; } -}; -} // namespace SampleMfgSpecificAttribute0x00000x1002 -namespace SampleMfgSpecificAttribute0x00000x1049 { -struct TypeInfo -{ - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; - - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::SampleMfgSpecificAttribute0x00000x1049::Id; } -}; -} // namespace SampleMfgSpecificAttribute0x00000x1049 -namespace SampleMfgSpecificAttribute0x00010x1002 { -struct TypeInfo -{ - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; - - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::SampleMfgSpecificAttribute0x00010x1002::Id; } -}; -} // namespace SampleMfgSpecificAttribute0x00010x1002 -namespace SampleMfgSpecificAttribute0x00010x1040 { -struct TypeInfo -{ - using Type = uint16_t; - using DecodableType = uint16_t; - using DecodableArgType = uint16_t; - - static constexpr ClusterId GetClusterId() { return Clusters::OnOff::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::SampleMfgSpecificAttribute0x00010x1040::Id; } -}; -} // namespace SampleMfgSpecificAttribute0x00010x1040 namespace GlobalSceneControl { struct TypeInfo { @@ -32692,190 +32493,6 @@ struct TypeInfo } // namespace ClusterRevision } // namespace Attributes } // namespace GroupKeyManagement -namespace SampleMfgSpecificCluster { - -namespace Commands { -// Forward-declarations so we can reference these later. - -namespace CommandOne { -struct Type; -struct DecodableType; -} // namespace CommandOne - -} // namespace Commands - -namespace Commands { -namespace CommandOne { -enum class Fields -{ - kArgOne = 0, -}; - -struct Type -{ -public: - // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand - static constexpr CommandId GetCommandId() { return Commands::CommandOne::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster::Id; } - - uint8_t argOne; - - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - - using ResponseType = DataModel::NullObjectType; -}; - -struct DecodableType -{ -public: - static constexpr CommandId GetCommandId() { return Commands::CommandOne::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster::Id; } - - uint8_t argOne; - CHIP_ERROR Decode(TLV::TLVReader & reader); -}; -}; // namespace CommandOne -} // namespace Commands - -namespace Attributes { -namespace EmberSampleAttribute { -struct TypeInfo -{ - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; - - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::EmberSampleAttribute::Id; } -}; -} // namespace EmberSampleAttribute -namespace EmberSampleAttribute2 { -struct TypeInfo -{ - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; - - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::EmberSampleAttribute2::Id; } -}; -} // namespace EmberSampleAttribute2 -namespace FeatureMap { -struct TypeInfo -{ - using Type = uint32_t; - using DecodableType = uint32_t; - using DecodableArgType = uint32_t; - - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::FeatureMap::Id; } -}; -} // namespace FeatureMap -namespace ClusterRevision { -struct TypeInfo -{ - using Type = uint16_t; - using DecodableType = uint16_t; - using DecodableArgType = uint16_t; - - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::ClusterRevision::Id; } -}; -} // namespace ClusterRevision -} // namespace Attributes -} // namespace SampleMfgSpecificCluster -namespace SampleMfgSpecificCluster2 { - -namespace Commands { -// Forward-declarations so we can reference these later. - -namespace CommandTwo { -struct Type; -struct DecodableType; -} // namespace CommandTwo - -} // namespace Commands - -namespace Commands { -namespace CommandTwo { -enum class Fields -{ - kArgOne = 0, -}; - -struct Type -{ -public: - // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand - static constexpr CommandId GetCommandId() { return Commands::CommandTwo::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster2::Id; } - - uint8_t argOne; - - CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - - using ResponseType = DataModel::NullObjectType; -}; - -struct DecodableType -{ -public: - static constexpr CommandId GetCommandId() { return Commands::CommandTwo::Id; } - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster2::Id; } - - uint8_t argOne; - CHIP_ERROR Decode(TLV::TLVReader & reader); -}; -}; // namespace CommandTwo -} // namespace Commands - -namespace Attributes { -namespace EmberSampleAttribute3 { -struct TypeInfo -{ - using Type = uint16_t; - using DecodableType = uint16_t; - using DecodableArgType = uint16_t; - - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster2::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::EmberSampleAttribute3::Id; } -}; -} // namespace EmberSampleAttribute3 -namespace EmberSampleAttribute4 { -struct TypeInfo -{ - using Type = uint16_t; - using DecodableType = uint16_t; - using DecodableArgType = uint16_t; - - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster2::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::EmberSampleAttribute4::Id; } -}; -} // namespace EmberSampleAttribute4 -namespace FeatureMap { -struct TypeInfo -{ - using Type = uint32_t; - using DecodableType = uint32_t; - using DecodableArgType = uint32_t; - - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster2::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::FeatureMap::Id; } -}; -} // namespace FeatureMap -namespace ClusterRevision { -struct TypeInfo -{ - using Type = uint16_t; - using DecodableType = uint16_t; - using DecodableArgType = uint16_t; - - static constexpr ClusterId GetClusterId() { return Clusters::SampleMfgSpecificCluster2::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::ClusterRevision::Id; } -}; -} // namespace ClusterRevision -} // namespace Attributes -} // namespace SampleMfgSpecificCluster2 } // namespace Clusters } // namespace app diff --git a/zzz_generated/app-common/app-common/zap-generated/command-id.h b/zzz_generated/app-common/app-common/zap-generated/command-id.h index 44c07c5da7569d..9e892ef9d5c2a6 100644 --- a/zzz_generated/app-common/app-common/zap-generated/command-id.h +++ b/zzz_generated/app-common/app-common/zap-generated/command-id.h @@ -73,13 +73,8 @@ // Commands for cluster: On/Off #define ZCL_OFF_COMMAND_ID (0x00) -#define ZCL_SAMPLE_MFG_SPECIFIC_OFF_WITH_TRANSITION_COMMAND_ID (0x00) #define ZCL_ON_COMMAND_ID (0x01) -#define ZCL_SAMPLE_MFG_SPECIFIC_ON_WITH_TRANSITION_COMMAND_ID (0x01) -#define ZCL_SAMPLE_MFG_SPECIFIC_ON_WITH_TRANSITION2_COMMAND_ID (0x01) #define ZCL_TOGGLE_COMMAND_ID (0x02) -#define ZCL_SAMPLE_MFG_SPECIFIC_TOGGLE_WITH_TRANSITION_COMMAND_ID (0x02) -#define ZCL_SAMPLE_MFG_SPECIFIC_TOGGLE_WITH_TRANSITION2_COMMAND_ID (0x02) #define ZCL_OFF_WITH_EFFECT_COMMAND_ID (0x40) #define ZCL_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID (0x41) #define ZCL_ON_WITH_TIMED_OFF_COMMAND_ID (0x42) @@ -507,9 +502,3 @@ // Commands for cluster: Binding #define ZCL_BIND_COMMAND_ID (0x00) #define ZCL_UNBIND_COMMAND_ID (0x01) - -// Commands for cluster: Sample Mfg Specific Cluster -#define ZCL_COMMAND_ONE_COMMAND_ID (0x00) - -// Commands for cluster: Sample Mfg Specific Cluster 2 -#define ZCL_COMMAND_TWO_COMMAND_ID (0x00) diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index f3a521bbd07341..274616f63e20c2 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -416,22 +416,6 @@ namespace OnOff { static constexpr AttributeId Id = 0x00000000; } // namespace OnOff -namespace SampleMfgSpecificAttribute0x00000x1002 { -static constexpr AttributeId Id = 0x10020000; -} // namespace SampleMfgSpecificAttribute0x00000x1002 - -namespace SampleMfgSpecificAttribute0x00000x1049 { -static constexpr AttributeId Id = 0x10490000; -} // namespace SampleMfgSpecificAttribute0x00000x1049 - -namespace SampleMfgSpecificAttribute0x00010x1002 { -static constexpr AttributeId Id = 0x10020001; -} // namespace SampleMfgSpecificAttribute0x00010x1002 - -namespace SampleMfgSpecificAttribute0x00010x1040 { -static constexpr AttributeId Id = 0x10490001; -} // namespace SampleMfgSpecificAttribute0x00010x1040 - namespace GlobalSceneControl { static constexpr AttributeId Id = 0x00004000; } // namespace GlobalSceneControl @@ -5409,50 +5393,6 @@ static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; } // namespace Attributes } // namespace GroupKeyManagement -namespace SampleMfgSpecificCluster { -namespace Attributes { - -namespace EmberSampleAttribute { -static constexpr AttributeId Id = 0x10020000; -} // namespace EmberSampleAttribute - -namespace EmberSampleAttribute2 { -static constexpr AttributeId Id = 0x10020001; -} // namespace EmberSampleAttribute2 - -namespace FeatureMap { -static constexpr AttributeId Id = Globals::Attributes::FeatureMap::Id; -} // namespace FeatureMap - -namespace ClusterRevision { -static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace SampleMfgSpecificCluster - -namespace SampleMfgSpecificCluster2 { -namespace Attributes { - -namespace EmberSampleAttribute3 { -static constexpr AttributeId Id = 0x10490000; -} // namespace EmberSampleAttribute3 - -namespace EmberSampleAttribute4 { -static constexpr AttributeId Id = 0x10490001; -} // namespace EmberSampleAttribute4 - -namespace FeatureMap { -static constexpr AttributeId Id = Globals::Attributes::FeatureMap::Id; -} // namespace FeatureMap - -namespace ClusterRevision { -static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; -} // namespace ClusterRevision - -} // namespace Attributes -} // namespace SampleMfgSpecificCluster2 - } // namespace Clusters } // namespace app } // namespace chip diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h b/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h index bab79dfc4b85f7..dc102cc4a17b12 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h @@ -358,12 +358,6 @@ static constexpr ClusterId Id = 0x0000F000; namespace GroupKeyManagement { static constexpr ClusterId Id = 0x0000F004; } // namespace GroupKeyManagement -namespace SampleMfgSpecificCluster { -static constexpr ClusterId Id = 0x1002FC00; -} // namespace SampleMfgSpecificCluster -namespace SampleMfgSpecificCluster2 { -static constexpr ClusterId Id = 0x1049FC00; -} // namespace SampleMfgSpecificCluster2 } // namespace Clusters } // namespace app diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h index b2727639724342..b485d66d69ecb5 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h @@ -184,34 +184,14 @@ namespace Off { static constexpr CommandId Id = 0x00000000; } // namespace Off -namespace SampleMfgSpecificOffWithTransition { -static constexpr CommandId Id = 0x10020000; -} // namespace SampleMfgSpecificOffWithTransition - namespace On { static constexpr CommandId Id = 0x00000001; } // namespace On -namespace SampleMfgSpecificOnWithTransition { -static constexpr CommandId Id = 0x10020001; -} // namespace SampleMfgSpecificOnWithTransition - -namespace SampleMfgSpecificOnWithTransition2 { -static constexpr CommandId Id = 0x10490001; -} // namespace SampleMfgSpecificOnWithTransition2 - namespace Toggle { static constexpr CommandId Id = 0x00000002; } // namespace Toggle -namespace SampleMfgSpecificToggleWithTransition { -static constexpr CommandId Id = 0x10020002; -} // namespace SampleMfgSpecificToggleWithTransition - -namespace SampleMfgSpecificToggleWithTransition2 { -static constexpr CommandId Id = 0x10490002; -} // namespace SampleMfgSpecificToggleWithTransition2 - namespace OffWithEffect { static constexpr CommandId Id = 0x00000040; } // namespace OffWithEffect @@ -1833,26 +1813,6 @@ static constexpr CommandId Id = 0x00000001; } // namespace Commands } // namespace Binding -namespace SampleMfgSpecificCluster { -namespace Commands { - -namespace CommandOne { -static constexpr CommandId Id = 0x10020000; -} // namespace CommandOne - -} // namespace Commands -} // namespace SampleMfgSpecificCluster - -namespace SampleMfgSpecificCluster2 { -namespace Commands { - -namespace CommandTwo { -static constexpr CommandId Id = 0x10490000; -} // namespace CommandTwo - -} // namespace Commands -} // namespace SampleMfgSpecificCluster2 - } // namespace Clusters } // namespace app } // namespace chip diff --git a/zzz_generated/app-common/app-common/zap-generated/print-cluster.h b/zzz_generated/app-common/app-common/zap-generated/print-cluster.h index 3710086c58ea58..744b72c6cf8e65 100644 --- a/zzz_generated/app-common/app-common/zap-generated/print-cluster.h +++ b/zzz_generated/app-common/app-common/zap-generated/print-cluster.h @@ -764,19 +764,6 @@ #define CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER #endif -#if defined(ZCL_USING_SAMPLE_MFG_SPECIFIC_CLUSTER_SERVER) || defined(ZCL_USING_SAMPLE_MFG_SPECIFIC_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER { ZCL_SAMPLE_MFG_SPECIFIC_CLUSTER_ID, 64512, "Sample Mfg Specific Cluster" }, -#else -#define CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER -#endif - -#if defined(ZCL_USING_SAMPLE_MFG_SPECIFIC_CLUSTER_2_SERVER) || defined(ZCL_USING_SAMPLE_MFG_SPECIFIC_CLUSTER_2_CLIENT) -#define CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER_2 \ - { ZCL_SAMPLE_MFG_SPECIFIC_CLUSTER_2_ID, 64512, "Sample Mfg Specific Cluster 2" }, -#else -#define CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER_2 -#endif - #define CLUSTER_IDS_TO_NAMES \ CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_TEMP_CLUSTER \ @@ -888,8 +875,6 @@ CHIP_PRINTCLUSTER_APPLIANCE_STATISTICS_CLUSTER \ CHIP_PRINTCLUSTER_ELECTRICAL_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_BINDING_CLUSTER \ - CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER \ - CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER \ - CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER_2 + CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER #define MAX_CLUSTER_NAME_LENGTH 52 From 22255ab2297747145ebd2bd444a4a3d8f588f373 Mon Sep 17 00:00:00 2001 From: Taras Drozdovskyi Date: Fri, 26 Nov 2021 18:00:52 +0200 Subject: [PATCH 4/8] Fix some alerts founded the LGTM system (#11966) Signed-off-by: Taras Drozdovskyi --- scripts/build/builders/mbed.py | 4 ---- scripts/tools/memory/memdf/df.py | 3 ++- scripts/tools/memory/report_summary.py | 2 -- src/controller/python/chip-repl.py | 8 -------- src/controller/python/chip/ChipDeviceCtrl.py | 4 ++-- src/controller/python/chip/ChipReplStartup.py | 3 +-- src/controller/python/chip/clusters/Attribute.py | 4 ++-- src/controller/python/chip/clusters/Command.py | 2 +- src/controller/python/chip/interaction_model/__init__.py | 2 +- 9 files changed, 9 insertions(+), 23 deletions(-) diff --git a/scripts/build/builders/mbed.py b/scripts/build/builders/mbed.py index d0198ca0c032e1..5ba45d136eb174 100644 --- a/scripts/build/builders/mbed.py +++ b/scripts/build/builders/mbed.py @@ -12,12 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging import os -import platform -import glob import shlex -import pathlib from enum import Enum, auto from .builder import Builder diff --git a/scripts/tools/memory/memdf/df.py b/scripts/tools/memory/memdf/df.py index a91e44c669d94b..7345f41e0163a6 100644 --- a/scripts/tools/memory/memdf/df.py +++ b/scripts/tools/memory/memdf/df.py @@ -32,7 +32,8 @@ def __init__(self, *args, **kwargs): self[c] = pd.Series() types = {c: self.dtype[c] for c in self.columns if c in self.dtype} typed_columns = list(types.keys()) - self[typed_columns] = self.astype(types, copy=False)[typed_columns] + self[typed_columns] = self.astype(types, copy=False)[ + typed_columns] # lgtm [py/hash-unhashable-value] self.attrs['name'] = self.name diff --git a/scripts/tools/memory/report_summary.py b/scripts/tools/memory/report_summary.py index 3b21f6a88bb8ea..5a3d0cd4ded8d0 100755 --- a/scripts/tools/memory/report_summary.py +++ b/scripts/tools/memory/report_summary.py @@ -28,8 +28,6 @@ import sys -import numpy # type: ignore - import memdf.collect import memdf.report import memdf.select diff --git a/src/controller/python/chip-repl.py b/src/controller/python/chip-repl.py index 0f6798137e4d06..49adafca317bb8 100755 --- a/src/controller/python/chip-repl.py +++ b/src/controller/python/chip-repl.py @@ -18,15 +18,7 @@ # import IPython -import chip -import chip.logging -import coloredlogs -import logging from traitlets.config import Config -from rich import print -from rich import pretty -from rich import inspect -import builtins import argparse import sys diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 4ca3aa94bbd0da..e093442043bcc1 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -346,11 +346,11 @@ def DeviceAvailableCallback(device, err): # The callback might have been received synchronously (during self._ChipStack.Call()). # Check if the device is already set before waiting for the callback. - if returnDevice.value == None: + if returnDevice.value is None: with deviceAvailableCV: deviceAvailableCV.wait() - if returnDevice.value == None: + if returnDevice.value is None: raise self._ChipStack.ErrorToException(CHIP_ERROR_INTERNAL) return returnDevice diff --git a/src/controller/python/chip/ChipReplStartup.py b/src/controller/python/chip/ChipReplStartup.py index 865042e34315be..8d032b9b356bdc 100644 --- a/src/controller/python/chip/ChipReplStartup.py +++ b/src/controller/python/chip/ChipReplStartup.py @@ -8,7 +8,6 @@ import chip.clusters as Clusters import coloredlogs import chip.logging -import argparse import builtins @@ -41,7 +40,7 @@ def ReplInit(): def matterhelp(classOrObj=None): - if (classOrObj == None): + if (classOrObj is None): inspect(builtins.devCtrl, methods=True, help=True, private=False) else: inspect(classOrObj, methods=True, help=True, private=False) diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index d8f3cebe68bc0c..fd39b3ca987cc4 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -18,8 +18,8 @@ from asyncio.futures import Future import ctypes from dataclasses import dataclass -from typing import Type, Union, List, Any -from ctypes import CFUNCTYPE, c_char_p, c_size_t, c_void_p, c_uint32, c_uint16, py_object +from typing import Union, List, Any +from ctypes import CFUNCTYPE, c_char_p, c_size_t, c_uint32, c_uint16, py_object from .ClusterObjects import ClusterAttributeDescriptor import chip.exceptions diff --git a/src/controller/python/chip/clusters/Command.py b/src/controller/python/chip/clusters/Command.py index 179c4ed9959da1..e097184297b518 100644 --- a/src/controller/python/chip/clusters/Command.py +++ b/src/controller/python/chip/clusters/Command.py @@ -74,7 +74,7 @@ def _handleResponse(self, path: CommandPath, status: Status, response: bytes): self._future.set_result(None) else: # If a type hasn't been assigned, let's auto-deduce it. - if (self._expect_type == None): + if (self._expect_type is None): self._expect_type = FindCommandClusterObject(False, path) if self._expect_type: diff --git a/src/controller/python/chip/interaction_model/__init__.py b/src/controller/python/chip/interaction_model/__init__.py index 0ef2d861c18fc8..2b4bef9145a0e8 100644 --- a/src/controller/python/chip/interaction_model/__init__.py +++ b/src/controller/python/chip/interaction_model/__init__.py @@ -26,7 +26,7 @@ from chip.exceptions import ChipStackException -__all__ = ["IMDelegate", "Status", "InteractionModelError"] +__all__ = ["Status", "InteractionModelError"] class Status(enum.IntEnum): From aa7d1994cef35f4ce05ed79a2ee75f74f5a8ce1b Mon Sep 17 00:00:00 2001 From: doru91 Date: Fri, 26 Nov 2021 18:31:03 +0200 Subject: [PATCH 5/8] [K32W0] Fix third_party paths (#11480) Change from third_party/k32w_sdk/nxp/k32w/k32w0/ to third_party/nxp/k32w0_sdk Signed-off-by: Doru Gucea --- .github/workflows/examples-k32w.yaml | 2 +- build_overrides/k32w0_sdk.gni | 2 +- examples/build_overrides/k32w0_sdk.gni | 2 +- .../lighting-app/nxp/k32w/k32w0/README.md | 16 ++++++++-------- examples/lock-app/nxp/k32w/k32w0/README.md | 12 ++++++------ gn_build.sh | 8 ++++---- scripts/examples/k32w_example.sh | 6 +++--- scripts/examples/k32w_se_example.sh | 4 ++-- src/platform/nxp/k32w/k32w0/args.gni | 2 +- .../k32w_sdk/sdk_fixes/patch_k32w_sdk.sh | 19 ------------------- .../nxp/k32w/k32w0 => nxp/k32w0_sdk}/BUILD.gn | 0 .../k32w0_sdk}/k32w0_executable.gni | 0 .../k32w0 => nxp/k32w0_sdk}/k32w0_sdk.gni | 2 +- .../k32w0_sdk}/sdk_fixes/SecLib.h | 0 .../sdk_fixes/app_dual_mode_low_power.h | 0 .../sdk_fixes/app_dual_mode_switch.h | 0 .../k32w0_sdk}/sdk_fixes/gpio_pins.h | 0 .../nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh | 19 +++++++++++++++++++ .../k32w0_sdk}/sdk_fixes/pin_mux.c | 0 .../platforms/nxp/k32w/k32w0/BUILD.gn | 2 +- 20 files changed, 48 insertions(+), 48 deletions(-) delete mode 100755 third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh rename third_party/{k32w_sdk/nxp/k32w/k32w0 => nxp/k32w0_sdk}/BUILD.gn (100%) rename third_party/{k32w_sdk/nxp/k32w/k32w0 => nxp/k32w0_sdk}/k32w0_executable.gni (100%) rename third_party/{k32w_sdk/nxp/k32w/k32w0 => nxp/k32w0_sdk}/k32w0_sdk.gni (99%) rename third_party/{k32w_sdk => nxp/k32w0_sdk}/sdk_fixes/SecLib.h (100%) rename third_party/{k32w_sdk => nxp/k32w0_sdk}/sdk_fixes/app_dual_mode_low_power.h (100%) rename third_party/{k32w_sdk => nxp/k32w0_sdk}/sdk_fixes/app_dual_mode_switch.h (100%) rename third_party/{k32w_sdk => nxp/k32w0_sdk}/sdk_fixes/gpio_pins.h (100%) create mode 100755 third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh rename third_party/{k32w_sdk => nxp/k32w0_sdk}/sdk_fixes/pin_mux.c (100%) diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 76e0f5f7873545..ea16700d130f2d 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.5.28 + image: connectedhomeip/chip-build-k32w:0.5.29 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/build_overrides/k32w0_sdk.gni b/build_overrides/k32w0_sdk.gni index e8519a3ecafe91..fa487e9e7fb254 100644 --- a/build_overrides/k32w0_sdk.gni +++ b/build_overrides/k32w0_sdk.gni @@ -14,5 +14,5 @@ declare_args() { # Root directory for K32W SDK build files. - k32w0_sdk_build_root = "//third_party/k32w_sdk/nxp/k32w/k32w0" + k32w0_sdk_build_root = "//third_party/nxp/k32w0_sdk" } diff --git a/examples/build_overrides/k32w0_sdk.gni b/examples/build_overrides/k32w0_sdk.gni index 51a2821b4ab1fc..e77b63d1e02fa9 100644 --- a/examples/build_overrides/k32w0_sdk.gni +++ b/examples/build_overrides/k32w0_sdk.gni @@ -15,5 +15,5 @@ declare_args() { # Root directory for k32w SDK. k32w0_sdk_build_root = - "//third_party/connectedhomeip/third_party/k32w_sdk/nxp/k32w/k32w0" + "//third_party/connectedhomeip/third_party/nxp/k32w0_sdk" } diff --git a/examples/lighting-app/nxp/k32w/k32w0/README.md b/examples/lighting-app/nxp/k32w/k32w0/README.md index 20f767dbb008e7..e316f6af1f197c 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/README.md +++ b/examples/lighting-app/nxp/k32w/k32w0/README.md @@ -16,7 +16,7 @@ network.
-- [CHIP K32W0 Lighting Example Application](#chip-k32w-lighting-example-application) - +- [CHIP K32W061 Lighting Example Application](#chip-k32w-lighting-example-application) - - [Introduction](#introduction) - [Bluetooth LE Advertising](#bluetooth-le-advertising) - [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous) @@ -33,7 +33,7 @@ network. ![K32W061 DK6](../../../../platform/nxp/k32w/k32w0/doc/images/k32w-dk6.jpg) -The K32W0 lighting example application provides a working demonstration of a +The K32W061 lighting example application provides a working demonstration of a light bulb device, built using the Project CHIP codebase and the NXP K32W061 SDK. The example supports remote access (e.g.: using CHIP Tool from a mobile phone) and control of a light bulb over a low-power, 802.15.4 Thread network. It @@ -58,7 +58,7 @@ devices. ### SE051H Secure Element Deployment of this firmware configuration requires the K32W061 board setups -using the K32W0/JN5189 module board, SE051 Expansion board and Generic Expansion +using the K32W061 module board, SE051 Expansion board and Generic Expansion board as shown below: ![SE051H + K32W061 DK6](../../../../platform/nxp/k32w/k32w0/doc/images/k32w-se.jpg) @@ -173,13 +173,13 @@ distribution (the demo-application was compiled on Ubuntu 20.04). - with Secure Element ``` -user@ubuntu:~/Desktop/git/connectedhomeip$ export K32W061_SDK_ROOT=/home/user/Desktop/SDK_2_6_4_K32W061DK6/ -user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh +user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W061_SDK_ROOT=/home/user/Desktop/SDK_2_6_4_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lighting-app/nxp/k32w/k32w0 -user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/nxp/k32w/k32w0$ gn gen out/debug --args="k32w0_sdk_root=\"${K32W061_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"mbedtls\" chip_with_se05x=1" -user@ubuntu:~/Desktop/git/connectedhomeip/examples/lightin-app/nxp/k32w/k32w0$ ninja -C out/debug -user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/nxp/k32w/k32w0$ $K32W061_SDK_ROOT/tools/imagetool/sign_images.sh out/debug/ +user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/nxp/k32w/k32w0$ gn gen out/debug --args="k32w0_sdk_root=\"${NXP_K32W061_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"mbedtls\" chip_with_se05x=1" +user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/nxp/k32w/k32w0$ ninja -C out/debug +user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/nxp/k32w/k32w0$ $NXP_K32W061_SDK_ROOT/tools/imagetool/sign_images.sh out/debug/ ``` - without Secure element diff --git a/examples/lock-app/nxp/k32w/k32w0/README.md b/examples/lock-app/nxp/k32w/k32w0/README.md index 71e227e9057ee2..32225580ab9c4f 100644 --- a/examples/lock-app/nxp/k32w/k32w0/README.md +++ b/examples/lock-app/nxp/k32w/k32w0/README.md @@ -34,7 +34,7 @@ network. ![K32W061 DK6](../../../../platform/nxp/k32w/k32w0/doc/images/k32w-dk6.jpg) -The K32W0 lock example application provides a working demonstration of a +The K32W061 lock example application provides a working demonstration of a connected door lock device, built using the Project CHIP codebase and the NXP K32W061 SDK. The example supports remote access (e.g.: using CHIP Tool from a mobile phone) and control of a simulated door lock over a low-power, 802.15.4 @@ -59,7 +59,7 @@ devices. ### SE051H Secure Element Deployment of this firmware configuration requires the K32W061 board setups -using the K32W0/JN5189 module board, SE051 Expansion board and Generic Expansion +using the K32W061 module board, SE051 Expansion board and Generic Expansion board as shown below: ![SE051H + K32W061 DK6](../../../../platform/nxp/k32w/k32w0/doc/images/k32w-se.jpg) @@ -177,13 +177,13 @@ distribution (the demo-application was compiled on Ubuntu 20.04). - with Secure Element ``` -user@ubuntu:~/Desktop/git/connectedhomeip$ export K32W061_SDK_ROOT=/home/user/Desktop/SDK_2_6_4_K32W061DK6/ -user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh +user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W061_SDK_ROOT=/home/user/Desktop/SDK_2_6_4_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lock-app/nxp/k32w/k32w0/ -user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ gn gen out/debug --args="k32w0_sdk_root=\"${K32W061_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"mbedtls\" chip_with_se05x=1" +user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ gn gen out/debug --args="k32w0_sdk_root=\"${NXP_K32W061_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"mbedtls\" chip_with_se05x=1" user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ ninja -C out/debug -user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ $K32W061_SDK_ROOT/tools/imagetool/sign_images.sh out/debug/ +user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ $NXP_K32W061_SDK_ROOT/tools/imagetool/sign_images.sh out/debug/ ``` - without Secure element diff --git a/gn_build.sh b/gn_build.sh index 361382dbdcef7c..7fe16d8038ce25 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -155,14 +155,14 @@ fi # K32W SDK setup k32w_sdk_args="" -if [[ -d "$K32W061_SDK_ROOT" ]]; then - k32w_sdk_args+="k32w_sdk_root=\"$K32W061_SDK_ROOT\"" +if [[ -d "$NXP_K32W061_SDK_ROOT" ]]; then + k32w_sdk_args+="k32w_sdk_root=\"$NXP_K32W061_SDK_ROOT\"" extra_args+=" $k32w_sdk_args enable_k32w_builds=true" fi echo -if [[ ! -d "$K32W061_SDK_ROOT" ]]; then - echo "Hint: Set \$K32W061_SDK_ROOT to enable building for K32W061" +if [[ ! -d "$NXP_K32W061_SDK_ROOT" ]]; then + echo "Hint: Set \$NXP_K32W061_SDK_ROOT to enable building for K32W061" else echo 'To build the K32W lock sample as a standalone project': echo "(cd $CHIP_ROOT/examples/lock-app/k32w; gn gen out/debug --args='$k32w_sdk_args'; ninja -C out/debug)" diff --git a/scripts/examples/k32w_example.sh b/scripts/examples/k32w_example.sh index d9614e45026077..0a8fc8d92d1dbb 100755 --- a/scripts/examples/k32w_example.sh +++ b/scripts/examples/k32w_example.sh @@ -25,12 +25,12 @@ source "$(dirname "$0")/../../scripts/activate.sh" set -x env -"$(dirname "$0")"/../../third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh +"$(dirname "$0")"/../../third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh if [ -z "$3" ]; then - gn gen --check --fail-on-unused-args --root="$1" "$2" --args="k32w0_sdk_root=\"$K32W061_SDK_ROOT\" is_debug=false chip_with_low_power=1" + gn gen --check --fail-on-unused-args --root="$1" "$2" --args="k32w0_sdk_root=\"$NXP_K32W061_SDK_ROOT\" is_debug=false chip_with_low_power=1" else - gn gen --check --fail-on-unused-args --root="$1" "$2" --args="k32w0_sdk_root=\"$K32W061_SDK_ROOT\" is_debug=false chip_with_low_power=0" + gn gen --check --fail-on-unused-args --root="$1" "$2" --args="k32w0_sdk_root=\"$NXP_K32W061_SDK_ROOT\" is_debug=false chip_with_low_power=0" fi ninja -C "$2" diff --git a/scripts/examples/k32w_se_example.sh b/scripts/examples/k32w_se_example.sh index 98909d90cf296b..27c0b5a29fe48c 100755 --- a/scripts/examples/k32w_se_example.sh +++ b/scripts/examples/k32w_se_example.sh @@ -25,7 +25,7 @@ source "$(dirname "$0")/../../scripts/activate.sh" set -x env -"$(dirname "$0")"/../../third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh +"$(dirname "$0")"/../../third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh -gn gen --check --fail-on-unused-args --root="$1" "$2" --args="k32w0_sdk_root=\"$K32W061_SDK_ROOT\" is_debug=false chip_crypto=\"mbedtls\" chip_with_se05x=1" +gn gen --check --fail-on-unused-args --root="$1" "$2" --args="k32w0_sdk_root=\"$NXP_K32W061_SDK_ROOT\" is_debug=false chip_crypto=\"mbedtls\" chip_with_se05x=1" ninja -C "$2" diff --git a/src/platform/nxp/k32w/k32w0/args.gni b/src/platform/nxp/k32w/k32w0/args.gni index 74d4b41b49c486..f0d5257522aa3e 100644 --- a/src/platform/nxp/k32w/k32w0/args.gni +++ b/src/platform/nxp/k32w/k32w0/args.gni @@ -28,7 +28,7 @@ chip_build_tests = false chip_mdns = "platform" -mbedtls_target = "${chip_root}/third_party/k32w_sdk/nxp/k32w/k32w0:mbedtls" +mbedtls_target = "${chip_root}/third_party/nxp/k32w0_sdk:mbedtls" openthread_external_mbedtls = mbedtls_target openthread_project_core_config_file = "OpenThreadConfig.h" diff --git a/third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh b/third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh deleted file mode 100755 index b9258f12af134a..00000000000000 --- a/third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -if [[ ! -d $K32W061_SDK_ROOT ]]; then - echo "K32W061_SDK_ROOT is not set" - exit 1 -fi - -cp ./third_party/k32w_sdk/sdk_fixes/gpio_pins.h "$K32W061_SDK_ROOT"/boards/k32w061dk6/wireless_examples/openthread/reed/bm/ -cp ./third_party/k32w_sdk/sdk_fixes/pin_mux.c "$K32W061_SDK_ROOT"/boards/k32w061dk6/wireless_examples/openthread/enablement/ - -#TODO internal: https://jira.sw.nxp.com/browse/MCB-2678 -cp ./third_party/k32w_sdk/sdk_fixes/SecLib.h "$K32W061_SDK_ROOT"/middleware/wireless/framework/SecLib/ - -# TODO internal: https://jira.sw.nxp.com/browse/MCB-2675 -cp -r ./third_party/k32w_sdk/sdk_fixes/app_dual_mode_low_power.h "$K32W061_SDK_ROOT"/boards/k32w061dk6/wireless_examples/hybrid/ble_ot/lped_ble_wuart/ble_802_15_4_common/ -cp -r ./third_party/k32w_sdk/sdk_fixes/app_dual_mode_switch.h "$K32W061_SDK_ROOT"/boards/k32w061dk6/wireless_examples/hybrid/ble_ot/lped_ble_wuart/ble_802_15_4_common/ - -echo "K32W SDK MR3 QP1 was patched!" -exit 0 diff --git a/third_party/k32w_sdk/nxp/k32w/k32w0/BUILD.gn b/third_party/nxp/k32w0_sdk/BUILD.gn similarity index 100% rename from third_party/k32w_sdk/nxp/k32w/k32w0/BUILD.gn rename to third_party/nxp/k32w0_sdk/BUILD.gn diff --git a/third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_executable.gni b/third_party/nxp/k32w0_sdk/k32w0_executable.gni similarity index 100% rename from third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_executable.gni rename to third_party/nxp/k32w0_sdk/k32w0_executable.gni diff --git a/third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni similarity index 99% rename from third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni rename to third_party/nxp/k32w0_sdk/k32w0_sdk.gni index b1ecebc4efd75e..e6e587e522616c 100644 --- a/third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni +++ b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni @@ -20,7 +20,7 @@ import("${chip_root}/src/platform/nxp/k32w/k32w0/args.gni") declare_args() { # Location of the k32w0 SDK. - k32w0_sdk_root = getenv("K32W_SDK_ROOT") + k32w0_sdk_root = getenv("NXP_K32W061_SDK_ROOT") chip_with_OM15082 = 0 chip_with_ot_cli = 0 chip_with_low_power = 0 diff --git a/third_party/k32w_sdk/sdk_fixes/SecLib.h b/third_party/nxp/k32w0_sdk/sdk_fixes/SecLib.h similarity index 100% rename from third_party/k32w_sdk/sdk_fixes/SecLib.h rename to third_party/nxp/k32w0_sdk/sdk_fixes/SecLib.h diff --git a/third_party/k32w_sdk/sdk_fixes/app_dual_mode_low_power.h b/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power.h similarity index 100% rename from third_party/k32w_sdk/sdk_fixes/app_dual_mode_low_power.h rename to third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power.h diff --git a/third_party/k32w_sdk/sdk_fixes/app_dual_mode_switch.h b/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch.h similarity index 100% rename from third_party/k32w_sdk/sdk_fixes/app_dual_mode_switch.h rename to third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch.h diff --git a/third_party/k32w_sdk/sdk_fixes/gpio_pins.h b/third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins.h similarity index 100% rename from third_party/k32w_sdk/sdk_fixes/gpio_pins.h rename to third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins.h diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh b/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh new file mode 100755 index 00000000000000..1787b1ac5953c0 --- /dev/null +++ b/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +if [[ ! -d $NXP_K32W061_SDK_ROOT ]]; then + echo "NXP_K32W061_SDK_ROOT is not set" + exit 1 +fi + +cp ./third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins.h "$NXP_K32W061_SDK_ROOT"/boards/k32w061dk6/wireless_examples/openthread/reed/bm/ +cp ./third_party/nxp/k32w0_sdk/sdk_fixes/pin_mux.c "$NXP_K32W061_SDK_ROOT"/boards/k32w061dk6/wireless_examples/openthread/enablement/ + +#TODO internal: https://jira.sw.nxp.com/browse/MCB-2678 +cp ./third_party/nxp/k32w0_sdk/sdk_fixes/SecLib.h "$NXP_K32W061_SDK_ROOT"/middleware/wireless/framework/SecLib/ + +# TODO internal: https://jira.sw.nxp.com/browse/MCB-2675 +cp -r ./third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power.h "$NXP_K32W061_SDK_ROOT"/boards/k32w061dk6/wireless_examples/hybrid/ble_ot/lped_ble_wuart/ble_802_15_4_common/ +cp -r ./third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch.h "$NXP_K32W061_SDK_ROOT"/boards/k32w061dk6/wireless_examples/hybrid/ble_ot/lped_ble_wuart/ble_802_15_4_common/ + +echo "K32W SDK MR3 QP1 was patched!" +exit 0 diff --git a/third_party/k32w_sdk/sdk_fixes/pin_mux.c b/third_party/nxp/k32w0_sdk/sdk_fixes/pin_mux.c similarity index 100% rename from third_party/k32w_sdk/sdk_fixes/pin_mux.c rename to third_party/nxp/k32w0_sdk/sdk_fixes/pin_mux.c diff --git a/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn b/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn index 746b0908e8794f..f78dda627c5f47 100644 --- a/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn +++ b/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/k32w0_sdk.gni") import("//build_overrides/openthread.gni") -import("${chip_root}/third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni") +import("${chip_root}/third_party/nxp/k32w0_sdk/k32w0_sdk.gni") openthread_nxp_root = "${chip_root}/third_party/openthread/ot-nxp" From 65f447518853c475c787176c633086dd4b28815a Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 26 Nov 2021 11:35:46 -0500 Subject: [PATCH 6/8] Revert "Fix some alerts founded the LGTM system (#11966)" (#12295) This reverts commit 22255ab2297747145ebd2bd444a4a3d8f588f373. --- scripts/build/builders/mbed.py | 4 ++++ scripts/tools/memory/memdf/df.py | 3 +-- scripts/tools/memory/report_summary.py | 2 ++ src/controller/python/chip-repl.py | 8 ++++++++ src/controller/python/chip/ChipDeviceCtrl.py | 4 ++-- src/controller/python/chip/ChipReplStartup.py | 3 ++- src/controller/python/chip/clusters/Attribute.py | 4 ++-- src/controller/python/chip/clusters/Command.py | 2 +- src/controller/python/chip/interaction_model/__init__.py | 2 +- 9 files changed, 23 insertions(+), 9 deletions(-) diff --git a/scripts/build/builders/mbed.py b/scripts/build/builders/mbed.py index 5ba45d136eb174..d0198ca0c032e1 100644 --- a/scripts/build/builders/mbed.py +++ b/scripts/build/builders/mbed.py @@ -12,8 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging import os +import platform +import glob import shlex +import pathlib from enum import Enum, auto from .builder import Builder diff --git a/scripts/tools/memory/memdf/df.py b/scripts/tools/memory/memdf/df.py index 7345f41e0163a6..a91e44c669d94b 100644 --- a/scripts/tools/memory/memdf/df.py +++ b/scripts/tools/memory/memdf/df.py @@ -32,8 +32,7 @@ def __init__(self, *args, **kwargs): self[c] = pd.Series() types = {c: self.dtype[c] for c in self.columns if c in self.dtype} typed_columns = list(types.keys()) - self[typed_columns] = self.astype(types, copy=False)[ - typed_columns] # lgtm [py/hash-unhashable-value] + self[typed_columns] = self.astype(types, copy=False)[typed_columns] self.attrs['name'] = self.name diff --git a/scripts/tools/memory/report_summary.py b/scripts/tools/memory/report_summary.py index 5a3d0cd4ded8d0..3b21f6a88bb8ea 100755 --- a/scripts/tools/memory/report_summary.py +++ b/scripts/tools/memory/report_summary.py @@ -28,6 +28,8 @@ import sys +import numpy # type: ignore + import memdf.collect import memdf.report import memdf.select diff --git a/src/controller/python/chip-repl.py b/src/controller/python/chip-repl.py index 49adafca317bb8..0f6798137e4d06 100755 --- a/src/controller/python/chip-repl.py +++ b/src/controller/python/chip-repl.py @@ -18,7 +18,15 @@ # import IPython +import chip +import chip.logging +import coloredlogs +import logging from traitlets.config import Config +from rich import print +from rich import pretty +from rich import inspect +import builtins import argparse import sys diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index e093442043bcc1..4ca3aa94bbd0da 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -346,11 +346,11 @@ def DeviceAvailableCallback(device, err): # The callback might have been received synchronously (during self._ChipStack.Call()). # Check if the device is already set before waiting for the callback. - if returnDevice.value is None: + if returnDevice.value == None: with deviceAvailableCV: deviceAvailableCV.wait() - if returnDevice.value is None: + if returnDevice.value == None: raise self._ChipStack.ErrorToException(CHIP_ERROR_INTERNAL) return returnDevice diff --git a/src/controller/python/chip/ChipReplStartup.py b/src/controller/python/chip/ChipReplStartup.py index 8d032b9b356bdc..865042e34315be 100644 --- a/src/controller/python/chip/ChipReplStartup.py +++ b/src/controller/python/chip/ChipReplStartup.py @@ -8,6 +8,7 @@ import chip.clusters as Clusters import coloredlogs import chip.logging +import argparse import builtins @@ -40,7 +41,7 @@ def ReplInit(): def matterhelp(classOrObj=None): - if (classOrObj is None): + if (classOrObj == None): inspect(builtins.devCtrl, methods=True, help=True, private=False) else: inspect(classOrObj, methods=True, help=True, private=False) diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index fd39b3ca987cc4..d8f3cebe68bc0c 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -18,8 +18,8 @@ from asyncio.futures import Future import ctypes from dataclasses import dataclass -from typing import Union, List, Any -from ctypes import CFUNCTYPE, c_char_p, c_size_t, c_uint32, c_uint16, py_object +from typing import Type, Union, List, Any +from ctypes import CFUNCTYPE, c_char_p, c_size_t, c_void_p, c_uint32, c_uint16, py_object from .ClusterObjects import ClusterAttributeDescriptor import chip.exceptions diff --git a/src/controller/python/chip/clusters/Command.py b/src/controller/python/chip/clusters/Command.py index e097184297b518..179c4ed9959da1 100644 --- a/src/controller/python/chip/clusters/Command.py +++ b/src/controller/python/chip/clusters/Command.py @@ -74,7 +74,7 @@ def _handleResponse(self, path: CommandPath, status: Status, response: bytes): self._future.set_result(None) else: # If a type hasn't been assigned, let's auto-deduce it. - if (self._expect_type is None): + if (self._expect_type == None): self._expect_type = FindCommandClusterObject(False, path) if self._expect_type: diff --git a/src/controller/python/chip/interaction_model/__init__.py b/src/controller/python/chip/interaction_model/__init__.py index 2b4bef9145a0e8..0ef2d861c18fc8 100644 --- a/src/controller/python/chip/interaction_model/__init__.py +++ b/src/controller/python/chip/interaction_model/__init__.py @@ -26,7 +26,7 @@ from chip.exceptions import ChipStackException -__all__ = ["Status", "InteractionModelError"] +__all__ = ["IMDelegate", "Status", "InteractionModelError"] class Status(enum.IntEnum): From 8a2fd0dfd65eaf8403811ed821a5617adf957557 Mon Sep 17 00:00:00 2001 From: rgoliver Date: Fri, 26 Nov 2021 14:56:34 -0500 Subject: [PATCH 7/8] RPC: Refactor RPC examples for better code reuse, and add RPCs to EFR lock app (#11633) * RPC: Move Rpc.cpp to platform Reduce code duplication by moving the Rpc.cpp file to the platform. This greatly reduces code required to add rpcs to examples. * RPC: Add RPCs to EFR lock app --- .../esp32/main/CMakeLists.txt | 7 + examples/all-clusters-app/esp32/main/Rpc.cpp | 352 ------------------ .../pigweed/protos/device_service.proto | 2 +- examples/lighting-app/efr32/BUILD.gn | 21 +- examples/lighting-app/efr32/src/Rpc.cpp | 92 ----- .../lighting-app/nrfconnect/CMakeLists.txt | 9 +- examples/lighting-app/nrfconnect/main/Rpc.cpp | 102 ----- .../nrfconnect/main/include/AppTask.h | 9 +- .../lighting-app/nrfconnect/main/main.cpp | 5 +- examples/lock-app/efr32/BUILD.gn | 45 +++ examples/lock-app/efr32/src/main.cpp | 8 + examples/lock-app/efr32/with_pw_rpc.gni | 5 +- examples/lock-app/esp32/main/CMakeLists.txt | 7 + examples/lock-app/esp32/main/Rpc.cpp | 99 ----- examples/platform/efr32/Rpc.cpp | 149 ++++++++ .../efr32/include => platform/efr32}/Rpc.h | 0 examples/platform/esp32/Rpc.cpp | 167 +++++++++ .../main/include => platform/esp32}/Rpc.h | 0 examples/platform/nrfconnect/Rpc.cpp | 152 ++++++++ .../include => platform/nrfconnect}/Rpc.h | 0 scripts/build/build/targets.py | 2 +- .../testdata/all_targets_except_host.txt | 1 + .../build/testdata/build_all_except_host.txt | 6 + .../glob_star_targets_except_host.txt | 1 + 24 files changed, 578 insertions(+), 663 deletions(-) delete mode 100644 examples/all-clusters-app/esp32/main/Rpc.cpp delete mode 100644 examples/lighting-app/efr32/src/Rpc.cpp delete mode 100644 examples/lighting-app/nrfconnect/main/Rpc.cpp delete mode 100644 examples/lock-app/esp32/main/Rpc.cpp create mode 100644 examples/platform/efr32/Rpc.cpp rename examples/{lighting-app/efr32/include => platform/efr32}/Rpc.h (100%) create mode 100644 examples/platform/esp32/Rpc.cpp rename examples/{all-clusters-app/esp32/main/include => platform/esp32}/Rpc.h (100%) create mode 100644 examples/platform/nrfconnect/Rpc.cpp rename examples/{lighting-app/nrfconnect/main/include => platform/nrfconnect}/Rpc.h (100%) diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 0b4520dca3d90d..29430a67c079a6 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -220,4 +220,11 @@ target_link_options(${COMPONENT_LIB} "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" ) +target_compile_options(${COMPONENT_LIB} PRIVATE + "-DPW_RPC_ATTRIBUTE_SERVICE=1" + "-DPW_RPC_BUTTON_SERVICE=1" + "-DPW_RPC_DEVICE_SERVICE=1" + "-DPW_RPC_LIGHTING_SERVICE=1" + "-DPW_RPC_LOCKING_SERVICE=1") + endif (CONFIG_ENABLE_PW_RPC) diff --git a/examples/all-clusters-app/esp32/main/Rpc.cpp b/examples/all-clusters-app/esp32/main/Rpc.cpp deleted file mode 100644 index 0de247455fcd61..00000000000000 --- a/examples/all-clusters-app/esp32/main/Rpc.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sdkconfig.h" -#if CONFIG_ENABLE_PW_RPC -#include "PigweedLoggerMutex.h" -#include "RpcService.h" -#include "esp_log.h" -#include "freertos/FreeRTOS.h" -#include "freertos/event_groups.h" -#include "freertos/semphr.h" -#include "freertos/task.h" -#include "pw_log/log.h" -#include "pw_rpc/server.h" -#include "pw_sys_io/sys_io.h" -#include "rpc_services/Attributes.h" -#include "rpc_services/Button.h" -#include "rpc_services/Device.h" -#include "rpc_services/Lighting.h" -#include "rpc_services/Locking.h" - -#include - -#include "ScreenManager.h" -#include "esp_event.h" -#include "esp_log.h" -#include "esp_netif.h" -#include "esp_system.h" -#include "esp_wifi.h" -#include "freertos/FreeRTOS.h" -#include "freertos/semphr.h" -#include "freertos/timers.h" -#include "pw_containers/flat_map.h" -#include "pw_status/status.h" -#include "pw_status/try.h" -#include "pw_trace_tokenized/trace_rpc_service_nanopb.h" -#include "wifi_service/wifi_service.rpc.pb.h" -#include - -#include "WiFiProvisioning.h" - -#include "ESP32Utils.h" - -static const char * TAG = "RPC"; - -// Define trace time for pw_trace -PW_TRACE_TIME_TYPE pw_trace_GetTraceTime() -{ - return (PW_TRACE_TIME_TYPE) chip::System::SystemClock().GetMonotonicMicroseconds64().count(); -} -// Microsecond time source -size_t pw_trace_GetTraceTimeTicksPerSecond() -{ - return 1000000; -} - -namespace chip { -namespace rpc { -namespace { - -constexpr pw::containers::FlatMap kChannelToFreqMap({ { - { 1, 2412 }, { 2, 2417 }, { 3, 2422 }, { 4, 2427 }, { 5, 2432 }, { 6, 2437 }, { 7, 2442 }, { 8, 2447 }, - { 9, 2452 }, { 10, 2457 }, { 11, 2462 }, { 12, 2467 }, { 13, 2472 }, { 14, 2484 }, { 32, 5160 }, { 34, 5170 }, - { 36, 5180 }, { 38, 5190 }, { 40, 5200 }, { 42, 5210 }, { 44, 5220 }, { 46, 5230 }, { 48, 5240 }, { 50, 5250 }, - { 52, 5260 }, { 54, 5270 }, { 56, 5280 }, { 58, 5290 }, { 60, 5300 }, { 62, 5310 }, { 64, 5320 }, { 68, 5340 }, - { 96, 5480 }, { 100, 5500 }, { 102, 5510 }, { 104, 5520 }, { 106, 5530 }, { 108, 5540 }, { 110, 5550 }, { 112, 5560 }, - { 114, 5570 }, { 116, 5580 }, { 118, 5590 }, { 120, 5600 }, { 122, 5610 }, { 124, 5620 }, { 126, 5630 }, { 128, 5640 }, - { 132, 5660 }, { 134, 5670 }, { 136, 5680 }, { 138, 5690 }, { 140, 5700 }, { 142, 5710 }, { 144, 5720 }, { 149, 5745 }, - { 151, 5755 }, { 153, 5765 }, { 155, 5775 }, { 157, 5785 }, { 159, 5795 }, { 161, 5805 }, { 165, 5825 }, { 169, 5845 }, - { 173, 5865 }, { 183, 4915 }, { 184, 4920 }, { 185, 4925 }, { 187, 4935 }, { 188, 4940 }, { 189, 4945 }, { 192, 4960 }, - { 196, 4980 }, -} }); - -// These are potentially large objects for the scan results. -constexpr size_t kScanRecordsMax = sizeof(chip_rpc_ScanResults().aps) / sizeof(chip_rpc_ScanResult); -chip_rpc_ScanResults out_scan_records; -wifi_ap_record_t scan_records[kScanRecordsMax]; - -class Esp32Button final : public Button -{ -public: - pw::Status Event(ServerContext &, const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override - { -#if CONFIG_DEVICE_TYPE_M5STACK - if (request.pushed) - { - ScreenManager::ButtonPressed(1 + request.idx); - } - return pw::OkStatus(); -#else // CONFIG_DEVICE_TYPE_M5STACK - return pw::Status::Unimplemented(); -#endif // CONFIG_DEVICE_TYPE_M5STACK - } -}; - -class Esp32Device final : public Device -{ -public: - pw::Status Reboot(ServerContext & ctx, const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override - { - mRebootTimer = xTimerCreateStatic("Reboot", kRebootTimerPeriodTicks, false, nullptr, RebootHandler, &mRebootTimerBuffer); - xTimerStart(mRebootTimer, 0); - return pw::OkStatus(); - } - -private: - static constexpr TickType_t kRebootTimerPeriodTicks = 1000; - TimerHandle_t mRebootTimer; - StaticTimer_t mRebootTimerBuffer; - - static void RebootHandler(TimerHandle_t) { esp_restart(); } -}; - -class Wifi final : public generated::Wifi -{ -public: - pw::Status GetChannel(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_Channel & response) - { - uint8_t channel = 0; - wifi_second_chan_t second; - PW_TRY(EspToPwStatus(esp_wifi_get_channel(&channel, &second))); - response.channel = channel; - return pw::OkStatus(); - } - - pw::Status GetSsid(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_Ssid & response) - { - wifi_config_t config; - PW_TRY(EspToPwStatus(esp_wifi_get_config(WIFI_IF_STA, &config))); - size_t size = std::min(sizeof(response.ssid.bytes), sizeof(config.sta.ssid)); - memcpy(response.ssid.bytes, config.sta.ssid, size); - response.ssid.size = size; - return pw::OkStatus(); - } - - pw::Status GetState(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_State & response) - { - wifi_ap_record_t ap_info; - esp_err_t err = esp_wifi_sta_get_ap_info(&ap_info); - PW_TRY(EspToPwStatus(err)); - response.connected = (err != ESP_ERR_WIFI_NOT_CONNECT); - return pw::OkStatus(); - } - - pw::Status GetMacAddress(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_MacAddress & response) - { - uint8_t mac[6]; - PW_TRY(EspToPwStatus(esp_wifi_get_mac(WIFI_IF_STA, mac))); - snprintf(response.mac_address, sizeof(response.mac_address), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], - mac[3], mac[4], mac[5]); - return pw::OkStatus(); - } - - pw::Status GetWiFiInterface(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_WiFiInterface & response) - { - wifi_ap_record_t ap_info; - PW_TRY(EspToPwStatus(esp_wifi_sta_get_ap_info(&ap_info))); - snprintf(response.interface, sizeof(response.interface), "STA"); - return pw::OkStatus(); - } - - pw::Status GetIP4Address(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_IP4Address & response) - { - esp_netif_ip_info_t ip_info; - PW_TRY(EspToPwStatus(esp_netif_get_ip_info(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"), &ip_info))); - snprintf(response.address, sizeof(response.address), IPSTR, IP2STR(&ip_info.ip)); - return pw::OkStatus(); - } - - pw::Status GetIP6Address(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_IP6Address & response) - { - esp_ip6_addr_t ip6; - PW_TRY(EspToPwStatus(esp_netif_get_ip6_linklocal(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"), &ip6))); - snprintf(response.address, sizeof(response.address), IPV6STR, IPV62STR(ip6)); - return pw::OkStatus(); - } - - // NOTE: Currently this is blocking, it can be made non-blocking if needed - // but would require another worker thread to handle the scanning. - void StartScan(ServerContext &, const chip_rpc_ScanConfig & request, ServerWriter & writer) - { - wifi_scan_config_t scan_config; - if (request.ssid_count != 0) - { - scan_config.ssid = const_cast(reinterpret_cast(request.ssid[0].bytes)); - } - if (request.bssid_count != 0) - { - scan_config.bssid = const_cast(reinterpret_cast(request.bssid[0].bytes)); - } - scan_config.channel = request.channel; - scan_config.show_hidden = request.show_hidden; - scan_config.scan_type = static_cast(request.active_scan); - if (request.active_scan) - { - scan_config.scan_time.active.min = request.scan_time_min_ms; - scan_config.scan_time.active.max = request.scan_time_max_ms; - } - else - { - scan_config.scan_time.passive = request.scan_time_min_ms; - } - - auto err = esp_wifi_scan_start(&scan_config, true /* block */); - if (ESP_OK != err) - { - ESP_LOGI(TAG, "Error starting scan: %d", err); - return; - } - - // Output scan results - uint16_t num_scan_records = kScanRecordsMax; - err = esp_wifi_scan_get_ap_records(&num_scan_records, scan_records); - if (ESP_OK != err) - { - ESP_LOGI(TAG, "Error getting scanned APs: %d", err); - num_scan_records = 0; - } - ESP_LOGI(TAG, "%d", num_scan_records); - out_scan_records.aps_count = num_scan_records; - - for (size_t i = 0; i < num_scan_records; ++i) - { - out_scan_records.aps[i].ssid.size = std::min(sizeof(scan_records[i].ssid), sizeof(out_scan_records.aps[i].ssid.bytes)); - memcpy(out_scan_records.aps[i].ssid.bytes, scan_records[i].ssid, out_scan_records.aps[i].ssid.size); - out_scan_records.aps[i].bssid.size = - std::min(sizeof(scan_records[i].bssid), sizeof(out_scan_records.aps[i].bssid.bytes)); - memcpy(out_scan_records.aps[i].bssid.bytes, scan_records[i].bssid, out_scan_records.aps[i].bssid.size); - out_scan_records.aps[i].security_type = static_cast(scan_records[i].authmode); - out_scan_records.aps[i].channel = scan_records[i].primary; - auto found_channel = kChannelToFreqMap.find(scan_records[i].primary); - out_scan_records.aps[i].frequency = (found_channel ? found_channel->second : 0); - out_scan_records.aps[i].signal = scan_records[i].rssi; - } - writer.Write(out_scan_records); - writer.Finish(); - } - - pw::Status StopScan(ServerContext &, const pw_protobuf_Empty & request, pw_protobuf_Empty & response) - { - esp_wifi_scan_stop(); - return pw::OkStatus(); - } - - pw::Status Connect(ServerContext &, const chip_rpc_ConnectionData & request, chip_rpc_ConnectionResult & response) - { - char ssid[sizeof(wifi_config_t().sta.ssid)]; - char password[sizeof(wifi_config_t().sta.password)]; - size_t ssid_size = std::min(sizeof(ssid) - 1, static_cast(request.ssid.size)); - memcpy(ssid, request.ssid.bytes, ssid_size); - ssid[ssid_size] = '\0'; - size_t password_size = std::min(sizeof(password) - 1, static_cast(request.secret.size)); - memcpy(password, request.secret.bytes, password_size); - password[password_size] = '\0'; - return SetWiFiStationProvisioning(ssid, password) == CHIP_NO_ERROR ? pw::OkStatus() : pw::Status::Unknown(); - } - - pw::Status Disconnect(ServerContext &, const pw_protobuf_Empty & request, pw_protobuf_Empty & response) - { - chip::DeviceLayer::ConnectivityMgr().ClearWiFiStationProvision(); - chip::DeviceLayer::ConnectivityMgr().SetWiFiStationMode(chip::DeviceLayer::ConnectivityManager::kWiFiStationMode_Disabled); - return pw::OkStatus(); - } - -private: - static constexpr pw::Status EspToPwStatus(esp_err_t err) - { - switch (err) - { - case ESP_OK: - return pw::OkStatus(); - case ESP_ERR_WIFI_NOT_INIT: - return pw::Status::FailedPrecondition(); - case ESP_ERR_INVALID_ARG: - return pw::Status::InvalidArgument(); - case ESP_ERR_ESP_NETIF_INVALID_PARAMS: - return pw::Status::InvalidArgument(); - case ESP_ERR_WIFI_IF: - return pw::Status::NotFound(); - case ESP_ERR_WIFI_NOT_CONNECT: - return pw::Status::FailedPrecondition(); - case ESP_ERR_WIFI_NOT_STARTED: - return pw::Status::FailedPrecondition(); - case ESP_ERR_WIFI_CONN: - return pw::Status::Internal(); - case ESP_FAIL: - return pw::Status::Internal(); - default: - return pw::Status::Unknown(); - } - } -}; - -constexpr size_t kRpcStackSizeBytes = (8 * 1024); -constexpr uint8_t kRpcTaskPriority = 5; - -TaskHandle_t rpcTaskHandle; - -Attributes attributes_service; -Esp32Button button_service; -Esp32Device device_service; -Lighting lighting_service; -Locking locking_service; -Wifi wifi_service; -pw::trace::TraceService trace_service; - -void RegisterServices(pw::rpc::Server & server) -{ - server.RegisterService(attributes_service); - server.RegisterService(button_service); - server.RegisterService(device_service); - server.RegisterService(lighting_service); - server.RegisterService(locking_service); - server.RegisterService(wifi_service); - server.RegisterService(trace_service); - PW_TRACE_SET_ENABLED(true); -} - -void RunRpcService(void *) -{ - Start(RegisterServices, &logger_mutex); -} - -} // namespace - -void Init() -{ - PigweedLogger::init(); - - ESP_LOGI(TAG, "----------- esp32-rpc-service starting -----------"); - - xTaskCreate(RunRpcService, "RPC", kRpcStackSizeBytes / sizeof(StackType_t), nullptr, kRpcTaskPriority, &rpcTaskHandle); -} - -} // namespace rpc -} // namespace chip - -#endif // CONFIG_ENABLE_PW_RPC diff --git a/examples/common/pigweed/protos/device_service.proto b/examples/common/pigweed/protos/device_service.proto index fdca9667a1daf9..1e9f3281ffb99d 100644 --- a/examples/common/pigweed/protos/device_service.proto +++ b/examples/common/pigweed/protos/device_service.proto @@ -20,7 +20,7 @@ message DeviceInfo { message FabricInfo { uint32 fabric_id = 1; - uint32 node_id = 2; + uint64 node_id = 2; } message DeviceState { diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index dd93106fd3636b..b7d2e00c3b5ae1 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -22,7 +22,6 @@ import("${efr32_sdk_build_root}/efr32_executable.gni") import("${efr32_sdk_build_root}/efr32_sdk.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") - if (chip_enable_pw_rpc) { import("//build_overrides/pigweed.gni") import("$dir_pw_build/target_types.gni") @@ -71,10 +70,7 @@ efr32_sdk("sdk") { ] if (chip_enable_pw_rpc) { - defines += [ - "HAL_VCOM_ENABLE=1", - "PW_RPC_ENABLED", - ] + defines += [ "HAL_VCOM_ENABLE=1" ] } } @@ -114,21 +110,24 @@ efr32_executable("lighting_app") { } if (chip_enable_pw_rpc) { - defines += [ "PW_RPC_ENABLED" ] + defines += [ + "PW_RPC_ENABLED", + "PW_RPC_ATTRIBUTE_SERVICE=1", + "PW_RPC_BUTTON_SERVICE=1", + "PW_RPC_DEVICE_SERVICE=1", + "PW_RPC_LIGHTING_SERVICE=1", + ] + sources += [ "${chip_root}/examples/common/pigweed/RpcService.cpp", "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", "${examples_plat_dir}/PigweedLogger.cpp", - "src/Rpc.cpp", + "${examples_plat_dir}/Rpc.cpp", ] deps += [ - "$dir_pw_assert", - "$dir_pw_checksum", "$dir_pw_hdlc:rpc_channel_output", - "$dir_pw_stream", "$dir_pw_stream:sys_io_stream", - "$dir_pw_sys_io", "${chip_root}/config/efr32/lib/pw_rpc:pw_rpc", "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", diff --git a/examples/lighting-app/efr32/src/Rpc.cpp b/examples/lighting-app/efr32/src/Rpc.cpp deleted file mode 100644 index d7969972530dc1..00000000000000 --- a/examples/lighting-app/efr32/src/Rpc.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "AppTask.h" -#include "FreeRTOS.h" -#include "PigweedLoggerMutex.h" -#include "pigweed/RpcService.h" -#include "pigweed/rpc_services/Attributes.h" -#include "pigweed/rpc_services/Button.h" -#include "pigweed/rpc_services/Device.h" -#include "pigweed/rpc_services/Lighting.h" -#include "pw_sys_io_efr32/init.h" -#include "task.h" - -namespace chip { -namespace rpc { - -class Efr32Button final : public Button -{ -public: - pw::Status Event(ServerContext &, const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override - { - GetAppTask().ButtonEventHandler(SL_SIMPLE_BUTTON_INSTANCE(request.idx) /* PB 0 or PB 1 */, request.pushed); - return pw::OkStatus(); - } -}; - -class Efr32Device final : public Device -{ -public: - pw::Status Reboot(ServerContext & ctx, const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override - { - NVIC_SystemReset(); - // WILL NOT RETURN - return pw::OkStatus(); - } -}; - -namespace { - -#define RPC_TASK_STACK_SIZE 4096 -#define RPC_TASK_PRIORITY 1 -static TaskHandle_t sRpcTaskHandle; -StaticTask_t sRpcTaskBuffer; -StackType_t sRpcTaskStack[RPC_TASK_STACK_SIZE]; - -Attributes attributes_service; -Efr32Button button_service; -Efr32Device device_service; -Lighting lighting_service; - -void RegisterServices(pw::rpc::Server & server) -{ - server.RegisterService(attributes_service); - server.RegisterService(button_service); - server.RegisterService(device_service); - server.RegisterService(lighting_service); -} - -} // namespace - -void RunRpcService(void *) -{ - Start(RegisterServices, &logger_mutex); -} - -void Init() -{ - pw_sys_io_Init(); - - // Start App task. - sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", ArraySize(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, - sRpcTaskStack, &sRpcTaskBuffer); -} - -} // namespace rpc -} // namespace chip diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 698c0bd65621de..6663936334d4a1 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -160,9 +160,9 @@ pw_proto_library(lighting_service ) target_sources(app PRIVATE - main/Rpc.cpp ../../common/pigweed/RpcService.cpp ../../common/pigweed/nrfconnect/PigweedLoggerMutex.cpp + ${NRFCONNECT_COMMON}/Rpc.cpp ${NRFCONNECT_COMMON}/util/PigweedLogger.cpp ) @@ -170,10 +170,17 @@ target_include_directories(app PRIVATE ${PIGWEED_ROOT}/pw_sys_io/public ${CHIP_ROOT}/src/lib/support ${CHIP_ROOT}/src/system + ${NRFCONNECT_COMMON} ../../common ../../common/pigweed ../../common/pigweed/nrfconnect) +target_compile_options(app PRIVATE + "-DPW_RPC_ATTRIBUTE_SERVICE=1" + "-DPW_RPC_BUTTON_SERVICE=1" + "-DPW_RPC_DEVICE_SERVICE=1" + "-DPW_RPC_LIGHTING_SERVICE=1") + target_link_libraries(app PRIVATE attributes_service.nanopb_rpc button_service.nanopb_rpc diff --git a/examples/lighting-app/nrfconnect/main/Rpc.cpp b/examples/lighting-app/nrfconnect/main/Rpc.cpp deleted file mode 100644 index 66100e38593f87..00000000000000 --- a/examples/lighting-app/nrfconnect/main/Rpc.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "AppTask.h" -#include "PigweedLoggerMutex.h" -#include "pigweed/RpcService.h" -#include "pw_sys_io_nrfconnect/init.h" -#include "rpc_services/Attributes.h" -#include "rpc_services/Button.h" -#include "rpc_services/Device.h" -#include "rpc_services/Lighting.h" - -#include - -LOG_MODULE_DECLARE(app); - -namespace chip { -namespace rpc { - -namespace { - -void reboot_timer_handler(struct k_timer * dummy) -{ - NVIC_SystemReset(); -} -K_TIMER_DEFINE(reboot_timer, reboot_timer_handler, NULL); - -} // namespace - -class NrfButton final : public Button -{ -public: - pw::Status Event(ServerContext &, const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override - { - GetAppTask().ButtonEventHandler(request.pushed << request.idx /* button_state */, 1 << request.idx /* has_changed */); - return pw::OkStatus(); - } -}; - -class NrfDevice final : public Device -{ -public: - pw::Status Reboot(ServerContext & ctx, const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override - { - k_timer_start(&reboot_timer, K_SECONDS(1), K_FOREVER); - return pw::OkStatus(); - } -}; - -namespace { - -constexpr size_t kRpcTaskSize = 4096; -constexpr int kRpcPriority = 5; - -K_THREAD_STACK_DEFINE(rpc_stack_area, kRpcTaskSize); -struct k_thread rpc_thread_data; - -Attributes attributes_service; -NrfButton button_service; -NrfDevice device_service; -Lighting lighting_service; - -void RegisterServices(pw::rpc::Server & server) -{ - server.RegisterService(attributes_service); - server.RegisterService(button_service); - server.RegisterService(device_service); - server.RegisterService(lighting_service); -} - -} // namespace - -k_tid_t Init() -{ - pw_sys_io_Init(); - k_tid_t tid = k_thread_create(&rpc_thread_data, rpc_stack_area, K_THREAD_STACK_SIZEOF(rpc_stack_area), RunRpcService, NULL, - NULL, NULL, kRpcPriority, 0, K_NO_WAIT); - return tid; -} - -void RunRpcService(void *, void *, void *) -{ - Start(RegisterServices, &logger_mutex); -} - -} // namespace rpc -} // namespace chip diff --git a/examples/lighting-app/nrfconnect/main/include/AppTask.h b/examples/lighting-app/nrfconnect/main/include/AppTask.h index 83f54267a555b2..12ff22ba963ca3 100644 --- a/examples/lighting-app/nrfconnect/main/include/AppTask.h +++ b/examples/lighting-app/nrfconnect/main/include/AppTask.h @@ -21,10 +21,13 @@ #include "AppEvent.h" #include "LEDWidget.h" #include "LightingManager.h" -#include "Rpc.h" #include +#ifdef CONFIG_CHIP_PW_RPC +#include "Rpc.h" +#endif + #ifdef CONFIG_MCUMGR_SMP_BT #include "DFUOverSMP.h" #endif @@ -43,9 +46,11 @@ class AppTask void UpdateClusterState(); private: +#ifdef CONFIG_CHIP_PW_RPC friend class chip::rpc::NrfButton; - friend AppTask & GetAppTask(void); +#endif + friend AppTask & GetAppTask(void); int Init(); static void ActionInitiated(LightingManager::Action_t aAction, int32_t aActor); diff --git a/examples/lighting-app/nrfconnect/main/main.cpp b/examples/lighting-app/nrfconnect/main/main.cpp index a3e5944651b9cf..1d2ae1530b813d 100644 --- a/examples/lighting-app/nrfconnect/main/main.cpp +++ b/examples/lighting-app/nrfconnect/main/main.cpp @@ -17,7 +17,6 @@ */ #include "AppTask.h" -#include "Rpc.h" #include #include @@ -25,6 +24,10 @@ #include +#ifdef CONFIG_CHIP_PW_RPC +#include "Rpc.h" +#endif + #ifdef CONFIG_USB #include #endif diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index 805f0a963d6e09..eae91987d71832 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -20,6 +20,12 @@ import("${build_root}/config/defaults.gni") import("${efr32_sdk_build_root}/efr32_executable.gni") import("${efr32_sdk_build_root}/efr32_sdk.gni") +import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") +if (chip_enable_pw_rpc) { + import("//build_overrides/pigweed.gni") + import("$dir_pw_build/target_types.gni") +} + assert(current_os == "freertos") efr32_project_dir = "${chip_root}/examples/lock-app/efr32" @@ -59,6 +65,10 @@ efr32_sdk("sdk") { "BOARD_ID=${efr32_board}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", ] + + if (chip_enable_pw_rpc) { + defines += [ "HAL_VCOM_ENABLE=1" ] + } } efr32_executable("lock_app") { @@ -97,6 +107,41 @@ efr32_executable("lock_app") { defines += [ "DISPLAY_ENABLED" ] } + if (chip_enable_pw_rpc) { + defines += [ + "PW_RPC_ENABLED", + "PW_RPC_ATTRIBUTE_SERVICE=1", + "PW_RPC_BUTTON_SERVICE=1", + "PW_RPC_DEVICE_SERVICE=1", + "PW_RPC_LOCKING_SERVICE=1", + ] + + sources += [ + "${chip_root}/examples/common/pigweed/RpcService.cpp", + "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", + "${examples_plat_dir}/PigweedLogger.cpp", + "${examples_plat_dir}/Rpc.cpp", + ] + + deps += [ + "$dir_pw_hdlc:rpc_channel_output", + "$dir_pw_stream:sys_io_stream", + "${chip_root}/config/efr32/lib/pw_rpc:pw_rpc", + "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:locking_service.nanopb_rpc", + "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32", + ] + + deps += pw_build_LINK_DEPS + + include_dirs += [ + "${chip_root}/examples/common", + "${chip_root}/examples/common/pigweed/efr32", + ] + } + if (enable_heap_monitoring) { defines += [ "HEAP_MONITORING" ] sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ] diff --git a/examples/lock-app/efr32/src/main.cpp b/examples/lock-app/efr32/src/main.cpp index 1e07cd63605644..012b1ddd63f162 100644 --- a/examples/lock-app/efr32/src/main.cpp +++ b/examples/lock-app/efr32/src/main.cpp @@ -48,6 +48,10 @@ #include "lcd.h" #endif +#if PW_RPC_ENABLED +#include "Rpc.h" +#endif + #if CHIP_ENABLE_OPENTHREAD #include #include @@ -104,6 +108,10 @@ int main(void) init_efrPlatform(); mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); +#if PW_RPC_ENABLED + chip::rpc::Init(); +#endif + EFR32_LOG("=================================================="); EFR32_LOG("chip-efr32-lock-example starting"); EFR32_LOG("=================================================="); diff --git a/examples/lock-app/efr32/with_pw_rpc.gni b/examples/lock-app/efr32/with_pw_rpc.gni index a64475b97e246e..f9f11473f56d43 100644 --- a/examples/lock-app/efr32/with_pw_rpc.gni +++ b/examples/lock-app/efr32/with_pw_rpc.gni @@ -18,8 +18,11 @@ import("//build_overrides/chip.gni") import("${chip_root}/config/efr32/lib/pw_rpc/pw_rpc.gni") -import("${chip_root}/src/platform/EFR32/args.gni") +import("${chip_root}/examples/platform/efr32/args.gni") efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") +chip_enable_pw_rpc = true +chip_enable_openthread = true + cpp_standard = "gnu++17" diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt index 75b0d406fa412b..ce2c2116ca6e59 100644 --- a/examples/lock-app/esp32/main/CMakeLists.txt +++ b/examples/lock-app/esp32/main/CMakeLists.txt @@ -98,6 +98,7 @@ pw_proto_library(locking_service ) target_link_libraries(${COMPONENT_LIB} PUBLIC + attributes_service.nanopb_rpc device_service.nanopb_rpc button_service.nanopb_rpc locking_service.nanopb_rpc @@ -107,6 +108,12 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC pw_rpc.server ) +target_compile_options(${COMPONENT_LIB} PRIVATE + "-DPW_RPC_ATTRIBUTE_SERVICE=2" + "-DPW_RPC_BUTTON_SERVICE=1" + "-DPW_RPC_DEVICE_SERVICE=1" + "-DPW_RPC_LOCKING_SERVICE=1") + else (CONFIG_ENABLE_PW_RPC) idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lock-app/" diff --git a/examples/lock-app/esp32/main/Rpc.cpp b/examples/lock-app/esp32/main/Rpc.cpp deleted file mode 100644 index 0aea9244960482..00000000000000 --- a/examples/lock-app/esp32/main/Rpc.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sdkconfig.h" -#if CONFIG_ENABLE_PW_RPC -#include "AppTask.h" -#include "PigweedLoggerMutex.h" -#include "RpcService.h" -#include "esp_log.h" -#include "esp_system.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "pw_rpc/server.h" -#include "pw_sys_io/sys_io.h" -#include "rpc_services/Button.h" -#include "rpc_services/Device.h" -#include "rpc_services/Locking.h" - -#include - -const char * TAG = "RPC"; - -using chip::DeviceLayer::ConfigurationMgr; - -static bool uartInitialised; - -namespace chip { -namespace rpc { - -class Esp32Button final : public Button -{ -public: - pw::Status Event(ServerContext &, const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override - { - GetAppTask().ButtonEventHandler(request.idx, request.pushed); - return pw::OkStatus(); - } -}; - -class Esp32Device final : public Device -{ -public: - pw::Status Reboot(ServerContext & ctx, const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override - { - esp_restart(); - // WILL NOT RETURN - return pw::OkStatus(); - } -}; - -constexpr size_t kRpcStackSizeBytes = (4 * 1024); -constexpr uint8_t kRpcTaskPriority = 5; - -TaskHandle_t rpcTaskHandle; - -Esp32Button button_service; -Locking locking_service; -Device device_service; - -void RegisterServices(pw::rpc::Server & server) -{ - server.RegisterService(locking_service); - server.RegisterService(button_service); - server.RegisterService(device_service); -} - -void RunRpcService(void *) -{ - Start(RegisterServices, &logger_mutex); -} - -void Init() -{ - PigweedLogger::init(); - uartInitialised = true; - - ESP_LOGI(TAG, "----------- esp32-rpc-service starting -----------"); - - xTaskCreate(RunRpcService, "RPC", kRpcStackSizeBytes / sizeof(StackType_t), nullptr, kRpcTaskPriority, &rpcTaskHandle); -} - -} // namespace rpc -} // namespace chip - -#endif diff --git a/examples/platform/efr32/Rpc.cpp b/examples/platform/efr32/Rpc.cpp new file mode 100644 index 00000000000000..89afffe420b0b1 --- /dev/null +++ b/examples/platform/efr32/Rpc.cpp @@ -0,0 +1,149 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "AppTask.h" +#include "FreeRTOS.h" +#include "PigweedLoggerMutex.h" +#include "pigweed/RpcService.h" +#include "pw_sys_io_efr32/init.h" +#include "task.h" + +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#include "pigweed/rpc_services/Attributes.h" +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +#include "pigweed/rpc_services/Button.h" +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +#include "pigweed/rpc_services/Device.h" +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +#include "pigweed/rpc_services/Lighting.h" +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +#include "pigweed/rpc_services/Locking.h" +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +namespace chip { +namespace rpc { + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +class Efr32Button final : public Button +{ +public: + pw::Status Event(ServerContext &, const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override + { + GetAppTask().ButtonEventHandler(SL_SIMPLE_BUTTON_INSTANCE(request.idx) /* PB 0 or PB 1 */, request.pushed); + return pw::OkStatus(); + } +}; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +class Efr32Device final : public Device +{ +public: + pw::Status Reboot(ServerContext & ctx, const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override + { + mRebootTimer = xTimerCreateStatic("Reboot", kRebootTimerPeriodTicks, false, nullptr, RebootHandler, &mRebootTimerBuffer); + xTimerStart(mRebootTimer, 0); + return pw::OkStatus(); + } + +private: + static constexpr TickType_t kRebootTimerPeriodTicks = 1000; + TimerHandle_t mRebootTimer; + StaticTimer_t mRebootTimerBuffer; + + static void RebootHandler(TimerHandle_t) { NVIC_SystemReset(); } +}; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +namespace { + +#define RPC_TASK_STACK_SIZE 4096 +#define RPC_TASK_PRIORITY 1 +static TaskHandle_t sRpcTaskHandle; +StaticTask_t sRpcTaskBuffer; +StackType_t sRpcTaskStack[RPC_TASK_STACK_SIZE]; + +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +Attributes attributes_service; +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +Efr32Button button_service; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +Efr32Device device_service; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +Lighting lighting_service; +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +Locking locking; +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +void RegisterServices(pw::rpc::Server & server) +{ +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + server.RegisterService(attributes_service); +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + server.RegisterService(button_service); +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + server.RegisterService(device_service); +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + server.RegisterService(lighting_service); +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + server.RegisterService(locking); +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +} + +} // namespace + +void RunRpcService(void *) +{ + Start(RegisterServices, &logger_mutex); +} + +void Init() +{ + pw_sys_io_Init(); + + // Start App task. + sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", ArraySize(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, + sRpcTaskStack, &sRpcTaskBuffer); +} + +} // namespace rpc +} // namespace chip diff --git a/examples/lighting-app/efr32/include/Rpc.h b/examples/platform/efr32/Rpc.h similarity index 100% rename from examples/lighting-app/efr32/include/Rpc.h rename to examples/platform/efr32/Rpc.h diff --git a/examples/platform/esp32/Rpc.cpp b/examples/platform/esp32/Rpc.cpp new file mode 100644 index 00000000000000..ccc877ecb46fdf --- /dev/null +++ b/examples/platform/esp32/Rpc.cpp @@ -0,0 +1,167 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "sdkconfig.h" + +#if CONFIG_ENABLE_PW_RPC +#include "PigweedLoggerMutex.h" +#include "RpcService.h" +#include "esp_log.h" +#include "freertos/FreeRTOS.h" +#include "freertos/event_groups.h" +#include "freertos/semphr.h" +#include "freertos/task.h" +#include "pw_log/log.h" +#include "pw_rpc/server.h" +#include "pw_sys_io/sys_io.h" +#include "support/CodeUtils.h" + +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#include "pigweed/rpc_services/Attributes.h" +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +#include "ScreenManager.h" +#include "pigweed/rpc_services/Button.h" +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +#include "pigweed/rpc_services/Device.h" +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +#include "pigweed/rpc_services/Lighting.h" +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +#include "pigweed/rpc_services/Locking.h" +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +namespace chip { +namespace rpc { + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +class Esp32Button final : public Button +{ +public: + pw::Status Event(ServerContext &, const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override + { +#if CONFIG_DEVICE_TYPE_M5STACK + if (request.pushed) + { + ScreenManager::ButtonPressed(1 + request.idx); + } + return pw::OkStatus(); +#else // CONFIG_DEVICE_TYPE_M5STACK + return pw::Status::Unimplemented(); +#endif // CONFIG_DEVICE_TYPE_M5STACK + } +}; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +class Esp32Device final : public Device +{ +public: + pw::Status Reboot(ServerContext & ctx, const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override + { + mRebootTimer = xTimerCreateStatic("Reboot", kRebootTimerPeriodTicks, false, nullptr, RebootHandler, &mRebootTimerBuffer); + xTimerStart(mRebootTimer, 0); + return pw::OkStatus(); + } + +private: + static constexpr TickType_t kRebootTimerPeriodTicks = 1000; + TimerHandle_t mRebootTimer; + StaticTimer_t mRebootTimerBuffer; + + static void RebootHandler(TimerHandle_t) { esp_restart(); } +}; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +namespace { + +#define RPC_TASK_STACK_SIZE (8 * 1024) +#define RPC_TASK_PRIORITY 5 +static TaskHandle_t sRpcTaskHandle; +StaticTask_t sRpcTaskBuffer; +StackType_t sRpcTaskStack[RPC_TASK_STACK_SIZE]; + +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +Attributes attributes_service; +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +Esp32Button button_service; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +Esp32Device device_service; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +Lighting lighting_service; +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +Locking locking; +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +void RegisterServices(pw::rpc::Server & server) +{ +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + server.RegisterService(attributes_service); +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + server.RegisterService(button_service); +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + server.RegisterService(device_service); +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + server.RegisterService(lighting_service); +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + server.RegisterService(locking); +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +} + +} // namespace + +void RunRpcService(void *) +{ + Start(RegisterServices, &logger_mutex); +} + +void Init() +{ + PigweedLogger::init(); + + // Start App task. + sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", ArraySize(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, + sRpcTaskStack, &sRpcTaskBuffer); +} + +} // namespace rpc +} // namespace chip + +#endif // CONFIG_ENABLE_PW_RPC diff --git a/examples/all-clusters-app/esp32/main/include/Rpc.h b/examples/platform/esp32/Rpc.h similarity index 100% rename from examples/all-clusters-app/esp32/main/include/Rpc.h rename to examples/platform/esp32/Rpc.h diff --git a/examples/platform/nrfconnect/Rpc.cpp b/examples/platform/nrfconnect/Rpc.cpp new file mode 100644 index 00000000000000..44cfb0e82eb01e --- /dev/null +++ b/examples/platform/nrfconnect/Rpc.cpp @@ -0,0 +1,152 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "AppTask.h" +#include "PigweedLoggerMutex.h" +#include "pigweed/RpcService.h" +#include "pw_sys_io_nrfconnect/init.h" + +#include + +LOG_MODULE_DECLARE(app); + +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#include "pigweed/rpc_services/Attributes.h" +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +#include "pigweed/rpc_services/Button.h" +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +#include "pigweed/rpc_services/Device.h" +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +#include "pigweed/rpc_services/Lighting.h" +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +#include "pigweed/rpc_services/Locking.h" +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +namespace chip { +namespace rpc { + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +namespace { + +void reboot_timer_handler(struct k_timer * dummy) +{ + NVIC_SystemReset(); +} +K_TIMER_DEFINE(reboot_timer, reboot_timer_handler, NULL); + +} // namespace + +class NrfDevice final : public Device +{ +public: + pw::Status Reboot(ServerContext & ctx, const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override + { + k_timer_start(&reboot_timer, K_SECONDS(1), K_FOREVER); + return pw::OkStatus(); + } +}; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +class NrfButton final : public Button +{ +public: + pw::Status Event(ServerContext &, const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override + { + GetAppTask().ButtonEventHandler(request.pushed << request.idx /* button_state */, 1 << request.idx /* has_changed */); + return pw::OkStatus(); + } +}; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +namespace { + +constexpr size_t kRpcTaskSize = 4096; +constexpr int kRpcPriority = 5; + +K_THREAD_STACK_DEFINE(rpc_stack_area, kRpcTaskSize); +struct k_thread rpc_thread_data; + +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +Attributes attributes_service; +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +NrfButton button_service; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +NrfDevice device_service; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +Lighting lighting_service; +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +Locking locking; +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +void RegisterServices(pw::rpc::Server & server) +{ +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + server.RegisterService(attributes_service); +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + server.RegisterService(button_service); +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + server.RegisterService(device_service); +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + server.RegisterService(lighting_service); +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + server.RegisterService(locking); +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +} + +} // namespace + +void RunRpcService(void *, void *, void *) +{ + Start(RegisterServices, &logger_mutex); +} + +k_tid_t Init() +{ + pw_sys_io_Init(); + k_tid_t tid = k_thread_create(&rpc_thread_data, rpc_stack_area, K_THREAD_STACK_SIZEOF(rpc_stack_area), RunRpcService, NULL, + NULL, NULL, kRpcPriority, 0, K_NO_WAIT); + return tid; +} + +} // namespace rpc +} // namespace chip diff --git a/examples/lighting-app/nrfconnect/main/include/Rpc.h b/examples/platform/nrfconnect/Rpc.h similarity index 100% rename from examples/lighting-app/nrfconnect/main/include/Rpc.h rename to examples/platform/nrfconnect/Rpc.h diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index c818bb2628660a..e013bd23a998a8 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -150,11 +150,11 @@ def Efr32Targets(): board=Efr32Board.BRD4161A) yield efr_target.Extend('window-covering', app=Efr32App.WINDOW_COVERING) - yield efr_target.Extend('lock', app=Efr32App.LOCK) yield efr_target.Extend('unit-test', app=Efr32App.UNIT_TEST) rpc_aware_targets = [ efr_target.Extend('light', app=Efr32App.LIGHT), + efr_target.Extend('lock', app=Efr32App.LOCK) ] for target in rpc_aware_targets: diff --git a/scripts/build/testdata/all_targets_except_host.txt b/scripts/build/testdata/all_targets_except_host.txt index 62abd8211112f8..ba1c11063b90d2 100644 --- a/scripts/build/testdata/all_targets_except_host.txt +++ b/scripts/build/testdata/all_targets_except_host.txt @@ -12,6 +12,7 @@ android-x86-chip-tool efr32-brd4161a-light efr32-brd4161a-light-rpc efr32-brd4161a-lock +efr32-brd4161a-lock-rpc efr32-brd4161a-unit-test efr32-brd4161a-window-covering esp32-c3devkit-all-clusters diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index 36c1866eda665b..734f2b84915638 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -133,6 +133,9 @@ gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/efr32 ' # Generating efr32-brd4161a-lock gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-lock +# Generating efr32-brd4161a-lock-rpc +gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A" import("//with_pw_rpc.gni")' {out}/efr32-brd4161a-lock-rpc + # Generating efr32-brd4161a-unit-test gn gen --check --fail-on-unused-args --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-unit-test @@ -587,6 +590,9 @@ ninja -C {out}/efr32-brd4161a-light-rpc # Building efr32-brd4161a-lock ninja -C {out}/efr32-brd4161a-lock +# Building efr32-brd4161a-lock-rpc +ninja -C {out}/efr32-brd4161a-lock-rpc + # Building efr32-brd4161a-unit-test ninja -C {out}/efr32-brd4161a-unit-test diff --git a/scripts/build/testdata/glob_star_targets_except_host.txt b/scripts/build/testdata/glob_star_targets_except_host.txt index a78108879d08eb..fce80642e1562a 100644 --- a/scripts/build/testdata/glob_star_targets_except_host.txt +++ b/scripts/build/testdata/glob_star_targets_except_host.txt @@ -12,6 +12,7 @@ android-x86-chip-tool efr32-brd4161a-light efr32-brd4161a-light-rpc efr32-brd4161a-lock +efr32-brd4161a-lock-rpc efr32-brd4161a-unit-test efr32-brd4161a-window-covering esp32-c3devkit-all-clusters From ab5734cf6b470f70e0e5311a46a1410805a05019 Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Sat, 27 Nov 2021 12:08:31 -0500 Subject: [PATCH 8/8] Make PAA trust store configurable (#12277) * Make PAA store configurable PAA store used by DefaultDeviceAttestationVerifier could not be replaced, forcing a few fixed test roots to always be used and nothing else, unless completely forking the DefaultDeviceAttestationVerifier. - This PR introduces the `PaaRootStore` interface, which the default `DeviceAttestationVerifier` expects to get configured at in constructor. - Examples were modified to use the default test PAA root store - Unit tests updated to use the testing root store - Refactored simple array-based Root store to self-extract the SKID Testing done: added new units tests which pass, ran cert tests, validated attestation succeeds the same as before with test keys. Fixed #11913 * Restyled by clang-format * Address review comments - Rename PaaRootStore to AttestationTrustStore - Add comments about ArrayAttestationtTrustStore lifecycle - Remove debug print * Fix python build * Fix tv-app scoping issue * Attempt to debug Darwin error * Restyled by clang-format * Remove debug logging used to diagnose CI Co-authored-by: Restyled.io --- .../chip-tool/commands/common/CHIPCommand.cpp | 5 +- examples/platform/linux/AppMain.cpp | 4 +- examples/tv-casting-app/linux/main.cpp | 8 +- .../java/AndroidDeviceControllerWrapper.cpp | 4 +- .../ChipDeviceController-ScriptBinding.cpp | 4 +- .../python/chip/internal/CommissionerImpl.cpp | 8 +- src/credentials/CHIPCert.h | 2 +- src/credentials/DeviceAttestationVerifier.h | 81 +++++++ .../DefaultDeviceAttestationVerifier.cpp | 208 +++++++++--------- .../DefaultDeviceAttestationVerifier.h | 22 +- .../tests/TestCertificationDeclaration.cpp | 4 +- .../TestDeviceAttestationCredentials.cpp | 80 ++++++- src/crypto/CHIPCryptoPAL.h | 2 + src/crypto/tests/CHIPCryptoPALTest.cpp | 4 +- .../Framework/CHIP/CHIPDeviceController.mm | 4 +- src/protocols/secure_channel/CASESession.h | 2 +- 16 files changed, 314 insertions(+), 128 deletions(-) diff --git a/examples/chip-tool/commands/common/CHIPCommand.cpp b/examples/chip-tool/commands/common/CHIPCommand.cpp index 44921d77b457f9..7f39cab591b99b 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.cpp +++ b/examples/chip-tool/commands/common/CHIPCommand.cpp @@ -45,7 +45,10 @@ CHIP_ERROR CHIPCommand::Run() chip::Platform::ScopedMemoryBuffer rcac; chip::Credentials::SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider()); - chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier()); + + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier(testingRootStore)); VerifyOrReturnError(noc.Alloc(chip::Controller::kMaxCHIPDERCertLength), CHIP_ERROR_NO_MEMORY); VerifyOrReturnError(icac.Alloc(chip::Controller::kMaxCHIPDERCertLength), CHIP_ERROR_NO_MEMORY); diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index 5b79f089d13674..44f9917c92e70d 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -234,7 +234,9 @@ CHIP_ERROR InitCommissioner() ReturnErrorOnFailure(gCommissioner.SetUdcListenPort(LinuxDeviceOptions::GetInstance().unsecuredCommissionerPort)); // Initialize device attestation verifier - SetDeviceAttestationVerifier(GetDefaultDACVerifier()); + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); chip::Platform::ScopedMemoryBuffer noc; VerifyOrReturnError(noc.Alloc(chip::Controller::kMaxCHIPDERCertLength), CHIP_ERROR_NO_MEMORY); diff --git a/examples/tv-casting-app/linux/main.cpp b/examples/tv-casting-app/linux/main.cpp index e2b356db9ae093..7cd5934347e967 100644 --- a/examples/tv-casting-app/linux/main.cpp +++ b/examples/tv-casting-app/linux/main.cpp @@ -195,8 +195,12 @@ int main(int argc, char * argv[]) // Initialize device attestation config SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - // Initialize device attestation verifier - SetDeviceAttestationVerifier(GetDefaultDACVerifier()); + // Initialize device attestation verifier from a constant version + { + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); + } if (!chip::ArgParser::ParseArgs(argv[0], argc, argv, allOptions)) { diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index bb18387a38a488..4f961e0a0dec97 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -204,7 +204,9 @@ AndroidDeviceControllerWrapper * AndroidDeviceControllerWrapper::AllocateNew(Jav wrapper->SetJavaObjectRef(vm, deviceControllerObj); // Initialize device attestation verifier - SetDeviceAttestationVerifier(GetDefaultDACVerifier()); + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); chip::Controller::FactoryInitParams initParams; chip::Controller::SetupParams setupParams; diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp index 9c1b09388d0f7f..c7fc136760d8fc 100644 --- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp +++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp @@ -182,7 +182,9 @@ ChipError::StorageType pychip_DeviceController_NewDeviceController(chip::Control } // Initialize device attestation verifier - SetDeviceAttestationVerifier(GetDefaultDACVerifier()); + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); CHIP_ERROR err = sOperationalCredentialsIssuer.Initialize(sStorageDelegate); VerifyOrReturnError(err == CHIP_NO_ERROR, err.AsInteger()); diff --git a/src/controller/python/chip/internal/CommissionerImpl.cpp b/src/controller/python/chip/internal/CommissionerImpl.cpp index 4386fc16ab549b..8d5b129d7d1159 100644 --- a/src/controller/python/chip/internal/CommissionerImpl.cpp +++ b/src/controller/python/chip/internal/CommissionerImpl.cpp @@ -108,6 +108,11 @@ extern "C" chip::Controller::DeviceCommissioner * pychip_internal_Commissioner_N chip::Platform::ScopedMemoryBuffer rcac; chip::Crypto::P256Keypair ephemeralKey; + // Initialize device attestation verifier + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier(testingRootStore)); + err = gFabricStorage.Initialize(&gServerStorage); SuccessOrExit(err); @@ -116,9 +121,6 @@ extern "C" chip::Controller::DeviceCommissioner * pychip_internal_Commissioner_N commissionerParams.pairingDelegate = &gPairingDelegate; commissionerParams.storageDelegate = &gServerStorage; - // Initialize device attestation verifier - chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier()); - err = ephemeralKey.Initialize(); SuccessOrExit(err); diff --git a/src/credentials/CHIPCert.h b/src/credentials/CHIPCert.h index 762e0f25f209f6..b957e60283b638 100644 --- a/src/credentials/CHIPCert.h +++ b/src/credentials/CHIPCert.h @@ -42,7 +42,7 @@ namespace chip { namespace Credentials { -static constexpr uint32_t kKeyIdentifierLength = 20; +static constexpr uint32_t kKeyIdentifierLength = static_cast(Crypto::kSubjectKeyIdentifierLength); static constexpr uint32_t kChip32bitAttrUTF8Length = 8; static constexpr uint32_t kChip64bitAttrUTF8Length = 16; static constexpr uint16_t kX509NoWellDefinedExpirationDateYear = 9999; diff --git a/src/credentials/DeviceAttestationVerifier.h b/src/credentials/DeviceAttestationVerifier.h index 09d843153943d5..75ee5a0eb50d0e 100644 --- a/src/credentials/DeviceAttestationVerifier.h +++ b/src/credentials/DeviceAttestationVerifier.h @@ -99,6 +99,87 @@ struct DeviceInfoForAttestation uint16_t paaVendorId = VendorId::NotSpecified; }; +/** + * @brief Helper utility to model a basic trust store usable for device attestation verifiers. + * + * API is synchronous. Real commissioner implementations may entirely + * hide Product Attestation Authority cert lookup behind the DeviceAttestationVerifier and + * never use this interface at all. It is provided as a utility to help build DeviceAttestationVerifier + * implementations suitable for testing or examples. + */ +class AttestationTrustStore +{ +public: + AttestationTrustStore() = default; + virtual ~AttestationTrustStore() = default; + + // Not copyable + AttestationTrustStore(const AttestationTrustStore &) = delete; + AttestationTrustStore & operator=(const AttestationTrustStore &) = delete; + + /** + * @brief Look-up a PAA cert by SKID + * + * The implementations of this interface must have access to a set of PAAs to trust. + * + * Interface is synchronous, and therefore this should not be used unless to expose a PAA + * store that is both fully local and quick to access. + * + * @param[in] skid Buffer containing the subject key identifier (SKID) of the PAA to look-up + * @param[inout] outPaaDerBuffer Buffer to receive the contents of the PAA root cert, if found. + * Size will be updated to match actual size. + * + * @returns CHIP_NO_ERROR on success, CHIP_INVALID_ARGUMENT if `skid` or `outPaaDerBuffer` arguments + * are not usable, CHIP_BUFFER_TOO_SMALL if certificate doesn't fit in `outPaaDerBuffer` + * span, CHIP_ERROR_CA_CERT_NOT_FOUND if no PAA found that matches `skid. + * + */ + virtual CHIP_ERROR GetProductAttestationAuthorityCert(const ByteSpan & skid, MutableByteSpan & outPaaDerBuffer) const = 0; +}; + +/** + * @brief Basic AttestationTrustStore that holds all data within caller-owned memory. + * + * This is useful to wrap a fixed constant array of certificates into a trust store + * implementation. + */ + +class ArrayAttestationTrustStore : public AttestationTrustStore +{ +public: + ArrayAttestationTrustStore(const ByteSpan * derCerts, size_t numCerts) : mDerCerts(derCerts), mNumCerts(numCerts) {} + + CHIP_ERROR GetProductAttestationAuthorityCert(const ByteSpan & skid, MutableByteSpan & outPaaDerBuffer) const override + { + VerifyOrReturnError(!skid.empty() && (skid.data() != nullptr), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(skid.size() == Crypto::kSubjectKeyIdentifierLength, CHIP_ERROR_INVALID_ARGUMENT); + + size_t paaIdx; + ByteSpan candidate; + + for (paaIdx = 0; paaIdx < mNumCerts; ++paaIdx) + { + uint8_t skidBuf[Crypto::kSubjectKeyIdentifierLength] = { 0 }; + candidate = mDerCerts[paaIdx]; + MutableByteSpan candidateSkidSpan{ skidBuf }; + VerifyOrReturnError(CHIP_NO_ERROR == Crypto::ExtractSKIDFromX509Cert(candidate, candidateSkidSpan), + CHIP_ERROR_INTERNAL); + + if (skid.data_equal(candidateSkidSpan)) + { + // Found a match + return CopySpanToMutableSpan(candidate, outPaaDerBuffer); + } + } + + return CHIP_ERROR_CA_CERT_NOT_FOUND; + } + +protected: + const ByteSpan * mDerCerts; + const size_t mNumCerts; +}; + class DeviceAttestationVerifier { public: diff --git a/src/credentials/examples/DefaultDeviceAttestationVerifier.cpp b/src/credentials/examples/DefaultDeviceAttestationVerifier.cpp index b6cf795092fd47..23acd0179f59f7 100644 --- a/src/credentials/examples/DefaultDeviceAttestationVerifier.cpp +++ b/src/credentials/examples/DefaultDeviceAttestationVerifier.cpp @@ -34,114 +34,98 @@ namespace Credentials { namespace { -CHIP_ERROR GetProductAttestationAuthorityCert(const ByteSpan & skid, MutableByteSpan & outDacBuffer) -{ - struct PAALookupTable - { - const uint8_t mPAACertificate[kMax_x509_Certificate_Length]; - const uint8_t mSKID[kKeyIdentifierLength]; - }; - - static PAALookupTable - sPAALookupTable[] = { - { /* - credentials/test/attestation/Chip-Test-PAA-FFF1-Cert.pem - -----BEGIN CERTIFICATE----- - MIIBmTCCAT+gAwIBAgIIaDhPq7kZ/N8wCgYIKoZIzj0EAwIwHzEdMBsGA1UEAwwU - TWF0dGVyIFRlc3QgUEFBIEZGRjEwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEy - MzU5NTlaMB8xHTAbBgNVBAMMFE1hdHRlciBUZXN0IFBBQSBGRkYxMFkwEwYHKoZI - zj0CAQYIKoZIzj0DAQcDQgAEG5isW7wR3GoXVaBbCsXha6AsRu5vwrvnb/fPbKeq - Tp/R15jcvvtP6uIl03c8kTSMwm1JMTHjCWMtXp7zHRLek6NjMGEwDwYDVR0TAQH/ - BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFO8Y4OzUZgQ03w28kR7U - UhaZZoOfMB8GA1UdIwQYMBaAFO8Y4OzUZgQ03w28kR7UUhaZZoOfMAoGCCqGSM49 - BAMCA0gAMEUCIQCn+l+nZv/3tf0VjNNPYl1IkSAOBYUO8SX23udWVPmXNgIgI7Ub - bkJTKCjbCZIDNwUNcPC2tyzNPLeB5nGsIl31Rys= - -----END CERTIFICATE----- - */ - { 0x30, 0x82, 0x01, 0x99, 0x30, 0x82, 0x01, 0x3F, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x68, 0x38, 0x4F, 0xAB, - 0xB9, 0x19, 0xFC, 0xDF, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x1F, 0x31, - 0x1D, 0x30, 0x1B, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x14, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, - 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, 0x20, 0x46, 0x46, 0x46, 0x31, 0x30, 0x20, 0x17, 0x0D, 0x32, 0x31, 0x30, 0x36, - 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5A, 0x18, 0x0F, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, - 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x1F, 0x31, 0x1D, 0x30, 0x1B, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, - 0x14, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, 0x20, 0x46, 0x46, - 0x46, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, - 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x1B, 0x98, 0xAC, 0x5B, 0xBC, 0x11, 0xDC, 0x6A, 0x17, - 0x55, 0xA0, 0x5B, 0x0A, 0xC5, 0xE1, 0x6B, 0xA0, 0x2C, 0x46, 0xEE, 0x6F, 0xC2, 0xBB, 0xE7, 0x6F, 0xF7, 0xCF, 0x6C, - 0xA7, 0xAA, 0x4E, 0x9F, 0xD1, 0xD7, 0x98, 0xDC, 0xBE, 0xFB, 0x4F, 0xEA, 0xE2, 0x25, 0xD3, 0x77, 0x3C, 0x91, 0x34, - 0x8C, 0xC2, 0x6D, 0x49, 0x31, 0x31, 0xE3, 0x09, 0x63, 0x2D, 0x5E, 0x9E, 0xF3, 0x1D, 0x12, 0xDE, 0x93, 0xA3, 0x63, - 0x30, 0x61, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, - 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1D, 0x06, - 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xEF, 0x18, 0xE0, 0xEC, 0xD4, 0x66, 0x04, 0x34, 0xDF, 0x0D, 0xBC, - 0x91, 0x1E, 0xD4, 0x52, 0x16, 0x99, 0x66, 0x83, 0x9F, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30, - 0x16, 0x80, 0x14, 0xEF, 0x18, 0xE0, 0xEC, 0xD4, 0x66, 0x04, 0x34, 0xDF, 0x0D, 0xBC, 0x91, 0x1E, 0xD4, 0x52, 0x16, - 0x99, 0x66, 0x83, 0x9F, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, - 0x30, 0x45, 0x02, 0x21, 0x00, 0xA7, 0xFA, 0x5F, 0xA7, 0x66, 0xFF, 0xF7, 0xB5, 0xFD, 0x15, 0x8C, 0xD3, 0x4F, 0x62, - 0x5D, 0x48, 0x91, 0x20, 0x0E, 0x05, 0x85, 0x0E, 0xF1, 0x25, 0xF6, 0xDE, 0xE7, 0x56, 0x54, 0xF9, 0x97, 0x36, 0x02, - 0x20, 0x23, 0xB5, 0x1B, 0x6E, 0x42, 0x53, 0x28, 0x28, 0xDB, 0x09, 0x92, 0x03, 0x37, 0x05, 0x0D, 0x70, 0xF0, 0xB6, - 0xB7, 0x2C, 0xCD, 0x3C, 0xB7, 0x81, 0xE6, 0x71, 0xAC, 0x22, 0x5D, 0xF5, 0x47, 0x2B }, - { 0xEF, 0x18, 0xE0, 0xEC, 0xD4, 0x66, 0x04, 0x34, 0xDF, 0x0D, - 0xBC, 0x91, 0x1E, 0xD4, 0x52, 0x16, 0x99, 0x66, 0x83, 0x9F } }, - { /* - credentials/test/attestation/Chip-Test-PAA-FFF2-Cert.pem - -----BEGIN CERTIFICATE----- - MIIBnTCCAUKgAwIBAgIIA5KnZVo+bHcwCgYIKoZIzj0EAwIwHzEdMBsGA1UEAwwU - TWF0dGVyIFRlc3QgUEFBIEZGRjIwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEy - MzU5NTlaMB8xHTAbBgNVBAMMFE1hdHRlciBUZXN0IFBBQSBGRkYyMFkwEwYHKoZI - zj0CAQYIKoZIzj0DAQcDQgAEdW4YkvnpULAOlQqilfM1sEhLh20i4m+WZZLKweUQ - 1f6Zsx1cmIgWeorWUDd+dRD7dYI8fluYuMAG7F8Gz66FSqNmMGQwEgYDVR0TAQH/ - BAgwBgEB/wIBATAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFOfv6sMzXF/Qw+Y0 - Up8WcEbEvKVcMB8GA1UdIwQYMBaAFOfv6sMzXF/Qw+Y0Up8WcEbEvKVcMAoGCCqG - SM49BAMCA0kAMEYCIQCSUQ0dYCFfARvaLqeV/ssklO+QppeHrQr8IGxhjAnMUgIh - AKA2sK+D40VcCTi5S/9HdRlyuNy+cZyfYbVW7LTqF8xX - -----END CERTIFICATE----- - */ - { 0x30, 0x82, 0x01, 0x9D, 0x30, 0x82, 0x01, 0x42, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x03, 0x92, 0xA7, 0x65, - 0x5A, 0x3E, 0x6C, 0x77, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x1F, 0x31, - 0x1D, 0x30, 0x1B, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x14, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, - 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, 0x20, 0x46, 0x46, 0x46, 0x32, 0x30, 0x20, 0x17, 0x0D, 0x32, 0x31, 0x30, 0x36, - 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5A, 0x18, 0x0F, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, - 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x1F, 0x31, 0x1D, 0x30, 0x1B, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, - 0x14, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, 0x20, 0x46, 0x46, - 0x46, 0x32, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, - 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x75, 0x6E, 0x18, 0x92, 0xF9, 0xE9, 0x50, 0xB0, 0x0E, - 0x95, 0x0A, 0xA2, 0x95, 0xF3, 0x35, 0xB0, 0x48, 0x4B, 0x87, 0x6D, 0x22, 0xE2, 0x6F, 0x96, 0x65, 0x92, 0xCA, 0xC1, - 0xE5, 0x10, 0xD5, 0xFE, 0x99, 0xB3, 0x1D, 0x5C, 0x98, 0x88, 0x16, 0x7A, 0x8A, 0xD6, 0x50, 0x37, 0x7E, 0x75, 0x10, - 0xFB, 0x75, 0x82, 0x3C, 0x7E, 0x5B, 0x98, 0xB8, 0xC0, 0x06, 0xEC, 0x5F, 0x06, 0xCF, 0xAE, 0x85, 0x4A, 0xA3, 0x66, - 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xFF, - 0x02, 0x01, 0x01, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, - 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0x5F, 0xD0, - 0xC3, 0xE6, 0x34, 0x52, 0x9F, 0x16, 0x70, 0x46, 0xC4, 0xBC, 0xA5, 0x5C, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, - 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0x5F, 0xD0, 0xC3, 0xE6, 0x34, 0x52, 0x9F, - 0x16, 0x70, 0x46, 0xC4, 0xBC, 0xA5, 0x5C, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, - 0x03, 0x49, 0x00, 0x30, 0x46, 0x02, 0x21, 0x00, 0x92, 0x51, 0x0D, 0x1D, 0x60, 0x21, 0x5F, 0x01, 0x1B, 0xDA, 0x2E, - 0xA7, 0x95, 0xFE, 0xCB, 0x24, 0x94, 0xEF, 0x90, 0xA6, 0x97, 0x87, 0xAD, 0x0A, 0xFC, 0x20, 0x6C, 0x61, 0x8C, 0x09, - 0xCC, 0x52, 0x02, 0x21, 0x00, 0xA0, 0x36, 0xB0, 0xAF, 0x83, 0xE3, 0x45, 0x5C, 0x09, 0x38, 0xB9, 0x4B, 0xFF, 0x47, - 0x75, 0x19, 0x72, 0xB8, 0xDC, 0xBE, 0x71, 0x9C, 0x9F, 0x61, 0xB5, 0x56, 0xEC, 0xB4, 0xEA, 0x17, 0xCC, 0x57 }, - { 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0x5F, 0xD0, 0xC3, 0xE6, - 0x34, 0x52, 0x9F, 0x16, 0x70, 0x46, 0xC4, 0xBC, 0xA5, 0x5C } }, - }; +/* +credentials/test/attestation/Chip-Test-PAA-FFF1-Cert.pem +-----BEGIN CERTIFICATE----- +MIIBmTCCAT+gAwIBAgIIaDhPq7kZ/N8wCgYIKoZIzj0EAwIwHzEdMBsGA1UEAwwU +TWF0dGVyIFRlc3QgUEFBIEZGRjEwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEy +MzU5NTlaMB8xHTAbBgNVBAMMFE1hdHRlciBUZXN0IFBBQSBGRkYxMFkwEwYHKoZI +zj0CAQYIKoZIzj0DAQcDQgAEG5isW7wR3GoXVaBbCsXha6AsRu5vwrvnb/fPbKeq +Tp/R15jcvvtP6uIl03c8kTSMwm1JMTHjCWMtXp7zHRLek6NjMGEwDwYDVR0TAQH/ +BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFO8Y4OzUZgQ03w28kR7U +UhaZZoOfMB8GA1UdIwQYMBaAFO8Y4OzUZgQ03w28kR7UUhaZZoOfMAoGCCqGSM49 +BAMCA0gAMEUCIQCn+l+nZv/3tf0VjNNPYl1IkSAOBYUO8SX23udWVPmXNgIgI7Ub +bkJTKCjbCZIDNwUNcPC2tyzNPLeB5nGsIl31Rys= +-----END CERTIFICATE----- +*/ +const uint8_t kChipTestPaaFff1[] = { + 0x30, 0x82, 0x01, 0x99, 0x30, 0x82, 0x01, 0x3F, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x68, 0x38, 0x4F, 0xAB, 0xB9, 0x19, + 0xFC, 0xDF, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x1F, 0x31, 0x1D, 0x30, 0x1B, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0C, 0x14, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x46, 0x46, 0x46, 0x31, 0x30, 0x20, 0x17, 0x0D, 0x32, 0x31, 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, + 0x5A, 0x18, 0x0F, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x1F, 0x31, + 0x1D, 0x30, 0x1B, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x14, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, + 0x20, 0x50, 0x41, 0x41, 0x20, 0x46, 0x46, 0x46, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, + 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x1B, 0x98, 0xAC, 0x5B, 0xBC, 0x11, + 0xDC, 0x6A, 0x17, 0x55, 0xA0, 0x5B, 0x0A, 0xC5, 0xE1, 0x6B, 0xA0, 0x2C, 0x46, 0xEE, 0x6F, 0xC2, 0xBB, 0xE7, 0x6F, 0xF7, 0xCF, + 0x6C, 0xA7, 0xAA, 0x4E, 0x9F, 0xD1, 0xD7, 0x98, 0xDC, 0xBE, 0xFB, 0x4F, 0xEA, 0xE2, 0x25, 0xD3, 0x77, 0x3C, 0x91, 0x34, 0x8C, + 0xC2, 0x6D, 0x49, 0x31, 0x31, 0xE3, 0x09, 0x63, 0x2D, 0x5E, 0x9E, 0xF3, 0x1D, 0x12, 0xDE, 0x93, 0xA3, 0x63, 0x30, 0x61, 0x30, + 0x0F, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30, 0x0E, 0x06, 0x03, 0x55, + 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, + 0x14, 0xEF, 0x18, 0xE0, 0xEC, 0xD4, 0x66, 0x04, 0x34, 0xDF, 0x0D, 0xBC, 0x91, 0x1E, 0xD4, 0x52, 0x16, 0x99, 0x66, 0x83, 0x9F, + 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xEF, 0x18, 0xE0, 0xEC, 0xD4, 0x66, 0x04, 0x34, + 0xDF, 0x0D, 0xBC, 0x91, 0x1E, 0xD4, 0x52, 0x16, 0x99, 0x66, 0x83, 0x9F, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, + 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, 0xA7, 0xFA, 0x5F, 0xA7, 0x66, 0xFF, 0xF7, 0xB5, 0xFD, 0x15, + 0x8C, 0xD3, 0x4F, 0x62, 0x5D, 0x48, 0x91, 0x20, 0x0E, 0x05, 0x85, 0x0E, 0xF1, 0x25, 0xF6, 0xDE, 0xE7, 0x56, 0x54, 0xF9, 0x97, + 0x36, 0x02, 0x20, 0x23, 0xB5, 0x1B, 0x6E, 0x42, 0x53, 0x28, 0x28, 0xDB, 0x09, 0x92, 0x03, 0x37, 0x05, 0x0D, 0x70, 0xF0, 0xB6, + 0xB7, 0x2C, 0xCD, 0x3C, 0xB7, 0x81, 0xE6, 0x71, 0xAC, 0x22, 0x5D, 0xF5, 0x47, 0x2B +}; - size_t paaLookupTableIdx; - for (paaLookupTableIdx = 0; paaLookupTableIdx < ArraySize(sPAALookupTable); ++paaLookupTableIdx) - { - if (skid.data_equal(ByteSpan(sPAALookupTable[paaLookupTableIdx].mSKID))) - { - break; - } - } +/* +credentials/test/attestation/Chip-Test-PAA-FFF2-Cert.pem +-----BEGIN CERTIFICATE----- +MIIBnTCCAUKgAwIBAgIIA5KnZVo+bHcwCgYIKoZIzj0EAwIwHzEdMBsGA1UEAwwU +TWF0dGVyIFRlc3QgUEFBIEZGRjIwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEy +MzU5NTlaMB8xHTAbBgNVBAMMFE1hdHRlciBUZXN0IFBBQSBGRkYyMFkwEwYHKoZI +zj0CAQYIKoZIzj0DAQcDQgAEdW4YkvnpULAOlQqilfM1sEhLh20i4m+WZZLKweUQ +1f6Zsx1cmIgWeorWUDd+dRD7dYI8fluYuMAG7F8Gz66FSqNmMGQwEgYDVR0TAQH/ +BAgwBgEB/wIBATAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFOfv6sMzXF/Qw+Y0 +Up8WcEbEvKVcMB8GA1UdIwQYMBaAFOfv6sMzXF/Qw+Y0Up8WcEbEvKVcMAoGCCqG +SM49BAMCA0kAMEYCIQCSUQ0dYCFfARvaLqeV/ssklO+QppeHrQr8IGxhjAnMUgIh +AKA2sK+D40VcCTi5S/9HdRlyuNy+cZyfYbVW7LTqF8xX +-----END CERTIFICATE----- +*/ +const uint8_t kChipTestPaaFff2[] = { + 0x30, 0x82, 0x01, 0x9D, 0x30, 0x82, 0x01, 0x42, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x03, 0x92, 0xA7, 0x65, 0x5A, 0x3E, + 0x6C, 0x77, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x1F, 0x31, 0x1D, 0x30, 0x1B, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0C, 0x14, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x46, 0x46, 0x46, 0x32, 0x30, 0x20, 0x17, 0x0D, 0x32, 0x31, 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, + 0x5A, 0x18, 0x0F, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x1F, 0x31, + 0x1D, 0x30, 0x1B, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x14, 0x4D, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, + 0x20, 0x50, 0x41, 0x41, 0x20, 0x46, 0x46, 0x46, 0x32, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, + 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x75, 0x6E, 0x18, 0x92, 0xF9, 0xE9, + 0x50, 0xB0, 0x0E, 0x95, 0x0A, 0xA2, 0x95, 0xF3, 0x35, 0xB0, 0x48, 0x4B, 0x87, 0x6D, 0x22, 0xE2, 0x6F, 0x96, 0x65, 0x92, 0xCA, + 0xC1, 0xE5, 0x10, 0xD5, 0xFE, 0x99, 0xB3, 0x1D, 0x5C, 0x98, 0x88, 0x16, 0x7A, 0x8A, 0xD6, 0x50, 0x37, 0x7E, 0x75, 0x10, 0xFB, + 0x75, 0x82, 0x3C, 0x7E, 0x5B, 0x98, 0xB8, 0xC0, 0x06, 0xEC, 0x5F, 0x06, 0xCF, 0xAE, 0x85, 0x4A, 0xA3, 0x66, 0x30, 0x64, 0x30, + 0x12, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01, 0x01, 0xFF, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xFF, 0x02, 0x01, 0x01, 0x30, 0x0E, + 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, + 0x04, 0x16, 0x04, 0x14, 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0x5F, 0xD0, 0xC3, 0xE6, 0x34, 0x52, 0x9F, 0x16, 0x70, 0x46, 0xC4, + 0xBC, 0xA5, 0x5C, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xE7, 0xEF, 0xEA, 0xC3, 0x33, + 0x5C, 0x5F, 0xD0, 0xC3, 0xE6, 0x34, 0x52, 0x9F, 0x16, 0x70, 0x46, 0xC4, 0xBC, 0xA5, 0x5C, 0x30, 0x0A, 0x06, 0x08, 0x2A, 0x86, + 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x03, 0x49, 0x00, 0x30, 0x46, 0x02, 0x21, 0x00, 0x92, 0x51, 0x0D, 0x1D, 0x60, 0x21, 0x5F, + 0x01, 0x1B, 0xDA, 0x2E, 0xA7, 0x95, 0xFE, 0xCB, 0x24, 0x94, 0xEF, 0x90, 0xA6, 0x97, 0x87, 0xAD, 0x0A, 0xFC, 0x20, 0x6C, 0x61, + 0x8C, 0x09, 0xCC, 0x52, 0x02, 0x21, 0x00, 0xA0, 0x36, 0xB0, 0xAF, 0x83, 0xE3, 0x45, 0x5C, 0x09, 0x38, 0xB9, 0x4B, 0xFF, 0x47, + 0x75, 0x19, 0x72, 0xB8, 0xDC, 0xBE, 0x71, 0x9C, 0x9F, 0x61, 0xB5, 0x56, 0xEC, 0xB4, 0xEA, 0x17, 0xCC, 0x57 +}; - VerifyOrReturnError(paaLookupTableIdx < ArraySize(sPAALookupTable), CHIP_ERROR_INVALID_ARGUMENT); +const ByteSpan kTestPaaRoots[] = { + ByteSpan{ kChipTestPaaFff1 }, + ByteSpan{ kChipTestPaaFff2 }, +}; - return CopySpanToMutableSpan(ByteSpan{ sPAALookupTable[paaLookupTableIdx].mPAACertificate }, outDacBuffer); -} +const ArrayAttestationTrustStore kTestAttestationTrustStore{ &kTestPaaRoots[0], ArraySize(kTestPaaRoots) }; +/** + * @brief Look-up of well-known keys used for CD signing by CSA. + * + * Current version uses only test key/cert provided in spec. + */ CHIP_ERROR GetCertificationDeclarationCertificate(const ByteSpan & skid, MutableByteSpan & outCertificate) { struct CertChainLookupTable { const uint8_t mCertificate[kMax_x509_Certificate_Length]; - const uint8_t mSKID[kKeyIdentifierLength]; + const uint8_t mSKID[Crypto::kSubjectKeyIdentifierLength]; }; static CertChainLookupTable @@ -191,6 +175,8 @@ CHIP_ERROR GetCertificationDeclarationCertificate(const ByteSpan & skid, Mutable class DefaultDACVerifier : public DeviceAttestationVerifier { public: + DefaultDACVerifier(const AttestationTrustStore * paaRootStore) : mAttestationTrustStore(paaRootStore) {} + AttestationVerificationResult VerifyAttestationInformation(const ByteSpan & attestationInfoBuffer, const ByteSpan & attestationChallengeBuffer, const ByteSpan & attestationSignatureBuffer, @@ -203,6 +189,11 @@ class DefaultDACVerifier : public DeviceAttestationVerifier AttestationVerificationResult ValidateCertificateDeclarationPayload(const ByteSpan & certDeclBuffer, const ByteSpan & firmwareInfo, const DeviceInfoForAttestation & deviceInfo) override; + +protected: + DefaultDACVerifier() {} + + const AttestationTrustStore * mAttestationTrustStore; }; AttestationVerificationResult DefaultDACVerifier::VerifyAttestationInformation(const ByteSpan & attestationInfoBuffer, @@ -246,7 +237,7 @@ AttestationVerificationResult DefaultDACVerifier::VerifyAttestationInformation(c deviceSignature) == CHIP_NO_ERROR, AttestationVerificationResult::kAttestationSignatureInvalid); - uint8_t akidBuf[Credentials::kKeyIdentifierLength]; + uint8_t akidBuf[Crypto::kAuthorityKeyIdentifierLength]; MutableByteSpan akid(akidBuf); ExtractAKIDFromX509Cert(paiCertDerBuffer, akid); @@ -254,7 +245,7 @@ AttestationVerificationResult DefaultDACVerifier::VerifyAttestationInformation(c chip::Platform::ScopedMemoryBuffer paaCert; VerifyOrReturnError(paaCert.Alloc(paaCertAllocatedLen), AttestationVerificationResult::kNoMemory); MutableByteSpan paa(paaCert.Get(), paaCertAllocatedLen); - VerifyOrReturnError(GetProductAttestationAuthorityCert(akid, paa) == CHIP_NO_ERROR, + VerifyOrReturnError(mAttestationTrustStore->GetProductAttestationAuthorityCert(akid, paa) == CHIP_NO_ERROR, AttestationVerificationResult::kPaaNotFound); VerifyOrReturnError(ValidateCertificateChain(paa.data(), paa.size(), paiCertDerBuffer.data(), paiCertDerBuffer.size(), @@ -279,9 +270,9 @@ AttestationVerificationResult DefaultDACVerifier::VerifyAttestationInformation(c ByteSpan firmwareInfoSpan; DeviceAttestationVendorReservedDeconstructor vendorReserved; - VerifyOrReturnError(DeconstructAttestationElements(attestationInfoBuffer, certificationDeclarationSpan, attestationNonceSpan, - timestampDeconstructed, firmwareInfoSpan, vendorReserved) == CHIP_NO_ERROR, - AttestationVerificationResult::kAttestationElementsMalformed); + CHIP_ERROR status = DeconstructAttestationElements(attestationInfoBuffer, certificationDeclarationSpan, attestationNonceSpan, + timestampDeconstructed, firmwareInfoSpan, vendorReserved); + VerifyOrReturnError(status == CHIP_NO_ERROR, AttestationVerificationResult::kAttestationElementsMalformed); // Verify that Nonce matches with what we sent VerifyOrReturnError(attestationNonceSpan.data_equal(attestationNonce), @@ -397,9 +388,14 @@ AttestationVerificationResult DefaultDACVerifier::ValidateCertificateDeclaration } // namespace -DeviceAttestationVerifier * GetDefaultDACVerifier() +const AttestationTrustStore * GetTestAttestationTrustStore() +{ + return &kTestAttestationTrustStore; +} + +DeviceAttestationVerifier * GetDefaultDACVerifier(const AttestationTrustStore * paaRootStore) { - static DefaultDACVerifier defaultDACVerifier; + static DefaultDACVerifier defaultDACVerifier{ paaRootStore }; return &defaultDACVerifier; } diff --git a/src/credentials/examples/DefaultDeviceAttestationVerifier.h b/src/credentials/examples/DefaultDeviceAttestationVerifier.h index aad200fdd3e434..4198e1c147348b 100644 --- a/src/credentials/examples/DefaultDeviceAttestationVerifier.h +++ b/src/credentials/examples/DefaultDeviceAttestationVerifier.h @@ -21,14 +21,30 @@ namespace chip { namespace Credentials { +/** + * @brief Get implementation of a PAA root store containing a basic set of static PAA roots + * sufficient for *testing* only. + * + * WARNING: The PAA list known to this PAA root store is a reduced subset that will likely + * cause users of it to fail attestation procedure in some cases. This is provided + * to support tests and examples, not to be used by real commissioners, as it + * contains several test roots which are not trustworthy for certified product usage. + * + * @returns a singleton AttestationTrustStore that contains some well-known PAA test root certs. + */ +const AttestationTrustStore * GetTestAttestationTrustStore(); + /** * @brief Get implementation of a sample DAC verifier to validate device * attestation procedure. * - * @returns a singleton DeviceAttestationVerifier that relies on no - * storage abstractions. + * @param[in] paaRootStore Pointer to the AttestationTrustStore instance to be used by implementation + * of default DeviceAttestationVerifier. Caller must ensure storage is + * always available while the DeviceAttestationVerifier could be used. + * + * @returns a singleton DeviceAttestationVerifier that satisfies basic device attestation procedure requirements. */ -DeviceAttestationVerifier * GetDefaultDACVerifier(); +DeviceAttestationVerifier * GetDefaultDACVerifier(const AttestationTrustStore * paaRootStore); } // namespace Credentials } // namespace chip diff --git a/src/credentials/tests/TestCertificationDeclaration.cpp b/src/credentials/tests/TestCertificationDeclaration.cpp index 12e49518de3e8f..3d15f39f2ea02e 100644 --- a/src/credentials/tests/TestCertificationDeclaration.cpp +++ b/src/credentials/tests/TestCertificationDeclaration.cpp @@ -247,7 +247,7 @@ static void TestCD_CMSSignAndVerify(nlTestSuite * inSuite, void * inContext) { ByteSpan cdContentIn(sTestCMS_CDContent01); ByteSpan cdContentOut; - uint8_t signerKeyIdBuf[kKeyIdentifierLength]; + uint8_t signerKeyIdBuf[Crypto::kSubjectKeyIdentifierLength]; MutableByteSpan signerKeyId(signerKeyIdBuf); uint8_t signedMessageBuf[kMaxCMSSignedCDMessage]; MutableByteSpan signedMessage(signedMessageBuf); @@ -297,7 +297,7 @@ static void TestCD_CMSVerifyAndExtract(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, testCase.cdContent.data_equal(cdContentOut)); // Test CMS_ExtractKeyId() - uint8_t signerKeyIdBuf[kKeyIdentifierLength]; + uint8_t signerKeyIdBuf[Crypto::kSubjectKeyIdentifierLength]; MutableByteSpan signerKeyId(signerKeyIdBuf); NL_TEST_ASSERT(inSuite, ExtractSKIDFromX509Cert(testCase.signerCert, signerKeyId) == CHIP_NO_ERROR); diff --git a/src/credentials/tests/TestDeviceAttestationCredentials.cpp b/src/credentials/tests/TestDeviceAttestationCredentials.cpp index f706582ddc087e..ea2de206212702 100644 --- a/src/credentials/tests/TestDeviceAttestationCredentials.cpp +++ b/src/credentials/tests/TestDeviceAttestationCredentials.cpp @@ -195,8 +195,7 @@ static void TestDACVerifierExample_AttestationInfoVerification(nlTestSuite * inS default_verifier->VerifyAttestationInformation(ByteSpan(), ByteSpan(), ByteSpan(), ByteSpan(), ByteSpan(), ByteSpan()); NL_TEST_ASSERT(inSuite, attestation_result == AttestationVerificationResult::kNotImplemented); - // Replace default verifier with example verifier - DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier(); + DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier(GetTestAttestationTrustStore()); NL_TEST_ASSERT(inSuite, example_dac_verifier != nullptr); NL_TEST_ASSERT(inSuite, default_verifier != example_dac_verifier); @@ -252,7 +251,7 @@ static void TestDACVerifierExample_CertDeclarationVerification(nlTestSuite * inS CHIP_ERROR err = CHIP_NO_ERROR; // Replace default verifier with example verifier - DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier(); + DeviceAttestationVerifier * example_dac_verifier = GetDefaultDACVerifier(GetTestAttestationTrustStore()); NL_TEST_ASSERT(inSuite, example_dac_verifier != nullptr); SetDeviceAttestationVerifier(example_dac_verifier); @@ -295,6 +294,80 @@ static void TestDACVerifierExample_CertDeclarationVerification(nlTestSuite * inS NL_TEST_ASSERT(inSuite, attestation_result == AttestationVerificationResult::kSuccess); } +static void TestAttestationTrustStore(nlTestSuite * inSuite, void * inContext) +{ + uint8_t kPaaFff1Start[] = { 0x30, 0x82, 0x01, 0x99, 0x30, 0x82, 0x01, 0x3F, 0xA0, 0x03, 0x02, 0x01, 0x02, + 0x02, 0x08, 0x68, 0x38, 0x4F, 0xAB, 0xB9, 0x19, 0xFC, 0xDF, 0x30, 0x0A, 0x06, + 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x1F, 0x31 }; + uint8_t kPaaFff1Skid[] = { 0xEF, 0x18, 0xE0, 0xEC, 0xD4, 0x66, 0x04, 0x34, 0xDF, 0x0D, + 0xBC, 0x91, 0x1E, 0xD4, 0x52, 0x16, 0x99, 0x66, 0x83, 0x9F }; + + uint8_t kPaaFff2Start[] = { 0x30, 0x82, 0x01, 0x9D, 0x30, 0x82, 0x01, 0x42, 0xA0, 0x03, 0x02, 0x01, 0x02, + 0x02, 0x08, 0x03, 0x92, 0xA7, 0x65, 0x5A, 0x3E, 0x6C, 0x77, 0x30, 0x0A, 0x06, + 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, 0x03, 0x02, 0x30, 0x1F, 0x31 }; + uint8_t kPaaFff2Skid[] = { 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0x5F, 0xD0, 0xC3, 0xE6, + 0x34, 0x52, 0x9F, 0x16, 0x70, 0x46, 0xC4, 0xBC, 0xA5, 0x5C }; + + // SKID to trigger CHIP_ERROR_INVALID_ARGUMENT + uint8_t kPaaBadSkid1[] = { 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0xD0, 0xC3, 0xE6, 0x34, + 0x52, 0x9F, 0x16, 0x70, 0x46, 0xC4, 0xBC, 0xA5, 0x5C }; + ByteSpan kPaaBadSkidSpan1{ kPaaBadSkid1 }; + + // SKID to trigger CHIP_ERROR_INVALID_ARGUMENT + ByteSpan kPaaBadSkidSpan2{ nullptr, sizeof(kPaaFff2Skid) }; + + // SKID to trigger CHIP_ERROR_CA_CERT_NOT_FOUND + uint8_t kPaaGoodSkidNotPresent[] = { 0xE7, 0xEF, 0xEA, 0xC3, 0x33, 0x5C, 0x5F, 0xD0, 0xC3, 0xE6, + 0x34, 0x52, 0x9F, 0x16, 0x70, 0xFF, 0xFF, 0xBC, 0xA5, 0x5C }; + + struct TestCase + { + ByteSpan skidSpan; + ByteSpan startSpan; + CHIP_ERROR expectedResult; + }; + + const TestCase kTestCases[] = { + { .skidSpan = ByteSpan{ kPaaFff1Skid }, .startSpan = ByteSpan{ kPaaFff1Start }, .expectedResult = CHIP_NO_ERROR }, + { .skidSpan = ByteSpan{ kPaaFff2Skid }, .startSpan = ByteSpan{ kPaaFff2Start }, .expectedResult = CHIP_NO_ERROR }, + { .skidSpan = ByteSpan{ kPaaFff2Skid }, + .startSpan = ByteSpan{ kPaaFff2Start }, + .expectedResult = CHIP_ERROR_BUFFER_TOO_SMALL }, + { .skidSpan = kPaaBadSkidSpan1, .startSpan = ByteSpan{}, .expectedResult = CHIP_ERROR_INVALID_ARGUMENT }, + { .skidSpan = kPaaBadSkidSpan2, .startSpan = ByteSpan{}, .expectedResult = CHIP_ERROR_INVALID_ARGUMENT }, + { .skidSpan = ByteSpan{ kPaaGoodSkidNotPresent }, .startSpan = ByteSpan{}, .expectedResult = CHIP_ERROR_CA_CERT_NOT_FOUND }, + }; + + const AttestationTrustStore * testAttestationTrustStore = GetTestAttestationTrustStore(); + NL_TEST_ASSERT(inSuite, testAttestationTrustStore != nullptr); + + size_t testCaseIdx = 0; + for (const auto & testCase : kTestCases) + { + uint8_t buf[kMaxDERCertLength]; + MutableByteSpan paaCertSpan{ buf }; + if (testCase.expectedResult == CHIP_ERROR_BUFFER_TOO_SMALL) + { + // Make the output much too small if checking for size handling + paaCertSpan = paaCertSpan.SubSpan(0, 16); + } + + // Try to obtain cert + CHIP_ERROR result = testAttestationTrustStore->GetProductAttestationAuthorityCert(testCase.skidSpan, paaCertSpan); + NL_TEST_ASSERT(inSuite, result == testCase.expectedResult); + + // In success cases, make sure the start of the cert matches expectation. Not using full certs + // to avoid repeating the known constants here. + if (testCase.expectedResult == CHIP_NO_ERROR) + { + NL_TEST_ASSERT(inSuite, paaCertSpan.size() > testCase.startSpan.size()); + paaCertSpan = paaCertSpan.SubSpan(0, testCase.startSpan.size()); + NL_TEST_ASSERT(inSuite, paaCertSpan.data_equal(testCase.startSpan) == true); + } + ++testCaseIdx; + } +} + /** * Set up the test suite. */ @@ -326,6 +399,7 @@ int TestDeviceAttestation_Teardown(void * inContext) static const nlTest sTests[] = { NL_TEST_DEF("Test Example Device Attestation Credentials Providers", TestDACProvidersExample_Providers), NL_TEST_DEF("Test Example Device Attestation Signature", TestDACProvidersExample_Signature), + NL_TEST_DEF("Test the 'for testing' Paa Root Store", TestAttestationTrustStore), NL_TEST_DEF("Test Example Device Attestation Information Verification", TestDACVerifierExample_AttestationInfoVerification), NL_TEST_DEF("Test Example Device Attestation Certification Declaration Verification", TestDACVerifierExample_CertDeclarationVerification), NL_TEST_SENTINEL() diff --git a/src/crypto/CHIPCryptoPAL.h b/src/crypto/CHIPCryptoPAL.h index 1d55e72a060cbd..78a58be47eb604 100644 --- a/src/crypto/CHIPCryptoPAL.h +++ b/src/crypto/CHIPCryptoPAL.h @@ -46,6 +46,8 @@ constexpr size_t kP256_ECDSA_Signature_Length_Raw = (2 * kP256_FE_Length); constexpr size_t kP256_Point_Length = (2 * kP256_FE_Length + 1); constexpr size_t kSHA256_Hash_Length = 32; constexpr size_t kSHA1_Hash_Length = 20; +constexpr size_t kSubjectKeyIdentifierLength = kSHA1_Hash_Length; +constexpr size_t kAuthorityKeyIdentifierLength = kSHA1_Hash_Length; constexpr size_t CHIP_CRYPTO_GROUP_SIZE_BYTES = kP256_FE_Length; constexpr size_t CHIP_CRYPTO_PUBLIC_KEY_SIZE_BYTES = kP256_Point_Length; diff --git a/src/crypto/tests/CHIPCryptoPALTest.cpp b/src/crypto/tests/CHIPCryptoPALTest.cpp index df2a737913afd6..dc3989bec15880 100644 --- a/src/crypto/tests/CHIPCryptoPALTest.cpp +++ b/src/crypto/tests/CHIPCryptoPALTest.cpp @@ -1874,7 +1874,7 @@ static void TestSKID_x509Extraction(nlTestSuite * inSuite, void * inContext) HeapChecker heapChecker(inSuite); CHIP_ERROR err = CHIP_NO_ERROR; - uint8_t skidBuf[Credentials::kKeyIdentifierLength]; + uint8_t skidBuf[kSubjectKeyIdentifierLength]; MutableByteSpan skidOut(skidBuf); ByteSpan cert; @@ -1901,7 +1901,7 @@ static void TestAKID_x509Extraction(nlTestSuite * inSuite, void * inContext) HeapChecker heapChecker(inSuite); CHIP_ERROR err = CHIP_NO_ERROR; - uint8_t akidBuf[Credentials::kKeyIdentifierLength]; + uint8_t akidBuf[kAuthorityKeyIdentifierLength]; MutableByteSpan akidOut(akidBuf); ByteSpan cert; diff --git a/src/darwin/Framework/CHIP/CHIPDeviceController.mm b/src/darwin/Framework/CHIP/CHIPDeviceController.mm index 794d6ed7ccd24f..1986c664cdbcda 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceController.mm +++ b/src/darwin/Framework/CHIP/CHIPDeviceController.mm @@ -190,7 +190,9 @@ - (BOOL)startup:(_Nullable id)storageDelegate } // Initialize device attestation verifier - chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier()); + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::GetDefaultDACVerifier(testingRootStore)); params.fabricStorage = _fabricStorage; commissionerParams.storageDelegate = _persistentStorageDelegateBridge; diff --git a/src/protocols/secure_channel/CASESession.h b/src/protocols/secure_channel/CASESession.h index a8bbadd3cf1b75..71cda76e5eabd7 100644 --- a/src/protocols/secure_channel/CASESession.h +++ b/src/protocols/secure_channel/CASESession.h @@ -47,7 +47,7 @@ namespace chip { constexpr uint16_t kSigmaParamRandomNumberSize = 32; -constexpr uint16_t kTrustedRootIdSize = Credentials::kKeyIdentifierLength; +constexpr uint16_t kTrustedRootIdSize = Crypto::kSubjectKeyIdentifierLength; constexpr uint16_t kMaxTrustedRootIds = 5; constexpr uint16_t kIPKSize = 16;