components/esp_matter: Add chime device type

This commit is contained in:
mahesh
2025-12-04 16:48:32 +05:30
parent 46d1af520f
commit 6daddbffe7
8 changed files with 144 additions and 5 deletions
@@ -59,6 +59,7 @@ enum device_type_enum {
ESP_MATTER_SOLAR_POWER,
ESP_MATTER_BATTERY_STORAGE,
ESP_MATTER_HEAT_PUMP,
ESP_MATTER_CHIME,
ESP_MATTER_THERMOSTAT_CONTROLLER,
ESP_MATTER_CLOSURE_CONTROLLER,
ESP_MATTER_CLOSURE,
@@ -128,6 +129,7 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
{"solar_power", ESP_MATTER_SOLAR_POWER},
{"battery_storage", ESP_MATTER_BATTERY_STORAGE},
{"heat_pump", ESP_MATTER_HEAT_PUMP},
{"chime", ESP_MATTER_CHIME},
{"thermostat_controller", ESP_MATTER_THERMOSTAT_CONTROLLER},
{"closure_controller", ESP_MATTER_CLOSURE_CONTROLLER},
{"closure", ESP_MATTER_CLOSURE},
@@ -29,6 +29,7 @@
#include <app/clusters/fan-control-server/fan-control-delegate.h>
#include <app/clusters/fan-control-server/fan-control-server.h>
#include "electrical_measurement/electrical_measurement.h"
#include "mock_delegates/mock_chime_delegate.h"
// External variables for electrical sensor initialization
bool g_electrical_sensor_created = false;
@@ -168,6 +169,8 @@ static void initialize_console(void)
namespace esp_matter {
static chip::app::Clusters::PowerTopology::PowerTopologyDelegate powerTopologyDelegate;
static chip::app::Clusters::Chime::MockChimeDelegate chimeDelegate;
namespace data_model {
int create(uint8_t device_type_index)
@@ -582,6 +585,12 @@ int create(uint8_t device_type_index)
endpoint = esp_matter::endpoint::heat_pump::create(node, &heat_pump_config, ENDPOINT_FLAG_NONE, NULL);
break;
}
case ESP_MATTER_CHIME: {
esp_matter::endpoint::chime::config_t chime_config;
chime_config.chime.delegate = &chimeDelegate;
endpoint = esp_matter::endpoint::chime::create(node, &chime_config, ENDPOINT_FLAG_NONE, NULL);
break;
}
case ESP_MATTER_THERMOSTAT_CONTROLLER: {
esp_matter::endpoint::thermostat_controller::config_t thermostat_controller_config;
endpoint = esp_matter::endpoint::thermostat_controller::create(node, &thermostat_controller_config, ENDPOINT_FLAG_NONE, NULL);
@@ -0,0 +1,44 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "esp_log.h"
#include "mock_chime_delegate.h"
namespace chip {
namespace app {
namespace Clusters {
namespace Chime {
MockChimeDelegate::~MockChimeDelegate() = default;
CHIP_ERROR MockChimeDelegate::GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chimeID, MutableCharSpan & name)
{
// Implement your own logic here.
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
return CHIP_NO_ERROR;
}
CHIP_ERROR MockChimeDelegate::GetChimeIDByIndex(uint8_t chimeIndex, uint8_t & chimeID)
{
// Implement your own logic here.
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
return CHIP_NO_ERROR;
}
Protocols::InteractionModel::Status MockChimeDelegate::PlayChimeSound()
{
// Implement your own logic here.
ESP_LOGE(LOG_TAG, "%s is not implemented", __func__);
return Protocols::InteractionModel::Status::Success;
}
} // namespace Chime
} // namespace Clusters
} // namespace app
} // namespace chip
@@ -0,0 +1,43 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#pragma once
#include <app-common/zap-generated/cluster-objects.h>
#include <app/clusters/chime-server/chime-server.h>
/*
* Mock Chime Delegate Implementation
* This file provides a mock implementation of the Chime::Delegate interface
* that returns success for all methods.
*/
namespace chip {
namespace app {
namespace Clusters {
namespace Chime {
class MockChimeDelegate : public ChimeDelegate
{
public:
MockChimeDelegate() = default;
~MockChimeDelegate() override;
CHIP_ERROR GetChimeSoundByIndex(uint8_t chimeIndex, uint8_t & chimeID, MutableCharSpan & name) override;
CHIP_ERROR GetChimeIDByIndex(uint8_t chimeIndex, uint8_t & chimeID) override;
Protocols::InteractionModel::Status PlayChimeSound() override;
private:
const char *LOG_TAG = "chime";
};
} // namespace Chime
} // namespace Clusters
} // namespace app
} // namespace chip