Skip to content

Commit

Permalink
Create constants file
Browse files Browse the repository at this point in the history
  • Loading branch information
andreilitvin committed Feb 20, 2024
1 parent 9c11019 commit 8f1e544
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 92 deletions.
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.

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

#include <lib/core/DataModelTypes.h>

namespace chip {

/**
* 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;

} // 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
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(kInteractionModelRevisionTag), kInteractionModelRevision);
}
} // namespace app
} // namespace chip
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 = 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 = 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 = kDataModelRevision;
ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(SessionParameters::Tag::kDataModelRevision), dataModel));

uint16_t interactionModel = CHIP_DEVICE_INTERACTION_MODEL_REVISION;
uint16_t interactionModel = kInteractionModelRevision;
ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(SessionParameters::Tag::kInteractionModelRevision), interactionModel));

uint32_t specVersion = CHIP_DEVICE_SPECIFICATION_VERSION;
uint32_t specVersion = kSpecificationVersion;
ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(SessionParameters::Tag::kSpecificationVersion), specVersion));

uint16_t maxPathsPerInvoke = CHIP_CONFIG_MAX_PATHS_PER_INVOKE;
Expand Down

0 comments on commit 8f1e544

Please sign in to comment.