Skip to content

Commit 578e3a4

Browse files
authored
Merge branch 'master' into compile-all-linux
2 parents 2ad115f + 36a1bbd commit 578e3a4

File tree

85 files changed

+7844
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+7844
-26
lines changed

.github/workflows/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ jobs:
200200
src/app/zap-templates/zcl/data-model/chip/time-synchronization-cluster.xml \
201201
src/app/zap-templates/zcl/data-model/chip/timer-cluster.xml \
202202
src/app/zap-templates/zcl/data-model/chip/tls-certificate-management-cluster.xml \
203+
src/app/zap-templates/zcl/data-model/chip/tls-client-management-cluster.xml \
203204
src/app/zap-templates/zcl/data-model/chip/user-label-cluster.xml \
204205
src/app/zap-templates/zcl/data-model/chip/unit-localization-cluster.xml \
205206
src/app/zap-templates/zcl/data-model/chip/wake-on-lan-cluster.xml \

docs/ids_and_codes/ERROR_CODES.md

+2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ This file was **AUTOMATICALLY** generated by
5656
| 38 | 0x26 | `CHIP_ERROR_WRONG_TLV_TYPE` |
5757
| 39 | 0x27 | `CHIP_ERROR_TLV_CONTAINER_OPEN` |
5858
| 40 | 0x28 | `CHIP_ERROR_IN_USE` |
59+
| 41 | 0x29 | `CHIP_ERROR_HAD_FAILURES` |
5960
| 42 | 0x2A | `CHIP_ERROR_INVALID_MESSAGE_TYPE` |
6061
| 43 | 0x2B | `CHIP_ERROR_UNEXPECTED_TLV_ELEMENT` |
62+
| 44 | 0x2C | `CHIP_ERROR_ALREADY_INITIALIZED` |
6163
| 45 | 0x2D | `CHIP_ERROR_NOT_IMPLEMENTED` |
6264
| 46 | 0x2E | `CHIP_ERROR_INVALID_ADDRESS` |
6365
| 47 | 0x2F | `CHIP_ERROR_INVALID_ARGUMENT` |

docs/ids_and_codes/zap_clusters.md

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Generally regenerate using one of:
140140
| 1872 | 0x750 | EcosystemInformation |
141141
| 1873 | 0x751 | CommissionerControl |
142142
| 2049 | 0x801 | TlsCertificateManagement |
143+
| 2050 | 0x802 | TlsClientManagement |
143144
| 4294048773 | 0xFFF1FC05 | UnitTesting |
144145
| 4294048774 | 0xFFF1FC06 | FaultInjection |
145146
| 4294048800 | 0xFFF1FC20 | SampleMei |

scripts/rules.matterlint

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ load "../src/app/zap-templates/zcl/data-model/chip/time-format-localization-clus
107107
load "../src/app/zap-templates/zcl/data-model/chip/time-synchronization-cluster.xml";
108108
load "../src/app/zap-templates/zcl/data-model/chip/timer-cluster.xml";
109109
load "../src/app/zap-templates/zcl/data-model/chip/tls-certificate-management-cluster.xml";
110+
load "../src/app/zap-templates/zcl/data-model/chip/tls-client-management-cluster.xml";
110111
load "../src/app/zap-templates/zcl/data-model/chip/unit-localization-cluster.xml";
111112
load "../src/app/zap-templates/zcl/data-model/chip/user-label-cluster.xml";
112113
load "../src/app/zap-templates/zcl/data-model/chip/wake-on-lan-cluster.xml";

scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/gen_config.h

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
#define MATTER_DM_ECOSYSTEM_INFORMATION_CLUSTER_SERVER_ENDPOINT_COUNT (0)
150150
#define MATTER_DM_COMMISSIONER_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (0)
151151
#define MATTER_DM_TLS_CERTIFICATE_MANAGEMENT_CLUSTER_SERVER_ENDPOINT_COUNT (0)
152+
#define MATTER_DM_TLS_CLIENT_MANAGEMENT_CLUSTER_SERVER_ENDPOINT_COUNT (0)
152153
#define MATTER_DM_UNIT_TESTING_CLUSTER_SERVER_ENDPOINT_COUNT (1)
153154
#define MATTER_DM_FAULT_INJECTION_CLUSTER_SERVER_ENDPOINT_COUNT (1)
154155
#define MATTER_DM_SAMPLE_MEI_CLUSTER_SERVER_ENDPOINT_COUNT (0)
@@ -281,6 +282,7 @@
281282
#define MATTER_DM_ECOSYSTEM_INFORMATION_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
282283
#define MATTER_DM_COMMISSIONER_CONTROL_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
283284
#define MATTER_DM_TLS_CERTIFICATE_MANAGEMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
285+
#define MATTER_DM_TLS_CLIENT_MANAGEMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
284286
#define MATTER_DM_UNIT_TESTING_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
285287
#define MATTER_DM_FAULT_INJECTION_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
286288
#define MATTER_DM_SAMPLE_MEI_CLUSTER_CLIENT_ENDPOINT_COUNT (0)

