Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a separate 'constants' source set in src/app #32228

Merged
merged 6 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -130,6 +122,17 @@ config("config-controller-dynamic-server") {
]
}

source_set("constants") {
sources = [
"InteractionModelRevision.h",
"InteractionModelTimeout.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.
Expand All @@ -146,7 +149,6 @@ static_library("interaction-model") {
"InteractionModelDelegatePointers.h",
"InteractionModelEngine.cpp",
"InteractionModelEngine.h",
"InteractionModelTimeout.h",
"OperationalSessionSetup.cpp",
"OperationalSessionSetup.h",
"OperationalSessionSetupPool.h",
Expand All @@ -169,6 +171,7 @@ static_library("interaction-model") {

public_deps = [
":app_config",
":constants",
":paths",
":subscription-manager",
"${chip_root}/src/app/MessageDef",
Expand Down Expand Up @@ -268,9 +271,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",
Expand Down
31 changes: 0 additions & 31 deletions src/app/DataModelRevision.h

This file was deleted.

33 changes: 27 additions & 6 deletions src/app/InteractionModelRevision.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,37 @@
#include <inttypes.h>
#include <stddef.h>

#include <lib/core/DataModelTypes.h>

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;
andy31415 marked this conversation as resolved.
Show resolved Hide resolved

/*
* 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
1 change: 0 additions & 1 deletion src/app/InteractionModelTimeout.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#pragma once

#include <system/SystemClock.h>
#include <transport/Session.h>

namespace chip {
namespace app {
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/InvokeRequestMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/InvokeResponseMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions src/app/MessageDef/MessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace chip {
namespace app {
CHIP_ERROR MessageBuilder::EncodeInteractionModelRevision()
{
return mpWriter->Put(TLV::ContextTag(kInteractionModelRevisionTag),
static_cast<InteractionModelRevision>(CHIP_DEVICE_INTERACTION_MODEL_REVISION));
return mpWriter->Put(TLV::ContextTag(Revision::kInteractionModelRevisionTag), Revision::kInteractionModelRevision);
}
} // namespace app
} // namespace chip
2 changes: 1 addition & 1 deletion src/app/MessageDef/MessageParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/ReadRequestMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/ReportDataMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/StatusResponseMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/SubscribeRequestMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/SubscribeResponseMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/TimedRequestMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/WriteRequestMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/WriteResponseMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
31 changes: 0 additions & 31 deletions src/app/SpecificationVersion.h

This file was deleted.

7 changes: 3 additions & 4 deletions src/app/clusters/basic-information/basic-information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app/DataModelRevision.h>
#include <app/EventLogging.h>
#include <app/InteractionModelEngine.h>
#include <app/SpecificationVersion.h>
#include <app/InteractionModelRevision.h>
#include <app/util/attribute-storage.h>
#include <lib/core/CHIPConfig.h>
#include <platform/CHIPDeviceLayer.h>
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/protocols/secure_channel/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
8 changes: 3 additions & 5 deletions src/protocols/secure_channel/PairingSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

#include <protocols/secure_channel/PairingSession.h>

#include <app/DataModelRevision.h>
#include <app/InteractionModelRevision.h>
#include <app/SpecificationVersion.h>
#include <lib/core/CHIPConfig.h>
#include <lib/core/TLVTypes.h>
#include <lib/support/SafeInt.h>
Expand Down Expand Up @@ -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;
Expand Down
Loading