mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 11:03:05 +00:00
components/esp_matter: Add chime device type
This commit is contained in:
@@ -89,3 +89,6 @@ j. Energy
|
|||||||
|
|
||||||
k. Network Infrastructure
|
k. Network Infrastructure
|
||||||
1. Thread Border Router
|
1. Thread Border Router
|
||||||
|
|
||||||
|
l. Camera Device Types
|
||||||
|
1. Chime
|
||||||
|
|||||||
@@ -4060,10 +4060,9 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
|||||||
cluster_t *cluster = esp_matter::cluster::create(endpoint, Chime::Id, flags);
|
cluster_t *cluster = esp_matter::cluster::create(endpoint, Chime::Id, flags);
|
||||||
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Chime::Id));
|
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Chime::Id));
|
||||||
if (flags & CLUSTER_FLAG_SERVER) {
|
if (flags & CLUSTER_FLAG_SERVER) {
|
||||||
if (config->delegate != nullptr) {
|
VerifyOrReturnValue(config != NULL && config->delegate != nullptr, NULL, ESP_LOGE(TAG, "Delegate cannot be nullptr"));
|
||||||
static const auto delegate_init_cb = ChimeDelegateInitCB;
|
static const auto delegate_init_cb = ChimeDelegateInitCB;
|
||||||
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
||||||
}
|
|
||||||
static const auto plugin_server_init_cb = CALL_ONCE(MatterChimePluginServerInitCallback);
|
static const auto plugin_server_init_cb = CALL_ONCE(MatterChimePluginServerInitCallback);
|
||||||
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
|
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
|
||||||
add_function_list(cluster, function_list, function_flags);
|
add_function_list(cluster, function_list, function_flags);
|
||||||
@@ -4078,7 +4077,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
|||||||
global::attribute::create_cluster_revision(cluster, cluster_revision);
|
global::attribute::create_cluster_revision(cluster, cluster_revision);
|
||||||
|
|
||||||
command::create_play_chime_sound(cluster);
|
command::create_play_chime_sound(cluster);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & CLUSTER_FLAG_CLIENT) {
|
if (flags & CLUSTER_FLAG_CLIENT) {
|
||||||
|
|||||||
@@ -2053,6 +2053,30 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
|
|||||||
|
|
||||||
} /* camera */
|
} /* camera */
|
||||||
|
|
||||||
|
namespace chime {
|
||||||
|
uint32_t get_device_type_id()
|
||||||
|
{
|
||||||
|
return ESP_MATTER_CHIME_DEVICE_TYPE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t get_device_type_version()
|
||||||
|
{
|
||||||
|
return ESP_MATTER_CHIME_DEVICE_TYPE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
|
||||||
|
{
|
||||||
|
return common::create<config_t>(node, config, flags, priv_data, add);
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t add(endpoint_t *endpoint, config_t *config)
|
||||||
|
{
|
||||||
|
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
|
||||||
|
VerifyOrReturnError(err == ESP_OK, err);
|
||||||
|
VerifyOrReturnError(cluster::chime::create(endpoint, &(config->chime), CLUSTER_FLAG_SERVER), ESP_ERR_NO_MEM);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
} /* chime */
|
||||||
|
|
||||||
namespace thermostat_controller {
|
namespace thermostat_controller {
|
||||||
uint32_t get_device_type_id()
|
uint32_t get_device_type_id()
|
||||||
|
|||||||
@@ -159,6 +159,8 @@
|
|||||||
#define ESP_MATTER_CLOSURE_DEVICE_TYPE_VERSION 1
|
#define ESP_MATTER_CLOSURE_DEVICE_TYPE_VERSION 1
|
||||||
#define ESP_MATTER_CLOSURE_PANEL_DEVICE_TYPE_ID 0x0231
|
#define ESP_MATTER_CLOSURE_PANEL_DEVICE_TYPE_ID 0x0231
|
||||||
#define ESP_MATTER_CLOSURE_PANEL_DEVICE_TYPE_VERSION 1
|
#define ESP_MATTER_CLOSURE_PANEL_DEVICE_TYPE_VERSION 1
|
||||||
|
#define ESP_MATTER_CHIME_DEVICE_TYPE_ID 0x0146
|
||||||
|
#define ESP_MATTER_CHIME_DEVICE_TYPE_VERSION 1
|
||||||
|
|
||||||
namespace esp_matter {
|
namespace esp_matter {
|
||||||
|
|
||||||
@@ -1047,6 +1049,20 @@ esp_err_t add(endpoint_t *endpoint, config_t *config);
|
|||||||
|
|
||||||
} /* camera */
|
} /* camera */
|
||||||
|
|
||||||
|
namespace chime {
|
||||||
|
|
||||||
|
typedef struct config {
|
||||||
|
cluster::descriptor::config_t descriptor;
|
||||||
|
cluster::chime::config_t chime;
|
||||||
|
} config_t;
|
||||||
|
|
||||||
|
uint32_t get_device_type_id();
|
||||||
|
uint8_t get_device_type_version();
|
||||||
|
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data);
|
||||||
|
esp_err_t add(endpoint_t *endpoint, config_t *config);
|
||||||
|
|
||||||
|
} /* chime */
|
||||||
|
|
||||||
|
|
||||||
namespace thermostat_controller {
|
namespace thermostat_controller {
|
||||||
using config_t = app_client_config;
|
using config_t = app_client_config;
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ enum device_type_enum {
|
|||||||
ESP_MATTER_SOLAR_POWER,
|
ESP_MATTER_SOLAR_POWER,
|
||||||
ESP_MATTER_BATTERY_STORAGE,
|
ESP_MATTER_BATTERY_STORAGE,
|
||||||
ESP_MATTER_HEAT_PUMP,
|
ESP_MATTER_HEAT_PUMP,
|
||||||
|
ESP_MATTER_CHIME,
|
||||||
ESP_MATTER_THERMOSTAT_CONTROLLER,
|
ESP_MATTER_THERMOSTAT_CONTROLLER,
|
||||||
ESP_MATTER_CLOSURE_CONTROLLER,
|
ESP_MATTER_CLOSURE_CONTROLLER,
|
||||||
ESP_MATTER_CLOSURE,
|
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},
|
{"solar_power", ESP_MATTER_SOLAR_POWER},
|
||||||
{"battery_storage", ESP_MATTER_BATTERY_STORAGE},
|
{"battery_storage", ESP_MATTER_BATTERY_STORAGE},
|
||||||
{"heat_pump", ESP_MATTER_HEAT_PUMP},
|
{"heat_pump", ESP_MATTER_HEAT_PUMP},
|
||||||
|
{"chime", ESP_MATTER_CHIME},
|
||||||
{"thermostat_controller", ESP_MATTER_THERMOSTAT_CONTROLLER},
|
{"thermostat_controller", ESP_MATTER_THERMOSTAT_CONTROLLER},
|
||||||
{"closure_controller", ESP_MATTER_CLOSURE_CONTROLLER},
|
{"closure_controller", ESP_MATTER_CLOSURE_CONTROLLER},
|
||||||
{"closure", ESP_MATTER_CLOSURE},
|
{"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-delegate.h>
|
||||||
#include <app/clusters/fan-control-server/fan-control-server.h>
|
#include <app/clusters/fan-control-server/fan-control-server.h>
|
||||||
#include "electrical_measurement/electrical_measurement.h"
|
#include "electrical_measurement/electrical_measurement.h"
|
||||||
|
#include "mock_delegates/mock_chime_delegate.h"
|
||||||
|
|
||||||
// External variables for electrical sensor initialization
|
// External variables for electrical sensor initialization
|
||||||
bool g_electrical_sensor_created = false;
|
bool g_electrical_sensor_created = false;
|
||||||
@@ -168,6 +169,8 @@ static void initialize_console(void)
|
|||||||
namespace esp_matter {
|
namespace esp_matter {
|
||||||
|
|
||||||
static chip::app::Clusters::PowerTopology::PowerTopologyDelegate powerTopologyDelegate;
|
static chip::app::Clusters::PowerTopology::PowerTopologyDelegate powerTopologyDelegate;
|
||||||
|
static chip::app::Clusters::Chime::MockChimeDelegate chimeDelegate;
|
||||||
|
|
||||||
namespace data_model {
|
namespace data_model {
|
||||||
|
|
||||||
int create(uint8_t device_type_index)
|
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);
|
endpoint = esp_matter::endpoint::heat_pump::create(node, &heat_pump_config, ENDPOINT_FLAG_NONE, NULL);
|
||||||
break;
|
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: {
|
case ESP_MATTER_THERMOSTAT_CONTROLLER: {
|
||||||
esp_matter::endpoint::thermostat_controller::config_t thermostat_controller_config;
|
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);
|
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
|
||||||
Reference in New Issue
Block a user