diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index f714560afc15cb..69f5926909756d 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -76,14 +76,6 @@ source_set("app_config") { deps = [ ":app_buildconfig" ] } -source_set("revision_info") { - sources = [ - "DataModelRevision.h", - "InteractionModelRevision.h", - "SpecificationVersion.h", - ] -} - source_set("paths") { sources = [ "AttributePathParams.h", @@ -130,6 +122,17 @@ config("config-controller-dynamic-server") { ] } +source_set("constants") { + sources = [ + "InteractionModelTimeout.h", + "SpecificationDefinedRevisions.h", + ] + public_deps = [ + "${chip_root}/src/lib/core", + "${chip_root}/src/system", + ] +} + # interaction-model is a static-library because it currently requires global functions (app/util/...) that are stubbed in different test files that depend on the app static_library # which in tern depens on the interaction-model. # Using source_set prevents the unit test to build correctly. @@ -149,7 +152,6 @@ static_library("interaction-model") { "InteractionModelEngine.cpp", "InteractionModelEngine.h", "InteractionModelHelper.h", - "InteractionModelTimeout.h", "OperationalSessionSetup.cpp", "OperationalSessionSetup.h", "OperationalSessionSetupPool.h", @@ -181,6 +183,7 @@ static_library("interaction-model") { public_deps = [ ":app_config", + ":constants", ":paths", ":subscription-manager", "${chip_root}/src/app/MessageDef", @@ -276,9 +279,9 @@ static_library("app") { public_deps = [ ":app_config", + ":constants", ":global-attributes", ":interaction-model", - ":revision_info", "${chip_root}/src/app/data-model", "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/lib/address_resolve", diff --git a/src/app/DataModelRevision.h b/src/app/DataModelRevision.h deleted file mode 100644 index 47ecb626a13ffa..00000000000000 --- a/src/app/DataModelRevision.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * 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 - -/** - * CHIP_DEVICE_DATA_MODEL_REVISION - * - * A monotonic number identifying the revision number of the Data Model against - * which the Node is certified. - * - * See section 7.1.1. "Revision History" in the "Data Model Specification" - * chapter of the core Matter specification. - */ -#ifndef CHIP_DEVICE_DATA_MODEL_REVISION -#define CHIP_DEVICE_DATA_MODEL_REVISION 17 -#endif diff --git a/src/app/InteractionModelTimeout.h b/src/app/InteractionModelTimeout.h index 3511ed5412049d..43153c679f2361 100644 --- a/src/app/InteractionModelTimeout.h +++ b/src/app/InteractionModelTimeout.h @@ -18,7 +18,6 @@ #pragma once #include -#include namespace chip { namespace app { diff --git a/src/app/MessageDef/BUILD.gn b/src/app/MessageDef/BUILD.gn index 4880a9a8b126e4..18b254038fe2b8 100644 --- a/src/app/MessageDef/BUILD.gn +++ b/src/app/MessageDef/BUILD.gn @@ -113,8 +113,8 @@ source_set("MessageDef") { deps = [ "${chip_root}/src/app:app_config", + "${chip_root}/src/app:constants", "${chip_root}/src/app:paths", - "${chip_root}/src/app:revision_info", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", "${chip_root}/src/protocols/interaction_model", diff --git a/src/app/MessageDef/InvokeRequestMessage.cpp b/src/app/MessageDef/InvokeRequestMessage.cpp index 50bd5cd45f70c0..d334b05dfa0362 100644 --- a/src/app/MessageDef/InvokeRequestMessage.cpp +++ b/src/app/MessageDef/InvokeRequestMessage.cpp @@ -74,7 +74,7 @@ CHIP_ERROR InvokeRequestMessage::Parser::PrettyPrint() const PRETTY_PRINT_DECDEPTH(); } break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/MessageDef/InvokeResponseMessage.cpp b/src/app/MessageDef/InvokeResponseMessage.cpp index f9887530c15e15..53568ce14d9b5e 100644 --- a/src/app/MessageDef/InvokeResponseMessage.cpp +++ b/src/app/MessageDef/InvokeResponseMessage.cpp @@ -73,7 +73,7 @@ CHIP_ERROR InvokeResponseMessage::Parser::PrettyPrint() const } #endif // CHIP_DETAIL_LOGGING break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/MessageDef/MessageBuilder.cpp b/src/app/MessageDef/MessageBuilder.cpp index b9ad0e58968d23..4effd887c6814c 100644 --- a/src/app/MessageDef/MessageBuilder.cpp +++ b/src/app/MessageDef/MessageBuilder.cpp @@ -24,8 +24,7 @@ namespace chip { namespace app { CHIP_ERROR MessageBuilder::EncodeInteractionModelRevision() { - return mpWriter->Put(TLV::ContextTag(kInteractionModelRevisionTag), - static_cast(CHIP_DEVICE_INTERACTION_MODEL_REVISION)); + return mpWriter->Put(TLV::ContextTag(Revision::kInteractionModelRevisionTag), Revision::kInteractionModelRevision); } } // namespace app } // namespace chip diff --git a/src/app/MessageDef/MessageBuilder.h b/src/app/MessageDef/MessageBuilder.h index 03210b3011cf21..fac114ad1379b5 100644 --- a/src/app/MessageDef/MessageBuilder.h +++ b/src/app/MessageDef/MessageBuilder.h @@ -18,7 +18,7 @@ #pragma once #include "StructBuilder.h" -#include +#include #include namespace chip { diff --git a/src/app/MessageDef/MessageDefHelper.cpp b/src/app/MessageDef/MessageDefHelper.cpp index db24b2623dcc00..82fcf286d1751b 100644 --- a/src/app/MessageDef/MessageDefHelper.cpp +++ b/src/app/MessageDef/MessageDefHelper.cpp @@ -24,7 +24,7 @@ #include "MessageDefHelper.h" #include #include -#include +#include #include #include #include diff --git a/src/app/MessageDef/MessageParser.cpp b/src/app/MessageDef/MessageParser.cpp index b855a93afcd7eb..7d74378b49f0c2 100644 --- a/src/app/MessageDef/MessageParser.cpp +++ b/src/app/MessageDef/MessageParser.cpp @@ -16,7 +16,7 @@ #include "MessageParser.h" #include "MessageDefHelper.h" -#include +#include namespace chip { namespace app { @@ -52,7 +52,7 @@ CHIP_ERROR MessageParser::CheckInteractionModelRevision(TLV::TLVReader & aReader CHIP_ERROR MessageParser::GetInteractionModelRevision(InteractionModelRevision * const apInteractionModelRevision) const { - return GetUnsignedInteger(kInteractionModelRevisionTag, apInteractionModelRevision); + return GetUnsignedInteger(Revision::kInteractionModelRevisionTag, apInteractionModelRevision); } } // namespace app diff --git a/src/app/MessageDef/MessageParser.h b/src/app/MessageDef/MessageParser.h index e307d5b905d965..4886f295e253eb 100644 --- a/src/app/MessageDef/MessageParser.h +++ b/src/app/MessageDef/MessageParser.h @@ -20,7 +20,7 @@ #include "StructParser.h" #include -#include +#include #include namespace chip { diff --git a/src/app/MessageDef/ReadRequestMessage.cpp b/src/app/MessageDef/ReadRequestMessage.cpp index 8b96b044d774c5..855d0a3e14d936 100644 --- a/src/app/MessageDef/ReadRequestMessage.cpp +++ b/src/app/MessageDef/ReadRequestMessage.cpp @@ -91,7 +91,7 @@ CHIP_ERROR ReadRequestMessage::Parser::PrettyPrint() const } #endif // CHIP_DETAIL_LOGGING break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/MessageDef/ReportDataMessage.cpp b/src/app/MessageDef/ReportDataMessage.cpp index c3c569572ae9fe..a2a8ec47968ec1 100644 --- a/src/app/MessageDef/ReportDataMessage.cpp +++ b/src/app/MessageDef/ReportDataMessage.cpp @@ -112,7 +112,7 @@ CHIP_ERROR ReportDataMessage::Parser::PrettyPrint() const } #endif // CHIP_DETAIL_LOGGING break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/MessageDef/StatusResponseMessage.cpp b/src/app/MessageDef/StatusResponseMessage.cpp index f702998c90ed23..fbf3a870d542c6 100644 --- a/src/app/MessageDef/StatusResponseMessage.cpp +++ b/src/app/MessageDef/StatusResponseMessage.cpp @@ -52,7 +52,7 @@ CHIP_ERROR StatusResponseMessage::Parser::PrettyPrint() const } #endif // CHIP_DETAIL_LOGGING break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/MessageDef/SubscribeRequestMessage.cpp b/src/app/MessageDef/SubscribeRequestMessage.cpp index b536570891bade..7224c850baaa20 100644 --- a/src/app/MessageDef/SubscribeRequestMessage.cpp +++ b/src/app/MessageDef/SubscribeRequestMessage.cpp @@ -115,7 +115,7 @@ CHIP_ERROR SubscribeRequestMessage::Parser::PrettyPrint() const } #endif // CHIP_DETAIL_LOGGING break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/MessageDef/SubscribeResponseMessage.cpp b/src/app/MessageDef/SubscribeResponseMessage.cpp index 99528895e49796..25ef8ec0bd3038 100644 --- a/src/app/MessageDef/SubscribeResponseMessage.cpp +++ b/src/app/MessageDef/SubscribeResponseMessage.cpp @@ -59,7 +59,7 @@ CHIP_ERROR SubscribeResponseMessage::Parser::PrettyPrint() const } #endif // CHIP_DETAIL_LOGGING break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/MessageDef/TimedRequestMessage.cpp b/src/app/MessageDef/TimedRequestMessage.cpp index bf6bdc5b79a45b..830a3d66894377 100644 --- a/src/app/MessageDef/TimedRequestMessage.cpp +++ b/src/app/MessageDef/TimedRequestMessage.cpp @@ -49,7 +49,7 @@ CHIP_ERROR TimedRequestMessage::Parser::PrettyPrint() const } #endif // CHIP_DETAIL_LOGGING break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/MessageDef/WriteRequestMessage.cpp b/src/app/MessageDef/WriteRequestMessage.cpp index 8cf3d4048d9b2f..5278fff2c94166 100644 --- a/src/app/MessageDef/WriteRequestMessage.cpp +++ b/src/app/MessageDef/WriteRequestMessage.cpp @@ -88,7 +88,7 @@ CHIP_ERROR WriteRequestMessage::Parser::PrettyPrint() const } #endif // CHIP_DETAIL_LOGGING break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/MessageDef/WriteResponseMessage.cpp b/src/app/MessageDef/WriteResponseMessage.cpp index 4426d5e3db7c5e..e8da708bfc94e5 100644 --- a/src/app/MessageDef/WriteResponseMessage.cpp +++ b/src/app/MessageDef/WriteResponseMessage.cpp @@ -54,7 +54,7 @@ CHIP_ERROR WriteResponseMessage::Parser::PrettyPrint() const ReturnErrorOnFailure(writeResponses.PrettyPrint()); PRETTY_PRINT_DECDEPTH(); break; - case kInteractionModelRevisionTag: + case Revision::kInteractionModelRevisionTag: ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader)); break; default: diff --git a/src/app/InteractionModelRevision.h b/src/app/SpecificationDefinedRevisions.h similarity index 51% rename from src/app/InteractionModelRevision.h rename to src/app/SpecificationDefinedRevisions.h index 529ac0f839c80e..cad67aced413b0 100644 --- a/src/app/InteractionModelRevision.h +++ b/src/app/SpecificationDefinedRevisions.h @@ -20,16 +20,37 @@ #include #include +#include + +namespace chip { +namespace Revision { + /** - * CHIP_DEVICE_INTERACTION_MODEL_REVISION - * * A monothonic number identifying the interaction model revision. * * See section 8.1.1. "Revision History" in the "Interaction Model * Specification" chapter of the core Matter specification. */ -#ifndef CHIP_DEVICE_INTERACTION_MODEL_REVISION -#define CHIP_DEVICE_INTERACTION_MODEL_REVISION 11 -#endif +inline constexpr InteractionModelRevision kInteractionModelRevision = 11; +inline constexpr uint8_t kInteractionModelRevisionTag = 0xFF; + +/** + * A monotonic number identifying the revision number of the Data Model against + * which the Node is certified. + * + * See section 7.1.1. "Revision History" in the "Data Model Specification" + * chapter of the core Matter specification. + */ +inline constexpr uint16_t kDataModelRevision = 17; + +/* + * A number identifying the specification version against which the + * Node is certified. + * + * See section 11.1.5.22. "SpecificationVersion Attribute" in "Service and + * Device Management" chapter of the core Matter specification. + */ +inline constexpr uint32_t kSpecificationVersion = 0x01030000; -inline constexpr uint8_t kInteractionModelRevisionTag = 0xFF; +} // namespace Revision +} // namespace chip diff --git a/src/app/SpecificationVersion.h b/src/app/SpecificationVersion.h deleted file mode 100644 index b0570dad14c4ce..00000000000000 --- a/src/app/SpecificationVersion.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * Copyright (c) 2023 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 - -/** - * CHIP_DEVICE_SPECIFICATION_VERSION - * - * A number identifying the specification version against which the - * Node is certified. - * - * See section 11.1.5.22. "SpecificationVersion Attribute" in "Service and - * Device Management" chapter of the core Matter specification. - */ -#ifndef CHIP_DEVICE_SPECIFICATION_VERSION -#define CHIP_DEVICE_SPECIFICATION_VERSION 0x01030000 -#endif diff --git a/src/app/clusters/basic-information/basic-information.cpp b/src/app/clusters/basic-information/basic-information.cpp index 641dc59a853dd6..91eef9d9dae899 100644 --- a/src/app/clusters/basic-information/basic-information.cpp +++ b/src/app/clusters/basic-information/basic-information.cpp @@ -20,10 +20,9 @@ #include #include -#include #include #include -#include +#include #include #include #include @@ -314,7 +313,7 @@ CHIP_ERROR BasicAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attrib CHIP_ERROR BasicAttrAccess::ReadDataModelRevision(AttributeValueEncoder & aEncoder) { - uint16_t revision = CHIP_DEVICE_DATA_MODEL_REVISION; + uint16_t revision = Revision::kDataModelRevision; return aEncoder.Encode(revision); } @@ -399,7 +398,7 @@ CHIP_ERROR BasicAttrAccess::ReadProductAppearance(AttributeValueEncoder & aEncod CHIP_ERROR BasicAttrAccess::ReadSpecificationVersion(AttributeValueEncoder & aEncoder) { - uint32_t specification_version = CHIP_DEVICE_SPECIFICATION_VERSION; + uint32_t specification_version = Revision::kSpecificationVersion; return aEncoder.Encode(specification_version); } diff --git a/src/protocols/secure_channel/BUILD.gn b/src/protocols/secure_channel/BUILD.gn index dcae65a6f4d271..1202c0bb88a9ae 100644 --- a/src/protocols/secure_channel/BUILD.gn +++ b/src/protocols/secure_channel/BUILD.gn @@ -88,5 +88,5 @@ static_library("secure_channel") { "${chip_root}/src/transport", ] - deps = [ "${chip_root}/src/app:revision_info" ] + deps = [ "${chip_root}/src/app:constants" ] } diff --git a/src/protocols/secure_channel/PairingSession.cpp b/src/protocols/secure_channel/PairingSession.cpp index 23daea30f2800c..80e048597578be 100644 --- a/src/protocols/secure_channel/PairingSession.cpp +++ b/src/protocols/secure_channel/PairingSession.cpp @@ -18,9 +18,7 @@ #include -#include -#include -#include +#include #include #include #include @@ -112,13 +110,13 @@ CHIP_ERROR PairingSession::EncodeSessionParameters(TLV::Tag tag, const Optional< ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(SessionParameters::Tag::kSessionActiveThreshold), mrpLocalConfig.mActiveThresholdTime.count())); - uint16_t dataModel = CHIP_DEVICE_DATA_MODEL_REVISION; + uint16_t dataModel = Revision::kDataModelRevision; ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(SessionParameters::Tag::kDataModelRevision), dataModel)); - uint16_t interactionModel = CHIP_DEVICE_INTERACTION_MODEL_REVISION; + uint16_t interactionModel = Revision::kInteractionModelRevision; ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(SessionParameters::Tag::kInteractionModelRevision), interactionModel)); - uint32_t specVersion = CHIP_DEVICE_SPECIFICATION_VERSION; + uint32_t specVersion = Revision::kSpecificationVersion; ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(SessionParameters::Tag::kSpecificationVersion), specVersion)); uint16_t maxPathsPerInvoke = CHIP_CONFIG_MAX_PATHS_PER_INVOKE;