Skip to content

Commit 67bedcd

Browse files
authored
Add chime server to build (#37365)
* Add chime server to build * Implement chime delegate instance for all-clusters-app * Implement chime delegate instance for all-clusters-app * Implement chime delegate instance for all-clusters-app * Implement chime delegate instance for all-clusters-app * Implement chime delegate instance for all-clusters-app
1 parent b9a94b5 commit 67bedcd

File tree

19 files changed

+557
-52
lines changed

19 files changed

+557
-52
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+35
Original file line numberDiff line numberDiff line change
@@ -7014,6 +7014,28 @@ cluster LowPower = 1288 {
70147014
command Sleep(): DefaultSuccess = 0;
70157015
}
70167016

7017+
/** This cluster provides facilities to configure and play Chime sounds, such as those used in a doorbell. */
7018+
provisional cluster Chime = 1366 {
7019+
revision 1;
7020+
7021+
struct ChimeSoundStruct {
7022+
int8u chimeID = 0;
7023+
char_string<48> name = 1;
7024+
}
7025+
7026+
readonly attribute ChimeSoundStruct installedChimeSounds[] = 0;
7027+
attribute int8u activeChimeID = 1;
7028+
attribute boolean enabled = 2;
7029+
readonly attribute command_id generatedCommandList[] = 65528;
7030+
readonly attribute command_id acceptedCommandList[] = 65529;
7031+
readonly attribute event_id eventList[] = 65530;
7032+
readonly attribute attrib_id attributeList[] = 65531;
7033+
readonly attribute bitmap32 featureMap = 65532;
7034+
readonly attribute int16u clusterRevision = 65533;
7035+
7036+
command PlayChimeSound(): DefaultSuccess = 0;
7037+
}
7038+
70177039
/** The Test Cluster is meant to validate the generated code */
70187040
internal cluster UnitTesting = 4294048773 {
70197041
revision 1; // NOTE: Default/not specifically set
@@ -9291,6 +9313,19 @@ endpoint 1 {
92919313
handle command Sleep;
92929314
}
92939315

9316+
server cluster Chime {
9317+
callback attribute installedChimeSounds;
9318+
callback attribute activeChimeID;
9319+
callback attribute enabled;
9320+
callback attribute generatedCommandList;
9321+
callback attribute acceptedCommandList;
9322+
callback attribute attributeList;
9323+
ram attribute featureMap default = 0;
9324+
ram attribute clusterRevision default = 1;
9325+
9326+
handle command PlayChimeSound;
9327+
}
9328+
92949329
server cluster UnitTesting {
92959330
emits event TestEvent;
92969331
emits event TestFabricScopedEvent;

examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

+149
Original file line numberDiff line numberDiff line change
@@ -20958,6 +20958,155 @@
2095820958
}
2095920959
]
2096020960
},
20961+
{
20962+
"name": "Chime",
20963+
"code": 1366,
20964+
"mfgCode": null,
20965+
"define": "CHIME_CLUSTER",
20966+
"side": "server",
20967+
"enabled": 1,
20968+
"apiMaturity": "provisional",
20969+
"commands": [
20970+
{
20971+
"name": "PlayChimeSound",
20972+
"code": 0,
20973+
"mfgCode": null,
20974+
"source": "client",
20975+
"isIncoming": 1,
20976+
"isEnabled": 1
20977+
}
20978+
],
20979+
"attributes": [
20980+
{
20981+
"name": "InstalledChimeSounds",
20982+
"code": 0,
20983+
"mfgCode": null,
20984+
"side": "server",
20985+
"type": "array",
20986+
"included": 1,
20987+
"storageOption": "External",
20988+
"singleton": 0,
20989+
"bounded": 0,
20990+
"defaultValue": "",
20991+
"reportable": 1,
20992+
"minInterval": 1,
20993+
"maxInterval": 65534,
20994+
"reportableChange": 0
20995+
},
20996+
{
20997+
"name": "ActiveChimeID",
20998+
"code": 1,
20999+
"mfgCode": null,
21000+
"side": "server",
21001+
"type": "int8u",
21002+
"included": 1,
21003+
"storageOption": "External",
21004+
"singleton": 0,
21005+
"bounded": 0,
21006+
"defaultValue": "",
21007+
"reportable": 1,
21008+
"minInterval": 1,
21009+
"maxInterval": 65534,
21010+
"reportableChange": 0
21011+
},
21012+
{
21013+
"name": "Enabled",
21014+
"code": 2,
21015+
"mfgCode": null,
21016+
"side": "server",
21017+
"type": "boolean",
21018+
"included": 1,
21019+
"storageOption": "External",
21020+
"singleton": 0,
21021+
"bounded": 0,
21022+
"defaultValue": "",
21023+
"reportable": 1,
21024+
"minInterval": 1,
21025+
"maxInterval": 65534,
21026+
"reportableChange": 0
21027+
},
21028+
{
21029+
"name": "GeneratedCommandList",
21030+
"code": 65528,
21031+
"mfgCode": null,
21032+
"side": "server",
21033+
"type": "array",
21034+
"included": 1,
21035+
"storageOption": "External",
21036+
"singleton": 0,
21037+
"bounded": 0,
21038+
"defaultValue": "",
21039+
"reportable": 1,
21040+
"minInterval": 1,
21041+
"maxInterval": 65534,
21042+
"reportableChange": 0
21043+
},
21044+
{
21045+
"name": "AcceptedCommandList",
21046+
"code": 65529,
21047+
"mfgCode": null,
21048+
"side": "server",
21049+
"type": "array",
21050+
"included": 1,
21051+
"storageOption": "External",
21052+
"singleton": 0,
21053+
"bounded": 0,
21054+
"defaultValue": "",
21055+
"reportable": 1,
21056+
"minInterval": 1,
21057+
"maxInterval": 65534,
21058+
"reportableChange": 0
21059+
},
21060+
{
21061+
"name": "AttributeList",
21062+
"code": 65531,
21063+
"mfgCode": null,
21064+
"side": "server",
21065+
"type": "array",
21066+
"included": 1,
21067+
"storageOption": "External",
21068+
"singleton": 0,
21069+
"bounded": 0,
21070+
"defaultValue": "",
21071+
"reportable": 1,
21072+
"minInterval": 1,
21073+
"maxInterval": 65534,
21074+
"reportableChange": 0
21075+
},
21076+
{
21077+
"name": "FeatureMap",
21078+
"code": 65532,
21079+
"mfgCode": null,
21080+
"side": "server",
21081+
"type": "bitmap32",
21082+
"included": 1,
21083+
"storageOption": "RAM",
21084+
"singleton": 0,
21085+
"bounded": 0,
21086+
"defaultValue": "0",
21087+
"reportable": 1,
21088+
"minInterval": 1,
21089+
"maxInterval": 65534,
21090+
"reportableChange": 0
21091+
},
21092+
{
21093+
"name": "ClusterRevision",
21094+
"code": 65533,
21095+
"mfgCode": null,
21096+
"side": "server",
21097+
"type": "int16u",
21098+
"included": 1,
21099+
"storageOption": "RAM",
21100+
"singleton": 0,
21101+
"bounded": 0,
21102+
"defaultValue": "1",
21103+
"reportable": 1,
21104+
"minInterval": 1,
21105+
"maxInterval": 65534,
21106+
"reportableChange": 0
21107+
}
21108+
]
21109+
},
2096121110
{
2096221111
"name": "Unit Testing",
2096321112
"code": 4294048773,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
*
3+
* Copyright (c) 2025 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#include <app/clusters/chime-server/chime-server.h>
22+
#include <app/util/config.h>
23+
#include <cstring>
24+
25+
namespace chip {
26+
namespace app {
27+
namespace Clusters {
28+
29+
/**
30+
* The application delegate to define the options & implement commands.
31+
*/
32+
class ChimeCommandDelegate : public ChimeDelegate
33+
{
34+
static ChimeCommandDelegate instance;
35+
static chip::app::Clusters::Chime::Structs::ChimeSoundStruct::Type supportedChimes[];
36+
37+
public:
38+
CHIP_ERROR GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chimeID, MutableCharSpan & name);
39+
40+
CHIP_ERROR GetChimeIDByIndex(uint8_t chimeIndex, uint8_t & chimeID);
41+
42+
Protocols::InteractionModel::Status PlayChimeSound();
43+
44+
ChimeCommandDelegate() = default;
45+
~ChimeCommandDelegate() = default;
46+
47+
static inline ChimeCommandDelegate & getInstance() { return instance; }
48+
};
49+
50+
} // namespace Clusters
51+
} // namespace app
52+
} // namespace chip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
*
3+
* Copyright (c) 2025 Matter Authors
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+
18+
#include <app-common/zap-generated/ids/Attributes.h>
19+
#include <app-common/zap-generated/ids/Clusters.h>
20+
#include <app/clusters/chime-server/chime-server.h>
21+
#include <chime-instance.h>
22+
23+
using namespace chip;
24+
using namespace chip::app;
25+
using namespace chip::app::DataModel;
26+
using namespace chip::app::Clusters;
27+
using namespace chip::app::Clusters::Chime;
28+
using namespace chip::app::Clusters::Chime::Attributes;
29+
using chip::Protocols::InteractionModel::Status;
30+
using ChimeSoundStructType = Structs::ChimeSoundStruct::Type;
31+
32+
ChimeCommandDelegate ChimeCommandDelegate::instance;
33+
34+
ChimeSoundStructType ChimeCommandDelegate::supportedChimes[] = {
35+
{ .chimeID = 5, .name = chip::CharSpan("Chime 5"_span) },
36+
{ .chimeID = 10, .name = chip::CharSpan("Chime 10"_span) },
37+
};
38+
39+
CHIP_ERROR ChimeCommandDelegate::GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chimeID, MutableCharSpan & name)
40+
{
41+
if (chimeIndex >= MATTER_ARRAY_SIZE(supportedChimes))
42+
{
43+
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
44+
}
45+
auto & selectedChime = supportedChimes[chimeIndex];
46+
chip::CopyCharSpanToMutableCharSpan(selectedChime.name, name);
47+
chimeID = selectedChime.chimeID;
48+
return CHIP_NO_ERROR;
49+
}
50+
51+
CHIP_ERROR ChimeCommandDelegate::GetChimeIDByIndex(uint8_t chimeIndex, uint8_t & chimeID)
52+
{
53+
if (chimeIndex >= MATTER_ARRAY_SIZE(supportedChimes))
54+
{
55+
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
56+
}
57+
auto & selectedChime = supportedChimes[chimeIndex];
58+
chimeID = selectedChime.chimeID;
59+
return CHIP_NO_ERROR;
60+
}
61+
62+
Status ChimeCommandDelegate::PlayChimeSound()
63+
{
64+
return Status::Success;
65+
}
66+
67+
static ChimeServer gChimeClusterServerInstance = ChimeServer(EndpointId(1), ChimeCommandDelegate::getInstance());
68+
69+
void emberAfChimeClusterInitCallback(EndpointId endpoint)
70+
{
71+
gChimeClusterServerInstance.Init();
72+
}

