From 739f54ee2df5ad75ebdda00b5245482759495406 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 25 May 2022 15:14:17 +0000 Subject: [PATCH 1/5] Interface for TestEventTriggerDelegate --- src/controller/TestEventTriggerDelegate.h | 69 +++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/controller/TestEventTriggerDelegate.h diff --git a/src/controller/TestEventTriggerDelegate.h b/src/controller/TestEventTriggerDelegate.h new file mode 100644 index 00000000000000..a96d28a1443395 --- /dev/null +++ b/src/controller/TestEventTriggerDelegate.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 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. + */ + +#pragma once + +#include +#include +#include +#include + +namespace chip { + +class TestEventTriggerDelegate +{ +public: + /** + * This API can be used to retrieve the test enable key. The enable key is copied into `buffer` + * if the size is large enough. + * + * @param[out] enableKey Buffer to put the test enable key into + * + * @return CHIP_ERROR_BUFFER_TOO_SMALL the provided MutableByteSpan is not big enough. + */ + // TODO should I just use MutableByteSpan instead? + virtual CHIP_ERROR GetEnableKey(MutableByteSpan enableKey) = 0; + + /** + * Expectation is that the caller has already validated the test enable key before calling this. + * Configures the test event trigger based on `eventTrigger` provided. + * + * @param[in] eventTrigger Event trigger to configure + * + * @return CHIP_ERROR_INVALID_ARGUMENT when eventTrigger is not a valid test event trigger. + */ + virtual CHIP_ERROR ConfigureTestEventTrigger(uint64_t eventTrigger) = 0; + + /** + * Get the count of all configured test event triggers. + * + * @return count of configured event triggers. + */ + virtual size_t ConfiguredEventTriggerCount() = 0; +}; + +#if 0 +// This is a lighter weight interface from General Diagnostics Cluster perspective placing all the burden on each +// implementation to perform required validation. +class TestEventTriggerDelegate +{ +public: + virtual CHIP_ERROR ConfigureTestEventTrigger(const ByteSpan testEventKey, uint64_t eventTrigger) = 0; + virtual size_t ConfiguredEventTriggerCount() = 0; +}; +#endif + +} // namespace chip From 4026716e8a4cd0070b2019d0c9711472167d1b26 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 25 May 2022 15:23:35 +0000 Subject: [PATCH 2/5] remove completed TODO --- src/controller/TestEventTriggerDelegate.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/controller/TestEventTriggerDelegate.h b/src/controller/TestEventTriggerDelegate.h index a96d28a1443395..52c9ac44fda3bc 100644 --- a/src/controller/TestEventTriggerDelegate.h +++ b/src/controller/TestEventTriggerDelegate.h @@ -34,7 +34,6 @@ class TestEventTriggerDelegate * * @return CHIP_ERROR_BUFFER_TOO_SMALL the provided MutableByteSpan is not big enough. */ - // TODO should I just use MutableByteSpan instead? virtual CHIP_ERROR GetEnableKey(MutableByteSpan enableKey) = 0; /** From a201d57648db3fc6e939fbb6bef6b29d3ac1cbe7 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 25 May 2022 16:38:23 +0000 Subject: [PATCH 3/5] Address PR comments --- src/controller/TestEventTriggerDelegate.h | 32 ++++++----------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/controller/TestEventTriggerDelegate.h b/src/controller/TestEventTriggerDelegate.h index 52c9ac44fda3bc..e85f97d05892b0 100644 --- a/src/controller/TestEventTriggerDelegate.h +++ b/src/controller/TestEventTriggerDelegate.h @@ -27,42 +27,26 @@ class TestEventTriggerDelegate { public: /** - * This API can be used to retrieve the test enable key. The enable key is copied into `buffer` - * if the size is large enough. + * Checks to see if `enableKey` provided matches value choosen by by the manufacturer. * - * @param[out] enableKey Buffer to put the test enable key into - * - * @return CHIP_ERROR_BUFFER_TOO_SMALL the provided MutableByteSpan is not big enough. + * @param[in] enableKey Buffer of the key to verify. */ - virtual CHIP_ERROR GetEnableKey(MutableByteSpan enableKey) = 0; + virtual bool DoesEnableKeyMatch(const ByteSpan & enableKey) const = 0; /** - * Expectation is that the caller has already validated the test enable key before calling this. - * Configures the test event trigger based on `eventTrigger` provided. + * Expectation is that the caller has already validated the enable key before calling this. + * Handles the test event trigger based on `eventTrigger` provided. * - * @param[in] eventTrigger Event trigger to configure + * @param[in] eventTrigger Event trigger to handle. * * @return CHIP_ERROR_INVALID_ARGUMENT when eventTrigger is not a valid test event trigger. */ - virtual CHIP_ERROR ConfigureTestEventTrigger(uint64_t eventTrigger) = 0; + virtual CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) = 0; /** * Get the count of all configured test event triggers. - * - * @return count of configured event triggers. */ - virtual size_t ConfiguredEventTriggerCount() = 0; -}; - -#if 0 -// This is a lighter weight interface from General Diagnostics Cluster perspective placing all the burden on each -// implementation to perform required validation. -class TestEventTriggerDelegate -{ -public: - virtual CHIP_ERROR ConfigureTestEventTrigger(const ByteSpan testEventKey, uint64_t eventTrigger) = 0; - virtual size_t ConfiguredEventTriggerCount() = 0; + virtual size_t ConfiguredEventTriggerCount() const = 0; }; -#endif } // namespace chip From 0e93e8a936745d6bf54679f69c51556ad7f357eb Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 25 May 2022 16:42:37 +0000 Subject: [PATCH 4/5] Move TestEventTriggerDelegate.h to src/app --- src/{controller => app}/TestEventTriggerDelegate.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{controller => app}/TestEventTriggerDelegate.h (100%) diff --git a/src/controller/TestEventTriggerDelegate.h b/src/app/TestEventTriggerDelegate.h similarity index 100% rename from src/controller/TestEventTriggerDelegate.h rename to src/app/TestEventTriggerDelegate.h From b4a22b745b8b52ba6a7e82f452c915c9b654b4d2 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 26 May 2022 13:29:04 +0000 Subject: [PATCH 5/5] Address comments from PR --- src/app/TestEventTriggerDelegate.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/app/TestEventTriggerDelegate.h b/src/app/TestEventTriggerDelegate.h index e85f97d05892b0..c0ec5213b22794 100644 --- a/src/app/TestEventTriggerDelegate.h +++ b/src/app/TestEventTriggerDelegate.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2022 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. @@ -27,7 +28,7 @@ class TestEventTriggerDelegate { public: /** - * Checks to see if `enableKey` provided matches value choosen by by the manufacturer. + * Checks to see if `enableKey` provided matches value chosen by the manufacturer. * * @param[in] enableKey Buffer of the key to verify. */ @@ -42,11 +43,6 @@ class TestEventTriggerDelegate * @return CHIP_ERROR_INVALID_ARGUMENT when eventTrigger is not a valid test event trigger. */ virtual CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) = 0; - - /** - * Get the count of all configured test event triggers. - */ - virtual size_t ConfiguredEventTriggerCount() const = 0; }; } // namespace chip