Skip to content

Commit

Permalink
Add chime server to build (#37365)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gmarcosb authored Feb 27, 2025
1 parent b9a94b5 commit 67bedcd
Show file tree
Hide file tree
Showing 19 changed files with 557 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7014,6 +7014,28 @@ cluster LowPower = 1288 {
command Sleep(): DefaultSuccess = 0;
}

/** This cluster provides facilities to configure and play Chime sounds, such as those used in a doorbell. */
provisional cluster Chime = 1366 {
revision 1;

struct ChimeSoundStruct {
int8u chimeID = 0;
char_string<48> name = 1;
}

readonly attribute ChimeSoundStruct installedChimeSounds[] = 0;
attribute int8u activeChimeID = 1;
attribute boolean enabled = 2;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

command PlayChimeSound(): DefaultSuccess = 0;
}

/** The Test Cluster is meant to validate the generated code */
internal cluster UnitTesting = 4294048773 {
revision 1; // NOTE: Default/not specifically set
Expand Down Expand Up @@ -9291,6 +9313,19 @@ endpoint 1 {
handle command Sleep;
}

server cluster Chime {
callback attribute installedChimeSounds;
callback attribute activeChimeID;
callback attribute enabled;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;

handle command PlayChimeSound;
}

server cluster UnitTesting {
emits event TestEvent;
emits event TestFabricScopedEvent;
Expand Down
149 changes: 149 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -20958,6 +20958,155 @@
}
]
},
{
"name": "Chime",
"code": 1366,
"mfgCode": null,
"define": "CHIME_CLUSTER",
"side": "server",
"enabled": 1,
"apiMaturity": "provisional",
"commands": [
{
"name": "PlayChimeSound",
"code": 0,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
}
],
"attributes": [
{
"name": "InstalledChimeSounds",
"code": 0,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ActiveChimeID",
"code": 1,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "Enabled",
"code": 2,
"mfgCode": null,
"side": "server",
"type": "boolean",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AcceptedCommandList",
"code": 65529,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "server",
"type": "bitmap32",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
}
]
},
{
"name": "Unit Testing",
"code": 4294048773,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* 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

#include <app/clusters/chime-server/chime-server.h>
#include <app/util/config.h>
#include <cstring>

namespace chip {
namespace app {
namespace Clusters {

/**
* The application delegate to define the options & implement commands.
*/
class ChimeCommandDelegate : public ChimeDelegate
{
static ChimeCommandDelegate instance;
static chip::app::Clusters::Chime::Structs::ChimeSoundStruct::Type supportedChimes[];

public:
CHIP_ERROR GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chimeID, MutableCharSpan & name);

CHIP_ERROR GetChimeIDByIndex(uint8_t chimeIndex, uint8_t & chimeID);

Protocols::InteractionModel::Status PlayChimeSound();

ChimeCommandDelegate() = default;
~ChimeCommandDelegate() = default;

static inline ChimeCommandDelegate & getInstance() { return instance; }
};

} // namespace Clusters
} // namespace app
} // namespace chip
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
*
* Copyright (c) 2025 Matter 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.
*/

#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/clusters/chime-server/chime-server.h>
#include <chime-instance.h>

using namespace chip;
using namespace chip::app;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::Chime;
using namespace chip::app::Clusters::Chime::Attributes;
using chip::Protocols::InteractionModel::Status;
using ChimeSoundStructType = Structs::ChimeSoundStruct::Type;

ChimeCommandDelegate ChimeCommandDelegate::instance;

ChimeSoundStructType ChimeCommandDelegate::supportedChimes[] = {
{ .chimeID = 5, .name = chip::CharSpan("Chime 5"_span) },
{ .chimeID = 10, .name = chip::CharSpan("Chime 10"_span) },
};

CHIP_ERROR ChimeCommandDelegate::GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chimeID, MutableCharSpan & name)
{
if (chimeIndex >= MATTER_ARRAY_SIZE(supportedChimes))
{
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
}
auto & selectedChime = supportedChimes[chimeIndex];
chip::CopyCharSpanToMutableCharSpan(selectedChime.name, name);
chimeID = selectedChime.chimeID;
return CHIP_NO_ERROR;
}

CHIP_ERROR ChimeCommandDelegate::GetChimeIDByIndex(uint8_t chimeIndex, uint8_t & chimeID)
{
if (chimeIndex >= MATTER_ARRAY_SIZE(supportedChimes))
{
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
}
auto & selectedChime = supportedChimes[chimeIndex];
chimeID = selectedChime.chimeID;
return CHIP_NO_ERROR;
}

Status ChimeCommandDelegate::PlayChimeSound()
{
return Status::Success;
}

static ChimeServer gChimeClusterServerInstance = ChimeServer(EndpointId(1), ChimeCommandDelegate::getInstance());

void emberAfChimeClusterInitCallback(EndpointId endpoint)
{
gChimeClusterServerInstance.Init();
}
1 change: 1 addition & 0 deletions examples/all-clusters-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ list(

${chip_dir}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/asr/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ asr_executable("clusters_app") {
sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp",
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/infineon/psoc6/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ psoc6_executable("clusters_app") {
sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp",
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ source_set("chip-all-clusters-common") {
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/dishwasher-alarm-stub.cpp",
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ target_sources(${APP_TARGET} PRIVATE
${MBED_COMMON}/util/DFUManager.cpp
${ALL_CLUSTERS_COMMON}/src/bridged-actions-stub.cpp
${ALL_CLUSTERS_COMMON}/src/air-quality-instance.cpp
${ALL_CLUSTERS_COMMON}/src/chime-instance.cpp
${ALL_CLUSTERS_COMMON}/src/concentration-measurement-instances.cpp
${ALL_CLUSTERS_COMMON}/src/fan-stub.cpp
${ALL_CLUSTERS_COMMON}/src/device-energy-management-stub.cpp
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ target_sources(app PRIVATE
${ALL_CLUSTERS_COMMON_DIR}/src/device-energy-management-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/air-quality-instance.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/chime-instance.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/concentration-measurement-instances.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/resource-monitoring-delegates.cpp
${ENERGY_MANAGEMENT_COMMON_DIR}/common/src/EnergyTimeUtils.cpp
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/nxp/mw320/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ mw320_executable("shell_mw320") {
sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/chime-instance.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp",
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/nxp/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ target_sources(app
${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/fan-stub.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/air-quality-instance.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/chime-instance.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/concentration-measurement-instances.cpp
${ALL_CLUSTERS_COMMON_DIR}/src/resource-monitoring-delegates.cpp
${EXAMPLE_PLATFORM_NXP_COMMON_DIR}/icd/source/ICDUtil.cpp
Expand Down
Loading

0 comments on commit 67bedcd

Please sign in to comment.