examples/all-clusters-app/ameba/chip_main.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ list(
157157

158158
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp
159159
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp
160+
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp
160161
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp
161162
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp
162163
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp

examples/all-clusters-app/asr/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ asr_executable("clusters_app") {
7373
sources = [
7474
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp",
7575
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
76+
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp",
7677
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp",
7778
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp",
7879
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp",

examples/all-clusters-app/infineon/psoc6/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ psoc6_executable("clusters_app") {
115115
sources = [
116116
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp",
117117
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
118+
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp",
118119
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp",
119120
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp",
120121
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp",

examples/all-clusters-app/linux/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ source_set("chip-all-clusters-common") {
3434
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp",
3535
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp",
3636
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
37+
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp",
3738
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp",
3839
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp",
3940
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/dishwasher-alarm-stub.cpp",

examples/all-clusters-app/mbed/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ target_sources(${APP_TARGET} PRIVATE
6666
${MBED_COMMON}/util/DFUManager.cpp
6767
${ALL_CLUSTERS_COMMON}/src/bridged-actions-stub.cpp
6868
${ALL_CLUSTERS_COMMON}/src/air-quality-instance.cpp
69+
${ALL_CLUSTERS_COMMON}/src/chime-instance.cpp
6970
${ALL_CLUSTERS_COMMON}/src/concentration-measurement-instances.cpp
7071
${ALL_CLUSTERS_COMMON}/src/fan-stub.cpp
7172
${ALL_CLUSTERS_COMMON}/src/device-energy-management-stub.cpp

examples/all-clusters-app/nrfconnect/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ target_sources(app PRIVATE
6363
${ALL_CLUSTERS_COMMON_DIR}/src/device-energy-management-stub.cpp
6464
${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp
6565
${ALL_CLUSTERS_COMMON_DIR}/src/air-quality-instance.cpp
66+
${ALL_CLUSTERS_COMMON_DIR}/src/chime-instance.cpp
6667
${ALL_CLUSTERS_COMMON_DIR}/src/concentration-measurement-instances.cpp
6768
${ALL_CLUSTERS_COMMON_DIR}/src/resource-monitoring-delegates.cpp
6869
${ENERGY_MANAGEMENT_COMMON_DIR}/common/src/EnergyTimeUtils.cpp

examples/all-clusters-app/nxp/mw320/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ mw320_executable("shell_mw320") {
8484
sources = [
8585
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp",
8686
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
87+
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp",
8788
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp",
8889
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp",
8990
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp",

examples/all-clusters-app/nxp/zephyr/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ target_sources(app
108108
${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp
109109
${ALL_CLUSTERS_COMMON_DIR}/src/fan-stub.cpp
110110
${ALL_CLUSTERS_COMMON_DIR}/src/air-quality-instance.cpp
111+
${ALL_CLUSTERS_COMMON_DIR}/src/chime-instance.cpp
111112
${ALL_CLUSTERS_COMMON_DIR}/src/concentration-measurement-instances.cpp
112113
${ALL_CLUSTERS_COMMON_DIR}/src/resource-monitoring-delegates.cpp
113114
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/icd/source/ICDUtil.cpp

0 commit comments

Comments
 (0)