scripts/tools/zap/tests/outputs/lighting-app/app-templates/gen_config.h

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
#define MATTER_DM_ECOSYSTEM_INFORMATION_CLUSTER_SERVER_ENDPOINT_COUNT (0)
150150
#define MATTER_DM_COMMISSIONER_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (0)
151151
#define MATTER_DM_TLS_CERTIFICATE_MANAGEMENT_CLUSTER_SERVER_ENDPOINT_COUNT (0)
152+
#define MATTER_DM_TLS_CLIENT_MANAGEMENT_CLUSTER_SERVER_ENDPOINT_COUNT (0)
152153
#define MATTER_DM_UNIT_TESTING_CLUSTER_SERVER_ENDPOINT_COUNT (0)
153154
#define MATTER_DM_FAULT_INJECTION_CLUSTER_SERVER_ENDPOINT_COUNT (0)
154155
#define MATTER_DM_SAMPLE_MEI_CLUSTER_SERVER_ENDPOINT_COUNT (0)
@@ -281,6 +282,7 @@
281282
#define MATTER_DM_ECOSYSTEM_INFORMATION_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
282283
#define MATTER_DM_COMMISSIONER_CONTROL_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
283284
#define MATTER_DM_TLS_CERTIFICATE_MANAGEMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
285+
#define MATTER_DM_TLS_CLIENT_MANAGEMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
284286
#define MATTER_DM_UNIT_TESTING_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
285287
#define MATTER_DM_FAULT_INJECTION_CLUSTER_CLIENT_ENDPOINT_COUNT (0)
286288
#define MATTER_DM_SAMPLE_MEI_CLUSTER_CLIENT_ENDPOINT_COUNT (0)

src/app/data-model-provider/Provider.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Provider : public ProviderMetadataTree
5656

5757
// During the transition phase, we expect a large subset of code to require access to
5858
// event emitting, path marking and other operations
59-
virtual InteractionModelContext CurrentContext() const { return mContext; }
59+
[[nodiscard]] const InteractionModelContext & CurrentContext() const { return mContext; }
6060

6161
/// NOTE: this code is NOT required to handle `List` global attributes:
6262
/// AcceptedCommandsList, GeneratedCommandsList OR AttributeList
@@ -117,7 +117,7 @@ class Provider : public ProviderMetadataTree
117117
virtual std::optional<ActionReturnStatus> InvokeCommand(const InvokeRequest & request, chip::TLV::TLVReader & input_arguments,
118118
CommandHandler * handler) = 0;
119119

120-
private:
120+
protected:
121121
InteractionModelContext mContext = { nullptr };
122122
};
123123

src/app/server-cluster/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ source_set("server-cluster") {
1717
sources = [
1818
"DefaultServerCluster.cpp",
1919
"DefaultServerCluster.h",
20+
"ServerClusterContext.h",
2021
"ServerClusterInterface.h",
2122
]
2223

src/app/server-cluster/DefaultServerCluster.cpp

+28-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <access/Privilege.h>
2020
#include <app-common/zap-generated/ids/Attributes.h>
21+
#include <app/ConcreteClusterPath.h>
2122
#include <app/data-model-provider/MetadataTypes.h>
2223
#include <crypto/RandUtils.h>
2324
#include <lib/support/BitFlags.h>
@@ -66,6 +67,11 @@ constexpr std::array<AttributeEntry, 5> kGlobalAttributeEntries{ {
6667

6768
} // namespace
6869

70+
Span<const DataModel::AttributeEntry> DefaultServerCluster::GlobalAttributes()
71+
{
72+
return { kGlobalAttributeEntries.data(), kGlobalAttributeEntries.size() };
73+
}
74+
6975
DefaultServerCluster::DefaultServerCluster()
7076
{
7177
// SPEC - 7.10.3. Cluster Data Version
@@ -76,7 +82,28 @@ DefaultServerCluster::DefaultServerCluster()
7682
CHIP_ERROR DefaultServerCluster::Attributes(const ConcreteClusterPath & path, DataModel::ListBuilder<AttributeEntry> & builder)
7783
{
7884

79-
return builder.ReferenceExisting(kGlobalAttributeEntries);
85+
return builder.ReferenceExisting(GlobalAttributes());
86+
}
87+
88+
CHIP_ERROR DefaultServerCluster::Startup(ServerClusterContext * context)
89+
{
90+
VerifyOrReturnError(mContext == nullptr, CHIP_ERROR_ALREADY_INITIALIZED);
91+
mContext = context;
92+
return CHIP_NO_ERROR;
93+
}
94+
95+
void DefaultServerCluster::Shutdown()
96+
{
97+
mContext = nullptr;
98+
}
99+
100+
void DefaultServerCluster::NotifyAttributeChanged(AttributeId attributeId)
101+
{
102+
IncreaseDataVersion();
103+
104+
VerifyOrReturn(mContext != nullptr);
105+
const ConcreteClusterPath path = GetPath();
106+
mContext->interactionContext->dataModelChangeListener->MarkDirty({ path.mEndpointId, path.mClusterId, attributeId });
80107
}
81108

82109
BitFlags<ClusterQualityFlags> DefaultServerCluster::GetClusterFlags() const

src/app/server-cluster/DefaultServerCluster.h

+19
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ class DefaultServerCluster : public ServerClusterInterface
4040

4141
//////////////////////////// ServerClusterInterface implementation ////////////////////////////////////////
4242

43+
/// Startup allows only a single initialization per cluster and will
44+
/// fail with CHIP_ERROR_ALREADY_INITIALIZED if the object has already
45+
/// been initialized.
46+
///
47+
/// Call Shutdown to de-initialize the object.
48+
CHIP_ERROR Startup(ServerClusterContext * context) override;
49+
void Shutdown() override;
50+
4351
[[nodiscard]] DataVersion GetDataVersion() const override { return mDataVersion; }
4452
[[nodiscard]] BitFlags<DataModel::ClusterQualityFlags> GetClusterFlags() const override;
4553

@@ -73,9 +81,20 @@ class DefaultServerCluster : public ServerClusterInterface
7381
/// Default implementation is a NOOP (no list items generated)
7482
CHIP_ERROR GeneratedCommands(const ConcreteClusterPath & path, DataModel::ListBuilder<CommandId> & builder) override;
7583

84+
/// Returns all global attributes that the spec defines in `7.13 Global Elements / Table 93: Global Attributes`
85+
static Span<const DataModel::AttributeEntry> GlobalAttributes();
86+
7687
protected:
88+
ServerClusterContext * mContext = nullptr;
89+
7790
void IncreaseDataVersion() { mDataVersion++; }
7891

92+
/// Marks that a specific attribute has changed value
93+
///
94+
/// This increases cluster data version and if a cluster context is available it will
95+
/// notify that the attribute has changed.
96+
void NotifyAttributeChanged(AttributeId attributeId);
97+
7998
private:
8099
DataVersion mDataVersion; // will be random-initialized as per spec
81100
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2025 Project CHIP Authors
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#pragma once
18+
19+
#include <app/data-model-provider/Context.h>
20+
#include <app/data-model-provider/Provider.h>
21+
#include <lib/core/CHIPPersistentStorageDelegate.h>
22+
23+
namespace chip {
24+
namespace app {
25+
26+
/// Represents a runtime context for server cluster interfaces to interact
27+
/// with the outside world such as:
28+
/// - notify of state changes to trigger attribute reports
29+
/// - emit events
30+
/// - potentially interact/review global metadata
31+
///
32+
/// The context object is quite large in terms of exposed functionality and not all clusters use
33+
/// all the information within, however a common context is used to minimize RAM overhead
34+
/// for every cluster maintaining such a context.
35+
struct ServerClusterContext
36+
{
37+
DataModel::Provider * const provider = nullptr; /// underlying provider that the cluster operates in
38+
PersistentStorageDelegate * const storage = nullptr; /// read/write persistent storage
39+
DataModel::InteractionModelContext * const interactionContext = nullptr; /// outside-world communication
40+
41+
ServerClusterContext(ServerClusterContext &&) = default;
42+
43+
bool operator!=(const ServerClusterContext & other) const
44+
{
45+
return (provider != other.provider) //
46+
|| (interactionContext != other.interactionContext) //
47+
|| (storage != other.storage);
48+
}
49+
};
50+
51+
} // namespace app
52+
} // namespace chip

src/app/server-cluster/ServerClusterInterface.h

+10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <app/data-model-provider/MetadataList.h>
2525
#include <app/data-model-provider/MetadataTypes.h>
2626
#include <app/data-model-provider/OperationTypes.h>
27+
#include <app/server-cluster/ServerClusterContext.h>
2728
#include <lib/core/CHIPError.h>
2829
#include <lib/core/DataModelTypes.h>
2930
#include <lib/support/BitFlags.h>
@@ -42,6 +43,15 @@ class ServerClusterInterface
4243
public:
4344
virtual ~ServerClusterInterface() = default;
4445

46+
/// Starts up the server cluster interface.
47+
///
48+
/// The `context` lifetime must be guaranteed to last
49+
/// until `Shutdown` is called.
50+
virtual CHIP_ERROR Startup(ServerClusterContext * context) = 0;
51+
52+
/// A shutdown will always be paired with a corresponding Startup.
53+
virtual void Shutdown() = 0;
54+
4555
///////////////////////////////////// Cluster Metadata Support //////////////////////////////////////////////////
4656

4757
/// The path to this cluster instance.
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) 2025 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
import("//build_overrides/build.gni")
15+
import("//build_overrides/chip.gni")
16+
import("${chip_root}/build/chip/chip_test_suite.gni")
17+
18+
source_set("testing") {
19+
sources = [
20+
"EmptyProvider.cpp",
21+
"EmptyProvider.h",
22+
"TestEventGenerator.h",
23+
"TestProviderChangeListener.h",
24+
"TestServerClusterContext.h",
25+
]
26+
27+
public_deps = [
28+
"${chip_root}/src/app/server-cluster",
29+
"${chip_root}/src/lib/support:testing",
30+
]
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright (c) 2025 Project CHIP Authors
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#include <app/server-cluster/testing/EmptyProvider.h>
18+
19+
namespace chip {
20+
namespace Test {
21+
22+
using Protocols::InteractionModel::Status;
23+
using namespace chip::app;
24+
using namespace chip::app::DataModel;
25+
26+
CHIP_ERROR EmptyProvider::Shutdown()
27+
{
28+
return CHIP_NO_ERROR;
29+
}
30+
31+
CHIP_ERROR EmptyProvider::Endpoints(ListBuilder<app::DataModel::EndpointEntry> & builder)
32+
{
33+
return CHIP_NO_ERROR;
34+
}
35+
36+
CHIP_ERROR EmptyProvider::SemanticTags(EndpointId endpointId, ListBuilder<SemanticTag> & builder)
37+
{
38+
return CHIP_IM_GLOBAL_STATUS(UnsupportedEndpoint);
39+
}
40+
CHIP_ERROR EmptyProvider::DeviceTypes(EndpointId endpointId, ListBuilder<app::DataModel::DeviceTypeEntry> & builder)
41+
{
42+
return CHIP_IM_GLOBAL_STATUS(UnsupportedEndpoint);
43+
}
44+
45+
CHIP_ERROR EmptyProvider::ClientClusters(EndpointId endpointId, ListBuilder<ClusterId> & builder)
46+
{
47+
return CHIP_IM_GLOBAL_STATUS(UnsupportedEndpoint);
48+
}
49+
CHIP_ERROR EmptyProvider::ServerClusters(EndpointId endpointId, ListBuilder<app::DataModel::ServerClusterEntry> & builder)
50+
{
51+
return CHIP_IM_GLOBAL_STATUS(UnsupportedEndpoint);
52+
}
53+
54+
CHIP_ERROR EmptyProvider::Attributes(const app::ConcreteClusterPath & path, ListBuilder<app::DataModel::AttributeEntry> & builder)
55+
{
56+
return CHIP_IM_GLOBAL_STATUS(UnsupportedEndpoint);
57+
}
58+
59+
CHIP_ERROR EmptyProvider::GeneratedCommands(const app::ConcreteClusterPath & path, ListBuilder<CommandId> & builder)
60+
{
61+
return CHIP_IM_GLOBAL_STATUS(UnsupportedEndpoint);
62+
}
63+
64+
CHIP_ERROR EmptyProvider::AcceptedCommands(const app::ConcreteClusterPath & path,
65+
ListBuilder<app::DataModel::AcceptedCommandEntry> & builder)
66+
{
67+
return CHIP_IM_GLOBAL_STATUS(UnsupportedEndpoint);
68+
}
69+
70+
void EmptyProvider::Temporary_ReportAttributeChanged(const app::AttributePathParams & path) {}
71+
72+
ActionReturnStatus EmptyProvider::ReadAttribute(const app::DataModel::ReadAttributeRequest & request,
73+
app::AttributeValueEncoder & encoder)
74+
{
75+
return Status::UnsupportedEndpoint;
76+
}
77+
78+
ActionReturnStatus EmptyProvider::WriteAttribute(const app::DataModel::WriteAttributeRequest & request,
79+
app::AttributeValueDecoder & decoder)
80+
{
81+
return Status::UnsupportedEndpoint;
82+
}
83+
std::optional<ActionReturnStatus> EmptyProvider::InvokeCommand(const app::DataModel::InvokeRequest & request,
84+
chip::TLV::TLVReader & input_arguments,
85+
app::CommandHandler * handler)
86+
{
87+
return Status::UnsupportedEndpoint;
88+
}
89+
90+
} // namespace Test
91+
} // namespace chip

0 commit comments

Comments
 (0)