submodule: update connectedhomeip submodule to commit id 8f943388af

This commit is contained in:
WanqQixiang
2026-01-06 09:45:20 +08:00
parent 20385fb136
commit baf5959df1
99 changed files with 6072 additions and 3927 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ variables:
IDF_CHECKOUT_REF: "v5.4.1"
# This variable represents the short hash of the connectedhomeip submodule.
# Note: Do change this short hash on submodule update MRs.
CHIP_SHORT_HASH: "cf84d0360c"
CHIP_SHORT_HASH: "8f943388a"
DOCKER_IMAGE_NAME: "espressif/chip-idf"
.add_gitlab_ssh_key: &add_gitlab_ssh_key |
+1 -1
View File
@@ -30,7 +30,7 @@ section in the ESP-Matter Programming Guide.
## Supported ESP-IDF and connectedhomeip versions
- This SDK currently works with commit [cf84d0360c] (https://github.com/project-chip/connectedhomeip/tree/cf84d0360c) of connectedhomeip.
- This SDK currently works with commit [8f943388af] (https://github.com/project-chip/connectedhomeip/tree/8f943388af) of connectedhomeip.
- For Matter projects development with this SDK, it is recommended to utilize ESP-IDF [v5.4.1](https://github.com/espressif/esp-idf/tree/v5.4.1).
- For ESP32C5 and ESP32C61, it is recommended to utilize ESP-IDF [v5.5.1](https://github.com/espressif/esp-idf/tree/v5.5.1).
+12 -7
View File
@@ -22,25 +22,30 @@ if (CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER)
get_supported_cluster_dirs(SUPPORTED_CLUSTER_DIRS)
foreach(CLUSTER_DIR ${SUPPORTED_CLUSTER_DIRS})
# If the cluster directory has .c/.cpp file, add it to SRC_DIRS_LIST
file(GLOB_RECURSE C_CPP_FILES "${CLUSTER_DIR}/*.c" "${CLUSTER_DIR}/*.cpp")
file(GLOB C_CPP_FILES "${CLUSTER_DIR}/*.c" "${CLUSTER_DIR}/*.cpp")
if (C_CPP_FILES)
list(APPEND SRC_DIRS_LIST "${CLUSTER_DIR}")
endif()
file(GLOB_RECURSE CODEGEN_INTEGRATION_FILE "${CLUSTER_DIR}/CodegenIntegration.cpp")
if (CODEGEN_INTEGRATION_FILE)
list(APPEND EXCLUDE_SRCS_LIST "${CLUSTER_DIR}/CodegenIntegration.cpp")
file(GLOB_RECURSE CODEGEN_FILES "${CLUSTER_DIR}/Codegen*.cpp")
if (CODEGEN_FILES)
list(APPEND EXCLUDE_SRCS_LIST ${CODEGEN_FILES})
endif()
endforeach()
list(APPEND SRC_DIRS_LIST "${MATTER_SDK_PATH}/src/app/clusters/on-off-server/codegen"
"${MATTER_SDK_PATH}/src/app/clusters/level-control/codegen")
file(GLOB ESP_MATTER_CLUSTER_DIRS_LIST "data_model_provider/clusters/*")
foreach(ESP_MATTER_CLUSTER_DIR ${ESP_MATTER_CLUSTER_DIRS_LIST})
list(APPEND SRC_DIRS_LIST ${ESP_MATTER_CLUSTER_DIR})
endforeach()
list(APPEND SRC_DIRS_LIST "data_model"
"data_model_provider"
"data_model_provider/clusters"
"data_model/private")
list(APPEND INCLUDE_DIRS_LIST "zap_common"
"data_model")
list(APPEND PRIV_INCLUDE_DIRS_LIST "data_model/private")
list(APPEND EXCLUDE_SRCS_LIST "${MATTER_SDK_PATH}/src/app/clusters/network-commissioning/CodegenInstance.cpp"
"${MATTER_SDK_PATH}/src/app/clusters/general-commissioning-server/TemporaryTestCoupling.cpp")
endif(CONFIG_ESP_MATTER_ENABLE_DATA_MODEL)
else()
list(APPEND EXCLUDE_SRCS_LIST "esp_matter_identify.cpp"
@@ -847,6 +847,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
/* Commands */
command::create_set_utc_time(cluster);
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterTimeSynchronizationClusterServerInitCallback,
ESPMatterTimeSynchronizationClusterServerShutdownCallback);
}
event::create_time_failure(cluster);
@@ -874,6 +876,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
/* Attributes not managed internally */
global::attribute::create_cluster_revision(cluster, cluster_revision);
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterUnitLocalizationClusterServerInitCallback,
ESPMatterUnitLocalizationClusterServerShutdownCallback);
}
return cluster;
@@ -971,8 +975,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, IcdManagement::Id));
#if CONFIG_ENABLE_ICD_SERVER
if (flags & CLUSTER_FLAG_SERVER) {
static const auto plugin_server_init_cb = CALL_ONCE(MatterIcdManagementPluginServerInitCallback);
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
set_plugin_server_init_callback(cluster, nullptr);
add_function_list(cluster, function_list, function_flags);
/* Attributes managed internally */
@@ -983,6 +986,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
/* Attributes not managed internally */
global::attribute::create_cluster_revision(cluster, cluster_revision);
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterIcdManagementClusterServerInitCallback,
ESPMatterIcdManagementClusterServerShutdownCallback);
}
#endif // CONFIG_ENABLE_ICD_SERVER
return cluster;
@@ -1130,11 +1135,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
} /* groups */
namespace scenes_management {
const function_generic_t function_list[] = {
(function_generic_t)emberAfScenesManagementClusterServerInitCallback,
(function_generic_t)MatterScenesManagementClusterServerShutdownCallback,
};
const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_SHUTDOWN_FUNCTION;
const function_generic_t *function_list = nullptr;
const int function_flags = CLUSTER_FLAG_NONE;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{
@@ -1158,6 +1160,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
} else {
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
}
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterScenesManagementClusterServerInitCallback,
ESPMatterScenesManagementClusterServerShutdownCallback);
}
/* Commands */
@@ -1540,14 +1544,24 @@ static cluster_t *create(endpoint_t *endpoint, T *config, uint8_t flags, uint32_
namespace hepa_filter_monitoring {
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{
return resource_monitoring::create<config_t, HepaFilterMonitoringDelegateInitCB>(endpoint, config, flags,HepaFilterMonitoring::Id, cluster_revision);
cluster_t *cluster = resource_monitoring::create<config_t, HepaFilterMonitoringDelegateInitCB>(endpoint, config, flags,HepaFilterMonitoring::Id, cluster_revision);
if (cluster && (flags & CLUSTER_FLAG_SERVER)) {
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterHepaFilterMonitoringClusterServerInitCallback,
ESPMatterHepaFilterMonitoringClusterServerShutdownCallback);
}
return cluster;
}
} /* hepa_filter_monitoring */
namespace activated_carbon_filter_monitoring {
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{
return resource_monitoring::create<config_t, ActivatedCarbonFilterMonitoringDelegateInitCB>(endpoint, config, flags,ActivatedCarbonFilterMonitoring::Id, cluster_revision);
cluster_t *cluster = resource_monitoring::create<config_t, ActivatedCarbonFilterMonitoringDelegateInitCB>(endpoint, config, flags,ActivatedCarbonFilterMonitoring::Id, cluster_revision);
if (cluster && (flags & CLUSTER_FLAG_SERVER)) {
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterActivatedCarbonFilterMonitoringClusterServerInitCallback,
ESPMatterActivatedCarbonFilterMonitoringClusterServerShutdownCallback);
}
return cluster;
}
} /* activated_carbon_filter_monitoring */
@@ -2238,10 +2252,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
} /* relative_humidity_measurement */
namespace occupancy_sensing {
const function_generic_t function_list[] = {
(function_generic_t)emberAfOccupancySensingClusterServerInitCallback,
};
const int function_flags = CLUSTER_FLAG_INIT_FUNCTION;
const function_generic_t *function_list = nullptr;
const int function_flags = CLUSTER_FLAG_NONE;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{
@@ -2296,6 +2308,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
if (has(feature::vision::get_id())) {
feature::vision::add(cluster);
}
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterOccupancySensingClusterServerInitCallback,
ESPMatterOccupancySensingClusterServerShutdownCallback);
} // if (flags & CLUSTER_FLAG_SERVER)
if (flags & CLUSTER_FLAG_CLIENT) {
@@ -2365,6 +2379,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
/* Attributes not managed internally */
global::attribute::create_cluster_revision(cluster, cluster_revision);
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterBooleanStateConfigurationClusterServerInitCallback,
ESPMatterBooleanStateConfigurationClusterServerShutdownCallback);
}
if (flags & CLUSTER_FLAG_CLIENT) {
@@ -3121,6 +3137,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
feature::dynamic_power_flow::add(cluster);
}
}
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterPowerTopologyClusterServerInitCallback,
ESPMatterPowerTopologyClusterServerShutdownCallback);
} // if (flags & CLUSTER_FLAG_SERVER)
return cluster;
@@ -3176,6 +3194,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
feature::power_quality::add(cluster);
}
}
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterElectricalPowerMeasurementClusterServerInitCallback,
ESPMatterElectricalPowerMeasurementClusterServerShutdownCallback);
} // if (flags & CLUSTER_FLAG_SERVER)
return cluster;
@@ -3221,6 +3241,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
if (has(feature::periodic_energy::get_id())) {
feature::periodic_energy::add(cluster);
}
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterElectricalEnergyMeasurementClusterServerInitCallback,
ESPMatterElectricalEnergyMeasurementClusterServerShutdownCallback);
} // if (flags & CLUSTER_FLAG_SERVER)
return cluster;
@@ -3379,6 +3401,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
attribute::create_abs_max_power(cluster, 0);
/** Attributes not managed internally **/
global::attribute::create_cluster_revision(cluster, cluster_revision);
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterDeviceEnergyManagementClusterServerInitCallback,
ESPMatterDeviceEnergyManagementClusterServerShutdownCallback);
}
if (flags & CLUSTER_FLAG_CLIENT) {
@@ -3925,7 +3949,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
command::create_provide_answer(cluster);
command::create_provide_ice_candidates(cluster);
command::create_end_session(cluster);
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterWebRTCTransportProviderClusterServerInitCallback,
ESPMatterWebRTCTransportProviderClusterServerShutdownCallback);
}
if (flags & CLUSTER_FLAG_CLIENT) {
@@ -4065,6 +4090,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
global::attribute::create_cluster_revision(cluster, cluster_revision);
command::create_play_chime_sound(cluster);
cluster::set_init_and_shutdown_callbacks(cluster, ESPMatterChimeClusterServerInitCallback,
ESPMatterChimeClusterServerShutdownCallback);
}
if (flags & CLUSTER_FLAG_CLIENT) {
@@ -160,49 +160,6 @@ static esp_err_t esp_matter_command_callback_add_group_if_identifying(const Conc
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_register_client(const ConcreteCommandPath &command_path,
TLVReader &tlv_data, void *opaque_ptr)
{
chip::app::Clusters::IcdManagement::Commands::RegisterClient::DecodableType command_data;
chip::app::CommandHandler *command_obj = (chip::app::CommandHandler *)opaque_ptr;
CHIP_ERROR error = command_data.Decode(tlv_data, command_obj->GetAccessingFabricIndex());
if (error == CHIP_NO_ERROR) {
#if CONFIG_ENABLE_ICD_SERVER
emberAfIcdManagementClusterRegisterClientCallback((CommandHandler *)opaque_ptr, command_path, command_data);
#endif
}
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_unregister_client(const ConcreteCommandPath &command_path,
TLVReader &tlv_data, void *opaque_ptr)
{
chip::app::Clusters::IcdManagement::Commands::UnregisterClient::DecodableType command_data;
chip::app::CommandHandler *command_obj = (chip::app::CommandHandler *)opaque_ptr;
CHIP_ERROR error = command_data.Decode(tlv_data, command_obj->GetAccessingFabricIndex());
if (error == CHIP_NO_ERROR) {
#if CONFIG_ENABLE_ICD_SERVER
emberAfIcdManagementClusterUnregisterClientCallback((CommandHandler *)opaque_ptr, command_path, command_data);
#endif
}
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_stay_active_request(const ConcreteCommandPath &command_path,
TLVReader &tlv_data, void *opaque_ptr)
{
chip::app::Clusters::IcdManagement::Commands::StayActiveRequest::DecodableType command_data;
CHIP_ERROR error = Decode(tlv_data, command_data);
if (error == CHIP_NO_ERROR) {
#if CONFIG_ENABLE_ICD_SERVER
emberAfIcdManagementClusterStayActiveRequestCallback((CommandHandler *)opaque_ptr, command_path, command_data);
#endif
}
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_off(const ConcreteCommandPath &command_path, TLVReader &tlv_data,
void *opaque_ptr)
{
@@ -1112,26 +1069,6 @@ static esp_err_t esp_matter_command_callback_send_key(const ConcreteCommandPath
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_suppress_alarm(const ConcreteCommandPath &command_path, TLVReader &tlv_data, void *opaque_ptr)
{
chip::app::Clusters::BooleanStateConfiguration::Commands::SuppressAlarm::DecodableType command_data;
CHIP_ERROR error = Decode(tlv_data, command_data);
if (error == CHIP_NO_ERROR) {
emberAfBooleanStateConfigurationClusterSuppressAlarmCallback((CommandHandler *)opaque_ptr, command_path, command_data);
}
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_enable_disable_alarm(const ConcreteCommandPath &command_path, TLVReader &tlv_data, void *opaque_ptr)
{
chip::app::Clusters::BooleanStateConfiguration::Commands::EnableDisableAlarm::DecodableType command_data;
CHIP_ERROR error = Decode(tlv_data, command_data);
if (error == CHIP_NO_ERROR) {
emberAfBooleanStateConfigurationClusterEnableDisableAlarmCallback((CommandHandler *)opaque_ptr, command_path, command_data);
}
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_open(const ConcreteCommandPath &command_path, TLVReader &tlv_data, void *opaque_ptr)
{
chip::app::Clusters::ValveConfigurationAndControl::Commands::Open::DecodableType command_data;
@@ -1152,64 +1089,6 @@ static esp_err_t esp_matter_command_callback_close(const ConcreteCommandPath &co
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_set_utc_time(const ConcreteCommandPath &command_path, TLVReader &tlv_data,
void *opaque_ptr)
{
chip::app::Clusters::TimeSynchronization::Commands::SetUTCTime::DecodableType command_data;
CHIP_ERROR error = Decode(tlv_data, command_data);
if (error == CHIP_NO_ERROR) {
emberAfTimeSynchronizationClusterSetUTCTimeCallback((CommandHandler *)opaque_ptr, command_path, command_data);
}
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_set_trusted_time_source(const ConcreteCommandPath &command_path,
TLVReader &tlv_data, void *opaque_ptr)
{
chip::app::Clusters::TimeSynchronization::Commands::SetTrustedTimeSource::DecodableType command_data;
chip::app::CommandHandler *command_obj = (chip::app::CommandHandler *)opaque_ptr;
CHIP_ERROR error = command_data.Decode(tlv_data, command_obj->GetAccessingFabricIndex());
if (error == CHIP_NO_ERROR) {
emberAfTimeSynchronizationClusterSetTrustedTimeSourceCallback((CommandHandler *)opaque_ptr, command_path,
command_data);
}
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_set_time_zone(const ConcreteCommandPath &command_path, TLVReader &tlv_data,
void *opaque_ptr)
{
chip::app::Clusters::TimeSynchronization::Commands::SetTimeZone::DecodableType command_data;
CHIP_ERROR error = Decode(tlv_data, command_data);
if (error == CHIP_NO_ERROR) {
emberAfTimeSynchronizationClusterSetTimeZoneCallback((CommandHandler *)opaque_ptr, command_path, command_data);
}
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_set_dst_offset(const ConcreteCommandPath &command_path, TLVReader &tlv_data,
void *opaque_ptr)
{
chip::app::Clusters::TimeSynchronization::Commands::SetDSTOffset::DecodableType command_data;
CHIP_ERROR error = Decode(tlv_data, command_data);
if (error == CHIP_NO_ERROR) {
emberAfTimeSynchronizationClusterSetDSTOffsetCallback((CommandHandler *)opaque_ptr, command_path, command_data);
}
return ESP_OK;
}
static esp_err_t esp_matter_command_callback_set_default_ntp(const ConcreteCommandPath &command_path, TLVReader &tlv_data,
void *opaque_ptr)
{
chip::app::Clusters::TimeSynchronization::Commands::SetDefaultNTP::DecodableType command_data;
CHIP_ERROR error = Decode(tlv_data, command_data);
if (error == CHIP_NO_ERROR) {
emberAfTimeSynchronizationClusterSetDefaultNTPCallback((CommandHandler *)opaque_ptr, command_path, command_data);
}
return ESP_OK;
}
namespace esp_matter {
namespace cluster {
@@ -1829,7 +1708,7 @@ namespace command {
command_t *create_register_client(cluster_t *cluster)
{
return esp_matter::command::create(cluster, IcdManagement::Commands::RegisterClient::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_register_client);
nullptr);
}
command_t *create_register_client_response(cluster_t *cluster)
@@ -1841,13 +1720,13 @@ command_t *create_register_client_response(cluster_t *cluster)
command_t *create_unregister_client(cluster_t *cluster)
{
return esp_matter::command::create(cluster, IcdManagement::Commands::UnregisterClient::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_unregister_client);
nullptr);
}
command_t *create_stay_active_request(cluster_t *cluster)
{
return esp_matter::command::create(cluster, IcdManagement::Commands::StayActiveRequest::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_stay_active_request);
nullptr);
}
command_t *create_stay_active_response(cluster_t *cluster)
{
@@ -2527,12 +2406,12 @@ namespace boolean_state_configuration {
namespace command {
command_t *create_suppress_alarm(cluster_t *cluster)
{
return esp_matter::command::create(cluster, BooleanStateConfiguration::Commands::SuppressAlarm::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_suppress_alarm);
return esp_matter::command::create(cluster, BooleanStateConfiguration::Commands::SuppressAlarm::Id, COMMAND_FLAG_ACCEPTED, nullptr);
}
command_t *create_enable_disable_alarm(cluster_t *cluster)
{
return esp_matter::command::create(cluster, BooleanStateConfiguration::Commands::EnableDisableAlarm::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_enable_disable_alarm);
return esp_matter::command::create(cluster, BooleanStateConfiguration::Commands::EnableDisableAlarm::Id, COMMAND_FLAG_ACCEPTED, nullptr);
}
} /* command */
@@ -2819,19 +2698,19 @@ namespace command {
command_t *create_set_utc_time(cluster_t *cluster)
{
return esp_matter::command::create(cluster, TimeSynchronization::Commands::SetUTCTime::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_set_utc_time);
nullptr);
}
command_t *create_set_trusted_time_source(cluster_t *cluster)
{
return esp_matter::command::create(cluster, TimeSynchronization::Commands::SetTrustedTimeSource::Id,
COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_set_trusted_time_source);
COMMAND_FLAG_ACCEPTED, nullptr);
}
command_t *create_set_time_zone(cluster_t *cluster)
{
return esp_matter::command::create(cluster, TimeSynchronization::Commands::SetTimeZone::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_set_time_zone);
nullptr);
}
command_t *create_set_time_zone_response(cluster_t *cluster)
@@ -2843,13 +2722,13 @@ command_t *create_set_time_zone_response(cluster_t *cluster)
command_t *create_set_dst_offset(cluster_t *cluster)
{
return esp_matter::command::create(cluster, TimeSynchronization::Commands::SetDSTOffset::Id,
COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_set_dst_offset);
COMMAND_FLAG_ACCEPTED, nullptr);
}
command_t *create_set_default_ntp(cluster_t *cluster)
{
return esp_matter::command::create(cluster, TimeSynchronization::Commands::SetDefaultNTP::Id,
COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_set_default_ntp);
COMMAND_FLAG_ACCEPTED, nullptr);
}
} /* command */
@@ -41,6 +41,7 @@
#include <lib/core/DataModelTypes.h>
#include <lib/core/TLV.h>
#include <lib/support/ScopedBuffer.h>
#include "support/CodeUtils.h"
#define ESP_MATTER_MAX_DEVICE_TYPE_COUNT CONFIG_ESP_MATTER_MAX_DEVICE_TYPE_COUNT
#define ESP_MATTER_MAX_SEMANTIC_TAG_COUNT 3
@@ -881,7 +882,7 @@ esp_err_t get_val(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_
writer.Init(scoped_buf.Get(), k_max_tlv_size_to_read_attribute_value);
chip::app::AttributeReportIBs::Builder reportBuilder = chip::app::AttributeReportIBs::Builder();
reportBuilder.Init(&writer);
VerifyOrReturnValue(reportBuilder.Init(&writer) == CHIP_NO_ERROR, ESP_FAIL);
chip::Access::SubjectDescriptor subjectDescriptor;
auto concrete_path = chip::app::ConcreteAttributePath(endpoint_id, cluster_id, attribute_id);
@@ -17,6 +17,7 @@
#include <esp_matter_attribute_utils.h>
#include <app/data-model-provider/Provider.h>
#include "app/ConcreteCommandPath.h"
#include "app/server-cluster/ServerClusterInterface.h"
#include "app/util/af-types.h"
#include "lib/core/DataModelTypes.h"
#include "lib/core/TLVReader.h"
@@ -550,7 +551,7 @@ typedef void (*initialization_callback_t)(uint16_t endpoint_id);
*
* This callback will be called when the data model is shutdown.
*/
typedef void (*shutdown_callback_t)(uint16_t endpoint_id);
typedef void (*shutdown_callback_t)(uint16_t endpoint_id, chip::app::ClusterShutdownType shutdownType);
/** Create cluster
*
@@ -26,13 +26,9 @@
#include <app/clusters/fan-control-server/fan-control-server.h>
#include <app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.h>
#include <app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-cluster.h>
#include <app/clusters/device-energy-management-server/device-energy-management-server.h>
#include <app/clusters/door-lock-server/door-lock-server.h>
#include <app/clusters/boolean-state-configuration-server/boolean-state-configuration-server.h>
#include <app/clusters/time-synchronization-server/time-synchronization-cluster.h>
#include <app/clusters/application-basic-server/application-basic-server.h>
#include <app/clusters/power-topology-server/power-topology-server.h>
#include <app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h>
#include <app/clusters/laundry-washer-controls-server/laundry-washer-controls-server.h>
#include <app/clusters/window-covering-server/window-covering-server.h>
#include <app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.h>
@@ -44,19 +40,25 @@
#include <app/clusters/commissioner-control-server/commissioner-control-server.h>
#include <app/clusters/actions-server/actions-server.h>
#include <app/clusters/thermostat-server/thermostat-server.h>
#include <app/clusters/ota-provider/ota-provider-cluster.h>
#include <app/clusters/ota-provider/CodegenIntegration.h>
#include <app/clusters/diagnostic-logs-server/diagnostic-logs-server.h>
#include <app/clusters/chime-server/chime-server.h>
#include <app/clusters/closure-control-server/closure-control-server.h>
#include <app/clusters/closure-dimension-server/closure-dimension-server.h>
#include <app/clusters/push-av-stream-transport-server/push-av-stream-transport-cluster.h>
#include <app/clusters/commodity-tariff-server/commodity-tariff-server.h>
#include <app/clusters/commodity-price-server/commodity-price-server.h>
#include <app/clusters/electrical-grid-conditions-server/electrical-grid-conditions-server.h>
#include <app/clusters/meter-identification-server/meter-identification-server.h>
#include <unordered_map>
#include <clusters/ota_software_update_provider/integration.h>
#include <clusters/push_av_stream_transport/integration.h>
#include <clusters/power_topology/integration.h>
#include <clusters/device_energy_management/integration.h>
#include <clusters/diagnostic_logs/integration.h>
#include <clusters/electrical_power_measurement/integration.h>
#include <clusters/time_synchronization/integration.h>
#include <clusters/resource_monitor/integration.h>
#include <clusters/chime/integration.h>
using namespace chip::app::Clusters;
namespace esp_matter {
namespace cluster {
@@ -95,21 +97,6 @@ chip::BitMask<EnergyEvse::OptionalAttributes> get_energy_evse_enabled_optional_a
return optional_attrs;
}
chip::BitMask<PowerTopology::OptionalAttributes> get_power_topology_enabled_optional_attributes(uint16_t endpoint_id)
{
chip::BitMask<PowerTopology::OptionalAttributes> optional_attrs = 0;
if (endpoint::is_attribute_enabled(endpoint_id, PowerTopology::Id, PowerTopology::Attributes::AvailableEndpoints::Id)) {
optional_attrs.Set(PowerTopology::OptionalAttributes::kOptionalAttributeAvailableEndpoints);
}
if (endpoint::is_attribute_enabled(endpoint_id, PowerTopology::Id, PowerTopology::Attributes::ActiveEndpoints::Id)) {
optional_attrs.Set(PowerTopology::OptionalAttributes::kOptionalAttributeActiveEndpoints);
}
return optional_attrs;
}
chip::BitMask<ElectricalPowerMeasurement::OptionalAttributes> get_electrical_power_measurement_enabled_optional_attributes(uint16_t endpoint_id)
{
chip::BitMask<ElectricalPowerMeasurement::OptionalAttributes> optional_attrs = 0;
@@ -191,7 +178,7 @@ void InitModeDelegate(void *delegate, uint16_t endpoint_id, uint32_t cluster_id)
ModeBase::Delegate *mode_delegate = static_cast<ModeBase::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, cluster_id);
modeInstance = new ModeBase::Instance(mode_delegate, endpoint_id, cluster_id, feature_map);
modeInstance->Init();
(void)modeInstance->Init();
}
void LaundryWasherModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -243,12 +230,16 @@ void MicrowaveOvenModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
} else {
modeInstance = s_microwave_oven_mode_instances[endpoint_id];
}
modeInstance->Init();
(void)modeInstance->Init();
}
void DeviceEnergyManagementModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
InitModeDelegate(delegate, endpoint_id, DeviceEnergyManagementMode::Id);
VerifyOrReturn(delegate != nullptr);
DeviceEnergyManagement::Delegate *_delegate = static_cast<DeviceEnergyManagement::Delegate*>(delegate);
chip::BitMask<DeviceEnergyManagement::Feature> feature_map(get_feature_map_value(endpoint_id, DeviceEnergyManagement::Id));
DeviceEnergyManagement::Instance *instance = new DeviceEnergyManagement::Instance(endpoint_id, *_delegate, feature_map);
(void)instance->Init();
}
void EnergyEvseDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -261,7 +252,7 @@ void EnergyEvseDelegateInitCB(void *delegate, uint16_t endpoint_id)
chip::BitMask<EnergyEvse::OptionalCommands> optional_cmds = get_energy_evse_enabled_optional_commands(endpoint_id);
energyEvseInstance = new EnergyEvse::Instance(endpoint_id, *energy_evse_delegate, chip::BitMask<EnergyEvse::Feature, uint32_t>(feature_map),
optional_attrs, optional_cmds);
energyEvseInstance->Init();
(void)energyEvseInstance->Init();
}
void MicrowaveOvenControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -300,7 +291,7 @@ void MicrowaveOvenControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
uint32_t feature_map = get_feature_map_value(endpoint_id, MicrowaveOvenControl::Id);
microwaveOvenControlInstance = new MicrowaveOvenControl::Instance(microwave_oven_control_delegate, endpoint_id, MicrowaveOvenControl::Id, feature_map,
*operationalStateInstance, *microwaveOvenModeInstance);
microwaveOvenControlInstance->Init();
(void)microwaveOvenControlInstance->Init();
}
void OperationalStateDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -316,7 +307,7 @@ void OperationalStateDelegateInitCB(void *delegate, uint16_t endpoint_id)
} else {
operationalStateInstance = s_operational_state_instances[endpoint_id];
}
operationalStateInstance->Init();
(void)operationalStateInstance->Init();
}
void FanControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -329,23 +320,17 @@ void FanControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
void HepaFilterMonitoringDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
VerifyOrReturn(delegate != nullptr);
static ResourceMonitoring::Instance * hepaFilterMonitoringInstance = nullptr;
ResourceMonitoring::Delegate *resource_monitoring_delegate = static_cast<ResourceMonitoring::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, HepaFilterMonitoring::Id);
hepaFilterMonitoringInstance = new ResourceMonitoring::Instance(resource_monitoring_delegate, endpoint_id, HepaFilterMonitoring::Id,
static_cast<uint32_t>(feature_map), ResourceMonitoring::DegradationDirectionEnum::kDown, true);
hepaFilterMonitoringInstance->Init();
(void) chip::app::Clusters::ResourceMonitoring::SetDefaultDelegate(endpoint_id, HepaFilterMonitoring::Id,
resource_monitoring_delegate);
}
void ActivatedCarbonFilterMonitoringDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
VerifyOrReturn(delegate != nullptr);
static ResourceMonitoring::Instance * activatedCarbonFilterMonitoringInstance = nullptr;
ResourceMonitoring::Delegate *resource_monitoring_delegate = static_cast<ResourceMonitoring::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, ActivatedCarbonFilterMonitoring::Id);
activatedCarbonFilterMonitoringInstance = new ResourceMonitoring::Instance(resource_monitoring_delegate, endpoint_id, ActivatedCarbonFilterMonitoring::Id,
static_cast<uint32_t>(feature_map), ResourceMonitoring::DegradationDirectionEnum::kDown, true);
activatedCarbonFilterMonitoringInstance->Init();
(void) chip::app::Clusters::ResourceMonitoring::SetDefaultDelegate(endpoint_id, ActivatedCarbonFilterMonitoring::Id,
resource_monitoring_delegate);
}
void LaundryDryerControlsDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -369,14 +354,14 @@ void DeviceEnergyManagementDelegateInitCB(void *delegate, uint16_t endpoint_id)
DeviceEnergyManagement::Delegate *device_energy_management_delegate = static_cast<DeviceEnergyManagement::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, DeviceEnergyManagement::Id);
deviceEnergyManagementInstance = new DeviceEnergyManagement::Instance(endpoint_id, *device_energy_management_delegate, chip::BitMask<DeviceEnergyManagement::Feature, uint32_t>(feature_map));
deviceEnergyManagementInstance->Init();
(void)deviceEnergyManagementInstance->Init();
}
void DoorLockDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
VerifyOrReturn(delegate != nullptr);
DoorLock::Delegate *door_lock_delegate = static_cast<DoorLock::Delegate*>(delegate);
DoorLockServer::Instance().SetDelegate(endpoint_id, door_lock_delegate);
(void)DoorLockServer::Instance().SetDelegate(endpoint_id, door_lock_delegate);
}
void BooleanStateConfigurationDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -405,11 +390,9 @@ void PowerTopologyDelegateInitCB(void *delegate, uint16_t endpoint_id)
VerifyOrReturn(delegate != nullptr);
static PowerTopology::Instance * powerTopologyInstance = nullptr;
PowerTopology::Delegate *power_topology_delegate = static_cast<PowerTopology::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, PowerTopology::Id);
chip::BitMask<PowerTopology::OptionalAttributes> optional_attrs = get_power_topology_enabled_optional_attributes(endpoint_id);
powerTopologyInstance = new PowerTopology::Instance(endpoint_id, *power_topology_delegate, chip::BitMask<PowerTopology::Feature,
uint32_t>(feature_map), optional_attrs);
powerTopologyInstance->Init();
chip::BitMask<PowerTopology::Feature> feature_map(get_feature_map_value(endpoint_id, PowerTopology::Id));
powerTopologyInstance = new PowerTopology::Instance(endpoint_id, *power_topology_delegate, feature_map);
(void)powerTopologyInstance->Init();
}
void ElectricalPowerMeasurementDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -421,7 +404,7 @@ void ElectricalPowerMeasurementDelegateInitCB(void *delegate, uint16_t endpoint_
chip::BitMask<ElectricalPowerMeasurement::OptionalAttributes> optional_attrs = get_electrical_power_measurement_enabled_optional_attributes(endpoint_id);
electricalPowerMeasurementInstance = new ElectricalPowerMeasurement::Instance(endpoint_id, *electrical_power_measurement_delegate,
chip::BitMask<ElectricalPowerMeasurement::Feature, uint32_t>(feature_map), optional_attrs);
electricalPowerMeasurementInstance->Init();
(void)electricalPowerMeasurementInstance->Init();
}
void LaundryWasherControlsDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -473,7 +456,7 @@ void ThreadBorderRouterManagementDelegateInitCB(void *delegate, uint16_t endpoin
assert(thread_br_delegate->GetPanChangeSupported() == pan_change_supported);
ThreadBorderRouterManagement::ServerInstance *server_instance =
chip::Platform::New<ThreadBorderRouterManagement::ServerInstance>(endpoint_id, thread_br_delegate, chip::Server::GetInstance().GetFailSafeContext());
server_instance->Init();
(void)server_instance->Init();
}
void ServiceAreaDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -491,7 +474,7 @@ void WaterHeaterManagementDelegateInitCB(void *delegate, uint16_t endpoint_id)
WaterHeaterManagement::Delegate *whtr_delegate = static_cast<WaterHeaterManagement::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, WaterHeaterManagement::Id);
wHtrInstance = new WaterHeaterManagement::Instance(endpoint_id, *whtr_delegate, chip::BitMask<WaterHeaterManagement::Feature, uint32_t>(feature_map));
wHtrInstance->Init();
(void)wHtrInstance->Init();
}
void EnergyPreferenceDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -514,7 +497,7 @@ void CommissionerControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
CommissionerControl::CommissionerControlServer *commissioner_control_instance = nullptr;
commissioner_control_instance =
new CommissionerControl::CommissionerControlServer(commissioner_control_delegate, endpoint_id);
commissioner_control_instance->Init();
(void)commissioner_control_instance->Init();
}
void ActionsDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -523,7 +506,7 @@ void ActionsDelegateInitCB(void *delegate, uint16_t endpoint_id)
static Actions::ActionsServer *actionsServer = nullptr;
Actions::Delegate *actions_delegate = static_cast<Actions::Delegate*>(delegate);
actionsServer = new Actions::ActionsServer(endpoint_id, *actions_delegate);
actionsServer->Init();
(void)actionsServer->Init();
}
@@ -542,17 +525,17 @@ void OtaSoftwareUpdateProviderDelegateInitCB(void *delegate, uint16_t endpoint_i
void DiagnosticLogsDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
VerifyOrReturn(delegate != nullptr);
VerifyOrReturn(delegate != nullptr && endpoint_id == chip::kRootEndpointId);
DiagnosticLogs::DiagnosticLogsProviderDelegate *diagnostic_logs_delegate = static_cast<DiagnosticLogs::DiagnosticLogsProviderDelegate*>(delegate);
DiagnosticLogs::DiagnosticLogsServer::Instance().SetDiagnosticLogsProviderDelegate(endpoint_id, diagnostic_logs_delegate);
DiagnosticLogs::SetDiagnosticLogsProviderDelegate(diagnostic_logs_delegate);
}
void ChimeDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
VerifyOrReturn(delegate != nullptr);
ChimeDelegate *chime_delegate = static_cast<ChimeDelegate*>(delegate);
ChimeServer *chime_server = new ChimeServer(endpoint_id, *chime_delegate);
chime_server->Init();
Chime::ChimeServer *chime_server = new Chime::ChimeServer(endpoint_id, *chime_delegate);
(void)chime_server->Init();
}
void ClosureControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
@@ -562,7 +545,7 @@ void ClosureControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
ClosureControl::MatterContext *matter_context = new ClosureControl::MatterContext(endpoint_id);
ClosureControl::ClusterLogic *cluster_logic = new ClosureControl::ClusterLogic(*closure_control_delegate, *matter_context);
ClosureControl::Interface *server_interface = new ClosureControl::Interface(endpoint_id, *cluster_logic);
server_interface->Init();
(void)server_interface->Init();
}
@@ -573,19 +556,15 @@ void ClosureDimensionDelegateInitCB(void *delegate, uint16_t endpoint_id)
ClosureDimension::MatterContext *matter_context = new ClosureDimension::MatterContext(endpoint_id);
ClosureDimension::ClusterLogic *cluster_logic = new ClosureDimension::ClusterLogic(*closure_dimension_delegate, *matter_context);
ClosureDimension::Interface *server_interface = new ClosureDimension::Interface(endpoint_id, *cluster_logic);
server_interface->Init();
(void)server_interface->Init();
}
void PushAvStreamTransportDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
VerifyOrReturn(delegate != nullptr);
static PushAvStreamTransportServer * pushavstreamtransportserverinstance = nullptr;
PushAvStreamTransportDelegate *push_av_stream_transport_delegate = static_cast<PushAvStreamTransportDelegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, PushAvStreamTransport::Id);
pushavstreamtransportserverinstance = new PushAvStreamTransportServer(endpoint_id, chip::BitMask<PushAvStreamTransport::Feature, uint32_t>(feature_map));
pushavstreamtransportserverinstance->SetDelegate(push_av_stream_transport_delegate);
pushavstreamtransportserverinstance->Init();
chip::app::Clusters::PushAvStreamTransport::SetDelegate(endpoint_id, push_av_stream_transport_delegate);
}
@@ -595,7 +574,7 @@ void CommodityTariffDelegateInitCB(void *delegate, uint16_t endpoint_id)
CommodityTariff::Delegate *commodity_tariff_delegate = static_cast<CommodityTariff::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, CommodityTariff::Id);
CommodityTariff::Instance *commodity_tariff_instance = new CommodityTariff::Instance(endpoint_id, *commodity_tariff_delegate, chip::BitMask<CommodityTariff::Feature, uint32_t>(feature_map));
commodity_tariff_instance->Init();
(void)commodity_tariff_instance->Init();
}
@@ -605,7 +584,7 @@ void CommodityPriceDelegateInitCB(void *delegate, uint16_t endpoint_id)
CommodityPrice::Delegate *commodity_price_delegate = static_cast<CommodityPrice::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, CommodityPrice::Id);
CommodityPrice::Instance *commodity_price_instance = new CommodityPrice::Instance(endpoint_id, *commodity_price_delegate, chip::BitMask<CommodityPrice::Feature, uint32_t>(feature_map));
commodity_price_instance->Init();
(void)commodity_price_instance->Init();
}
@@ -615,7 +594,7 @@ void ElectricalGridConditionsDelegateInitCB(void *delegate, uint16_t endpoint_id
ElectricalGridConditions::Delegate *electrical_grid_conditions_delegate = static_cast<ElectricalGridConditions::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, ElectricalGridConditions::Id);
ElectricalGridConditions::Instance *electrical_grid_conditions_instance = new ElectricalGridConditions::Instance(endpoint_id, *electrical_grid_conditions_delegate, chip::BitMask<ElectricalGridConditions::Feature, uint32_t>(feature_map));
electrical_grid_conditions_instance->Init();
(void)electrical_grid_conditions_instance->Init();
}
/* Not a delegate but an Initialization callback */
@@ -36,11 +36,11 @@ void ESPMatterAccessControlClusterServerInitCallback(EndpointId endpoint)
}
}
void ESPMatterAccessControlClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterAccessControlClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
// We implement the cluster as a singleton on the root endpoint.
VerifyOrReturn(endpointId == kRootEndpointId);
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister AccessControl - Error %" CHIP_ERROR_FORMAT, err.Format());
}
@@ -52,9 +52,9 @@ void ESPMatterAdministratorCommissioningClusterServerInitCallback(EndpointId end
}
}
void ESPMatterAdministratorCommissioningClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterAdministratorCommissioningClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Admin Commissioning unregister error: %" CHIP_ERROR_FORMAT, err.Format());
}
@@ -59,12 +59,12 @@ void ESPMatterBasicInformationClusterServerInitCallback(EndpointId endpoint)
}
}
void ESPMatterBasicInformationClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterBasicInformationClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
// We implement the cluster as a singleton on the root endpoint.
VerifyOrReturn(endpointId == kRootEndpointId);
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(gRegistration.serverClusterInterface);
esp_matter::data_model::provider::get_instance().registry().Unregister(gRegistration.serverClusterInterface, shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister BasicInformation - Error: %" CHIP_ERROR_FORMAT, err.Format());
}
@@ -13,7 +13,7 @@
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/bindings/binding-cluster.h>
#include <app/clusters/bindings/BindingCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <unordered_map>
@@ -41,10 +41,10 @@ void ESPMatterBindingClusterServerInitCallback(EndpointId endpointId)
}
}
void ESPMatterBindingClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterBindingClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster());
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister Binding on endpoint %u - Error: %" CHIP_ERROR_FORMAT, endpointId,
err.Format());
@@ -13,9 +13,10 @@
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/boolean-state-server/boolean-state-cluster.h>
#include <app/clusters/boolean-state-server/BooleanStateCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <unordered_map>
#include "integration.h"
using namespace chip;
using namespace chip::app;
@@ -41,10 +42,10 @@ void ESPMatterBooleanStateClusterServerInitCallback(EndpointId endpointId)
}
}
void ESPMatterBooleanStateClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterBooleanStateClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster());
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister BooleanState on endpoint %u - Error: %" CHIP_ERROR_FORMAT,
endpointId, err.Format());
@@ -55,3 +56,15 @@ void ESPMatterBooleanStateClusterServerShutdownCallback(EndpointId endpointId)
void MatterBooleanStatePluginServerInitCallback() {}
void MatterBooleanStatePluginServerShutdownCallback() {}
namespace chip::app::Clusters::BooleanState {
BooleanStateCluster * FindClusterOnEndpoint(EndpointId endpointId)
{
if (gServers[endpointId].IsConstructed()) {
return &gServers[endpointId].Cluster();
}
return nullptr;
}
} // namespace chip::app::Clusters::BooleanState
@@ -0,0 +1,23 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/boolean-state-server/BooleanStateCluster.h>
namespace chip::app::Clusters::BooleanState {
BooleanStateCluster * FindClusterOnEndpoint(EndpointId endpointId);
} // namespace chip::app::Clusters::BooleanState
@@ -0,0 +1,137 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "integration.h"
#include "esp_matter_attribute_utils.h"
#include "esp_matter_data_model.h"
#include "esp_matter_data_model_priv.h"
#include "esp_matter_data_model_provider.h"
#include <unordered_map>
#include "app/clusters/boolean-state-configuration-server/BooleanStateConfigurationCluster.h"
#include "app/server-cluster/ServerClusterInterfaceRegistry.h"
#include "clusters/BooleanStateConfiguration/Enums.h"
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::BooleanStateConfiguration;
namespace {
std::unordered_map<EndpointId, LazyRegisteredServerCluster<BooleanStateConfigurationCluster>> gServers;
esp_err_t get_attr_val(esp_matter::cluster_t *cluster, uint32_t attribute_id, esp_matter_attr_val_t &val)
{
esp_matter::attribute_t *attr = esp_matter::attribute::get(cluster, attribute_id);
if (!attr) {
return ESP_FAIL;
}
return esp_matter::attribute::get_val_internal(attr, &val);
}
CHIP_ERROR GetClusterConfig(EndpointId endpointId, BitMask<Feature> &featureMap, uint8_t &supportedSensitivityLevels,
uint8_t &defaultSensitivityLevel,
BooleanStateConfiguration::AlarmModeBitmap &alarmsSupported,
BooleanStateConfigurationCluster::OptionalAttributesSet &optionalAttrSet)
{
esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpointId, BooleanStateConfiguration::Id);
if (!cluster) {
return CHIP_ERROR_NOT_FOUND;
}
esp_matter_attr_val_t tmp_attr_val;
VerifyOrReturnError(get_attr_val(cluster, Globals::Attributes::FeatureMap::Id, tmp_attr_val) == ESP_OK &&
tmp_attr_val.type == ESP_MATTER_VAL_TYPE_BITMAP32,
CHIP_ERROR_INTERNAL);
featureMap = BitMask<BooleanStateConfiguration::Feature>(tmp_attr_val.val.u32);
if (featureMap.Has(Feature::kSensitivityLevel)) {
VerifyOrReturnError(get_attr_val(cluster, Attributes::SupportedSensitivityLevels::Id, tmp_attr_val) == ESP_OK &&
tmp_attr_val.type == ESP_MATTER_VAL_TYPE_UINT8,
CHIP_ERROR_INTERNAL);
supportedSensitivityLevels = tmp_attr_val.val.u8;
if (get_attr_val(cluster, Attributes::DefaultSensitivityLevel::Id, tmp_attr_val) == ESP_OK &&
tmp_attr_val.type == ESP_MATTER_VAL_TYPE_UINT8) {
defaultSensitivityLevel = tmp_attr_val.val.u8;
optionalAttrSet.Set<Attributes::DefaultSensitivityLevel::Id>();
}
}
if (featureMap.Has(Feature::kAudible) || featureMap.Has(Feature::kVisual)) {
VerifyOrReturnError(get_attr_val(cluster, Attributes::AlarmsSupported::Id, tmp_attr_val) == ESP_OK &&
tmp_attr_val.type == ESP_MATTER_VAL_TYPE_BITMAP8,
CHIP_ERROR_INTERNAL);
alarmsSupported = AlarmModeBitmap(tmp_attr_val.val.u8);
if (esp_matter::attribute::get(cluster, Attributes::AlarmsEnabled::Id)) {
optionalAttrSet.Set<Attributes::AlarmsEnabled::Id>();
}
}
if (esp_matter::attribute::get(cluster, Attributes::SensorFault::Id)) {
optionalAttrSet.Set<Attributes::SensorFault::Id>();
}
return CHIP_NO_ERROR;
}
} // namespace
namespace chip::app::Clusters::BooleanStateConfiguration {
BooleanStateConfigurationCluster *FindClusterOnEndpoint(EndpointId endpointId)
{
if (gServers[endpointId].IsConstructed()) {
return &gServers[endpointId].Cluster();
}
return nullptr;
}
} // namespace chip::app::Clusters::BooleanStateConfiguration
void ESPMatterBooleanStateConfigurationClusterServerInitCallback(EndpointId endpointId)
{
if (gServers[endpointId].IsConstructed()) {
return;
}
BitMask<Feature> featureMap;
uint8_t supportedSensitivityLevels = 0, defaultSensitivityLevel = 0;
AlarmModeBitmap alarmsSupported = AlarmModeBitmap::kAudible;
BooleanStateConfigurationCluster::OptionalAttributesSet optionalAttrSet;
CHIP_ERROR err = GetClusterConfig(endpointId, featureMap, supportedSensitivityLevels, defaultSensitivityLevel,
alarmsSupported, optionalAttrSet);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to get config of BooleanStateConfiguration - Error %" CHIP_ERROR_FORMAT,
err.Format());
return;
}
gServers[endpointId].Create(endpointId, featureMap, optionalAttrSet,
BooleanStateConfigurationCluster::StartupConfiguration{
.supportedSensitivityLevels = supportedSensitivityLevels,
.defaultSensitivityLevel = defaultSensitivityLevel,
.alarmsSupported = alarmsSupported,
});
err = esp_matter::data_model::provider::get_instance().registry().Register(gServers[endpointId].Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register BooleanStateConfiguration - Error %" CHIP_ERROR_FORMAT,
err.Format());
}
}
void ESPMatterBooleanStateConfigurationClusterServerShutdownCallback(EndpointId endpointId,
ClusterShutdownType shutdownType)
{
if (!gServers[endpointId].IsConstructed()) {
return;
}
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(
&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister BooleanStateConfiguration - Error %" CHIP_ERROR_FORMAT,
err.Format());
}
gServers[endpointId].Destroy();
}
@@ -0,0 +1,101 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/boolean-state-configuration-server/BooleanStateConfigurationCluster.h>
#include <app/clusters/boolean-state-configuration-server/boolean-state-configuration-delegate.h>
namespace chip::app::Clusters::BooleanStateConfiguration {
// Get access to the underlying cluster registered on the given endpoint
BooleanStateConfigurationCluster *FindClusterOnEndpoint(EndpointId endpointId);
////////////////////////////////////////////////////////////////////////////////////
// The methods below are DEPRECATED. Please interact with the cluster directly
// via `FindClusterOnEndpoint` (for code generated builds)
////////////////////////////////////////////////////////////////////////////////////
inline void SetDefaultDelegate(EndpointId endpoint, Delegate *delegate)
{
// NOTE: this will only work AFTER cluster startup (i.e. emberAfClusterInit)
if (auto cluster = FindClusterOnEndpoint(endpoint); cluster != nullptr) {
cluster->SetDelegate(delegate);
}
}
inline Delegate *GetDefaultDelegate(EndpointId endpoint)
{
if (auto cluster = FindClusterOnEndpoint(endpoint); cluster != nullptr) {
return cluster->GetDelegate();
}
return nullptr;
}
inline CHIP_ERROR SetAlarmsActive(EndpointId ep, BitMask<AlarmModeBitmap> alarms)
{
auto cluster = FindClusterOnEndpoint(ep);
VerifyOrReturnError(cluster != nullptr, CHIP_ERROR_NO_ENDPOINT);
auto status = cluster->SetAlarmsActive(alarms);
return (status == Protocols::InteractionModel::Status::Success) ? CHIP_NO_ERROR
: CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status);
}
inline CHIP_ERROR SetAllEnabledAlarmsActive(EndpointId ep)
{
auto cluster = FindClusterOnEndpoint(ep);
VerifyOrReturnError(cluster != nullptr, CHIP_ERROR_NO_ENDPOINT);
auto status = cluster->SetAllEnabledAlarmsActive();
return (status == Protocols::InteractionModel::Status::Success) ? CHIP_NO_ERROR
: CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status);
}
inline CHIP_ERROR ClearAllAlarms(EndpointId ep)
{
auto cluster = FindClusterOnEndpoint(ep);
VerifyOrReturnError(cluster != nullptr, CHIP_ERROR_NO_ENDPOINT);
cluster->ClearAllAlarms();
return CHIP_NO_ERROR;
}
inline CHIP_ERROR SuppressAlarms(EndpointId ep, BitMask<BooleanStateConfiguration::AlarmModeBitmap> alarms)
{
auto cluster = FindClusterOnEndpoint(ep);
VerifyOrReturnError(cluster != nullptr, CHIP_ERROR_NO_ENDPOINT);
auto status = cluster->SuppressAlarms(alarms);
return (status == Protocols::InteractionModel::Status::Success) ? CHIP_NO_ERROR
: CHIP_ERROR_IM_GLOBAL_STATUS_VALUE(status);
}
inline CHIP_ERROR SetCurrentSensitivityLevel(EndpointId ep, uint8_t level)
{
auto cluster = FindClusterOnEndpoint(ep);
VerifyOrReturnError(cluster != nullptr, CHIP_ERROR_NO_ENDPOINT);
return cluster->SetCurrentSensitivityLevel(level);
}
inline CHIP_ERROR EmitSensorFault(EndpointId ep, BitMask<BooleanStateConfiguration::SensorFaultBitmap> fault)
{
auto cluster = FindClusterOnEndpoint(ep);
VerifyOrReturnError(cluster != nullptr, CHIP_ERROR_NO_ENDPOINT);
cluster->GenerateSensorFault(fault);
return CHIP_NO_ERROR;
}
inline bool HasFeature(EndpointId ep, Feature feature)
{
auto cluster = FindClusterOnEndpoint(ep);
VerifyOrReturnValue(cluster != nullptr, false);
return cluster->GetFeatures().Has(feature);
}
} // namespace chip::app::Clusters::BooleanStateConfiguration
@@ -0,0 +1,39 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "integration.h"
#include "esp_matter_data_model_provider.h"
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::Chime;
namespace chip::app::Clusters::Chime {
ChimeServer::~ChimeServer()
{
RETURN_SAFELY_IGNORED esp_matter::data_model::provider::get_instance().registry().Unregister(&(mCluster.Cluster()));
}
CHIP_ERROR ChimeServer::Init()
{
return esp_matter::data_model::provider::get_instance().registry().Register(mCluster.Registration());
}
} // namespace chip::app::Clusters
void ESPMatterChimeClusterServerInitCallback(EndpointId) {}
void ESPMatterChimeClusterServerShutdownCallback(EndpointId, ClusterShutdownType) {}
// Stub callbacks for ZAP generated code
void MatterChimePluginServerInitCallback() {}
void MatterChimePluginServerShutdownCallback() {}
@@ -0,0 +1,81 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/ChimeCluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
namespace chip::app::Clusters::Chime {
class ChimeServer {
public:
/**
* Creates a chime server instance. This is just a backwards compatibility wrapper around the ChimeCluster.
* @param aEndpointId The endpoint on which this cluster exists. This must match the zap configuration.
* @param aDelegate A reference to the delegate to be used by this server.
* Note: the caller must ensure that the delegate lives throughout the instance's lifetime.
*/
ChimeServer(EndpointId endpointId, ChimeDelegate &delegate)
: mCluster(endpointId, delegate)
{
}
~ChimeServer();
/**
* Register the chime cluster instance with the ESP-Matter data model provider.
* @return Returns an error if registration fails.
*/
CHIP_ERROR Init();
// Attribute Setters
/**
* Sets the SelectedChime attribute. Note, this also handles writing the new value into non-volatile storage.
* @param chimeSoundID The value to which the SelectedChime is to be set.
* @return Returns a ConstraintError if the chimeSoundID value is not valid. Returns Success otherwise.
*/
Protocols::InteractionModel::Status SetSelectedChime(uint8_t chimeSoundID)
{
return mCluster.Cluster().SetSelectedChime(chimeSoundID);
}
/**
* Sets the Enabled attribute. Note, this also handles writing the new value into non-volatile storage.
* @param Enabled The value to which the Enabled is to be set.
*/
Protocols::InteractionModel::Status SetEnabled(bool enabled) { return mCluster.Cluster().SetEnabled(enabled); }
// Attribute Getters
/**
* @return The Current SelectedChime.
*/
uint8_t GetSelectedChime() const { return mCluster.Cluster().GetSelectedChime(); }
/**
* @return The Enabled attribute..
*/
bool GetEnabled() const { return mCluster.Cluster().GetEnabled(); }
/**
* @return The endpoint ID.
*/
EndpointId GetEndpointId() { return mCluster.Cluster().GetPaths()[0].mEndpointId; }
// Cluster constants from the spec
static constexpr uint8_t kMaxChimeSoundNameSize = ChimeCluster::kMaxChimeSoundNameSize;
// The Code Driven ChimeCluster instance
chip::app::RegisteredServerCluster<ChimeCluster> mCluster;
};
} // namespace chip::app::Clusters::Chime
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <app/clusters/descriptor/descriptor-cluster.h>
#include <app/clusters/descriptor/DescriptorCluster.h>
#include <esp_matter_data_model.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
@@ -111,7 +111,7 @@ void ESPMatterDescriptorClusterServerInitCallback(EndpointId endpointId)
}
}
void ESPMatterDescriptorClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterDescriptorClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster());
@@ -0,0 +1,68 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/util/generic-callbacks.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <protocols/interaction_model/StatusCode.h>
#include "integration.h"
namespace chip {
namespace app {
namespace Clusters {
namespace DeviceEnergyManagement {
Instance::Instance(EndpointId aEndpointId, Delegate & aDelegate, BitMask<Feature> aFeature) :
mCluster(DeviceEnergyManagementCluster::Config(aEndpointId, aFeature, aDelegate))
{}
CHIP_ERROR Instance::Init()
{
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(mCluster.Registration());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Failed to register cluster %u/" ChipLogFormatMEI ": %" CHIP_ERROR_FORMAT,
mCluster.Cluster().GetPaths()[0].mEndpointId, ChipLogValueMEI(DeviceEnergyManagement::Id), err.Format());
}
return err;
}
void Instance::Shutdown()
{
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&mCluster.Cluster());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Failed to unregister cluster %u/" ChipLogFormatMEI ": %" CHIP_ERROR_FORMAT,
mCluster.Cluster().GetPaths()[0].mEndpointId, ChipLogValueMEI(DeviceEnergyManagement::Id), err.Format());
}
}
bool Instance::HasFeature(Feature aFeature) const
{
return mCluster.Cluster().Features().Has(aFeature);
}
} // namespace DeviceEnergyManagement
} // namespace Clusters
} // namespace app
} // namespace chip
void ESPMatterDeviceEnergyManagementClusterServerInitCallback(chip::EndpointId endpoint) {}
void ESPMatterDeviceEnergyManagementClusterServerShutdownCallback(chip::EndpointId endpoint, chip::app::ClusterShutdownType shutdownType) {}
// Legacy callback stubs
void MatterDeviceEnergyManagementPluginServerInitCallback() {}
void MatterDeviceEnergyManagementPluginServerShutdownCallback() {}
@@ -0,0 +1,36 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/device-energy-management-server/DeviceEnergyManagementCluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
namespace chip::app::Clusters::DeviceEnergyManagement {
class Instance
{
public:
Instance(EndpointId aEndpointId, Delegate & aDelegate, BitMask<Feature> aFeature);
CHIP_ERROR Init();
void Shutdown();
bool HasFeature(Feature aFeature) const;
private:
RegisteredServerCluster<DeviceEnergyManagementCluster> mCluster;
};
}
@@ -16,6 +16,7 @@
#include <app/clusters/diagnostic-logs-server/DiagnosticLogsCluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include "integration.h"
using namespace chip;
using namespace chip::app;
@@ -35,12 +36,12 @@ void ESPMatterDiagnosticLogsClusterServerInitCallback(EndpointId endpoint)
}
}
void ESPMatterDiagnosticLogsClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterDiagnosticLogsClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
// We implement the cluster as a singleton on the root endpoint.
VerifyOrReturn(endpointId == kRootEndpointId && gServer.IsConstructed());
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister DiagnosticLogs on endpoint %u - Error: %" CHIP_ERROR_FORMAT,
endpointId, err.Format());
@@ -50,3 +51,12 @@ void ESPMatterDiagnosticLogsClusterServerShutdownCallback(EndpointId endpointId)
void MatterDiagnosticLogsPluginServerInitCallback() {}
void MatterDiagnosticLogsPluginServerShutdownCallback() {}
namespace chip::app::Clusters::DiagnosticLogs {
void SetDiagnosticLogsProviderDelegate(DiagnosticLogsProviderDelegate * delegate)
{
gServer.Cluster().SetDelegate(delegate);
}
} // namespace chip::app::Clusters::DiagnosticLogs
@@ -0,0 +1,23 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/diagnostic-logs-server/DiagnosticLogsProviderDelegate.h>
namespace chip::app::Clusters::DiagnosticLogs {
void SetDiagnosticLogsProviderDelegate(DiagnosticLogsProviderDelegate * delegate);
} // namespace chip::app::Clusters::DiagnosticLogs
@@ -0,0 +1,144 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "integration.h"
#include "esp_matter_data_model.h"
#include "esp_matter_data_model_priv.h"
#include "esp_matter_data_model_provider.h"
#include <unordered_map>
#include "app/clusters/electrical-energy-measurement-server/ElectricalEnergyMeasurementCluster.h"
#include "app/server-cluster/ServerClusterInterfaceRegistry.h"
#include "clusters/ElectricalEnergyMeasurement/Enums.h"
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ElectricalEnergyMeasurement;
namespace {
std::unordered_map<EndpointId, LazyRegisteredServerCluster<ElectricalEnergyMeasurementCluster>> gServers;
uint32_t get_feature_map(esp_matter::cluster_t *cluster)
{
esp_matter::attribute_t *attribute = esp_matter::attribute::get(cluster, Globals::Attributes::FeatureMap::Id);
if (attribute) {
esp_matter_attr_val_t val = esp_matter_invalid(nullptr);
if (esp_matter::attribute::get_val_internal(attribute, &val) == ESP_OK &&
val.type == ESP_MATTER_VAL_TYPE_BITMAP32) {
return val.val.u32;
}
}
return 0;
}
ElectricalEnergyMeasurementCluster::Config GetClusterConfig(EndpointId endpointId)
{
ElectricalEnergyMeasurementCluster::Config config;
config.endpointId = endpointId;
esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpointId, ElectricalEnergyMeasurement::Id);
config.featureFlags = BitMask<ElectricalEnergyMeasurement::Feature>(get_feature_map(cluster));
if (esp_matter::attribute::get(cluster, Attributes::CumulativeEnergyReset::Id)) {
config.optionalAttributes.SetField(OptionalAttributes::kOptionalAttributeCumulativeEnergyReset, 1);
} else {
config.optionalAttributes.Clear(OptionalAttributes::kOptionalAttributeCumulativeEnergyReset);
}
return config;
}
} // namespace
namespace chip::app::Clusters::ElectricalEnergyMeasurement {
ElectricalEnergyMeasurementCluster *GetClusterInstance(EndpointId endpointId)
{
if (gServers[endpointId].IsConstructed()) {
return &gServers[endpointId].Cluster();
}
return nullptr;
}
const ElectricalEnergyMeasurement::MeasurementData *MeasurementDataForEndpoint(EndpointId endpointId)
{
ElectricalEnergyMeasurementCluster *cluster = GetClusterInstance(endpointId);
VerifyOrReturnValue(cluster != nullptr, nullptr);
return cluster->GetMeasurementData();
}
CHIP_ERROR SetMeasurementAccuracy(EndpointId endpointId, const Structs::MeasurementAccuracyStruct::Type &accuracy)
{
ElectricalEnergyMeasurementCluster *cluster = GetClusterInstance(endpointId);
VerifyOrReturnError(cluster != nullptr, CHIP_ERROR_NOT_FOUND);
return cluster->SetMeasurementAccuracy(accuracy);
}
CHIP_ERROR SetCumulativeReset(EndpointId endpointId,
const Optional<Structs::CumulativeEnergyResetStruct::Type> &cumulativeReset)
{
ElectricalEnergyMeasurementCluster *cluster = GetClusterInstance(endpointId);
VerifyOrReturnError(cluster != nullptr, CHIP_ERROR_NOT_FOUND);
return cluster->SetCumulativeEnergyReset(cumulativeReset);
}
bool NotifyCumulativeEnergyMeasured(EndpointId endpointId,
const Optional<Structs::EnergyMeasurementStruct::Type> &energyImported,
const Optional<Structs::EnergyMeasurementStruct::Type> &energyExported)
{
ElectricalEnergyMeasurementCluster *cluster = GetClusterInstance(endpointId);
VerifyOrReturnValue(cluster != nullptr, false);
VerifyOrReturnValue(cluster->Features().Has(Feature::kCumulativeEnergy), false);
cluster->CumulativeEnergySnapshot(energyImported, energyExported);
return true;
}
bool NotifyPeriodicEnergyMeasured(EndpointId endpointId,
const Optional<Structs::EnergyMeasurementStruct::Type> &energyImported,
const Optional<Structs::EnergyMeasurementStruct::Type> &energyExported)
{
ElectricalEnergyMeasurementCluster *cluster = GetClusterInstance(endpointId);
VerifyOrReturnValue(cluster != nullptr, false);
VerifyOrReturnValue(cluster->Features().Has(Feature::kPeriodicEnergy), false);
cluster->PeriodicEnergySnapshot(energyImported, energyExported);
return true;
}
} // namespace chip::app::Clusters::ElectricalEnergyMeasurement
void ESPMatterElectricalEnergyMeasurementClusterServerInitCallback(EndpointId endpoint)
{
if (gServers[endpoint].IsConstructed()) {
return;
}
ElectricalEnergyMeasurementCluster::Config config = GetClusterConfig(endpoint);
gServers[endpoint].Create(config);
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Register(gServers[endpoint].Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register AccessControl - Error %" CHIP_ERROR_FORMAT, err.Format());
}
}
void ESPMatterElectricalEnergyMeasurementClusterServerShutdownCallback(EndpointId endpointId,
ClusterShutdownType shutdownType)
{
VerifyOrReturn(gServers[endpointId].IsConstructed());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(
&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister AccessControl - Error %" CHIP_ERROR_FORMAT, err.Format());
}
gServers[endpointId].Destroy();
}
@@ -0,0 +1,34 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/electrical-energy-measurement-server/ElectricalEnergyMeasurementCluster.h>
namespace chip::app::Clusters::ElectricalEnergyMeasurement {
bool NotifyCumulativeEnergyMeasured(EndpointId endpointId, const Optional<Structs::EnergyMeasurementStruct::Type> & energyImported,
const Optional<Structs::EnergyMeasurementStruct::Type> & energyExported);
bool NotifyPeriodicEnergyMeasured(EndpointId endpointId, const Optional<Structs::EnergyMeasurementStruct::Type> & energyImported,
const Optional<Structs::EnergyMeasurementStruct::Type> & energyExported);
CHIP_ERROR SetMeasurementAccuracy(EndpointId endpointId, const Structs::MeasurementAccuracyStruct::Type & accuracy);
CHIP_ERROR SetCumulativeReset(EndpointId endpointId, const Optional<Structs::CumulativeEnergyResetStruct::Type> & cumulativeReset);
const ElectricalEnergyMeasurement::MeasurementData * MeasurementDataForEndpoint(EndpointId endpointId);
ElectricalEnergyMeasurementCluster *GetClusterInstance(EndpointId endpointId);
}
@@ -0,0 +1,72 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "integration.h"
#include <app/server-cluster/ServerClusterInterface.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
namespace chip {
namespace app {
namespace Clusters {
namespace ElectricalPowerMeasurement {
ElectricalPowerMeasurementCluster::OptionalAttributesSet Instance::FromLegacyOptionalAttributes(
BitMask<OptionalAttributes> aOptionalAttributes)
{
ElectricalPowerMeasurementCluster::OptionalAttributesSet attrs;
attrs.Set<Attributes::Ranges::Id>(aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeRanges));
attrs.Set<Attributes::Voltage::Id>(aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeVoltage));
attrs.Set<Attributes::ActiveCurrent::Id>(
aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeActiveCurrent));
attrs.Set<Attributes::ReactiveCurrent::Id>(
aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeReactiveCurrent));
attrs.Set<Attributes::ApparentCurrent::Id>(
aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeApparentCurrent));
attrs.Set<Attributes::ReactivePower::Id>(
aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeReactivePower));
attrs.Set<Attributes::ApparentPower::Id>(
aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeApparentPower));
attrs.Set<Attributes::RMSVoltage::Id>(aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeRMSVoltage));
attrs.Set<Attributes::RMSCurrent::Id>(aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeRMSCurrent));
attrs.Set<Attributes::RMSPower::Id>(aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeRMSPower));
attrs.Set<Attributes::Frequency::Id>(aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeFrequency));
attrs.Set<Attributes::PowerFactor::Id>(aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributePowerFactor));
attrs.Set<Attributes::NeutralCurrent::Id>(
aOptionalAttributes.Has(OptionalAttributes::kOptionalAttributeNeutralCurrent));
return attrs;
}
CHIP_ERROR Instance::Init()
{
return esp_matter::data_model::provider::get_instance().registry().Register(mCluster.Registration());
}
void Instance::Shutdown()
{
RETURN_SAFELY_IGNORED esp_matter::data_model::provider::get_instance().registry().Unregister(&(mCluster.Cluster()));
}
} // namespace ElectricalPowerMeasurement
} // namespace Clusters
} // namespace app
} // namespace chip
void ESPMatterElectricalPowerMeasurementClusterServerInitCallback(chip::EndpointId endpointId)
{
}
void ESPMatterElectricalPowerMeasurementClusterServerShutdownCallback(chip::EndpointId endpointId,
chip::app::ClusterShutdownType shutdownType)
{
}
@@ -0,0 +1,65 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/electrical-power-measurement-server/ElectricalPowerMeasurementDelegate.h>
#include <app/clusters/electrical-power-measurement-server/ElectricalPowerMeasurementCluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
namespace chip::app::Clusters::ElectricalPowerMeasurement {
enum class OptionalAttributes : uint32_t
{
kOptionalAttributeRanges = 0x1,
kOptionalAttributeVoltage = 0x2,
kOptionalAttributeActiveCurrent = 0x4,
kOptionalAttributeReactiveCurrent = 0x8,
kOptionalAttributeApparentCurrent = 0x10,
kOptionalAttributeReactivePower = 0x20,
kOptionalAttributeApparentPower = 0x40,
kOptionalAttributeRMSVoltage = 0x80,
kOptionalAttributeRMSCurrent = 0x100,
kOptionalAttributeRMSPower = 0x200,
kOptionalAttributeFrequency = 0x400,
kOptionalAttributePowerFactor = 0x800,
kOptionalAttributeNeutralCurrent = 0x1000,
};
class Instance
{
public:
Instance(EndpointId aEndpointId, Delegate & aDelegate, BitMask<Feature> aFeature,
BitMask<OptionalAttributes> aOptionalAttributes) :
mCluster(ElectricalPowerMeasurementCluster::Config{
.endpointId = aEndpointId,
.delegate = aDelegate,
.features = aFeature,
.optionalAttributes = FromLegacyOptionalAttributes(aOptionalAttributes),
})
{}
CHIP_ERROR Init();
void Shutdown();
~Instance() {}
private:
static ElectricalPowerMeasurementCluster::OptionalAttributesSet
FromLegacyOptionalAttributes(BitMask<OptionalAttributes> aOptionalAttributes);
RegisteredServerCluster<ElectricalPowerMeasurementCluster> mCluster;
};
}
@@ -13,9 +13,10 @@
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/ethernet-network-diagnostics-server/ethernet-diagnostics-cluster.h>
#include <app/clusters/ethernet-network-diagnostics-server/EthernetDiagnosticsCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <esp_matter_data_model.h>
#include <esp_matter_data_model_priv.h>
#include <unordered_map>
using namespace chip;
@@ -30,7 +31,8 @@ uint32_t get_feature_map(esp_matter::cluster_t *cluster)
esp_matter::attribute_t *attribute = esp_matter::attribute::get(cluster, Globals::Attributes::FeatureMap::Id);
if (attribute) {
esp_matter_attr_val_t val = esp_matter_invalid(nullptr);
if (esp_matter::attribute::get_val(attribute, &val) == ESP_OK && val.type == ESP_MATTER_VAL_TYPE_BITMAP32) {
if (esp_matter::attribute::get_val_internal(attribute, &val) == ESP_OK &&
val.type == ESP_MATTER_VAL_TYPE_BITMAP32) {
return val.val.u32;
}
}
@@ -76,10 +78,11 @@ void ESPMatterEthernetNetworkDiagnosticsClusterServerInitCallback(EndpointId end
}
}
void ESPMatterEthernetNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterEthernetNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpointId,
ClusterShutdownType shutdownType)
{
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(
&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer,
"Failed to unregister EthernetNetworkDiagnostics on endpoint %u - Error: %" CHIP_ERROR_FORMAT,
@@ -88,6 +91,10 @@ void ESPMatterEthernetNetworkDiagnosticsClusterServerShutdownCallback(EndpointId
gServers[endpointId].Destroy();
}
void MatterEthernetNetworkDiagnosticsPluginServerInitCallback() {}
void MatterEthernetNetworkDiagnosticsPluginServerInitCallback()
{
}
void MatterEthernetNetworkDiagnosticsPluginServerShutdownCallback() {}
void MatterEthernetNetworkDiagnosticsPluginServerShutdownCallback()
{
}
@@ -13,7 +13,7 @@
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/fixed-label-server/fixed-label-cluster.h>
#include <app/clusters/fixed-label-server/FixedLabelCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <unordered_map>
@@ -41,10 +41,10 @@ void ESPMatterFixedLabelClusterServerInitCallback(EndpointId endpointId)
}
}
void ESPMatterFixedLabelClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterFixedLabelClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster());
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister FixedLabel on endpoint %u - Error: %" CHIP_ERROR_FORMAT,
endpointId, err.Format());
@@ -0,0 +1,110 @@
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
//
// 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/ClusterCallbacks.h>
#include <app/clusters/general-commissioning-server/GeneralCommissioningCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <esp_matter_data_model.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
#include <lib/core/DataModelTypes.h>
#include <lib/support/CodeUtils.h>
#include "integration.h"
#if CHIP_CONFIG_TERMS_AND_CONDITIONS_REQUIRED
#include <app/server/TermsAndConditionsManager.h>
#endif
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
namespace {
LazyRegisteredServerCluster<GeneralCommissioningCluster> gServer;
}
namespace chip::app::Clusters::GeneralCommissioning {
GeneralCommissioningCluster * Instance()
{
GeneralCommissioningCluster::OptionalAttributes optionalAttrs;
if (esp_matter::endpoint::is_attribute_enabled(kRootEndpointId, GeneralCommissioning::Id, GeneralCommissioning::Attributes::IsCommissioningWithoutPower::Id)) {
optionalAttrs.Set<GeneralCommissioning::Attributes::IsCommissioningWithoutPower::Id>();
}
if (!gServer.IsConstructed()) {
gServer.Create(
GeneralCommissioningCluster::Context {
.commissioningWindowManager = Server::GetInstance().GetCommissioningWindowManager(), //
.configurationManager = DeviceLayer::ConfigurationMgr(), //
.deviceControlServer = DeviceLayer::DeviceControlServer::DeviceControlSvr(), //
.fabricTable = Server::GetInstance().GetFabricTable(), //
.failsafeContext = Server::GetInstance().GetFailSafeContext(), //
.platformManager = DeviceLayer::PlatformMgr(), //
#if CHIP_CONFIG_TERMS_AND_CONDITIONS_REQUIRED
.termsAndConditionsProvider = TermsAndConditionsManager::GetInstance(),
#endif // CHIP_CONFIG_TERMS_AND_CONDITIONS_REQUIRED
},
optionalAttrs);
}
return &gServer.Cluster();
}
} // namespace chip::app::Clusters::GeneralCommissioning
void ESPMatterGeneralCommissioningClusterServerInitCallback(EndpointId endpointId)
{
if (endpointId != kRootEndpointId) {
return;
}
GeneralCommissioningCluster::OptionalAttributes optionalAttrs;
if (esp_matter::endpoint::is_attribute_enabled(endpointId, GeneralCommissioning::Id, GeneralCommissioning::Attributes::IsCommissioningWithoutPower::Id)) {
optionalAttrs.Set<GeneralCommissioning::Attributes::IsCommissioningWithoutPower::Id>();
}
if (!gServer.IsConstructed()) {
gServer.Create(
GeneralCommissioningCluster::Context {
.commissioningWindowManager = Server::GetInstance().GetCommissioningWindowManager(), //
.configurationManager = DeviceLayer::ConfigurationMgr(), //
.deviceControlServer = DeviceLayer::DeviceControlServer::DeviceControlSvr(), //
.fabricTable = Server::GetInstance().GetFabricTable(), //
.failsafeContext = Server::GetInstance().GetFailSafeContext(), //
.platformManager = DeviceLayer::PlatformMgr(), //
#if CHIP_CONFIG_TERMS_AND_CONDITIONS_REQUIRED
.termsAndConditionsProvider = TermsAndConditionsManager::GetInstance(),
#endif // CHIP_CONFIG_TERMS_AND_CONDITIONS_REQUIRED
},
optionalAttrs);
}
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gServer.Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register GeneralCommissioning - Error: %" CHIP_ERROR_FORMAT, err.Format());
}
}
void ESPMatterGeneralCommissioningClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
VerifyOrReturn(endpointId == kRootEndpointId && gServer.IsConstructed());
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister GeneralCommissioning - Error: %" CHIP_ERROR_FORMAT, err.Format());
}
gServer.Destroy();
}
void MatterGeneralCommissioningPluginServerInitCallback() {}
void MatterGeneralCommissioningPluginServerShutdownCallback() {}
@@ -14,7 +14,7 @@
#pragma once
#include <app/clusters/general-commissioning-server/general-commissioning-cluster.h>
#include <app/clusters/general-commissioning-server/GeneralCommissioningCluster.h>
namespace chip::app::Clusters::GeneralCommissioning {
@@ -1,73 +0,0 @@
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
//
// 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/ClusterCallbacks.h>
#include <app/clusters/general-commissioning-server/general-commissioning-cluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <esp_matter_data_model.h>
#include "app/server-cluster/ServerClusterInterfaceRegistry.h"
#include "core/DataModelTypes.h"
#include "support/CodeUtils.h"
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
namespace {
LazyRegisteredServerCluster<GeneralCommissioningCluster> gServer;
}
namespace chip::app::Clusters::GeneralCommissioning {
GeneralCommissioningCluster * Instance()
{
if (!gServer.IsConstructed()) {
gServer.Create();
}
return &gServer.Cluster();
}
} // namespace chip::app::Clusters::GeneralCommissioning
void ESPMatterGeneralCommissioningClusterServerInitCallback(EndpointId endpointId)
{
if (endpointId != kRootEndpointId) {
return;
}
if (!gServer.IsConstructed()) {
gServer.Create();
}
if (esp_matter::endpoint::is_attribute_enabled(endpointId, GeneralCommissioning::Id, GeneralCommissioning::Attributes::IsCommissioningWithoutPower::Id)) {
gServer.Cluster().GetOptionalAttributes().Set<GeneralCommissioning::Attributes::IsCommissioningWithoutPower::Id>();
}
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gServer.Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register GeneralCommissioning - Error: %" CHIP_ERROR_FORMAT, err.Format());
}
}
void ESPMatterGeneralCommissioningClusterServerShutdownCallback(EndpointId endpointId)
{
VerifyOrReturn(endpointId == kRootEndpointId && gServer.IsConstructed());
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister GeneralCommissioning - Error: %" CHIP_ERROR_FORMAT, err.Format());
}
gServer.Destroy();
}
void MatterGeneralCommissioningPluginServerInitCallback() {}
void MatterGeneralCommissioningPluginServerShutdownCallback() {}
@@ -12,12 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/general-diagnostics-server/general-diagnostics-cluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
#include <clusters/GeneralDiagnostics/ClusterId.h>
#include <esp_matter_attribute_utils.h>
#include <esp_matter_data_model_priv.h>
#include <data_model/esp_matter_data_model.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include "integration.h"
#include <app/ClusterCallbacks.h>
#include <app/clusters/general-diagnostics-server/GeneralDiagnosticsCluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
#include <clusters/GeneralDiagnostics/ClusterId.h>
#include <app/InteractionModelEngine.h>
#include <clusters/GeneralDiagnostics/Enums.h>
#include <lib/support/BitFlags.h>
#include <lib/support/CodeUtils.h>
using namespace chip;
using namespace chip::app;
@@ -88,6 +96,10 @@ void ESPMatterGeneralDiagnosticsClusterServerInitCallback(EndpointId endpointId)
if (IsAttributeEnabled(endpointId, GeneralDiagnostics::Attributes::ActiveNetworkFaults::Id)) {
attrSet.Set<GeneralDiagnostics::Attributes::ActiveNetworkFaults::Id>();
}
attribute_t *feature = attribute::get(endpointId, GeneralDiagnostics::Id, Globals::Attributes::FeatureMap::Id);
esp_matter_attr_val_t feature_val = esp_matter_invalid(nullptr);
VerifyOrReturn(attribute::get_val_internal(feature, &feature_val) == ESP_OK && feature_val.type == ESP_MATTER_VAL_TYPE_BITMAP32);
BitFlags<GeneralDiagnostics::Feature> featureFlags(feature_val.val.u32);
CHIP_ERROR err = CHIP_NO_ERROR;
if (IsCommandEnabled(endpointId, GeneralDiagnostics::Commands::PayloadTestRequest::Id, COMMAND_FLAG_ACCEPTED) ||
@@ -102,11 +114,11 @@ void ESPMatterGeneralDiagnosticsClusterServerInitCallback(EndpointId endpointId)
IsCommandEnabled(endpointId, GeneralDiagnostics::Commands::PayloadTestRequest::Id, COMMAND_FLAG_ACCEPTED),
};
gServer.fullConfigurableServer.Create(attrSet, functionsConfig);
gServer.fullConfigurableServer.Create(attrSet,featureFlags, InteractionModelEngine::GetInstance(), functionsConfig);
err = esp_matter::data_model::provider::get_instance().registry().Register(
gServer.fullConfigurableServer.Registration());
} else {
gServer.server.Create(attrSet);
gServer.server.Create(attrSet, featureFlags, InteractionModelEngine::GetInstance());
err = esp_matter::data_model::provider::get_instance().registry().Register(gServer.server.Registration());
}
if (err != CHIP_NO_ERROR) {
@@ -114,7 +126,7 @@ void ESPMatterGeneralDiagnosticsClusterServerInitCallback(EndpointId endpointId)
}
}
void ESPMatterGeneralDiagnosticsClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterGeneralDiagnosticsClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
VerifyOrReturn(endpointId == kRootEndpointId);
CHIP_ERROR err = CHIP_NO_ERROR;
@@ -0,0 +1,30 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/general-diagnostics-server/GeneralDiagnosticsCluster.h>
namespace chip::app::Clusters::GeneralDiagnostics {
void GlobalNotifyDeviceReboot(GeneralDiagnostics::BootReasonEnum bootReason);
void GlobalNotifyHardwareFaultsDetect(const DeviceLayer::GeneralFaults<DeviceLayer::kMaxHardwareFaults> & previous,
const DeviceLayer::GeneralFaults<DeviceLayer::kMaxHardwareFaults> & current);
void GlobalNotifyRadioFaultsDetect(const DeviceLayer::GeneralFaults<DeviceLayer::kMaxRadioFaults> & previous,
const DeviceLayer::GeneralFaults<DeviceLayer::kMaxRadioFaults> & current);
void GlobalNotifyNetworkFaultsDetect(const DeviceLayer::GeneralFaults<DeviceLayer::kMaxNetworkFaults> & previous,
const DeviceLayer::GeneralFaults<DeviceLayer::kMaxNetworkFaults> & current);
} // namespace chip::app::Clusters::GeneralDiagnostics
@@ -13,7 +13,7 @@
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/group-key-mgmt-server/group-key-mgmt-cluster.h>
#include <app/clusters/group-key-mgmt-server/GroupKeyManagementCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
using namespace chip;
@@ -36,11 +36,11 @@ void ESPMatterGroupKeyManagementClusterServerInitCallback(EndpointId endpoint)
}
}
void ESPMatterGroupKeyManagementClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterGroupKeyManagementClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
// We implement the cluster as a singleton on the root endpoint.
VerifyOrReturn(endpointId == kRootEndpointId);
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister GroupKeyManagement - Error: %" CHIP_ERROR_FORMAT, err.Format());
}
@@ -43,11 +43,11 @@ void ESPMatterGroupcastClusterServerInitCallback(chip::EndpointId endpointId)
}
}
void ESPMatterGroupcastClusterServerShutdownCallback(chip::EndpointId endpointId)
void ESPMatterGroupcastClusterServerShutdownCallback(chip::EndpointId endpointId, ClusterShutdownType shutdownType)
{
VerifyOrDie(endpointId == chip::kRootEndpointId);
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister Groupcast - Error %" CHIP_ERROR_FORMAT, err.Format());
}
@@ -0,0 +1,111 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "esp_matter_attribute_utils.h"
#include "esp_matter_data_model.h"
#include "esp_matter_data_model_priv.h"
#include "esp_matter_data_model_provider.h"
#include <app/clusters/icd-management-server/ICDManagementCluster.h>
#include <string.h>
#include "app/server-cluster/ServerClusterInterfaceRegistry.h"
#include "app/server/Server.h"
#include "clusters/IcdManagement/Enums.h"
#include "core/DataModelTypes.h"
#include "lib/support/BitMask.h"
#include "lib/support/Span.h"
#include "support/CodeUtils.h"
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::IcdManagement;
namespace {
#if CHIP_CONFIG_ENABLE_ICD_CIP
LazyRegisteredServerCluster<ICDManagementClusterWithCIP> gServer;
#else
LazyRegisteredServerCluster<ICDManagementCluster> gServer;
#endif
esp_err_t get_attr_val(esp_matter::cluster_t *cluster, uint32_t attribute_id, esp_matter_attr_val_t &val)
{
esp_matter::attribute_t *attr = esp_matter::attribute::get(cluster, attribute_id);
if (!attr) {
return ESP_FAIL;
}
return esp_matter::attribute::get_val_internal(attr, &val);
}
CHIP_ERROR GetClusterConfig(EndpointId endpointId, ICDManagementCluster::OptionalAttributeSet &optionalAttrSet,
BitMask<OptionalCommands> &optionalCommands, BitMask<UserActiveModeTriggerBitmap> &uatHint,
MutableCharSpan &instructionSpan)
{
esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpointId, IcdManagement::Id);
if (!cluster) {
return CHIP_ERROR_NOT_FOUND;
}
if (esp_matter::command::get(cluster, Commands::StayActiveRequest::Id, esp_matter::COMMAND_FLAG_ACCEPTED)) {
optionalCommands.SetField(OptionalCommands::kStayActive, 1);
} else {
optionalCommands.SetField(OptionalCommands::kStayActive, 0);
}
esp_matter_attr_val_t attr_val;
if (get_attr_val(cluster, Attributes::UserActiveModeTriggerHint::Id, attr_val) == ESP_OK &&
attr_val.type == ESP_MATTER_VAL_TYPE_BITMAP32) {
uatHint = BitMask<UserActiveModeTriggerBitmap>(attr_val.val.u32);
if (get_attr_val(cluster, Attributes::UserActiveModeTriggerInstruction::Id, attr_val) == ESP_OK &&
attr_val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING && instructionSpan.size() >= attr_val.val.a.s) {
memcpy(instructionSpan.data(), (const char *)attr_val.val.a.b, attr_val.val.a.s);
instructionSpan.reduce_size(attr_val.val.a.s);
optionalAttrSet.Set<Attributes::UserActiveModeTriggerInstruction::Id>();
}
}
return CHIP_NO_ERROR;
}
} // namespace
void ESPMatterIcdManagementClusterServerInitCallback(EndpointId endpointId)
{
VerifyOrReturn(endpointId == kRootEndpointId);
VerifyOrReturn(!gServer.IsConstructed());
ICDManagementCluster::OptionalAttributeSet optionalAttrSet;
BitMask<OptionalCommands> optionalCommands;
BitMask<UserActiveModeTriggerBitmap> uatHint;
char instructionBuffer[kUserActiveModeTriggerInstructionMaxLength];
MutableCharSpan instructionSpan(instructionBuffer);
CHIP_ERROR err = GetClusterConfig(endpointId, optionalAttrSet, optionalCommands, uatHint, instructionSpan);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to get config for IcdManagement - Error %" CHIP_ERROR_FORMAT, err.Format());
return;
}
gServer.Create(endpointId, *Server::GetInstance().GetSessionKeystore(), Server::GetInstance().GetFabricTable(),
ICDConfigurationData::GetInstance(), optionalAttrSet, optionalCommands, uatHint, instructionSpan);
err = esp_matter::data_model::provider::get_instance().registry().Register(gServer.Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register IcdManagement - Error %" CHIP_ERROR_FORMAT, err.Format());
}
}
void ESPMatterIcdManagementClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
VerifyOrReturn(endpointId == kRootEndpointId);
VerifyOrReturn(gServer.IsConstructed());
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister IcdManagement - Error %" CHIP_ERROR_FORMAT, err.Format());
}
gServer.Destroy();
}
@@ -19,16 +19,17 @@
#include <app-common/zap-generated/ids/Commands.h>
#include <app/CommandHandler.h>
#include <app/ConcreteCommandPath.h>
#include <app/DefaultTimerDelegate.h>
#include <app/InteractionModelEngine.h>
#include <app/clusters/identify-server/IdentifyCluster.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/server-cluster/DefaultServerCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/TextOnlyLogging.h>
#include <lib/support/TimerDelegate.h>
#include <platform/DefaultTimerDelegate.h>
#include <tracing/macros.h>
#include "support/logging/TextOnlyLogging.h"
#include "integration.h"
namespace {
@@ -167,7 +168,7 @@ void ESPMatterIdentifyClusterServerInitCallback(EndpointId endpointId)
// Intentionally make this function empty as the identify cluster will be registered when enabling endpoint.
}
void ESPMatterIdentifyClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterIdentifyClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
// Intentionally make this function empty as the identify cluster will be unregistered when disabling endpoint.
}
@@ -175,3 +176,10 @@ void ESPMatterIdentifyClusterServerShutdownCallback(EndpointId endpointId)
// Legacy PluginServer callback stubs
void MatterIdentifyPluginServerInitCallback() {}
void MatterIdentifyPluginServerShutdownCallback() {}
namespace chip::app::Clusters::Identify {
IdentifyCluster * FindClusterOnEndpoint(EndpointId endpointId)
{
return FindIdentifyClusterOnEndpoint(endpointId);
}
}
@@ -0,0 +1,21 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/identify-server/IdentifyCluster.h>
namespace chip::app::Clusters::Identify {
IdentifyCluster * FindClusterOnEndpoint(EndpointId endpointId);
}
@@ -12,10 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <app/clusters/localization-configuration-server/localization-configuration-cluster.h>
#include <app/clusters/localization-configuration-server/LocalizationConfigurationCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <esp_matter_attribute_utils.h>
#include <esp_matter_data_model.h>
#include <esp_matter_data_model_priv.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/Span.h>
#include <platform/DeviceInfoProvider.h>
@@ -37,7 +38,7 @@ void ESPMatterLocalizationConfigurationClusterServerInitCallback(EndpointId endp
esp_matter::attribute_t *active_locale = esp_matter::attribute::get(
endpointId, LocalizationConfiguration::Id, LocalizationConfiguration::Attributes::ActiveLocale::Id);
esp_matter_attr_val_t attr_val;
if (active_locale && esp_matter::attribute::get_val(active_locale, &attr_val) == ESP_OK &&
if (active_locale && esp_matter::attribute::get_val_internal(active_locale, &attr_val) == ESP_OK &&
attr_val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING &&
attr_val.val.a.s <= LocalizationConfiguration::Attributes::ActiveLocale::TypeInfo::MaxLength()) {
ChipLogError(AppServer, "Failed to get active locale on endpoint %u", endpointId);
@@ -46,19 +47,22 @@ void ESPMatterLocalizationConfigurationClusterServerInitCallback(EndpointId endp
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gServer.Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register LocalizationConfiguration - Error: %" CHIP_ERROR_FORMAT, err.Format());
ChipLogError(AppServer, "Failed to register LocalizationConfiguration - Error: %" CHIP_ERROR_FORMAT,
err.Format());
}
}
void ESPMatterLocalizationConfigurationClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterLocalizationConfigurationClusterServerShutdownCallback(EndpointId endpointId,
ClusterShutdownType shutdownType)
{
if (endpointId != kRootEndpointId) {
return;
}
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister LocalizationConfiguration - Error: %" CHIP_ERROR_FORMAT, err.Format());
ChipLogError(AppServer, "Failed to unregister LocalizationConfiguration - Error: %" CHIP_ERROR_FORMAT,
err.Format());
}
}
@@ -21,7 +21,7 @@
#include <lib/support/CodeUtils.h>
#include <platform/ESP32/NetworkCommissioningDriver.h>
#include <platform/OpenThread/GenericNetworkCommissioningThreadDriver.h>
#include "general_commissioning_integration.h"
#include <clusters/general_commissioning/integration.h>
using namespace chip;
using namespace chip::app;
@@ -94,45 +94,45 @@ void ESPMatterNetworkCommissioningClusterServerInitCallback(EndpointId endpointI
if (endpointId == CONFIG_THREAD_NETWORK_ENDPOINT_ID) {
static DeviceLayer::NetworkCommissioning::GenericThreadDriver sThreadDriver;
gServers[index].Create(endpointId, &sThreadDriver, gBreadcrumbTracker);
gServers[index].Cluster().Init();
(void)esp_matter::data_model::provider::get_instance().registry().Register(gServers[index].Registration());
LogErrorOnFailure(gServers[index].Cluster().Init());
LogErrorOnFailure(esp_matter::data_model::provider::get_instance().registry().Register(gServers[index].Registration()));
}
#endif
#ifdef CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
if (endpointId == CONFIG_WIFI_NETWORK_ENDPOINT_ID) {
gServers[index].Create(endpointId, &(DeviceLayer::NetworkCommissioning::ESPWiFiDriver::GetInstance()), gBreadcrumbTracker);
gServers[index].Cluster().Init();
(void)esp_matter::data_model::provider::get_instance().registry().Register(gServers[index].Registration());
LogErrorOnFailure(gServers[index].Cluster().Init());
LogErrorOnFailure(esp_matter::data_model::provider::get_instance().registry().Register(gServers[index].Registration()));
}
#endif
#ifdef CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
if (endpointId == CONFIG_ETHERNET_NETWORK_ENDPOINT_ID) {
gServers[index].Create(endpointId, &(DeviceLayer::NetworkCommissioning::ESPEthernetDriver::GetInstance()), gBreadcrumbTracker);
gServers[index].Cluster().Init();
(void)esp_matter::data_model::provider::get_instance().registry().Register(gServers[index].Registration());
LogErrorOnFailure(gServers[index].Cluster().Init());
LogErrorOnFailure(esp_matter::data_model::provider::get_instance().registry().Register(gServers[index].Registration()));
}
#endif
}
void ESPMatterNetworkCommissioningClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterNetworkCommissioningClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
uint16_t index = GetServerIndex(endpointId);
VerifyOrReturn(index != UINT16_MAX);
#ifdef CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER
if (endpointId == CONFIG_THREAD_NETWORK_ENDPOINT_ID) {
(void)esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[index].Cluster());
LogErrorOnFailure(esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[index].Cluster(), shutdownType));
gServers[index].Cluster().Deinit();
}
#endif
#ifdef CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
if (endpointId == CONFIG_WIFI_NETWORK_ENDPOINT_ID) {
(void)esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[index].Cluster());
LogErrorOnFailure(esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[index].Cluster(), shutdownType));
gServers[index].Cluster().Deinit();
}
#endif
#ifdef CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
if (endpointId == CONFIG_ETHERNET_NETWORK_ENDPOINT_ID) {
(void)esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[index].Cluster());
LogErrorOnFailure(esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[index].Cluster(), shutdownType));
gServers[index].Cluster().Deinit();
}
#endif
@@ -0,0 +1,120 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "integration.h"
#include "esp_matter_attribute_utils.h"
#include "esp_matter_data_model_priv.h"
#include <esp_matter_data_model.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app/clusters/occupancy-sensor-server/OccupancySensingCluster.h>
#include <app/server-cluster/OptionalAttributeSet.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <platform/DefaultTimerDelegate.h>
#include <unordered_map>
#include "support/logging/TextOnlyLogging.h"
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::OccupancySensing;
using namespace chip::app::Clusters::OccupancySensing::Attributes;
namespace {
std::unordered_map<EndpointId, LazyRegisteredServerCluster<OccupancySensingCluster>> gServers;
DefaultTimerDelegate gDefaultTimerDelegate;
OccupancySensing::Feature getFeature(EndpointId endpointId)
{
esp_matter::attribute_t *attr =
esp_matter::attribute::get(endpointId, OccupancySensing::Id, Globals::Attributes::FeatureMap::Id);
esp_matter_attr_val_t val = esp_matter_invalid(nullptr);
if (attr && esp_matter::attribute::get_val_internal(attr, &val) == ESP_OK &&
val.type == ESP_MATTER_VAL_TYPE_BITMAP32) {
return static_cast<OccupancySensing::Feature>(val.val.u32);
}
return static_cast<OccupancySensing::Feature>(0);
}
} // namespace
void ESPMatterOccupancySensingClusterServerInitCallback(EndpointId endpointId)
{
if (gServers[endpointId].IsConstructed()) {
return;
}
OccupancySensingCluster::Config config(endpointId);
config.WithFeatures(getFeature(endpointId));
if (esp_matter::endpoint::is_attribute_enabled(endpointId, OccupancySensing::Id,
OccupancySensing::Attributes::HoldTime::Id)) {
// Initializes hold time with default limits and timer delegate. The Application can use SetHoldTimeLimits() and
// SetHoldTime() later to customize. Initial defaults come from typical values found in real devices on the
// market.
constexpr chip::app::Clusters::OccupancySensing::Structs::HoldTimeLimitsStruct::Type kDefaultHoldTimeLimits = {
.holdTimeMin = 1, .holdTimeMax = 300, .holdTimeDefault = 30};
config.WithHoldTime(kDefaultHoldTimeLimits.holdTimeDefault, kDefaultHoldTimeLimits, gDefaultTimerDelegate);
// Show deprecated attributes if enabled in Zap
config.WithDeprecatedAttributes(
esp_matter::endpoint::is_attribute_enabled(endpointId, OccupancySensing::Id,
Attributes::PIROccupiedToUnoccupiedDelay::Id) ||
esp_matter::endpoint::is_attribute_enabled(endpointId, OccupancySensing::Id,
Attributes::UltrasonicOccupiedToUnoccupiedDelay::Id) ||
esp_matter::endpoint::is_attribute_enabled(endpointId, OccupancySensing::Id,
Attributes::PhysicalContactOccupiedToUnoccupiedDelay::Id));
}
gServers[endpointId].Create(config);
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Register(gServers[endpointId].Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register OccupancySensing - Error %" CHIP_ERROR_FORMAT, err.Format());
}
}
void ESPMatterOccupancySensingClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
if (!gServers[endpointId].IsConstructed()) {
return;
}
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(
&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister OccupancySensing - Error %" CHIP_ERROR_FORMAT, err.Format());
}
gServers[endpointId].Destroy();
}
namespace chip::app::Clusters::OccupancySensing {
OccupancySensingCluster *FindClusterOnEndpoint(EndpointId endpointId)
{
if (gServers[endpointId].IsConstructed()) {
return &gServers[endpointId].Cluster();
}
return nullptr;
}
} // namespace chip::app::Clusters::OccupancySensing
void MatterOccupancySensingPluginServerInitCallback()
{
}
void MatterOccupancySensingPluginServerShutdownCallback()
{
}
@@ -0,0 +1,23 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/occupancy-sensor-server/OccupancySensingCluster.h>
namespace chip::app::Clusters::OccupancySensing {
OccupancySensingCluster * FindClusterOnEndpoint(EndpointId endpointId);
} // namespace chip::app::Clusters::OccupancySensing
@@ -14,7 +14,7 @@
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/operational-credentials-server/operational-credentials-cluster.h>
#include <app/clusters/operational-credentials-server/OperationalCredentialsCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
using namespace chip;
@@ -42,11 +42,11 @@ void ESPMatterOperationalCredentialsClusterServerInitCallback(EndpointId endpoin
}
}
void ESPMatterOperationalCredentialsClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterOperationalCredentialsClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
// We implement the cluster as a singleton on the root endpoint.
VerifyOrReturn(endpointId == kRootEndpointId);
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister OperationalCredentials - Error: %" CHIP_ERROR_FORMAT,
err.Format());
@@ -13,10 +13,12 @@
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/ota-provider/ota-provider-cluster.h>
#include <app/clusters/ota-provider/OTAProviderCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <unordered_map>
#include "integration.h"
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
@@ -40,10 +42,10 @@ void ESPMatterOtaSoftwareUpdateProviderClusterServerInitCallback(EndpointId endp
}
}
void ESPMatterOtaSoftwareUpdateProviderClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterOtaSoftwareUpdateProviderClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster());
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister OTA on endpoint %u - Error: %" CHIP_ERROR_FORMAT, endpointId,
err.Format());
@@ -55,17 +57,11 @@ void MatterOtaSoftwareUpdateProviderPluginServerInitCallback() {}
void MatterOtaSoftwareUpdateProviderPluginServerShutdownCallback() {}
namespace chip {
namespace app {
namespace Clusters {
namespace OTAProvider {
namespace chip::app::Clusters::OTAProvider {
void SetDelegate(EndpointId endpointId, OTAProviderDelegate *delegate)
{
gServers[endpointId].Cluster().SetDelegate(delegate);
}
} // namespace OTAProvider
} // namespace Clusters
} // namespace app
} // namespace chip
} // namespace chip::app::Clusters::OTAProvider
@@ -0,0 +1,21 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/clusters/ota-provider/ota-provider-delegate.h>
namespace chip::app::Clusters::OTAProvider {
void SetDelegate(EndpointId endpointId, OTAProviderDelegate * delegate);
} // chip::app::Clusters::OTAProvider
@@ -0,0 +1,50 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/ClusterCallbacks.h>
#include <app/clusters/power-topology-server/PowerTopologyCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <unordered_map>
#include "integration.h"
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
namespace {
std::unordered_map<EndpointId, LazyRegisteredServerCluster<PowerTopology::PowerTopologyCluster>> gServers;
} // namespace
namespace chip::app::Clusters::PowerTopology {
CHIP_ERROR Instance::Init()
{
return esp_matter::data_model::provider::get_instance().registry().Register(mCluster.Registration());
}
void Instance::Shutdown()
{
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&mCluster.Cluster());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Failed to unregister Power Topology cluster: %" CHIP_ERROR_FORMAT, err.Format());
}
}
} // namespace chip::app::Clusters::PowerTopology
void ESPMatterPowerTopologyClusterServerInitCallback(chip::EndpointId endpoint) {}
void ESPMatterPowerTopologyClusterServerShutdownCallback(chip::EndpointId endpoint, chip::app::ClusterShutdownType shutdownType) {}
@@ -0,0 +1,41 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/power-topology-server/PowerTopologyCluster.h>
#include <app/clusters/power-topology-server/PowerTopologyDelegate.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
namespace chip::app::Clusters::PowerTopology {
class Instance
{
public:
Instance(EndpointId aEndpointId, Delegate & aDelegate, BitMask<Feature> aFeature) :
mCluster(PowerTopologyCluster::Config{
.endpointId = aEndpointId,
.delegate = aDelegate,
.features = aFeature,
})
{}
~Instance() { Shutdown(); }
CHIP_ERROR Init();
void Shutdown();
private:
RegisteredServerCluster<PowerTopologyCluster> mCluster;
};
} // namespace chip::app::Clusters::PowerTopology
@@ -15,7 +15,7 @@
#include <esp_matter_data_model_priv.h>
#include <app/ClusterCallbacks.h>
#include <app/clusters/push-av-stream-transport-server/push-av-stream-transport-cluster.h>
#include <app/clusters/push-av-stream-transport-server/PushAVStreamTransportCluster.h>
#include <data_model/esp_matter_data_model.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <unordered_map>
@@ -63,13 +63,13 @@ void ESPMatterPushAvStreamTransportClusterServerInitCallback(EndpointId endpoint
}
}
void ESPMatterPushAvStreamTransportClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterPushAvStreamTransportClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
if (!IsClusterEnabled(endpointId) || !gServers[endpointId].IsConstructed()) {
return;
}
CHIP_ERROR err = data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster());
CHIP_ERROR err = data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer,
"Failed to unregister Push AV Stream Transport on endpoint %u - Error: %" CHIP_ERROR_FORMAT,
@@ -82,18 +82,22 @@ void MatterPushAvStreamTransportPluginServerInitCallback() {}
void MatterPushAvStreamTransportPluginServerShutdownCallback() {}
namespace chip {
namespace app {
namespace Clusters {
namespace PushAvStreamTransport {
namespace chip::app::Clusters::PushAvStreamTransport {
void SetDelegate(EndpointId endpointId, PushAvStreamTransportDelegate *delegate)
void SetDelegate(EndpointId endpointId, PushAvStreamTransportDelegate * delegate)
{
gServers[endpointId].Cluster().SetDelegate(delegate);
gServers[endpointId].Cluster().Init();
(void)gServers[endpointId].Cluster().Init();
}
} // namespace PushAvStreamTransport
} // namespace Clusters
} // namespace app
} // namespace chip
void SetTLSClientManagementDelegate(EndpointId endpointId, TlsClientManagementDelegate * delegate)
{
gServers[endpointId].Cluster().SetTLSClientManagementDelegate(delegate);
}
void SetTlsCertificateManagementDelegate(EndpointId endpointId, TlsCertificateManagementDelegate * delegate)
{
gServers[endpointId].Cluster().SetTlsCertificateManagementDelegate(delegate);
}
}
@@ -0,0 +1,29 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/push-av-stream-transport-server/push-av-stream-transport-delegate.h>
#include <app/clusters/tls-certificate-management-server/TlsCertificateManagementCluster.h>
#include <app/clusters/tls-client-management-server/TlsClientManagementCluster.h>
namespace chip::app::Clusters::PushAvStreamTransport {
void SetDelegate(EndpointId endpointId, PushAvStreamTransportDelegate * delegate);
void SetTLSClientManagementDelegate(EndpointId endpointId, TlsClientManagementDelegate * delegate);
void SetTlsCertificateManagementDelegate(EndpointId endpointId, TlsCertificateManagementDelegate * delegate);
}
@@ -0,0 +1,158 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "integration.h"
#include <app/clusters/resource-monitoring-server/ResourceMonitoringCluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <esp_check.h>
#include <esp_matter_data_model.h>
#include <esp_matter_data_model_priv.h>
#include <unordered_map>
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ResourceMonitoring;
namespace {
std::unordered_map<uint64_t, LazyRegisteredServerCluster<ResourceMonitoringCluster>> gServers;
esp_err_t get_attr_val(esp_matter::cluster_t *cluster, uint32_t attribute_id, esp_matter_attr_val_t &val)
{
esp_matter::attribute_t *attr = esp_matter::attribute::get(cluster, attribute_id);
if (!attr) {
return ESP_FAIL;
}
return esp_matter::attribute::get_val_internal(attr, &val);
}
esp_err_t GetClusterConfig(EndpointId endpointId, ClusterId clusterId,
BitFlags<ResourceMonitoring::Feature> &enabledFeatures,
ResourceMonitoringCluster::OptionalAttributeSet &optionalAttributeSet,
Attributes::DegradationDirection::TypeInfo::Type &aDegradationDirection,
bool &aResetConditionCommandSupported)
{
esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpointId, clusterId);
if (!cluster) {
return ESP_FAIL;
}
esp_matter_attr_val_t feature_val;
ESP_RETURN_ON_ERROR(get_attr_val(cluster, Globals::Attributes::FeatureMap::Id, feature_val), "TimeSync",
"Failed to get feature map");
VerifyOrReturnError(feature_val.type == ESP_MATTER_VAL_TYPE_BITMAP32, ESP_FAIL);
enabledFeatures = BitFlags<ResourceMonitoring::Feature>(feature_val.val.u32);
esp_matter_attr_val_t attr_val;
ESP_RETURN_ON_ERROR(get_attr_val(cluster, Attributes::DegradationDirection::Id, attr_val), "ResourceMonitoring",
"Failed to get DegradationDirection");
VerifyOrReturnError(attr_val.type == ESP_MATTER_VAL_TYPE_ENUM8, ESP_FAIL);
aDegradationDirection = (Attributes::DegradationDirection::TypeInfo::Type)attr_val.val.u8;
if (esp_matter::command::get(cluster, Commands::ResetCondition::Id, esp_matter::COMMAND_FLAG_ACCEPTED)) {
aResetConditionCommandSupported = true;
} else {
aResetConditionCommandSupported = false;
}
if (esp_matter::attribute::get(cluster, Attributes::InPlaceIndicator::Id)) {
optionalAttributeSet.Set<Attributes::InPlaceIndicator::Id>();
}
if (esp_matter::attribute::get(cluster, Attributes::LastChangedTime::Id)) {
optionalAttributeSet.Set<Attributes::LastChangedTime::Id>();
}
return ESP_OK;
}
void ESPMatterResourceMonitoringClusterInitCallback(EndpointId endpointId, ClusterId clusterId)
{
uint64_t index = ((uint64_t)(endpointId) << 32) + clusterId;
if (gServers[index].IsConstructed()) {
return;
}
BitFlags<ResourceMonitoring::Feature> enabledFeatures;
ResourceMonitoringCluster::OptionalAttributeSet optionalAttributeSet;
Attributes::DegradationDirection::TypeInfo::Type degradationDirection;
bool resetConditionCommandSupported;
if (GetClusterConfig(endpointId, clusterId, enabledFeatures, optionalAttributeSet, degradationDirection,
resetConditionCommandSupported) != ESP_OK) {
ChipLogError(AppServer, "Failed to get config for Cluster %" PRIu32, clusterId);
return;
}
gServers[index].Create(endpointId, clusterId, enabledFeatures, optionalAttributeSet, degradationDirection,
resetConditionCommandSupported);
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Register(gServers[index].Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register Cluster %" PRIu32 " - Error %" CHIP_ERROR_FORMAT, clusterId,
err.Format());
}
}
void ESPMatterResourceMonitoringClusterShutdownCallback(EndpointId endpointId, ClusterId clusterId,
ClusterShutdownType shutdownType)
{
uint64_t index = ((uint64_t)(endpointId) << 32) + clusterId;
if (!gServers[index].IsConstructed()) {
return;
}
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[index].Cluster(),
shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister Cluster %" PRIu32 " - Error %" CHIP_ERROR_FORMAT, clusterId,
err.Format());
}
gServers[index].Destroy();
}
} // namespace
namespace chip::app::Clusters::ResourceMonitoring {
ResourceMonitoringCluster *GetClusterInstance(EndpointId endpointId, ClusterId clusterId)
{
uint64_t index = ((uint64_t)(endpointId) << 32) + clusterId;
if (gServers[index].IsConstructed()) {
return &gServers[index].Cluster();
}
return nullptr;
}
CHIP_ERROR SetDefaultDelegate(EndpointId endpointId, ClusterId clusterId, Delegate *delegate)
{
uint64_t index = ((uint64_t)(endpointId) << 32) + clusterId;
if (gServers[index].IsConstructed()) {
return gServers[index].Cluster().SetDelegate(delegate);
}
return CHIP_ERROR_INCORRECT_STATE;
}
} // namespace chip::app::Clusters::ResourceMonitoring
void ESPMatterActivatedCarbonFilterMonitoringClusterServerInitCallback(EndpointId endpointId)
{
ESPMatterResourceMonitoringClusterInitCallback(endpointId, ActivatedCarbonFilterMonitoring::Id);
}
void ESPMatterActivatedCarbonFilterMonitoringClusterServerShutdownCallback(EndpointId endpointId,
ClusterShutdownType shutdownType)
{
ESPMatterResourceMonitoringClusterShutdownCallback(endpointId, ActivatedCarbonFilterMonitoring::Id, shutdownType);
}
void ESPMatterHepaFilterMonitoringClusterServerInitCallback(EndpointId endpointId)
{
ESPMatterResourceMonitoringClusterInitCallback(endpointId, HepaFilterMonitoring::Id);
}
void ESPMatterHepaFilterMonitoringClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
ESPMatterResourceMonitoringClusterShutdownCallback(endpointId, HepaFilterMonitoring::Id, shutdownType);
}
@@ -0,0 +1,26 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/resource-monitoring-server/ResourceMonitoringCluster.h>
#include <app/clusters/resource-monitoring-server/ResourceMonitoringDelegate.h>
namespace chip::app::Clusters::ResourceMonitoring {
ResourceMonitoringCluster *GetClusterInstance(EndpointId endpointId, ClusterId clusterId);
CHIP_ERROR SetDefaultDelegate(EndpointId endpointId, ClusterId clusterId, Delegate *delegate);
}
@@ -0,0 +1,196 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "attribute_value_pair_validator.h"
#include <esp_matter_attribute_utils.h>
#include <esp_matter_data_model.h>
#include <esp_matter_data_model_priv.h>
namespace chip::scenes {
namespace {
using AttributeValuePairType = app::Clusters::ScenesManagement::Structs::AttributeValuePairStruct::Type;
template <typename Type>
typename app::NumericAttributeTraits<Type>::WorkingType ConvertDefaultValueToWorkingValue(
const esp_matter_attr_val_t &attr_val)
{
switch (attr_val.type & (~ESP_MATTER_VAL_NULLABLE_BASE)) {
case ESP_MATTER_VAL_TYPE_BOOLEAN:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.b);
case ESP_MATTER_VAL_TYPE_INT8:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.i8);
case ESP_MATTER_VAL_TYPE_INT16:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.i16);
case ESP_MATTER_VAL_TYPE_INT32:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.i32);
case ESP_MATTER_VAL_TYPE_INT64:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.i64);
case ESP_MATTER_VAL_TYPE_UINT8:
case ESP_MATTER_VAL_TYPE_ENUM8:
case ESP_MATTER_VAL_TYPE_BITMAP8:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.u8);
case ESP_MATTER_VAL_TYPE_UINT16:
case ESP_MATTER_VAL_TYPE_ENUM16:
case ESP_MATTER_VAL_TYPE_BITMAP16:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.u16);
case ESP_MATTER_VAL_TYPE_UINT32:
case ESP_MATTER_VAL_TYPE_BITMAP32:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.u32);
case ESP_MATTER_VAL_TYPE_UINT64:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.u64);
case ESP_MATTER_VAL_TYPE_FLOAT:
return static_cast<typename app::NumericAttributeTraits<Type>::WorkingType>(attr_val.val.f);
default:
return 0;
}
return 0;
}
/// IsExactlyOneValuePopulated
/// @brief Helper function to verify that exactly one value is populated in a given AttributeValuePairType
/// @param AttributeValuePairType & type AttributeValuePairType to verify
/// @return bool true if only one value is populated, false otherwise
bool IsExactlyOneValuePopulated(const AttributeValuePairType &type)
{
int count = 0;
if (type.valueUnsigned8.HasValue())
count++;
if (type.valueSigned8.HasValue())
count++;
if (type.valueUnsigned16.HasValue())
count++;
if (type.valueSigned16.HasValue())
count++;
if (type.valueUnsigned32.HasValue())
count++;
if (type.valueSigned32.HasValue())
count++;
if (type.valueUnsigned64.HasValue())
count++;
if (type.valueSigned64.HasValue())
count++;
return count == 1;
}
/// CapAttributeValue
/// Cap the attribute value based on the attribute's min and max if they are defined,
/// or based on the attribute's size if they are not.
///
/// The TypeForMinMax template parameter determines the type to use for the
/// min/max computation. The Type template parameter determines how the
/// resulting value is actually represented, because for booleans we
/// unfortunately end up using uint8, not an actual boolean.
///
/// @param[in] value The value from the AttributeValuePairType that we were given.
/// @param[in] metadata The metadata for the attribute the value is for.
///
///
///
template <typename Type, typename TypeForMinMax = Type>
void CapAttributeValue(typename app::NumericAttributeTraits<Type>::WorkingType &value, esp_matter::attribute_t *attr)
{
using IntType = app::NumericAttributeTraits<TypeForMinMax>;
using WorkingType = std::remove_reference_t<decltype(value)>;
esp_matter_attr_val_t attr_val;
if (esp_matter::attribute::get_val_internal(attr, &attr_val) != ESP_OK) {
return;
}
bool is_nullable = (attr_val.type & ESP_MATTER_VAL_NULLABLE_BASE);
WorkingType minValue = IntType::MinValue(is_nullable);
WorkingType maxValue = IntType::MaxValue(is_nullable);
// Check metadata for min and max values
esp_matter_attr_bounds_t bounds;
if (esp_matter::attribute::get_bounds(attr, &bounds)) {
minValue = ConvertDefaultValueToWorkingValue<Type>(bounds.min);
maxValue = ConvertDefaultValueToWorkingValue<Type>(bounds.max);
}
if (is_nullable && (minValue > value || maxValue < value)) {
// If the attribute is nullable, the value can be set to NULL
app::NumericAttributeTraits<WorkingType>::SetNull(value);
return;
}
if (minValue > value) {
value = minValue;
} else if (maxValue < value) {
value = maxValue;
}
}
} // namespace
CHIP_ERROR CodegenAttributeValuePairValidator::Validate(const app::ConcreteClusterPath &clusterPath,
AttributeValuePairType &value)
{
esp_matter::attribute_t *attr =
esp_matter::attribute::get(clusterPath.mEndpointId, clusterPath.mClusterId, value.attributeID);
esp_matter_attr_val_t attr_val;
if (nullptr == attr || esp_matter::attribute::get_val_internal(attr, &attr_val) != ESP_OK) {
return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute);
}
// There should never be more than one populated value in an ExtensionFieldSet
VerifyOrReturnError(IsExactlyOneValuePopulated(value), CHIP_ERROR_INVALID_ARGUMENT);
switch (attr_val.type & (~ESP_MATTER_VAL_NULLABLE_BASE)) {
case ESP_MATTER_VAL_TYPE_BOOLEAN:
VerifyOrReturnError(value.valueUnsigned8.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
CapAttributeValue<uint8_t, bool>(value.valueUnsigned8.Value(), attr);
break;
case ESP_MATTER_VAL_TYPE_UINT8:
case ESP_MATTER_VAL_TYPE_ENUM8:
case ESP_MATTER_VAL_TYPE_BITMAP8:
VerifyOrReturnError(value.valueUnsigned8.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
CapAttributeValue<uint8_t>(value.valueUnsigned8.Value(), attr);
break;
case ESP_MATTER_VAL_TYPE_UINT16:
case ESP_MATTER_VAL_TYPE_ENUM16:
case ESP_MATTER_VAL_TYPE_BITMAP16:
VerifyOrReturnError(value.valueUnsigned16.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
CapAttributeValue<uint16_t>(value.valueUnsigned16.Value(), attr);
break;
case ESP_MATTER_VAL_TYPE_UINT32:
case ESP_MATTER_VAL_TYPE_BITMAP32:
VerifyOrReturnError(value.valueUnsigned32.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
CapAttributeValue<uint32_t>(value.valueUnsigned32.Value(), attr);
break;
case ESP_MATTER_VAL_TYPE_UINT64:
VerifyOrReturnError(value.valueUnsigned64.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
CapAttributeValue<uint64_t>(value.valueUnsigned64.Value(), attr);
break;
case ESP_MATTER_VAL_TYPE_INT8:
VerifyOrReturnError(value.valueSigned8.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
CapAttributeValue<int8_t>(value.valueSigned8.Value(), attr);
break;
case ESP_MATTER_VAL_TYPE_INT16:
VerifyOrReturnError(value.valueSigned16.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
CapAttributeValue<int16_t>(value.valueSigned16.Value(), attr);
break;
case ESP_MATTER_VAL_TYPE_INT32:
VerifyOrReturnError(value.valueSigned32.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
CapAttributeValue<int32_t>(value.valueSigned32.Value(), attr);
break;
case ESP_MATTER_VAL_TYPE_INT64:
VerifyOrReturnError(value.valueSigned64.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
CapAttributeValue<int64_t>(value.valueSigned64.Value(), attr);
break;
default:
return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute);
}
return CHIP_NO_ERROR;
}
} // namespace chip::scenes
@@ -0,0 +1,35 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/scenes-server/AttributeValuePairValidator.h>
namespace chip::scenes {
// This class is used by on-off, level-control, color-control, and mode-select cluster, temporarily use this name until
// those clusters are decoupled with ember.
class CodegenAttributeValuePairValidator : public AttributeValuePairValidator {
public:
~CodegenAttributeValuePairValidator() override = default;
CHIP_ERROR Validate(const app::ConcreteClusterPath &clusterPath, AttributeValuePairType &value) override;
static CodegenAttributeValuePairValidator &Instance()
{
static CodegenAttributeValuePairValidator sInstance;
return sInstance;
}
};
} // namespace chip::scenes
@@ -0,0 +1,223 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "integration.h"
#include "esp_err.h"
#include <esp_check.h>
#include <esp_matter_data_model.h>
#include <esp_matter_data_model_priv.h>
#include <app/clusters/scenes-server/SceneTable.h>
#include <app/clusters/scenes-server/SceneTableImpl.h>
#include <app/clusters/scenes-server/ScenesManagementCluster.h>
#include <app/server/Server.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <filesystem>
#include <unordered_map>
#include "credentials/GroupDataProvider.h"
using SceneTable = chip::scenes::SceneTable<chip::scenes::ExtensionFieldSetsImpl>;
namespace chip::app::Clusters::ScenesManagement {
namespace {
class DefaultScenesManagementTableProvider : public ScenesManagementTableProvider {
public:
void SetParameters(EndpointId endpointId, uint16_t endpointTableSize)
{
mEndpointId = endpointId;
mEndpointTableSize = endpointTableSize;
}
EndpointId GetEndpointId() const { return mEndpointId; }
ScenesManagementSceneTable *Take() override { return scenes::GetSceneTableImpl(mEndpointId, mEndpointTableSize); }
void Release(ScenesManagementSceneTable *) override {}
private:
EndpointId mEndpointId = kInvalidEndpointId;
uint16_t mEndpointTableSize = scenes::kMaxScenesPerEndpoint;
};
std::unordered_map<EndpointId, LazyRegisteredServerCluster<ScenesManagementCluster>> gServers;
std::unordered_map<EndpointId, DefaultScenesManagementTableProvider> gTableProviders;
} // namespace
ScenesManagementCluster *FindClusterOnEndpoint(EndpointId endpointId)
{
if (gServers[endpointId].IsConstructed()) {
return &gServers[endpointId].Cluster();
}
return nullptr;
}
ScenesServer &ScenesServer::Instance()
{
static ScenesServer gInstance;
return gInstance;
}
bool ScenesServer::IsHandlerRegistered(EndpointId aEndpointId, scenes::SceneHandler *handler)
{
SceneTable *sceneTable = scenes::GetSceneTableImpl(aEndpointId);
return sceneTable->mHandlerList.Contains(handler);
}
void ScenesServer::RegisterSceneHandler(EndpointId aEndpointId, scenes::SceneHandler *handler)
{
SceneTable *sceneTable = scenes::GetSceneTableImpl(aEndpointId);
if (!IsHandlerRegistered(aEndpointId, handler)) {
sceneTable->RegisterHandler(handler);
}
}
void ScenesServer::UnregisterSceneHandler(EndpointId aEndpointId, scenes::SceneHandler *handler)
{
SceneTable *sceneTable = scenes::GetSceneTableImpl(aEndpointId);
if (IsHandlerRegistered(aEndpointId, handler)) {
sceneTable->UnregisterHandler(handler);
}
}
void ScenesServer::GroupWillBeRemoved(FabricIndex aFabricIx, EndpointId aEndpointId, GroupId aGroupId)
{
ScenesManagementCluster *cluster = FindClusterOnEndpoint(aEndpointId);
VerifyOrReturn(cluster != nullptr);
TEMPORARY_RETURN_IGNORED cluster->GroupWillBeRemoved(aFabricIx, aGroupId);
}
void ScenesServer::MakeSceneInvalid(EndpointId aEndpointId, FabricIndex aFabricIx)
{
ScenesManagementCluster *cluster = FindClusterOnEndpoint(aEndpointId);
VerifyOrReturn(cluster != nullptr);
TEMPORARY_RETURN_IGNORED cluster->MakeSceneInvalid(aFabricIx);
}
void ScenesServer::MakeSceneInvalidForAllFabrics(EndpointId aEndpointId)
{
ScenesManagementCluster *cluster = FindClusterOnEndpoint(aEndpointId);
VerifyOrReturn(cluster != nullptr);
TEMPORARY_RETURN_IGNORED cluster->MakeSceneInvalidForAllFabrics();
}
void ScenesServer::StoreCurrentScene(FabricIndex aFabricIx, EndpointId aEndpointId, GroupId aGroupId, SceneId aSceneId)
{
ScenesManagementCluster *cluster = FindClusterOnEndpoint(aEndpointId);
VerifyOrReturn(cluster != nullptr);
TEMPORARY_RETURN_IGNORED cluster->StoreCurrentScene(aFabricIx, aGroupId, aSceneId);
}
void ScenesServer::RecallScene(FabricIndex aFabricIx, EndpointId aEndpointId, GroupId aGroupId, SceneId aSceneId)
{
ScenesManagementCluster *cluster = FindClusterOnEndpoint(aEndpointId);
VerifyOrReturn(cluster != nullptr);
TEMPORARY_RETURN_IGNORED cluster->RecallScene(aFabricIx, aGroupId, aSceneId);
}
void ScenesServer::RemoveFabric(EndpointId aEndpointId, FabricIndex aFabricIndex)
{
ScenesManagementCluster *cluster = FindClusterOnEndpoint(aEndpointId);
VerifyOrReturn(cluster != nullptr);
TEMPORARY_RETURN_IGNORED cluster->RemoveFabric(aFabricIndex);
}
} // namespace chip::app::Clusters::ScenesManagement
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ScenesManagement;
namespace {
esp_err_t get_attr_val(esp_matter::cluster_t *cluster, AttributeId attrId, esp_matter_attr_val_t &val)
{
esp_matter::attribute_t *attr = esp_matter::attribute::get(cluster, attrId);
if (!attr) {
return ESP_ERR_NOT_FOUND;
}
return esp_matter::attribute::get_val_internal(attr, &val);
}
esp_err_t GetScenesClusterContextParams(EndpointId endpointId, BitMask<ScenesManagement::Feature> &featureMap,
bool &supportsCopyScene, uint16_t &tableSize)
{
esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpointId, ScenesManagement::Id);
esp_matter_attr_val_t attr_val;
ESP_RETURN_ON_ERROR(get_attr_val(cluster, Globals::Attributes::FeatureMap::Id, attr_val), "Scenes",
"Failed to get feature map");
VerifyOrReturnValue(attr_val.type == ESP_MATTER_VAL_TYPE_BITMAP32, ESP_ERR_INVALID_ARG);
featureMap = BitMask<ScenesManagement::Feature>(attr_val.val.u32);
supportsCopyScene =
(esp_matter::command::get(endpointId, ScenesManagement::Id, Commands::CopyScene::Id) != nullptr);
ESP_RETURN_ON_ERROR(get_attr_val(cluster, Attributes::SceneTableSize::Id, attr_val), "Scenes",
"Failed to get scenes table size");
VerifyOrReturnValue(attr_val.type == ESP_MATTER_VAL_TYPE_UINT16, ESP_ERR_INVALID_ARG);
tableSize = attr_val.val.u16;
return ESP_OK;
}
} // namespace
void ESPMatterScenesManagementClusterServerInitCallback(EndpointId endpointId)
{
if (gServers[endpointId].IsConstructed()) {
return;
}
BitMask<ScenesManagement::Feature> featureMap;
bool supportsCopyScene;
uint16_t tableSize;
if (GetScenesClusterContextParams(endpointId, featureMap, supportsCopyScene, tableSize) != ESP_OK) {
ESP_LOGE("Scenes", "Failed to get cluster context parameters");
return;
}
gTableProviders[endpointId].SetParameters(endpointId, tableSize);
gServers[endpointId].Create(endpointId,
ScenesManagementCluster::Context{
.groupDataProvider = Credentials::GetGroupDataProvider(),
.fabricTable = &Server::GetInstance().GetFabricTable(),
.features = featureMap,
.sceneTableProvider = gTableProviders[endpointId],
.supportsCopyScene = supportsCopyScene,
});
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Register(gServers[endpointId].Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register Scenes on endpoint %u - Error: %" CHIP_ERROR_FORMAT, endpointId,
err.Format());
}
}
void ESPMatterScenesManagementClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
if (!gServers[endpointId].IsConstructed()) {
return;
}
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(
&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register Scenes on endpoint %u - Error: %" CHIP_ERROR_FORMAT, endpointId,
err.Format());
}
gServers[endpointId].Destroy();
}
void MatterScenesManagementPluginServerInitCallback()
{
}
@@ -0,0 +1,55 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/scenes-server/ScenesManagementCluster.h>
// most ember implementations will want access to these
#include <app/clusters/scenes-server/SceneHandlerImpl.h>
namespace chip::app::Clusters::ScenesManagement {
class ScenesServer
{
public:
static constexpr SceneId kGlobalSceneId = 0x00;
static constexpr GroupId kGlobalSceneGroupId = 0x0000;
ScenesServer() = default;
~ScenesServer() = default;
static ScenesServer & Instance();
// Callbacks
void GroupWillBeRemoved(FabricIndex aFabricIx, EndpointId aEndpointId, GroupId aGroupId);
void MakeSceneInvalid(EndpointId aEndpointId, FabricIndex aFabricIx);
void MakeSceneInvalidForAllFabrics(EndpointId aEndpointId);
void StoreCurrentScene(FabricIndex aFabricIx, EndpointId aEndpointId, GroupId aGroupId, SceneId aSceneId);
void RecallScene(FabricIndex aFabricIx, EndpointId aEndpointId, GroupId aGroupId, SceneId aSceneId);
// Handlers for extension field sets
bool IsHandlerRegistered(EndpointId endpointId, scenes::SceneHandler * handler);
void RegisterSceneHandler(EndpointId endpointId, scenes::SceneHandler * handler);
void UnregisterSceneHandler(EndpointId endpointId, scenes::SceneHandler * handler);
// Fabric
void RemoveFabric(EndpointId aEndpointId, FabricIndex aFabricIndex);
};
/// Returns the cluster instance on the given endpoint or nullptr if the cluster does not exist
/// or was not yet initialized
ScenesManagementCluster * FindClusterOnEndpoint(EndpointId endpointId);
} // namespace chip::app::Clusters::ScenesManagement
@@ -13,8 +13,8 @@
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/software-diagnostics-server/software-diagnostics-cluster.h>
#include <app/clusters/software-diagnostics-server/software-diagnostics-logic.h>
#include <app/clusters/software-diagnostics-server/SoftwareDiagnosticsCluster.h>
#include <app/clusters/software-diagnostics-server/SoftwareDiagnosticsLogic.h>
#include <data_model/esp_matter_data_model.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
@@ -60,10 +60,10 @@ void ESPMatterSoftwareDiagnosticsClusterServerInitCallback(EndpointId endpointId
}
}
void ESPMatterSoftwareDiagnosticsClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterSoftwareDiagnosticsClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
VerifyOrReturn(endpointId == kRootEndpointId);
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister SoftwareDiagnostics - Error: %" CHIP_ERROR_FORMAT, err.Format());
}
@@ -13,8 +13,9 @@
// limitations under the License.
#include "esp_matter_data_model.h"
#include "esp_matter_data_model_priv.h"
#include <app/ClusterCallbacks.h>
#include <app/clusters/time-format-localization-server/time-format-localization-cluster.h>
#include <app/clusters/time-format-localization-server/TimeFormatLocalizationCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include "clusters/TimeFormatLocalization/Enums.h"
@@ -30,7 +31,8 @@ uint32_t get_feature_map(esp_matter::cluster_t *cluster)
esp_matter::attribute_t *attribute = esp_matter::attribute::get(cluster, Globals::Attributes::FeatureMap::Id);
if (attribute) {
esp_matter_attr_val_t val = esp_matter_invalid(nullptr);
if (esp_matter::attribute::get_val(attribute, &val) == ESP_OK && val.type == ESP_MATTER_VAL_TYPE_BITMAP32) {
if (esp_matter::attribute::get_val_internal(attribute, &val) == ESP_OK &&
val.type == ESP_MATTER_VAL_TYPE_BITMAP32) {
return val.val.u32;
}
}
@@ -43,7 +45,8 @@ TimeFormatLocalization::HourFormatEnum get_default_hour_format(esp_matter::clust
esp_matter::attribute::get(cluster, TimeFormatLocalization::Attributes::HourFormat::Id);
if (attribute) {
esp_matter_attr_val_t val = esp_matter_invalid(nullptr);
if (esp_matter::attribute::get_val(attribute, &val) == ESP_OK && val.type == ESP_MATTER_VAL_TYPE_ENUM8) {
if (esp_matter::attribute::get_val_internal(attribute, &val) == ESP_OK &&
val.type == ESP_MATTER_VAL_TYPE_ENUM8) {
return TimeFormatLocalization::HourFormatEnum(val.val.u8);
}
}
@@ -56,7 +59,8 @@ TimeFormatLocalization::CalendarTypeEnum get_default_calendar_type(esp_matter::c
esp_matter::attribute::get(cluster, TimeFormatLocalization::Attributes::ActiveCalendarType::Id);
if (attribute) {
esp_matter_attr_val_t val = esp_matter_invalid(nullptr);
if (esp_matter::attribute::get_val(attribute, &val) == ESP_OK && val.type == ESP_MATTER_VAL_TYPE_ENUM8) {
if (esp_matter::attribute::get_val_internal(attribute, &val) == ESP_OK &&
val.type == ESP_MATTER_VAL_TYPE_ENUM8) {
return TimeFormatLocalization::CalendarTypeEnum(val.val.u8);
}
}
@@ -81,16 +85,19 @@ void ESPMatterTimeFormatLocalizationClusterServerInitCallback(EndpointId endpoin
}
}
void ESPMatterTimeFormatLocalizationClusterServerShutdownCallback(EndpointId endpoint)
void ESPMatterTimeFormatLocalizationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType)
{
// This cluster should only exist in Root endpoint.
VerifyOrReturn(endpoint == kRootEndpointId);
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster());
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "TimeFormatLocalization unregister error: %" CHIP_ERROR_FORMAT, err.Format());
}
gServer.Destroy();
}
void MatterTimeFormatLocalizationPluginServerInitCallback() {}
void MatterTimeFormatLocalizationPluginServerInitCallback()
{
}
@@ -0,0 +1,147 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "integration.h"
#include <esp_matter_attribute_utils.h>
#include <esp_matter_data_model_priv.h>
#include <app/clusters/time-synchronization-server/TimeSynchronizationCluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <esp_matter_data_model.h>
#include <lib/support/BitFlags.h>
#include <clusters/TimeSynchronization/Enums.h>
#include <esp_check.h>
#include "support/CodeUtils.h"
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::TimeSynchronization;
namespace {
LazyRegisteredServerCluster<TimeSynchronizationCluster> gServer;
TimeSynchronization::Delegate * gDelegate = nullptr;
esp_err_t get_attr_val(esp_matter::cluster_t *cluster, uint32_t attribute_id, esp_matter_attr_val_t &val)
{
esp_matter::attribute_t *attr = esp_matter::attribute::get(cluster, attribute_id);
if (!attr) {
return ESP_FAIL;
}
return esp_matter::attribute::get_val_internal(attr, &val);
}
esp_err_t GetClusterConfig(EndpointId endpointId, TimeSynchronizationCluster::OptionalAttributeSet &attrSet,
TimeSynchronizationCluster::StartupConfiguration &startupConfig,
BitFlags<TimeSynchronization::Feature> &featureMap)
{
esp_matter::cluster_t *cluster = esp_matter::cluster::get(endpointId, TimeSynchronization::Id);
if (!cluster) {
return ESP_FAIL;
}
esp_matter_attr_val_t feature_val;
ESP_RETURN_ON_ERROR(get_attr_val(cluster, Globals::Attributes::FeatureMap::Id, feature_val), "TimeSync",
"Failed to get feature map");
VerifyOrReturnError(feature_val.type == ESP_MATTER_VAL_TYPE_BITMAP32, ESP_FAIL);
featureMap = BitFlags<TimeSynchronization::Feature>(feature_val.val.u32);
esp_matter_attr_val_t attr_val;
if (featureMap.Has(Feature::kNTPClient) || featureMap.Has(Feature::kNTPServer)) {
ESP_RETURN_ON_ERROR(get_attr_val(cluster, Attributes::SupportsDNSResolve::Id, attr_val), "TimeSync",
"Failed to get SupportsDNSResolve");
VerifyOrReturnError(attr_val.type == ESP_MATTER_VAL_TYPE_BOOLEAN, ESP_FAIL);
if (featureMap.Has(Feature::kNTPClient)) {
startupConfig.supportsDNSResolve = attr_val.val.b;
}
if (featureMap.Has(Feature::kNTPServer)) {
startupConfig.ntpServerAvailable = attr_val.val.b;
}
}
if (featureMap.Has(Feature::kTimeZone)) {
ESP_RETURN_ON_ERROR(get_attr_val(cluster, Attributes::TimeZoneDatabase::Id, attr_val), "TimeSync",
"Failed to get TimeZoneDatabase");
VerifyOrReturnError(attr_val.type == ESP_MATTER_VAL_TYPE_ENUM8, ESP_FAIL);
startupConfig.timeZoneDatabase = (TimeZoneDatabaseEnum)attr_val.val.u8;
}
if (get_attr_val(cluster, Attributes::TimeSource::Id, attr_val) == ESP_OK &&
attr_val.type == ESP_MATTER_VAL_TYPE_ENUM8) {
attrSet.Set<Attributes::TimeSource::Id>();
startupConfig.timeSource = (TimeSourceEnum)attr_val.val.u8;
}
startupConfig.delegate = GetDefaultDelegate();
return ESP_OK;
}
}
void ESPMatterTimeSynchronizationClusterServerInitCallback(EndpointId endpointId)
{
VerifyOrReturn(endpointId == kRootEndpointId);
TimeSynchronizationCluster::OptionalAttributeSet attrSet;
TimeSynchronizationCluster::StartupConfiguration startupConfig;
BitFlags<TimeSynchronization::Feature> featureMap;
VerifyOrReturn(GetClusterConfig(endpointId, attrSet, startupConfig, featureMap) == ESP_OK);
gServer.Create(endpointId, featureMap, attrSet, startupConfig);
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(gServer.Registration());
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to register TimeSynchronization - Error %" CHIP_ERROR_FORMAT, err.Format());
}
}
void ESPMatterTimeSynchronizationClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
VerifyOrReturn(endpointId == kRootEndpointId);
VerifyOrReturn(gServer.IsConstructed());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServer.Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister TimeSynchronization - Error %" CHIP_ERROR_FORMAT, err.Format());
}
gServer.Destroy();
}
void MatterTimeSynchronizationPluginServerInitCallback() {}
namespace chip::app::Clusters::TimeSynchronization {
TimeSynchronizationCluster * GetClusterInstance()
{
VerifyOrReturnValue(gServer.IsConstructed(), nullptr);
return &gServer.Cluster();
}
void SetDefaultDelegate(Delegate * delegate)
{
VerifyOrReturn(delegate != nullptr);
gDelegate = delegate;
auto timeSynchronization = GetClusterInstance();
if (timeSynchronization != nullptr)
{
timeSynchronization->SetDelegate(gDelegate);
}
}
Delegate * GetDefaultDelegate()
{
auto timeSynchronization = GetClusterInstance();
if (timeSynchronization != nullptr)
{
return timeSynchronization->GetDelegate();
}
if (gDelegate == nullptr)
{
static DefaultTimeSyncDelegate delegate;
gDelegate = &delegate;
}
return gDelegate;
}
} // namespace chip::app::Clusters::TimeSynchronization
@@ -0,0 +1,27 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/time-synchronization-server/TimeSynchronizationCluster.h>
namespace chip::app::Clusters::TimeSynchronization {
TimeSynchronizationCluster * GetClusterInstance();
// Delegate functions
void SetDefaultDelegate(Delegate * delegate);
Delegate * GetDefaultDelegate();
} // namespace chip::app::Clusters::TimeSynchronization
@@ -0,0 +1,46 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 "integration.h"
#include "app/AttributeAccessInterfaceRegistry.h"
#include <app/server-cluster/ServerClusterInterface.h>
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::UnitLocalization;
namespace chip::app::Clusters::UnitLocalization {
UnitLocalizationServer & UnitLocalizationServer::Instance()
{
static UnitLocalizationServer mInstance;
return mInstance;
}
} // namespace chip::app::Clusters::UnitLocalization
void ESPMatterUnitLocalizationServerInitCallback(EndpointId endpointId) {}
void ESPMatterUnitLocalizationServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType) {}
void MatterUnitLocalizationPluginServerInitCallback()
{
LogErrorOnFailure(UnitLocalizationServer::Instance().Init());
AttributeAccessInterfaceRegistry::Instance().Register(&UnitLocalizationServer::Instance());
}
void MatterUnitLocalizationPluginServerShutdownCallback()
{
AttributeAccessInterfaceRegistry::Instance().Unregister(&UnitLocalizationServer::Instance());
}
@@ -0,0 +1,27 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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/unit-localization-server/UnitLocalizationCluster.h>
namespace chip::app::Clusters::UnitLocalization {
class UnitLocalizationServer : public UnitLocalizationCluster
{
public:
static UnitLocalizationServer & Instance();
};
}
@@ -13,7 +13,7 @@
// limitations under the License.
#include <app/ClusterCallbacks.h>
#include <app/clusters/user-label-server/user-label-cluster.h>
#include <app/clusters/user-label-server/UserLabelCluster.h>
#include <data_model_provider/esp_matter_data_model_provider.h>
#include <unordered_map>
@@ -41,10 +41,10 @@ void ESPMatterUserLabelClusterServerInitCallback(EndpointId endpointId)
}
}
void ESPMatterUserLabelClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterUserLabelClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
CHIP_ERROR err =
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster());
esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR) {
ChipLogError(AppServer, "Failed to unregister UserLabel on endpoint %u - Error: %" CHIP_ERROR_FORMAT,
endpointId, err.Format());
@@ -0,0 +1,36 @@
// Copyright 2026 Espressif Systems (Shanghai) PTE LTD
//
// 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 <lib/core/DataModelTypes.h>
#include <lib/support/logging/CHIPLogging.h>
#include <app/server-cluster/ServerClusterInterface.h>
void ESPMatterWebRTCTransportProviderClusterServerInitCallback(chip::EndpointId endpointId)
{
}
void ESPMatterWebRTCTransportProviderClusterServerShutdownCallback(
chip::EndpointId endpointId, chip::app::ClusterShutdownType shutdownType)
{
}
void MatterWebRTCTransportProviderPluginServerInitCallback()
{
ChipLogProgress(Zcl, "Initializing WebRTC Transport Provider cluster.");
}
void MatterWebRTCTransportProviderPluginServerShutdownCallback()
{
ChipLogProgress(Zcl, "Shutdown WebRTC Transport Provider cluster.");
}
@@ -15,7 +15,7 @@
#include <esp_matter_data_model_priv.h>
#include <app/ClusterCallbacks.h>
#include <app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-cluster.h>
#include <app/clusters/wifi-network-diagnostics-server/WiFiNetworkDiagnosticsCluster.h>
#include <app/server-cluster/ServerClusterInterfaceRegistry.h>
#include <clusters/WiFiNetworkDiagnostics/ClusterId.h>
#include <data_model/esp_matter_data_model.h>
@@ -79,10 +79,10 @@ void ESPMatterWiFiNetworkDiagnosticsClusterServerInitCallback(EndpointId endpoin
}
// This callback is called for any endpoint (fixed or dynamic) that is registered with the Ember machinery.
void ESPMatterWiFiNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpointId)
void ESPMatterWiFiNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpointId, ClusterShutdownType shutdownType)
{
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&gServers[endpointId].Cluster(), shutdownType);
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Failed to unregister WiFiNetworkDiagnostics on endpoint %u - Error: %" CHIP_ERROR_FORMAT, endpointId,
@@ -165,7 +165,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
switch (m_attr_val.type) {
case ESP_MATTER_VAL_TYPE_NULLABLE_BOOLEAN:
if (chip::app::NumericAttributeTraits<bool>::IsNullValue(m_attr_val.val.b)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -176,7 +176,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
case ESP_MATTER_VAL_TYPE_NULLABLE_ENUM8:
case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP8:
if (chip::app::NumericAttributeTraits<uint8_t>::IsNullValue(m_attr_val.val.u8)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -189,7 +189,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
case ESP_MATTER_VAL_TYPE_NULLABLE_ENUM16:
case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP16:
if (chip::app::NumericAttributeTraits<uint16_t>::IsNullValue(m_attr_val.val.u16)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -201,7 +201,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT32:
case ESP_MATTER_VAL_TYPE_NULLABLE_BITMAP32:
if (chip::app::NumericAttributeTraits<uint32_t>::IsNullValue(m_attr_val.val.u32)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -211,7 +211,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
break;
case ESP_MATTER_VAL_TYPE_NULLABLE_UINT64:
if (chip::app::NumericAttributeTraits<uint64_t>::IsNullValue(m_attr_val.val.u64)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -220,7 +220,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
break;
case ESP_MATTER_VAL_TYPE_NULLABLE_INT8:
if (chip::app::NumericAttributeTraits<int8_t>::IsNullValue(m_attr_val.val.i8)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -229,7 +229,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
break;
case ESP_MATTER_VAL_TYPE_NULLABLE_INT16:
if (chip::app::NumericAttributeTraits<int16_t>::IsNullValue(m_attr_val.val.i16)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -238,7 +238,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
break;
case ESP_MATTER_VAL_TYPE_NULLABLE_INT32:
if (chip::app::NumericAttributeTraits<int32_t>::IsNullValue(m_attr_val.val.i32)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -247,7 +247,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
break;
case ESP_MATTER_VAL_TYPE_NULLABLE_INT64:
if (chip::app::NumericAttributeTraits<int64_t>::IsNullValue(m_attr_val.val.i64)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -256,7 +256,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
break;
case ESP_MATTER_VAL_TYPE_NULLABLE_FLOAT:
if (chip::app::NumericAttributeTraits<float>::IsNullValue(m_attr_val.val.f)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
// Fall through
@@ -267,7 +267,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
case ESP_MATTER_VAL_TYPE_LONG_CHAR_STRING: {
if (m_attr_val.val.a.b == nullptr &&
m_attr_val.val.a.s == (m_attr_val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING ? 0xFF : 0xFFFF)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
if (m_attr_val.val.a.b == nullptr) {
@@ -281,7 +281,7 @@ CHIP_ERROR attribute_data_encode_buffer::Encode(chip::TLV::TLVWriter &writer, ch
case ESP_MATTER_VAL_TYPE_LONG_OCTET_STRING: {
if (m_attr_val.val.a.b == nullptr &&
m_attr_val.val.a.s == (m_attr_val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING ? 0xFF : 0xFFFF)) {
writer.PutNull(tag);
ReturnErrorOnFailure(writer.PutNull(tag));
break;
}
ReturnErrorOnFailure(writer.PutBytes(tag, m_attr_val.val.a.b, m_attr_val.val.a.s));
@@ -258,7 +258,7 @@ CHIP_ERROR provider::Startup(InteractionModelContext context)
ep = endpoint::get_next(ep);
}
if (GetAttributePersistenceProvider() == nullptr) {
gDefaultAttributePersistence.Init(&Server::GetInstance().GetPersistentStorage());
ReturnErrorOnFailure(gDefaultAttributePersistence.Init(&Server::GetInstance().GetPersistentStorage()));
SetAttributePersistenceProvider(&gDefaultAttributePersistence);
}
return mRegistry.SetContext(ServerClusterContext{
@@ -734,6 +734,8 @@ EmberAfDefaultAttributeValue get_default_attr_value_from_val(esp_matter_attr_val
namespace chip {
namespace app {
// TODO: Remove EnabledEndpointsWithServerCluster when door-lock, power-source-configuration, and ota-requestor server
// is decoupled from ember.
EnabledEndpointsWithServerCluster::EnabledEndpointsWithServerCluster(ClusterId clusterId)
: mEndpointCount(esp_matter::endpoint::get_count(esp_matter::node::get()))
, mClusterId(clusterId)
@@ -743,7 +745,7 @@ EnabledEndpointsWithServerCluster::EnabledEndpointsWithServerCluster(ClusterId c
EndpointId EnabledEndpointsWithServerCluster::operator*() const
{
return emberAfEndpointFromIndex(mEndpointIndex);
return esp_matter::endpoint::get_id(get_endpoint_at_index(mEndpointIndex));
}
EnabledEndpointsWithServerCluster &EnabledEndpointsWithServerCluster::operator++()
@@ -766,181 +768,16 @@ void EnabledEndpointsWithServerCluster::EnsureMatchingEndpoint()
}
}
namespace Compatibility {
namespace Internal {
// Remove AttributeBaseType() when scenes management cluster is decoupled from ember.
EmberAfAttributeType AttributeBaseType(EmberAfAttributeType type)
{
switch (type) {
case ZCL_ACTION_ID_ATTRIBUTE_TYPE: // Action Id
case ZCL_FABRIC_IDX_ATTRIBUTE_TYPE: // Fabric Index
case ZCL_BITMAP8_ATTRIBUTE_TYPE: // 8-bit bitmap
case ZCL_ENUM8_ATTRIBUTE_TYPE: // 8-bit enumeration
case ZCL_STATUS_ATTRIBUTE_TYPE: // Status Code
case ZCL_PERCENT_ATTRIBUTE_TYPE: // Percentage
static_assert(std::is_same<chip::Percent, uint8_t>::value,
"chip::Percent is expected to be uint8_t, change this when necessary");
return ZCL_INT8U_ATTRIBUTE_TYPE;
case ZCL_ENDPOINT_NO_ATTRIBUTE_TYPE: // Endpoint Number
case ZCL_GROUP_ID_ATTRIBUTE_TYPE: // Group Id
case ZCL_VENDOR_ID_ATTRIBUTE_TYPE: // Vendor Id
case ZCL_ENUM16_ATTRIBUTE_TYPE: // 16-bit enumeration
case ZCL_BITMAP16_ATTRIBUTE_TYPE: // 16-bit bitmap
case ZCL_PERCENT100THS_ATTRIBUTE_TYPE: // 100ths of a percent
static_assert(std::is_same<chip::EndpointId, uint16_t>::value,
"chip::EndpointId is expected to be uint16_t, change this when necessary");
static_assert(std::is_same<chip::GroupId, uint16_t>::value,
"chip::GroupId is expected to be uint16_t, change this when necessary");
static_assert(std::is_same<chip::Percent100ths, uint16_t>::value,
"chip::Percent100ths is expected to be uint16_t, change this when necessary");
return ZCL_INT16U_ATTRIBUTE_TYPE;
case ZCL_CLUSTER_ID_ATTRIBUTE_TYPE: // Cluster Id
case ZCL_ATTRIB_ID_ATTRIBUTE_TYPE: // Attribute Id
case ZCL_FIELD_ID_ATTRIBUTE_TYPE: // Field Id
case ZCL_EVENT_ID_ATTRIBUTE_TYPE: // Event Id
case ZCL_COMMAND_ID_ATTRIBUTE_TYPE: // Command Id
case ZCL_TRANS_ID_ATTRIBUTE_TYPE: // Transaction Id
case ZCL_DEVTYPE_ID_ATTRIBUTE_TYPE: // Device Type Id
case ZCL_DATA_VER_ATTRIBUTE_TYPE: // Data Version
case ZCL_BITMAP32_ATTRIBUTE_TYPE: // 32-bit bitmap
case ZCL_EPOCH_S_ATTRIBUTE_TYPE: // Epoch Seconds
case ZCL_ELAPSED_S_ATTRIBUTE_TYPE: // Elapsed Seconds
static_assert(std::is_same<chip::ClusterId, uint32_t>::value,
"chip::Cluster is expected to be uint32_t, change this when necessary");
static_assert(std::is_same<chip::AttributeId, uint32_t>::value,
"chip::AttributeId is expected to be uint32_t, change this when necessary");
static_assert(std::is_same<chip::AttributeId, uint32_t>::value,
"chip::AttributeId is expected to be uint32_t, change this when necessary");
static_assert(std::is_same<chip::EventId, uint32_t>::value,
"chip::EventId is expected to be uint32_t, change this when necessary");
static_assert(std::is_same<chip::CommandId, uint32_t>::value,
"chip::CommandId is expected to be uint32_t, change this when necessary");
static_assert(std::is_same<chip::TransactionId, uint32_t>::value,
"chip::TransactionId is expected to be uint32_t, change this when necessary");
static_assert(std::is_same<chip::DeviceTypeId, uint32_t>::value,
"chip::DeviceTypeId is expected to be uint32_t, change this when necessary");
static_assert(std::is_same<chip::DataVersion, uint32_t>::value,
"chip::DataVersion is expected to be uint32_t, change this when necessary");
return ZCL_INT32U_ATTRIBUTE_TYPE;
case ZCL_AMPERAGE_MA_ATTRIBUTE_TYPE: // Amperage
case ZCL_ENERGY_MWH_ATTRIBUTE_TYPE: // Energy
case ZCL_ENERGY_MVAH_ATTRIBUTE_TYPE: // Apparent Energy
case ZCL_ENERGY_MVARH_ATTRIBUTE_TYPE: // Reactive Energy
case ZCL_POWER_MW_ATTRIBUTE_TYPE: // Power
case ZCL_POWER_MVA_ATTRIBUTE_TYPE: // Apparent Power
case ZCL_POWER_MVAR_ATTRIBUTE_TYPE: // Reactive Power
case ZCL_VOLTAGE_MV_ATTRIBUTE_TYPE: // Voltage
case ZCL_MONEY_ATTRIBUTE_TYPE: // Money
return ZCL_INT64S_ATTRIBUTE_TYPE;
case ZCL_EVENT_NO_ATTRIBUTE_TYPE: // Event Number
case ZCL_FABRIC_ID_ATTRIBUTE_TYPE: // Fabric Id
case ZCL_NODE_ID_ATTRIBUTE_TYPE: // Node Id
case ZCL_BITMAP64_ATTRIBUTE_TYPE: // 64-bit bitmap
case ZCL_EPOCH_US_ATTRIBUTE_TYPE: // Epoch Microseconds
case ZCL_POSIX_MS_ATTRIBUTE_TYPE: // POSIX Milliseconds
case ZCL_SYSTIME_MS_ATTRIBUTE_TYPE: // System time Milliseconds
case ZCL_SYSTIME_US_ATTRIBUTE_TYPE: // System time Microseconds
static_assert(std::is_same<chip::EventNumber, uint64_t>::value,
"chip::EventNumber is expected to be uint64_t, change this when necessary");
static_assert(std::is_same<chip::FabricId, uint64_t>::value,
"chip::FabricId is expected to be uint64_t, change this when necessary");
static_assert(std::is_same<chip::NodeId, uint64_t>::value,
"chip::NodeId is expected to be uint64_t, change this when necessary");
return ZCL_INT64U_ATTRIBUTE_TYPE;
case ZCL_TEMPERATURE_ATTRIBUTE_TYPE: // Temperature
return ZCL_INT16S_ATTRIBUTE_TYPE;
default:
return type;
}
}
} // namespace Internal
} // namespace Compatibility
} // namespace app
} // namespace chip
// Override Ember functions
// TODO: Remove the emberAfEndpointIndexIsEnabled and emberAfEndpointCount functions when FabricTableImpl is decoupled
// from ember
chip::EndpointId emberAfEndpointFromIndex(uint16_t index)
{
esp_matter::endpoint_t *ep = get_endpoint_at_index(index);
if (ep) {
return esp_matter::endpoint::get_id(ep);
}
return chip::kInvalidEndpointId;
}
bool emberAfEndpointIndexIsEnabled(uint16_t index)
{
esp_matter::endpoint_t *ep = get_endpoint_at_index(index);
if (ep) {
return esp_matter::endpoint::is_enabled(ep);
}
return false;
}
uint16_t emberAfEndpointCount()
{
return esp_matter::endpoint::get_count(esp_matter::node::get());
}
// TODO: Remove the emberAfGetClusterCountForEndpoint when scenes cluster is decoupled from ember
uint8_t emberAfGetClusterCountForEndpoint(chip::EndpointId endpoint)
{
esp_matter::endpoint_t *ep = esp_matter::endpoint::get(endpoint);
if (ep) {
esp_matter::cluster_t *cluster = esp_matter::cluster::get_first(ep);
if (cluster) {
uint8_t count = 0;
while (cluster) {
count++;
cluster = esp_matter::cluster::get_next(cluster);
}
return count;
}
}
return 0;
}
// TODO: Remove the emberAfGetClustersFromEndpoint function when scenes cluster is decoupled from ember
uint8_t emberAfGetClustersFromEndpoint(chip::EndpointId endpoint, chip::ClusterId *clusterList, uint8_t listLen,
bool server)
{
esp_matter::endpoint_t *ep = esp_matter::endpoint::get(endpoint);
if (ep) {
esp_matter::cluster_t *cluster = esp_matter::cluster::get_first(ep);
if (cluster) {
uint8_t count = 0;
while (cluster) {
if ((server && (esp_matter::cluster::get_flags(cluster) & esp_matter::CLUSTER_FLAG_SERVER)) ||
(!server && (esp_matter::cluster::get_flags(cluster) & esp_matter::CLUSTER_FLAG_CLIENT))) {
clusterList[count++] = esp_matter::cluster::get_id(cluster);
if (count >= listLen) {
break;
}
}
cluster = esp_matter::cluster::get_next(cluster);
}
return count;
}
}
return 0;
}
// TODO: Remove the emberAfGetClusterServerEndpointIndex function when laundry-dryer-controls, keypad-input,
// door-lock, level-control, target-navigator, fan-control, occupancy-sensor, valve-configuration-and-control,
// media-playback, content-launch, audio-output, power-source, application-basic, low-power, diagnostic-logs,
// scenes, color-control, channel, laundry-washer-controls, wake-on-lan, window-covering, content-control,
// dishwasher-alarm, on-off, media-input, application-launcher, account-login, thermostat, electrical-energy-measurement,
// color-control, channel, laundry-washer-controls, wake-on-lan, window-covering, content-control, dishwasher-alarm,
// on-off, media-input, application-launcher, account-login, thermostat, electrical-energy-measurement,
// content-app-observer, and boolean-state-configuration clusters are decoupled from ember.
uint16_t emberAfGetClusterServerEndpointIndex(chip::EndpointId endpoint, chip::ClusterId clusterId,
uint16_t fixedClusterServerEndpointCount)
+9 -4
View File
@@ -28,6 +28,7 @@
#include <core/Optional.h>
#include <core/TLVReader.h>
#include <core/TLVWriter.h>
#include "support/CodeUtils.h"
#ifdef CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER
#include <app/clusters/bindings/BindingManager.h>
#endif
@@ -186,7 +187,9 @@ static void __binding_manager_init(intptr_t arg)
.mStorage = &server.GetPersistentStorage(),
};
chip::app::Clusters::Binding::Manager::GetInstance().Init(binding_init_params);
if (chip::app::Clusters::Binding::Manager::GetInstance().Init(binding_init_params) != CHIP_NO_ERROR) {
ESP_LOGE(TAG, "Failed to initialize Binding Manager");
}
chip::app::Clusters::Binding::Manager::GetInstance().RegisterBoundDeviceChangedHandler(esp_matter_command_client_binding_callback);
chip::app::Clusters::Binding::Manager::GetInstance().RegisterBoundDeviceContextReleaseHandler(esp_matter_binding_context_release);
}
@@ -195,7 +198,9 @@ void binding_manager_init()
{
#ifdef CONFIG_ESP_MATTER_ENABLE_DATA_MODEL
if (endpoint::get_cluster_count(chip::kInvalidEndpointId, Binding::Id, CLUSTER_FLAG_SERVER) > 0) {
chip::DeviceLayer::PlatformMgr().ScheduleWork(__binding_manager_init);
if (chip::DeviceLayer::PlatformMgr().ScheduleWork(__binding_manager_init) != CHIP_NO_ERROR) {
ESP_LOGE(TAG, "Failed to schedule work to initialize Binding Manager");
}
}
#endif // CONFIG_ESP_MATTER_ENABLE_DATA_MODEL
}
@@ -248,7 +253,7 @@ esp_err_t send_request(void *ctx, peer_device_t *remote_device, const CommandPat
timed_invoke_timeout_ms.HasValue());
VerifyOrReturnError(command_sender != nullptr, ESP_ERR_NO_MEM, ESP_LOGE(TAG, "No memory for command sender"));
chip::app::CommandSender::AddRequestDataParameters add_request_data_params(timed_invoke_timeout_ms);
command_sender->AddRequestData(command_path, encodable, add_request_data_params);
VerifyOrReturnError(command_sender->AddRequestData(command_path, encodable, add_request_data_params) == CHIP_NO_ERROR, ESP_FAIL, ESP_LOGE(TAG, "Failed to add request data"));;
VerifyOrReturnError(command_sender->SendCommandRequest(remote_device->GetSecureSession().Value(), response_timeout) == CHIP_NO_ERROR, ESP_FAIL, ESP_LOGE(TAG, "Failed to send command request"));
(void)decoder.release();
(void)command_sender.release();
@@ -265,7 +270,7 @@ esp_err_t send_group_request(const uint8_t fabric_index, const CommandPathParams
auto command_sender = chip::Platform::MakeUnique<chip::app::CommandSender>(nullptr, exchange_mgr);
VerifyOrReturnError(command_sender != nullptr, ESP_ERR_NO_MEM, ESP_LOGE(TAG, "No memory for command sender"));
chip::app::CommandSender::AddRequestDataParameters add_request_data_params;
command_sender->AddRequestData(command_path, encodeable, add_request_data_params);
VerifyOrReturnError(command_sender->AddRequestData(command_path, encodeable, add_request_data_params) == CHIP_NO_ERROR, ESP_FAIL, ESP_LOGE(TAG, "Failed to add request data"));
VerifyOrReturnError(command_sender->SendGroupCommandRequest(SessionHandle(session)) == CHIP_NO_ERROR, ESP_FAIL, ESP_LOGE(TAG, "Failed to send command request"));
return ESP_OK;
}
+35 -8
View File
@@ -185,7 +185,10 @@ static void esp_matter_chip_init_task(intptr_t context)
chip::CommonCaseDeviceServerInitParams &initParams =
s_server_init_params ? *s_server_init_params : defaultInitParams;
initParams.InitializeStaticResourcesBeforeServerInit();
if (initParams.InitializeStaticResourcesBeforeServerInit() != CHIP_NO_ERROR) {
ESP_LOGE(TAG, "Failed to initialize static resources before server initialization");
return;
}
if (!initParams.appDelegate) {
initParams.appDelegate = &s_app_delegate;
}
@@ -209,7 +212,9 @@ static void esp_matter_chip_init_task(intptr_t context)
CHIP_CONFIG_MAX_GROUP_KEYS_PER_FABRIC);
groupDataProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
groupDataProvider.SetSessionKeystore(initParams.sessionKeystore);
groupDataProvider.Init();
if (groupDataProvider.Init() != CHIP_NO_ERROR) {
ESP_LOGE(TAG, "Failed to initialize group data provider");
}
initParams.groupDataProvider = &groupDataProvider;
}
#endif // CONFIG_ESP_MATTER_ENABLE_DATA_MODEL
@@ -219,7 +224,10 @@ static void esp_matter_chip_init_task(intptr_t context)
{
ESP_LOGE(TAG, "Failed to add fabric delegate, err:%" CHIP_ERROR_FORMAT, ret.Format());
}
chip::Server::GetInstance().Init(initParams);
ret = chip::Server::GetInstance().Init(initParams);
if (ret != CHIP_NO_ERROR) {
ESP_LOGE(TAG, "Failed to init server instance, err:%" CHIP_ERROR_FORMAT, ret.Format());
}
#ifdef CONFIG_ESP_MATTER_ENABLE_DATA_MODEL
if (endpoint::enable_all() != ESP_OK) {
@@ -239,7 +247,9 @@ static void esp_matter_chip_init_task(intptr_t context)
chip::Server::GetInstance().GetICDManager().Shutdown();
}
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
PlatformMgr().ScheduleWork(deinit_ble_if_commissioned, reinterpret_cast<intptr_t>(nullptr));
if (PlatformMgr().ScheduleWork(deinit_ble_if_commissioned, reinterpret_cast<intptr_t>(nullptr)) != CHIP_NO_ERROR) {
ESP_LOGE(TAG, "Schedule ble deinitialization fails");
}
xTaskNotifyGive(task_to_notify);
}
#endif // CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER
@@ -265,7 +275,9 @@ static void device_callback_internal(const ChipDeviceEvent * event, intptr_t arg
case chip::DeviceLayer::DeviceEventType::kCommissioningComplete:
ESP_LOGI(TAG, "Commissioning Complete");
PlatformMgr().ScheduleWork(deinit_ble_if_commissioned, reinterpret_cast<intptr_t>(nullptr));
if (PlatformMgr().ScheduleWork(deinit_ble_if_commissioned, reinterpret_cast<intptr_t>(nullptr)) != CHIP_NO_ERROR) {
ESP_LOGE(TAG, "Schedule ble deinitialization fails");
}
break;
case chip::DeviceLayer::DeviceEventType::kCHIPoBLEConnectionClosed:
@@ -318,13 +330,28 @@ static esp_err_t chip_init(event_callback_t callback, intptr_t callback_arg)
ESP_LOGE(TAG, "Failed to launch Matter main task");
return ESP_FAIL;
}
PlatformMgr().AddEventHandler(device_callback_internal, static_cast<intptr_t>(NULL));
if (PlatformMgr().AddEventHandler(device_callback_internal, static_cast<intptr_t>(NULL)) != CHIP_NO_ERROR) {
(void)PlatformMgr().StopEventLoopTask();
chip::Platform::MemoryShutdown();
ESP_LOGE(TAG, "Failed to add internal device callback");
return ESP_FAIL;
}
if(callback) {
PlatformMgr().AddEventHandler(callback, callback_arg);
if (PlatformMgr().AddEventHandler(callback, callback_arg) != CHIP_NO_ERROR) {
(void)PlatformMgr().StopEventLoopTask();
chip::Platform::MemoryShutdown();
ESP_LOGE(TAG, "Failed to add user callback");
return ESP_FAIL;
}
}
init_thread_stack_and_start_thread_task();
#if CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER
PlatformMgr().ScheduleWork(esp_matter_chip_init_task, reinterpret_cast<intptr_t>(xTaskGetCurrentTaskHandle()));
if (PlatformMgr().ScheduleWork(esp_matter_chip_init_task, reinterpret_cast<intptr_t>(xTaskGetCurrentTaskHandle())) != CHIP_NO_ERROR) {
(void)PlatformMgr().StopEventLoopTask();
chip::Platform::MemoryShutdown();
ESP_LOGE(TAG, "Failed to schedule chip init task");
return ESP_FAIL;
}
// Wait for the matter stack to be initialized
xTaskNotifyWait(0, 0, NULL, portMAX_DELAY);
#endif // CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER
@@ -28,7 +28,7 @@ using namespace chip::System::Clock;
static constexpr char *TAG = "icd";
namespace chip {
namespace Test {
namespace Testing {
class ICDConfigurationDataTestAccess {
// This class is a friend class for ICDConfigurationData, so it can access private members of ICDConfigurationData.
public:
@@ -39,7 +39,7 @@ public:
static void SetSlowPollingInterval(Milliseconds32 pollInterval)
{
ICDConfigurationData::GetInstance().SetSlowPollingInterval(pollInterval);
(void)ICDConfigurationData::GetInstance().SetSlowPollingInterval(pollInterval);
if (pollInterval >= Milliseconds32(15000)) {
// Active Threshold SHALL NOT be smaller than 5 seconds for LIT ICD.
ICDConfigurationData::GetInstance().SetICDMode(ICDConfigurationData::ICDMode::LIT);
@@ -84,10 +84,10 @@ static esp_err_t set_polling_intervals(std::optional<uint32_t> fast_interval_ms,
return ESP_ERR_INVALID_ARG;
}
#endif
chip::Test::ICDConfigurationDataTestAccess::SetSlowPollingInterval(Milliseconds32(slow_interval_ms.value()));
chip::Testing::ICDConfigurationDataTestAccess::SetSlowPollingInterval(Milliseconds32(slow_interval_ms.value()));
}
if (fast_interval_ms.has_value()) {
chip::Test::ICDConfigurationDataTestAccess::SetFastPollingInterval(Milliseconds32(fast_interval_ms.value()));
chip::Testing::ICDConfigurationDataTestAccess::SetFastPollingInterval(Milliseconds32(fast_interval_ms.value()));
}
return ESP_OK;
}
@@ -101,13 +101,13 @@ static esp_err_t set_mode_durations(std::optional<uint32_t> active_mode_duration
Seconds32 idle_mode_duration = idle_mode_duration_s.has_value()
? Seconds32(idle_mode_duration_s.value())
: chip::ICDConfigurationData::GetInstance().GetIdleModeDuration();
return chip::Test::ICDConfigurationDataTestAccess::SetModeDurations(chip::MakeOptional(active_mode_duration),
return chip::Testing::ICDConfigurationDataTestAccess::SetModeDurations(chip::MakeOptional(active_mode_duration),
chip::MakeOptional(idle_mode_duration));
}
static esp_err_t set_active_threshold(uint32_t active_threshold_ms)
{
return chip::Test::ICDConfigurationDataTestAccess::SetActiveThreshold(Milliseconds32(active_threshold_ms));
return chip::Testing::ICDConfigurationDataTestAccess::SetActiveThreshold(Milliseconds32(active_threshold_ms));
}
static bool s_enable_icd_server = CHIP_CONFIG_ENABLE_ICD_SERVER;
+4 -1
View File
@@ -97,7 +97,10 @@ void esp_matter_ota_requestor_start(void)
chip::SetRequestorInstance(&gRequestorCore);
gRequestorStorage.Init(Server::GetInstance().GetPersistentStorage());
gRequestorCore.Init(Server::GetInstance(), gRequestorStorage, *s_ota_requestor_impl.driver, gDownloader);
if (gRequestorCore.Init(Server::GetInstance(), gRequestorStorage, *s_ota_requestor_impl.driver, gDownloader) != CHIP_NO_ERROR) {
ESP_LOGE("OTARequestor", "Failed to init OTARequestor core");
return;
}
gImageProcessor.SetOTADownloader(&gDownloader);
+4 -2
View File
@@ -21,6 +21,7 @@
#include <lib/support/SafeInt.h>
#include <stdlib.h>
#include "support/CodeUtils.h"
using namespace chip;
using chip::TLV::TLVElementType;
@@ -394,7 +395,7 @@ static esp_err_t encode_tlv_element(const cJSON *val, TLV::TLVWriter &writer, co
for (size_t i = 0; i < array_size; ++i) {
if ((err = encode_tlv_element(cJSON_GetArrayItem(val, i), writer, nested_element_ctx)) != ESP_OK) {
ESP_LOGE(TAG, "Failed to encode");
writer.EndContainer(container_type);
ReturnValueOnFailure(writer.EndContainer(container_type), ESP_FAIL);
return err;
}
}
@@ -423,7 +424,8 @@ static esp_err_t encode_tlv_element(const cJSON *val, TLV::TLVWriter &writer, co
if ((err = encode_tlv_element(cJSON_GetObjectItem(val, element_array[element_idx].json_name), writer,
element_array[element_idx])) != ESP_OK) {
ESP_LOGE(TAG, "Failed to encode");
writer.EndContainer(container_type);
// Ignore the return value of EndContainer()
(void)writer.EndContainer(container_type);
return err;
}
}
@@ -1,429 +1,434 @@
#pragma once
#include <lib/core/DataModelTypes.h>
#include <app/server-cluster/ServerClusterInterface.h>
using chip::EndpointId;
using chip::app::ClusterShutdownType;
void ESPMatterAccessControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterAccessControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterAccessControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterAccountLoginClusterServerInitCallback(EndpointId endpoint);
void ESPMatterAccountLoginClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterAccountLoginClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterActionsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterActionsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterActionsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterActivatedCarbonFilterMonitoringClusterServerInitCallback(EndpointId endpoint);
void ESPMatterActivatedCarbonFilterMonitoringClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterActivatedCarbonFilterMonitoringClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterAdministratorCommissioningClusterServerInitCallback(EndpointId endpoint);
void ESPMatterAdministratorCommissioningClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterAdministratorCommissioningClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterAirQualityClusterServerInitCallback(EndpointId endpoint);
void ESPMatterAirQualityClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterAirQualityClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterAmbientContextSensingClusterServerInitCallback(EndpointId endpoint);
void ESPMatterAmbientContextSensingClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterApplicationBasicClusterServerInitCallback(EndpointId endpoint);
void ESPMatterApplicationBasicClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterApplicationBasicClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterApplicationLauncherClusterServerInitCallback(EndpointId endpoint);
void ESPMatterApplicationLauncherClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterApplicationLauncherClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterAudioOutputClusterServerInitCallback(EndpointId endpoint);
void ESPMatterAudioOutputClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterAudioOutputClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterBallastConfigurationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterBallastConfigurationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterBallastConfigurationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterBasicInformationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterBasicInformationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterBasicInformationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterBindingClusterServerInitCallback(EndpointId endpoint);
void ESPMatterBindingClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterBindingClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterBooleanStateClusterServerInitCallback(EndpointId endpoint);
void ESPMatterBooleanStateClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterBooleanStateClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterBooleanStateConfigurationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterBooleanStateConfigurationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterBooleanStateConfigurationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterBridgedDeviceBasicInformationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterBridgedDeviceBasicInformationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterBridgedDeviceBasicInformationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterCameraAvSettingsUserLevelManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterCameraAvSettingsUserLevelManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterCameraAvSettingsUserLevelManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterCameraAvStreamManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterCameraAvStreamManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterCameraAvStreamManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterCarbonDioxideConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterCarbonDioxideConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterCarbonDioxideConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterCarbonMonoxideConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterCarbonMonoxideConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterCarbonMonoxideConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterChannelClusterServerInitCallback(EndpointId endpoint);
void ESPMatterChannelClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterChannelClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterChimeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterChimeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterChimeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterClosureControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterClosureControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterClosureControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterClosureDimensionClusterServerInitCallback(EndpointId endpoint);
void ESPMatterClosureDimensionClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterClosureDimensionClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterColorControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterColorControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterColorControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterCommissionerControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterCommissionerControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterCommissionerControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterCommodityMeteringClusterServerInitCallback(EndpointId endpoint);
void ESPMatterCommodityMeteringClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterCommodityMeteringClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterCommodityPriceClusterServerInitCallback(EndpointId endpoint);
void ESPMatterCommodityPriceClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterCommodityPriceClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterCommodityTariffClusterServerInitCallback(EndpointId endpoint);
void ESPMatterCommodityTariffClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterCommodityTariffClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterContentAppObserverClusterServerInitCallback(EndpointId endpoint);
void ESPMatterContentAppObserverClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterContentAppObserverClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterContentControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterContentControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterContentControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterContentLauncherClusterServerInitCallback(EndpointId endpoint);
void ESPMatterContentLauncherClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterContentLauncherClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterDescriptorClusterServerInitCallback(EndpointId endpoint);
void ESPMatterDescriptorClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterDescriptorClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterDeviceEnergyManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterDeviceEnergyManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterDeviceEnergyManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterDeviceEnergyManagementModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterDeviceEnergyManagementModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterDeviceEnergyManagementModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterDiagnosticLogsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterDiagnosticLogsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterDiagnosticLogsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterDishwasherAlarmClusterServerInitCallback(EndpointId endpoint);
void ESPMatterDishwasherAlarmClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterDishwasherAlarmClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterDishwasherModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterDishwasherModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterDishwasherModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterDoorLockClusterServerInitCallback(EndpointId endpoint);
void ESPMatterDoorLockClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterDoorLockClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterEcosystemInformationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterEcosystemInformationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterEcosystemInformationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterElectricalEnergyMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterElectricalEnergyMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterElectricalEnergyMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterElectricalGridConditionsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterElectricalGridConditionsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterElectricalGridConditionsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterElectricalPowerMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterElectricalPowerMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterElectricalPowerMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterEnergyEvseClusterServerInitCallback(EndpointId endpoint);
void ESPMatterEnergyEvseClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterEnergyEvseClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterEnergyEvseModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterEnergyEvseModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterEnergyEvseModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterEnergyPreferenceClusterServerInitCallback(EndpointId endpoint);
void ESPMatterEnergyPreferenceClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterEnergyPreferenceClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterEthernetNetworkDiagnosticsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterEthernetNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterEthernetNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterFanControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterFanControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterFanControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterFaultInjectionClusterServerInitCallback(EndpointId endpoint);
void ESPMatterFaultInjectionClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterFaultInjectionClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterFixedLabelClusterServerInitCallback(EndpointId endpoint);
void ESPMatterFixedLabelClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterFixedLabelClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterFlowMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterFlowMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterFlowMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterFormaldehydeConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterFormaldehydeConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterFormaldehydeConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterGeneralCommissioningClusterServerInitCallback(EndpointId endpoint);
void ESPMatterGeneralCommissioningClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterGeneralCommissioningClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterGeneralDiagnosticsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterGeneralDiagnosticsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterGeneralDiagnosticsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterGroupKeyManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterGroupKeyManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterGroupKeyManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterGroupcastClusterServerInitCallback(EndpointId endpoint);
void ESPMatterGroupcastClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterGroupcastClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterGroupsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterGroupsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterGroupsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterHepaFilterMonitoringClusterServerInitCallback(EndpointId endpoint);
void ESPMatterHepaFilterMonitoringClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterHepaFilterMonitoringClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterIcdManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterIcdManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterIcdManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterIdentifyClusterServerInitCallback(EndpointId endpoint);
void ESPMatterIdentifyClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterIdentifyClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterIlluminanceMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterIlluminanceMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterIlluminanceMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterJointFabricAdministratorClusterServerInitCallback(EndpointId endpoint);
void ESPMatterJointFabricAdministratorClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterJointFabricAdministratorClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterJointFabricDatastoreClusterServerInitCallback(EndpointId endpoint);
void ESPMatterJointFabricDatastoreClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterJointFabricDatastoreClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterKeypadInputClusterServerInitCallback(EndpointId endpoint);
void ESPMatterKeypadInputClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterKeypadInputClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterLaundryDryerControlsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterLaundryDryerControlsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterLaundryDryerControlsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterLaundryWasherControlsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterLaundryWasherControlsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterLaundryWasherControlsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterLaundryWasherModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterLaundryWasherModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterLaundryWasherModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterLevelControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterLevelControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterLevelControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterLocalizationConfigurationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterLocalizationConfigurationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterLocalizationConfigurationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterLowPowerClusterServerInitCallback(EndpointId endpoint);
void ESPMatterLowPowerClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterLowPowerClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterMediaInputClusterServerInitCallback(EndpointId endpoint);
void ESPMatterMediaInputClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterMediaInputClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterMediaPlaybackClusterServerInitCallback(EndpointId endpoint);
void ESPMatterMediaPlaybackClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterMediaPlaybackClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterMessagesClusterServerInitCallback(EndpointId endpoint);
void ESPMatterMessagesClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterMessagesClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterMeterIdentificationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterMeterIdentificationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterMeterIdentificationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterMicrowaveOvenControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterMicrowaveOvenControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterMicrowaveOvenControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterMicrowaveOvenModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterMicrowaveOvenModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterMicrowaveOvenModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterModeSelectClusterServerInitCallback(EndpointId endpoint);
void ESPMatterModeSelectClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterModeSelectClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterNetworkCommissioningClusterServerInitCallback(EndpointId endpoint);
void ESPMatterNetworkCommissioningClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterNetworkCommissioningClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterNitrogenDioxideConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterNitrogenDioxideConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterNitrogenDioxideConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterOccupancySensingClusterServerInitCallback(EndpointId endpoint);
void ESPMatterOccupancySensingClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterOccupancySensingClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterOnOffClusterServerInitCallback(EndpointId endpoint);
void ESPMatterOnOffClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterOnOffClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterOperationalCredentialsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterOperationalCredentialsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterOperationalCredentialsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterOperationalStateClusterServerInitCallback(EndpointId endpoint);
void ESPMatterOperationalStateClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterOperationalStateClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterOtaSoftwareUpdateProviderClusterServerInitCallback(EndpointId endpoint);
void ESPMatterOtaSoftwareUpdateProviderClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterOtaSoftwareUpdateProviderClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterOtaSoftwareUpdateRequestorClusterServerInitCallback(EndpointId endpoint);
void ESPMatterOtaSoftwareUpdateRequestorClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterOtaSoftwareUpdateRequestorClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterOvenCavityOperationalStateClusterServerInitCallback(EndpointId endpoint);
void ESPMatterOvenCavityOperationalStateClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterOvenCavityOperationalStateClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterOvenModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterOvenModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterOvenModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterOzoneConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterOzoneConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterOzoneConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPm10ConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPm10ConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPm10ConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPm1ConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPm1ConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPm1ConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPm25ConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPm25ConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPm25ConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPowerSourceClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPowerSourceClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPowerSourceClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPowerSourceConfigurationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPowerSourceConfigurationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPowerSourceConfigurationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPowerTopologyClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPowerTopologyClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPowerTopologyClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPressureMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPressureMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPressureMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterProxyConfigurationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterProxyConfigurationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterProxyConfigurationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterProxyDiscoveryClusterServerInitCallback(EndpointId endpoint);
void ESPMatterProxyDiscoveryClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterProxyDiscoveryClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterProxyValidClusterServerInitCallback(EndpointId endpoint);
void ESPMatterProxyValidClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterProxyValidClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPulseWidthModulationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPulseWidthModulationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPulseWidthModulationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPumpConfigurationAndControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPumpConfigurationAndControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPumpConfigurationAndControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterPushAvStreamTransportClusterServerInitCallback(EndpointId endpoint);
void ESPMatterPushAvStreamTransportClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterPushAvStreamTransportClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterRadonConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterRadonConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterRadonConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterRefrigeratorAlarmClusterServerInitCallback(EndpointId endpoint);
void ESPMatterRefrigeratorAlarmClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterRefrigeratorAlarmClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterRefrigeratorAndTemperatureControlledCabinetModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterRefrigeratorAndTemperatureControlledCabinetModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterRefrigeratorAndTemperatureControlledCabinetModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterRelativeHumidityMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterRelativeHumidityMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterRelativeHumidityMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterRvcCleanModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterRvcCleanModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterRvcCleanModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterRvcOperationalStateClusterServerInitCallback(EndpointId endpoint);
void ESPMatterRvcOperationalStateClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterRvcOperationalStateClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterRvcRunModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterRvcRunModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterRvcRunModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterSampleMeiClusterServerInitCallback(EndpointId endpoint);
void ESPMatterSampleMeiClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterSampleMeiClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterScenesManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterScenesManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterScenesManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterServiceAreaClusterServerInitCallback(EndpointId endpoint);
void ESPMatterServiceAreaClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterServiceAreaClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterSmokeCoAlarmClusterServerInitCallback(EndpointId endpoint);
void ESPMatterSmokeCoAlarmClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterSmokeCoAlarmClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterSoftwareDiagnosticsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterSoftwareDiagnosticsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterSoftwareDiagnosticsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterSoilMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterSoilMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterSoilMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterSwitchClusterServerInitCallback(EndpointId endpoint);
void ESPMatterSwitchClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterSwitchClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterTargetNavigatorClusterServerInitCallback(EndpointId endpoint);
void ESPMatterTargetNavigatorClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterTargetNavigatorClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterTemperatureControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterTemperatureControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterTemperatureControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterTemperatureMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterTemperatureMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterTemperatureMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterThermostatClusterServerInitCallback(EndpointId endpoint);
void ESPMatterThermostatClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterThermostatClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterThermostatUserInterfaceConfigurationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterThermostatUserInterfaceConfigurationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterThermostatUserInterfaceConfigurationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterThreadBorderRouterManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterThreadBorderRouterManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterThreadBorderRouterManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterThreadNetworkDiagnosticsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterThreadNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterThreadNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterThreadNetworkDirectoryClusterServerInitCallback(EndpointId endpoint);
void ESPMatterThreadNetworkDirectoryClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterThreadNetworkDirectoryClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterTimeFormatLocalizationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterTimeFormatLocalizationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterTimeFormatLocalizationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterTimeSynchronizationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterTimeSynchronizationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterTimeSynchronizationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterTlsCertificateManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterTlsCertificateManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterTlsCertificateManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterTlsClientManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterTlsClientManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterTlsClientManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterTotalVolatileOrganicCompoundsConcentrationMeasurementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterTotalVolatileOrganicCompoundsConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterTotalVolatileOrganicCompoundsConcentrationMeasurementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterUnitLocalizationClusterServerInitCallback(EndpointId endpoint);
void ESPMatterUnitLocalizationClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterUnitLocalizationClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterUnitTestingClusterServerInitCallback(EndpointId endpoint);
void ESPMatterUnitTestingClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterUnitTestingClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterUserLabelClusterServerInitCallback(EndpointId endpoint);
void ESPMatterUserLabelClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterUserLabelClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterValveConfigurationAndControlClusterServerInitCallback(EndpointId endpoint);
void ESPMatterValveConfigurationAndControlClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterValveConfigurationAndControlClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterWakeOnLanClusterServerInitCallback(EndpointId endpoint);
void ESPMatterWakeOnLanClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterWakeOnLanClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterWaterHeaterManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterWaterHeaterManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterWaterHeaterManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterWaterHeaterModeClusterServerInitCallback(EndpointId endpoint);
void ESPMatterWaterHeaterModeClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterWaterHeaterModeClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterWaterTankLevelMonitoringClusterServerInitCallback(EndpointId endpoint);
void ESPMatterWaterTankLevelMonitoringClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterWaterTankLevelMonitoringClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterWebRTCTransportProviderClusterServerInitCallback(EndpointId endpoint);
void ESPMatterWebRTCTransportProviderClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterWebRTCTransportProviderClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterWebRTCTransportRequestorClusterServerInitCallback(EndpointId endpoint);
void ESPMatterWebRTCTransportRequestorClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterWebRTCTransportRequestorClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterWiFiNetworkDiagnosticsClusterServerInitCallback(EndpointId endpoint);
void ESPMatterWiFiNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterWiFiNetworkDiagnosticsClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterWiFiNetworkManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterWiFiNetworkManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterWiFiNetworkManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterWindowCoveringClusterServerInitCallback(EndpointId endpoint);
void ESPMatterWindowCoveringClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterWindowCoveringClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
void ESPMatterZoneManagementClusterServerInitCallback(EndpointId endpoint);
void ESPMatterZoneManagementClusterServerShutdownCallback(EndpointId endpoint);
void ESPMatterZoneManagementClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);
@@ -5,6 +5,7 @@ void MatterActionsPluginServerInitCallback();
void MatterActivatedCarbonFilterMonitoringPluginServerInitCallback();
void MatterAdministratorCommissioningPluginServerInitCallback();
void MatterAirQualityPluginServerInitCallback();
void MatterAmbientContextSensingPluginServerInitCallback();
void MatterApplicationBasicPluginServerInitCallback();
void MatterApplicationLauncherPluginServerInitCallback();
void MatterAudioOutputPluginServerInitCallback();
@@ -113,17 +113,20 @@ def generate_plugin_application_callbacks_h(xml_files, output_dir):
header_file.write('void Matter{}PluginServerInitCallback();\n'.format(
format_cluster_name(get_cluster_name(cluster))))
def generate_cluster_callbacks_h(xml_files, output_dir):
with open(os.path.join(output_dir, 'app/ClusterCallbacks.h'), 'w') as header_file:
header_file.write('#pragma once\n\n')
header_file.write('#include <lib/core/DataModelTypes.h>\n\n')
header_file.write('using chip::EndpointId;\n\n')
header_file.write('#include <lib/core/DataModelTypes.h>\n')
header_file.write('#include <app/server-cluster/ServerClusterInterface.h>\n\n')
header_file.write('using chip::EndpointId;\n')
header_file.write('using chip::app::ClusterShutdownType;\n\n')
clusters = get_clusters_from_xml_files(xml_files)
clusters.sort(key=get_formatted_cluster_name)
for cluster in clusters:
header_file.write('void ESPMatter{}ClusterServerInitCallback(EndpointId endpoint);\n'.format(
format_cluster_name(get_cluster_name(cluster))))
header_file.write('void ESPMatter{}ClusterServerShutdownCallback(EndpointId endpoint);\n\n'.format(
header_file.write('void ESPMatter{}ClusterServerShutdownCallback(EndpointId endpoint, ClusterShutdownType shutdownType);\n\n'.format(
format_cluster_name(get_cluster_name(cluster))))
@@ -320,6 +320,7 @@
0x00000406, /* Cluster: Occupancy Sensing, Attribute: PhysicalContactOccupiedToUnoccupiedDelay, Privilege: manage */ \
0x00000406, /* Cluster: Occupancy Sensing, Attribute: PhysicalContactUnoccupiedToOccupiedDelay, Privilege: manage */ \
0x00000406, /* Cluster: Occupancy Sensing, Attribute: PhysicalContactUnoccupiedToOccupiedThreshold, Privilege: manage */ \
0x00000431, /* Cluster: Ambient Context Sensing, Attribute: HoldTime, Privilege: manage */ \
0x00000453, /* Cluster: Thread Network Directory, Attribute: PreferredExtendedPanID, Privilege: manage */ \
0x00000551, /* Cluster: Camera AV Stream Management, Attribute: HDRModeEnabled, Privilege: manage */ \
0x00000551, /* Cluster: Camera AV Stream Management, Attribute: NightVision, Privilege: manage */ \
@@ -435,6 +436,7 @@
0x00000030, /* Cluster: Occupancy Sensing, Attribute: PhysicalContactOccupiedToUnoccupiedDelay, Privilege: manage */ \
0x00000031, /* Cluster: Occupancy Sensing, Attribute: PhysicalContactUnoccupiedToOccupiedDelay, Privilege: manage */ \
0x00000032, /* Cluster: Occupancy Sensing, Attribute: PhysicalContactUnoccupiedToOccupiedThreshold, Privilege: manage */ \
0x00000009, /* Cluster: Ambient Context Sensing, Attribute: HoldTime, Privilege: manage */ \
0x00000000, /* Cluster: Thread Network Directory, Attribute: PreferredExtendedPanID, Privilege: manage */ \
0x0000000D, /* Cluster: Camera AV Stream Management, Attribute: HDRModeEnabled, Privilege: manage */ \
0x00000016, /* Cluster: Camera AV Stream Management, Attribute: NightVision, Privilege: manage */ \
@@ -550,6 +552,7 @@
chip::Access::Privilege::kManage, /* Cluster: Occupancy Sensing, Attribute: PhysicalContactOccupiedToUnoccupiedDelay, Privilege: manage */ \
chip::Access::Privilege::kManage, /* Cluster: Occupancy Sensing, Attribute: PhysicalContactUnoccupiedToOccupiedDelay, Privilege: manage */ \
chip::Access::Privilege::kManage, /* Cluster: Occupancy Sensing, Attribute: PhysicalContactUnoccupiedToOccupiedThreshold, Privilege: manage */ \
chip::Access::Privilege::kManage, /* Cluster: Ambient Context Sensing, Attribute: HoldTime, Privilege: manage */ \
chip::Access::Privilege::kManage, /* Cluster: Thread Network Directory, Attribute: PreferredExtendedPanID, Privilege: manage */ \
chip::Access::Privilege::kManage, /* Cluster: Camera AV Stream Management, Attribute: HDRModeEnabled, Privilege: manage */ \
chip::Access::Privilege::kManage, /* Cluster: Camera AV Stream Management, Attribute: NightVision, Privilege: manage */ \
@@ -5,7 +5,6 @@
#include <esp_log.h>
#include <esp_matter.h>
#include <esp_matter_console.h>
#include <app/util/attribute-storage-null-handling.h>
#define TAG "attribute_console"
@@ -12,7 +12,8 @@
#include <app-common/zap-generated/ids/Clusters.h>
#include <app-common/zap-generated/ids/Events.h>
#include <app/clusters/electrical-energy-measurement-server/ElectricalEnergyMeasurementCluster.h>
#include <app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h>
#include <data_model_provider/clusters/electrical_power_measurement/integration.h>
#include <data_model_provider/clusters/electrical_energy_measurement/integration.h>
#include <app/reporting/reporting.h>
#include <app/data-model/Nullable.h>
#include <system/SystemClock.h>
@@ -31,13 +32,10 @@ using namespace chip::app::Clusters::ElectricalPowerMeasurement::Structs;
static const char *TAG = "electrical_measurement";
// A pointer to store our attribute access object
static std::unique_ptr<ElectricalEnergyMeasurementAttrAccess> gEEMAttrAccess;
// Global pointer to our ElectricalPowerMeasurementDelegate
static std::unique_ptr<ElectricalPowerMeasurementDelegate> gEPMDelegate;
// Global pointer to our ElectricalPowerMeasurementInstance
static std::unique_ptr<ElectricalPowerMeasurementInstance> gEPMInstance;
static std::unique_ptr<ElectricalPowerMeasurement::Instance> gEPMInstance;
CHIP_ERROR PowerTopology::PowerTopologyDelegate::GetAvailableEndpointAtIndex(size_t index, EndpointId & endpointId)
{
@@ -116,21 +114,11 @@ esp_err_t electrical_measurement_example(uint16_t endpoint_id)
ESP_LOGI(TAG, "Initializing Electrical Energy Measurement cluster for endpoint %d", endpoint_id);
// First ensure we don't initialize it twice
if (gEEMAttrAccess) {
if (GetClusterInstance(endpoint_id)) {
ESP_LOGI(TAG, "Electrical Energy Measurement cluster already initialized");
return send_energy_measurement_events(endpoint_id);
}
// Create the attribute access instance with the desired features
gEEMAttrAccess = std::make_unique<ElectricalEnergyMeasurementAttrAccess>(
BitMask<ElectricalEnergyMeasurement::Feature, uint32_t>(
ElectricalEnergyMeasurement::Feature::kImportedEnergy,
ElectricalEnergyMeasurement::Feature::kExportedEnergy,
ElectricalEnergyMeasurement::Feature::kCumulativeEnergy,
ElectricalEnergyMeasurement::Feature::kPeriodicEnergy),
BitMask<ElectricalEnergyMeasurement::OptionalAttributes, uint32_t>(
ElectricalEnergyMeasurement::OptionalAttributes::kOptionalAttributeCumulativeEnergyReset));
// Create accuracy ranges for energy measurements
MeasurementAccuracyRangeStruct::Type energyAccuracyRanges[] = {
{
@@ -159,10 +147,7 @@ esp_err_t electrical_measurement_example(uint16_t endpoint_id)
};
// Initialize and set values if attribute access was created successfully
if (gEEMAttrAccess) {
ESP_LOGI(TAG, "Initializing electrical energy measurement attribute access");
gEEMAttrAccess->Init();
if (GetClusterInstance(endpoint_id)) {
// Set accuracy and reset information
CHIP_ERROR err = SetMeasurementAccuracy(endpoint_id, accuracy);
if (err != CHIP_NO_ERROR) {
@@ -9,7 +9,7 @@
#pragma once
#include <esp_err.h>
#include <app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h>
#include <data_model_provider/clusters/electrical_power_measurement/integration.h>
#include <app/util/af-types.h>
#include <lib/core/CHIPError.h>
File diff suppressed because it is too large Load Diff
+184 -241
View File
@@ -25,38 +25,35 @@
// Camera Constraints set to typical values.
// TODO: Look into ways to fetch from hardware, if required/possible.
static constexpr uint32_t kMaxContentBufferSizeBytes = 4096;
static constexpr uint32_t kMaxNetworkBandwidthbps = 128000000; // 128 Mbps
static constexpr uint8_t kMaxConcurrentEncoders = 1;
static constexpr uint8_t kSpeakerMinLevel = 1;
static constexpr uint8_t kSpeakerMaxLevel = 254; // Spec constraint
static constexpr uint8_t kSpeakerMaxChannelCount = 8; // Same as Microphone
static constexpr uint32_t kMaxEncodedPixelRate =
248832000; // 1080p at 120fps(1920 * 1080 * 120)
static constexpr uint8_t kMicrophoneMinLevel = 1;
static constexpr uint8_t kMicrophoneMaxLevel = 254; // Spec constraint
static constexpr uint8_t kMicrophoneMaxChannelCount =
8; // Spec Constraint in AudioStreamAllocate
static constexpr uint16_t kMinResolutionWidth = 640; // Low SD resolution
static constexpr uint16_t kMinResolutionHeight = 360; // Low SD resolution
static constexpr uint16_t k720pResolutionWidth = 1280; // 720p resolution
static constexpr uint16_t k720pResolutionHeight = 720; // 720p resolution
static constexpr uint16_t kMaxResolutionWidth = 1920; // 1080p resolution
static constexpr uint16_t kMaxResolutionHeight = 1080; // 1080p resolution
static constexpr uint16_t kSnapshotStreamFrameRate = 30;
static constexpr uint16_t kMaxVideoFrameRate = 120;
static constexpr uint16_t k60fpsVideoFrameRate = 60;
static constexpr uint16_t kMinVideoFrameRate = 30;
static constexpr uint32_t kMinBitRateBps = 10000; // 10 kbps
static constexpr uint32_t kMaxBitRateBps = 2000000; // 2 mbps
static constexpr uint32_t kKeyFrameIntervalMsec =
4000; // 4 sec; recommendation from Spec
static constexpr uint16_t kVideoSensorWidthPixels = 1920; // 1080p resolution
static constexpr uint16_t kVideoSensorHeightPixels = 1080; // 1080p resolution
static constexpr uint16_t kMinImageRotation = 0;
static constexpr uint16_t kMaxImageRotation = 359; // Spec constraint
static constexpr uint8_t kMaxZones = 10; // Spec has min 1
static constexpr uint8_t kMaxUserDefinedZones = 10; // Spec has min 5
static constexpr uint8_t kSensitivityMax = 10; // Spec has 2 to 10
static constexpr uint32_t kMaxNetworkBandwidthbps = 128000000; // 128 Mbps
static constexpr uint8_t kMaxConcurrentEncoders = 2;
static constexpr uint8_t kSpeakerMinLevel = 1;
static constexpr uint8_t kSpeakerMaxLevel = 254; // Spec constraint
static constexpr uint8_t kSpeakerMaxChannelCount = 8; // Same as Microphone
static constexpr uint32_t kMaxEncodedPixelRate = 373248000; // 1080p at 60fps + 120fps(1920 * 1080 * 180)
static constexpr uint8_t kMicrophoneMinLevel = 1;
static constexpr uint8_t kMicrophoneMaxLevel = 254; // Spec constraint
static constexpr uint8_t kMicrophoneMaxChannelCount = 8; // Spec Constraint in AudioStreamAllocate
static constexpr uint16_t kMinResolutionWidth = 640; // Low SD resolution
static constexpr uint16_t kMinResolutionHeight = 360; // Low SD resolution
static constexpr uint16_t k720pResolutionWidth = 1280; // 720p resolution
static constexpr uint16_t k720pResolutionHeight = 720; // 720p resolution
static constexpr uint16_t kMaxResolutionWidth = 1920; // 1080p resolution
static constexpr uint16_t kMaxResolutionHeight = 1080; // 1080p resolution
static constexpr uint16_t kSnapshotStreamFrameRate = 30;
static constexpr uint16_t kMaxVideoFrameRate = 120;
static constexpr uint16_t k60fpsVideoFrameRate = 60;
static constexpr uint16_t kMinVideoFrameRate = 30;
static constexpr uint32_t kMinBitRateBps = 10000; // 10 kbps
static constexpr uint32_t kMaxBitRateBps = 2000000; // 2 mbps
static constexpr uint32_t kKeyFrameIntervalMsec = 4000; // 4 sec; recommendation from Spec
static constexpr uint16_t kVideoSensorWidthPixels = 1920; // 1080p resolution
static constexpr uint16_t kVideoSensorHeightPixels = 1080; // 1080p resolution
static constexpr uint16_t kMinImageRotation = 0;
static constexpr uint16_t kMaxImageRotation = 359; // Spec constraint
static constexpr uint8_t kMaxZones = 10; // Spec has min 1
static constexpr uint8_t kMaxUserDefinedZones = 10; // Spec has min 5
static constexpr uint8_t kSensitivityMax = 10; // Spec has 2 to 10
// StreamIDs typically start from 0 and monotonically increase. Setting
// Invalid value to a large and practically unused value.
@@ -65,278 +62,224 @@ static constexpr uint16_t kInvalidStreamID = 65500;
namespace Camera {
class CameraDevice : public CameraDeviceInterface,
public CameraDeviceInterface::CameraHALInterface {
class CameraDevice : public CameraDeviceInterface, public CameraDeviceInterface::CameraHALInterface
{
public:
chip::app::Clusters::WebRTCTransportProvider::Delegate &
GetWebRTCProviderDelegate() override;
chip::app::Clusters::WebRTCTransportProvider::
WebRTCTransportProviderController &
GetWebRTCProviderController() override;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamMgmtDelegate &
GetCameraAVStreamMgmtDelegate() override;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamController &
GetCameraAVStreamMgmtController() override;
CameraDevice();
~CameraDevice();
chip::app::Clusters::WebRTCTransportProvider::Delegate & GetWebRTCProviderDelegate() override;
void
SetWebRTCTransportProvider(chip::app::Clusters::WebRTCTransportProvider::WebRTCTransportProviderCluster * provider) override;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate & GetCameraAVStreamMgmtDelegate() override;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamController & GetCameraAVStreamMgmtController() override;
CameraDevice();
~CameraDevice();
CameraDeviceInterface::CameraHALInterface &GetCameraHALInterface() override {
return *this;
}
CameraDeviceInterface::CameraHALInterface & GetCameraHALInterface() override { return *this; }
void Init();
void Init();
// HAL interface impl
CameraError InitializeCameraDevice() override;
// HAL interface impl
CameraError InitializeCameraDevice() override;
CameraError InitializeStreams() override;
CameraError InitializeStreams() override;
CameraError
CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct &resolution,
ImageSnapshot &outImageSnapshot) override;
CameraError CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID, const VideoResolutionStruct & resolution,
ImageSnapshot & outImageSnapshot) override;
// Allocate snapshot stream
CameraError AllocateSnapshotStream(
const chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamMgmtDelegate::SnapshotStreamAllocateArgs &args,
uint16_t &outStreamID) override;
// Allocate snapshot stream
CameraError AllocateSnapshotStream(
const chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate::SnapshotStreamAllocateArgs & args,
uint16_t & outStreamID) override;
uint8_t GetMaxConcurrentEncoders() override;
uint8_t GetMaxConcurrentEncoders() override;
uint32_t GetMaxEncodedPixelRate() override;
uint32_t GetMaxEncodedPixelRate() override;
VideoSensorParamsStruct &GetVideoSensorParams() override;
VideoSensorParamsStruct & GetVideoSensorParams() override;
bool GetCameraSupportsHDR() override;
bool GetCameraSupportsHDR() override;
bool GetCameraSupportsNightVision() override;
bool GetCameraSupportsNightVision() override;
bool GetNightVisionUsesInfrared() override;
bool GetNightVisionUsesInfrared() override;
bool GetCameraSupportsWatermark() override;
bool GetCameraSupportsWatermark() override;
bool GetCameraSupportsOSD() override;
bool GetCameraSupportsOSD() override;
bool GetCameraSupportsSoftPrivacy() override;
bool GetCameraSupportsSoftPrivacy() override;
bool GetCameraSupportsImageControl() override;
bool GetCameraSupportsImageControl() override;
VideoResolutionStruct &GetMinViewport() override;
VideoResolutionStruct & GetMinViewport() override;
std::vector<RateDistortionTradeOffStruct> &
GetRateDistortionTradeOffPoints() override;
std::vector<RateDistortionTradeOffStruct> & GetRateDistortionTradeOffPoints() override;
uint32_t GetMaxContentBufferSize() override;
uint32_t GetMaxContentBufferSize() override;
AudioCapabilitiesStruct &GetMicrophoneCapabilities() override;
AudioCapabilitiesStruct & GetMicrophoneCapabilities() override;
AudioCapabilitiesStruct &GetSpeakerCapabilities() override;
AudioCapabilitiesStruct & GetSpeakerCapabilities() override;
std::vector<SnapshotCapabilitiesStruct> &GetSnapshotCapabilities() override;
std::vector<SnapshotCapabilitiesStruct> & GetSnapshotCapabilities() override;
uint32_t GetMaxNetworkBandwidth() override;
uint32_t GetMaxNetworkBandwidth() override;
uint16_t GetCurrentFrameRate() override;
uint16_t GetCurrentFrameRate() override;
CameraError SetHDRMode(bool hdrMode) override;
bool GetHDRMode() override { return mHDREnabled; }
CameraError SetHDRMode(bool hdrMode) override;
bool GetHDRMode() override { return mHDREnabled; }
CameraError SetHardPrivacyMode(bool hardPrivacyMode) override;
bool GetHardPrivacyMode() override { return mHardPrivacyModeOn; }
CameraError SetHardPrivacyMode(bool hardPrivacyMode) override;
bool GetHardPrivacyMode() override { return mHardPrivacyModeOn; }
CameraError
SetNightVision(chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum
nightVision) override;
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum
GetNightVision() override {
return mNightVision;
}
CameraError SetNightVision(chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum nightVision) override;
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum GetNightVision() override { return mNightVision; }
std::vector<StreamUsageEnum> &GetSupportedStreamUsages() override;
std::vector<StreamUsageEnum> & GetSupportedStreamUsages() override;
std::vector<StreamUsageEnum> &GetStreamUsagePriorities() override {
return mStreamUsagePriorities;
}
CameraError SetStreamUsagePriorities(
std::vector<StreamUsageEnum> streamUsagePriorities) override;
std::vector<StreamUsageEnum> & GetStreamUsagePriorities() override { return mStreamUsagePriorities; }
CameraError SetStreamUsagePriorities(std::vector<StreamUsageEnum> streamUsagePriorities) override;
// Sets the Default Camera Viewport
CameraError
SetViewport(const chip::app::Clusters::Globals::Structs::ViewportStruct::Type
&viewPort) override;
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type &
GetViewport() override {
return mViewport;
}
// Sets the Default Camera Viewport
CameraError SetViewport(const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & viewPort) override;
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & GetViewport() override { return mViewport; }
/**
* Sets the Viewport for a specific stream. The implementation of this HAL API
* is responsible for updating the stream identified with the provided
* viewport. The invoker of this API shall have already ensured that the
* provided viewport conforms to the specification requirements on size and
* aspect ratio.
*
* @param stream the currently allocated video stream on which the viewport
* is being set
* @param viewport the viewport to be set on the stream
*/
CameraError
SetViewport(VideoStream &stream,
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type
&viewport) override;
/**
* Sets the Viewport for a specific stream. The implementation of this HAL API
* is responsible for updating the stream identified with the provided
* viewport. The invoker of this API shall have already ensured that the
* provided viewport conforms to the specification requirements on size and
* aspect ratio.
*
* @param stream the currently allocated video stream on which the viewport
* is being set
* @param viewport the viewport to be set on the stream
*/
CameraError SetViewport(VideoStream & stream,
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & viewport) override;
// Get/Set SoftRecordingPrivacyMode.
CameraError
SetSoftRecordingPrivacyModeEnabled(bool softRecordingPrivacyMode) override;
bool GetSoftRecordingPrivacyModeEnabled() override {
return mSoftRecordingPrivacyModeEnabled;
}
// Get/Set SoftRecordingPrivacyMode.
CameraError SetSoftRecordingPrivacyModeEnabled(bool softRecordingPrivacyMode) override;
bool GetSoftRecordingPrivacyModeEnabled() override { return mSoftRecordingPrivacyModeEnabled; }
// Get/Set SoftLivestreamPrivacyMode.
CameraError
SetSoftLivestreamPrivacyModeEnabled(bool softLivestreamPrivacyMode) override;
bool GetSoftLivestreamPrivacyModeEnabled() override {
return mSoftLivestreamPrivacyModeEnabled;
}
// Get/Set SoftLivestreamPrivacyMode.
CameraError SetSoftLivestreamPrivacyModeEnabled(bool softLivestreamPrivacyMode) override;
bool GetSoftLivestreamPrivacyModeEnabled() override { return mSoftLivestreamPrivacyModeEnabled; }
// Currently, defaulting to not supporting hard privacy switch.
bool HasHardPrivacySwitch() override { return false; }
// Currently, defaulting to not supporting hard privacy switch.
bool HasHardPrivacySwitch() override { return false; }
// Currently, defaulting to not supporting speaker.
bool HasSpeaker() override { return false; }
// Currently, defaulting to not supporting speaker.
bool HasSpeaker() override { return false; }
// Mute/Unmute speaker.
CameraError SetSpeakerMuted(bool muteSpeaker) override;
bool GetSpeakerMuted() override { return mSpeakerMuted; }
// Mute/Unmute speaker.
CameraError SetSpeakerMuted(bool muteSpeaker) override;
bool GetSpeakerMuted() override { return mSpeakerMuted; }
// Get/Set speaker volume level.
CameraError SetSpeakerVolume(uint8_t speakerVol) override;
uint8_t GetSpeakerVolume() override { return mSpeakerVol; }
// Get/Set speaker volume level.
CameraError SetSpeakerVolume(uint8_t speakerVol) override;
uint8_t GetSpeakerVolume() override { return mSpeakerVol; }
// Get the speaker max and min levels.
uint8_t GetSpeakerMaxLevel() override { return INVALID_SPKR_LEVEL; }
uint8_t GetSpeakerMinLevel() override { return INVALID_SPKR_LEVEL; }
// Get the speaker max and min levels.
uint8_t GetSpeakerMaxLevel() override { return INVALID_SPKR_LEVEL; }
uint8_t GetSpeakerMinLevel() override { return INVALID_SPKR_LEVEL; }
// Does camera have a microphone
bool HasMicrophone() override { return true; }
// Does camera have a microphone
bool HasMicrophone() override { return true; }
// Mute/Unmute microphone.
CameraError SetMicrophoneMuted(bool muteMicrophone) override;
bool GetMicrophoneMuted() override { return mMicrophoneMuted; }
// Mute/Unmute microphone.
CameraError SetMicrophoneMuted(bool muteMicrophone) override;
bool GetMicrophoneMuted() override { return mMicrophoneMuted; }
// Set microphone volume level.
CameraError SetMicrophoneVolume(uint8_t microphoneVol) override;
uint8_t GetMicrophoneVolume() override { return mMicrophoneVol; }
// Set microphone volume level.
CameraError SetMicrophoneVolume(uint8_t microphoneVol) override;
uint8_t GetMicrophoneVolume() override { return mMicrophoneVol; }
// Get the microphone max and min levels.
uint8_t GetMicrophoneMaxLevel() override { return mMicrophoneMaxLevel; }
uint8_t GetMicrophoneMinLevel() override { return mMicrophoneMinLevel; }
// Get the microphone max and min levels.
uint8_t GetMicrophoneMaxLevel() override { return mMicrophoneMaxLevel; }
uint8_t GetMicrophoneMinLevel() override { return mMicrophoneMinLevel; }
// Get/Set image control attributes
CameraError SetImageRotation(uint16_t imageRotation) override;
uint16_t GetImageRotation() override { return mImageRotation; }
// Get/Set image control attributes
CameraError SetImageRotation(uint16_t imageRotation) override;
uint16_t GetImageRotation() override { return mImageRotation; }
CameraError SetImageFlipHorizontal(bool imageFlipHorizontal) override;
bool GetImageFlipHorizontal() override { return mImageFlipHorizontal; }
CameraError SetImageFlipHorizontal(bool imageFlipHorizontal) override;
bool GetImageFlipHorizontal() override { return mImageFlipHorizontal; }
CameraError SetImageFlipVertical(bool imageFlipVertical) override;
bool GetImageFlipVertical() override { return mImageFlipVertical; }
CameraError SetImageFlipVertical(bool imageFlipVertical) override;
bool GetImageFlipVertical() override { return mImageFlipVertical; }
// Does camera have local storage
bool HasLocalStorage() override { return false; }
// Does camera have local storage
bool HasLocalStorage() override { return false; }
// Set/Get LocalVideoRecordingEnabled
CameraError
SetLocalVideoRecordingEnabled(bool localVideoRecordingEnabled) override;
bool GetLocalVideoRecordingEnabled() override {
return mLocalVideoRecordingEnabled;
}
// Set/Get LocalVideoRecordingEnabled
CameraError SetLocalVideoRecordingEnabled(bool localVideoRecordingEnabled) override;
bool GetLocalVideoRecordingEnabled() override { return mLocalVideoRecordingEnabled; }
// Set/Get LocalSnapshotRecordingEnabled
CameraError
SetLocalSnapshotRecordingEnabled(bool localSnapshotRecordingEnabled) override;
bool GetLocalSnapshotRecordingEnabled() override {
return mLocalSnapshotRecordingEnabled;
}
// Set/Get LocalSnapshotRecordingEnabled
CameraError SetLocalSnapshotRecordingEnabled(bool localSnapshotRecordingEnabled) override;
bool GetLocalSnapshotRecordingEnabled() override { return mLocalSnapshotRecordingEnabled; }
// Does camera have a status light
bool HasStatusLight() override { return true; }
// Does camera have a status light
bool HasStatusLight() override { return true; }
// Set/Get StatusLightEnabled
CameraError SetStatusLightEnabled(bool statusLightEnabled) override;
bool GetStatusLightEnabled() override { return mStatusLightEnabled; }
// Set/Get StatusLightEnabled
CameraError SetStatusLightEnabled(bool statusLightEnabled) override;
bool GetStatusLightEnabled() override { return mStatusLightEnabled; }
std::vector<VideoStream> &GetAvailableVideoStreams() override {
return mVideoStreams;
}
std::vector<VideoStream> & GetAvailableVideoStreams() override { return mVideoStreams; }
std::vector<AudioStream> &GetAvailableAudioStreams() override {
return mAudioStreams;
}
std::vector<AudioStream> & GetAvailableAudioStreams() override { return mAudioStreams; }
std::vector<SnapshotStream> &GetAvailableSnapshotStreams() override {
return mSnapshotStreams;
}
std::vector<SnapshotStream> & GetAvailableSnapshotStreams() override { return mSnapshotStreams; }
private:
std::vector<VideoStream>
mVideoStreams; // Vector to hold available video streams
std::vector<AudioStream>
mAudioStreams; // Vector to hold available audio streams
std::vector<SnapshotStream>
mSnapshotStreams; // Vector to hold available snapshot streams
std::vector<VideoStream> mVideoStreams; // Vector to hold available video streams
std::vector<AudioStream> mAudioStreams; // Vector to hold available audio streams
std::vector<SnapshotStream> mSnapshotStreams; // Vector to hold available snapshot streams
void InitializeVideoStreams();
void InitializeAudioStreams();
void InitializeSnapshotStreams();
void InitializeVideoStreams();
void InitializeAudioStreams();
void InitializeSnapshotStreams();
bool AddSnapshotStream(const chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamManager::SnapshotStreamAllocateArgs
&snapshotStreamAllocateArgs,
uint16_t &outStreamID);
bool AddSnapshotStream(const chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManager::SnapshotStreamAllocateArgs &
snapshotStreamAllocateArgs,
uint16_t & outStreamID);
bool MatchClosestSnapshotParams(
const VideoResolutionStruct &requested,
VideoResolutionStruct &outResolution,
chip::app::Clusters::CameraAvStreamManagement::ImageCodecEnum &outCodec);
bool MatchClosestSnapshotParams(const VideoResolutionStruct & requested, VideoResolutionStruct & outResolution,
chip::app::Clusters::CameraAvStreamManagement::ImageCodecEnum & outCodec);
// Various cluster server delegates
chip::app::Clusters::WebRTCTransportProvider::WebRTCProviderManager
mWebRTCProviderManager;
// Various cluster server delegates
chip::app::Clusters::WebRTCTransportProvider::WebRTCProviderManager mWebRTCProviderManager;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManager
mCameraAVStreamManager;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManager mCameraAVStreamManager;
// Use a standard 1080p aspect ratio
chip::app::Clusters::Globals::Structs::ViewportStruct::Type mViewport = {
0, 0, 1920, 1080};
uint16_t mCurrentVideoFrameRate = kMinVideoFrameRate;
bool mHDREnabled = false;
bool mSpeakerMuted = false;
bool mMicrophoneMuted = false;
bool mHardPrivacyModeOn = false;
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum mNightVision =
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum::kOff;
bool mSoftRecordingPrivacyModeEnabled = false;
bool mSoftLivestreamPrivacyModeEnabled = false;
uint8_t mSpeakerVol = kSpeakerMinLevel;
uint8_t mSpeakerMinLevel = kSpeakerMinLevel;
uint8_t mSpeakerMaxLevel = kSpeakerMaxLevel;
uint8_t mMicrophoneVol = kMicrophoneMinLevel;
uint8_t mMicrophoneMinLevel = kMicrophoneMinLevel;
uint8_t mMicrophoneMaxLevel = kMicrophoneMaxLevel;
bool mLocalVideoRecordingEnabled = false;
bool mLocalSnapshotRecordingEnabled = false;
bool mStatusLightEnabled = false;
uint16_t mImageRotation = kMinImageRotation;
bool mImageFlipHorizontal = false;
bool mImageFlipVertical = false;
uint8_t mDetectionSensitivity =
(1 + kSensitivityMax) / 2; // Average over the range
// Use a standard 1080p aspect ratio
chip::app::Clusters::Globals::Structs::ViewportStruct::Type mViewport = { 0, 0, 1920, 1080 };
uint16_t mCurrentVideoFrameRate = kMinVideoFrameRate;
bool mHDREnabled = false;
bool mSpeakerMuted = false;
bool mMicrophoneMuted = false;
bool mHardPrivacyModeOn = false;
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum mNightVision =
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum::kOff;
bool mSoftRecordingPrivacyModeEnabled = false;
bool mSoftLivestreamPrivacyModeEnabled = false;
uint8_t mSpeakerVol = kSpeakerMinLevel;
uint8_t mSpeakerMinLevel = kSpeakerMinLevel;
uint8_t mSpeakerMaxLevel = kSpeakerMaxLevel;
uint8_t mMicrophoneVol = kMicrophoneMinLevel;
uint8_t mMicrophoneMinLevel = kMicrophoneMinLevel;
uint8_t mMicrophoneMaxLevel = kMicrophoneMaxLevel;
bool mLocalVideoRecordingEnabled = false;
bool mLocalSnapshotRecordingEnabled = false;
bool mStatusLightEnabled = false;
uint16_t mImageRotation = kMinImageRotation;
bool mImageFlipHorizontal = false;
bool mImageFlipVertical = false;
uint8_t mDetectionSensitivity = (1 + kSensitivityMax) / 2; // Average over the range
std::vector<StreamUsageEnum> mStreamUsagePriorities = {
StreamUsageEnum::kLiveView, StreamUsageEnum::kRecording};
std::vector<StreamUsageEnum> mStreamUsagePriorities = { StreamUsageEnum::kLiveView, StreamUsageEnum::kRecording };
};
} // namespace Camera
File diff suppressed because it is too large Load Diff
@@ -1,8 +1,25 @@
/*
*
* 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 "camera-avstream-controller.h"
#include "camera-device-interface.h"
#include <app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h>
#include <app/clusters/camera-av-stream-management-server/CameraAVStreamManagementCluster.h>
#include <app/util/config.h>
#include <vector>
@@ -14,112 +31,90 @@ namespace CameraAvStreamManagement {
/**
* The application delegate to define the options & implement commands.
*/
class CameraAVStreamManager : public CameraAVStreamMgmtDelegate,
public CameraAVStreamController {
class CameraAVStreamManager : public CameraAVStreamManagementDelegate, public CameraAVStreamController
{
public:
Protocols::InteractionModel::Status
VideoStreamAllocate(const VideoStreamStruct &allocateArgs,
uint16_t &outStreamID) override;
Protocols::InteractionModel::Status VideoStreamAllocate(const VideoStreamStruct & allocateArgs,
uint16_t & outStreamID) override;
Protocols::InteractionModel::Status
VideoStreamModify(const uint16_t streamID,
const chip::Optional<bool> waterMarkEnabled,
const chip::Optional<bool> osdEnabled) override;
Protocols::InteractionModel::Status VideoStreamModify(const uint16_t streamID, const chip::Optional<bool> waterMarkEnabled,
const chip::Optional<bool> osdEnabled) override;
Protocols::InteractionModel::Status
VideoStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status VideoStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status
AudioStreamAllocate(const AudioStreamStruct &allocateArgs,
uint16_t &outStreamID) override;
Protocols::InteractionModel::Status AudioStreamAllocate(const AudioStreamStruct & allocateArgs,
uint16_t & outStreamID) override;
Protocols::InteractionModel::Status
AudioStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status AudioStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status
SnapshotStreamAllocate(const SnapshotStreamAllocateArgs &allocateArgs,
uint16_t &outStreamID) override;
Protocols::InteractionModel::Status SnapshotStreamAllocate(const SnapshotStreamAllocateArgs & allocateArgs,
uint16_t & outStreamID) override;
Protocols::InteractionModel::Status
SnapshotStreamModify(const uint16_t streamID,
const chip::Optional<bool> waterMarkEnabled,
const chip::Optional<bool> osdEnabled) override;
Protocols::InteractionModel::Status SnapshotStreamModify(const uint16_t streamID, const chip::Optional<bool> waterMarkEnabled,
const chip::Optional<bool> osdEnabled) override;
Protocols::InteractionModel::Status
SnapshotStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status SnapshotStreamDeallocate(const uint16_t streamID) override;
void OnVideoStreamAllocated(const VideoStreamStruct &allocatedStream,
StreamAllocationAction action) override;
void OnVideoStreamAllocated(const VideoStreamStruct & allocatedStream, StreamAllocationAction action) override;
void OnStreamUsagePrioritiesChanged() override;
void OnStreamUsagePrioritiesChanged() override;
void OnAttributeChanged(AttributeId attributeId) override;
void OnAttributeChanged(AttributeId attributeId) override;
Protocols::InteractionModel::Status
CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct &resolution,
ImageSnapshot &outImageSnapshot) override;
Protocols::InteractionModel::Status CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct & resolution,
ImageSnapshot & outImageSnapshot) override;
CHIP_ERROR
ValidateStreamUsage(
StreamUsageEnum streamUsage,
Optional<DataModel::Nullable<uint16_t>> &videoStreamId,
Optional<DataModel::Nullable<uint16_t>> &audioStreamId) override;
CHIP_ERROR
ValidateStreamUsage(StreamUsageEnum streamUsage, Optional<DataModel::Nullable<uint16_t>> & videoStreamId,
Optional<DataModel::Nullable<uint16_t>> & audioStreamId) override;
CHIP_ERROR
ValidateVideoStreamID(uint16_t videoStreamId) override;
CHIP_ERROR
ValidateVideoStreamID(uint16_t videoStreamId) override;
CHIP_ERROR
ValidateAudioStreamID(uint16_t audioStreamId) override;
CHIP_ERROR
ValidateAudioStreamID(uint16_t audioStreamId) override;
CHIP_ERROR IsHardPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsHardPrivacyModeActive(bool & isActive) override;
CHIP_ERROR IsSoftRecordingPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsSoftRecordingPrivacyModeActive(bool & isActive) override;
CHIP_ERROR IsSoftLivestreamPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsSoftLivestreamPrivacyModeActive(bool & isActive) override;
bool HasAllocatedVideoStreams() override;
bool HasAllocatedVideoStreams() override;
bool HasAllocatedAudioStreams() override;
bool HasAllocatedAudioStreams() override;
CHIP_ERROR SetHardPrivacyModeOn(bool hardPrivacyMode) override;
CHIP_ERROR SetHardPrivacyModeOn(bool hardPrivacyMode) override;
CHIP_ERROR PersistentAttributesLoadedCallback() override;
CHIP_ERROR PersistentAttributesLoadedCallback() override;
CHIP_ERROR
OnTransportAcquireAudioVideoStreams(uint16_t audioStreamID,
uint16_t videoStreamID) override;
CHIP_ERROR
OnTransportAcquireAudioVideoStreams(uint16_t audioStreamID, uint16_t videoStreamID) override;
CHIP_ERROR
OnTransportReleaseAudioVideoStreams(uint16_t audioStreamID,
uint16_t videoStreamID) override;
CHIP_ERROR
OnTransportReleaseAudioVideoStreams(uint16_t audioStreamID, uint16_t videoStreamID) override;
const std::vector<
chip::app::Clusters::CameraAvStreamManagement::VideoStreamStruct> &
GetAllocatedVideoStreams() const override;
const std::vector<chip::app::Clusters::CameraAvStreamManagement::VideoStreamStruct> & GetAllocatedVideoStreams() const override;
const std::vector<
chip::app::Clusters::CameraAvStreamManagement::AudioStreamStruct> &
GetAllocatedAudioStreams() const override;
const std::vector<chip::app::Clusters::CameraAvStreamManagement::AudioStreamStruct> & GetAllocatedAudioStreams() const override;
void GetBandwidthForStreams(
const Optional<DataModel::Nullable<uint16_t>> &videoStreamId,
const Optional<DataModel::Nullable<uint16_t>> &audioStreamId,
uint32_t &outBandwidthbps) override;
void GetBandwidthForStreams(const Optional<DataModel::Nullable<uint16_t>> & videoStreamId,
const Optional<DataModel::Nullable<uint16_t>> & audioStreamId, uint32_t & outBandwidthbps) override;
CameraAVStreamManager() = default;
~CameraAVStreamManager() = default;
CameraAVStreamManager() = default;
~CameraAVStreamManager() = default;
void SetCameraDeviceHAL(CameraDeviceInterface *aCameraDevice);
void SetCameraDeviceHAL(CameraDeviceInterface * aCameraDevice);
private:
CHIP_ERROR AllocatedVideoStreamsLoaded();
CHIP_ERROR AllocatedVideoStreamsLoaded();
CHIP_ERROR AllocatedAudioStreamsLoaded();
CHIP_ERROR AllocatedAudioStreamsLoaded();
CHIP_ERROR AllocatedSnapshotStreamsLoaded();
CHIP_ERROR AllocatedSnapshotStreamsLoaded();
CameraDeviceInterface *mCameraDeviceHAL = nullptr;
CameraDeviceInterface * mCameraDeviceHAL = nullptr;
};
} // namespace CameraAvStreamManagement
File diff suppressed because it is too large Load Diff
@@ -1,9 +1,26 @@
/*
*
* 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 "camera-device-interface.h"
#include <app-common/zap-generated/cluster-enums.h>
#include <app/CASESessionManager.h>
#include <app/clusters/webrtc-transport-provider-server/webrtc-transport-provider-server.h>
#include <app/clusters/webrtc-transport-provider-server/WebRTCTransportProviderCluster.h>
#include <map>
#include <webrtc-transport.h>
@@ -12,156 +29,129 @@ namespace app {
namespace Clusters {
namespace WebRTCTransportProvider {
using ICEServerDecodableStruct =
chip::app::Clusters::Globals::Structs::ICEServerStruct::DecodableType;
using WebRTCSessionStruct =
chip::app::Clusters::Globals::Structs::WebRTCSessionStruct::Type;
using ICECandidateStruct =
chip::app::Clusters::Globals::Structs::ICECandidateStruct::Type;
using StreamUsageEnum = chip::app::Clusters::Globals::StreamUsageEnum;
using WebRTCEndReasonEnum = chip::app::Clusters::Globals::WebRTCEndReasonEnum;
using ICEServerDecodableStruct = chip::app::Clusters::Globals::Structs::ICEServerStruct::DecodableType;
using WebRTCSessionStruct = chip::app::Clusters::Globals::Structs::WebRTCSessionStruct::Type;
using ICECandidateStruct = chip::app::Clusters::Globals::Structs::ICECandidateStruct::Type;
using StreamUsageEnum = chip::app::Clusters::Globals::StreamUsageEnum;
using WebRTCEndReasonEnum = chip::app::Clusters::Globals::WebRTCEndReasonEnum;
class WebRTCProviderManager : public Delegate,
public WebRTCTransportProviderController {
class WebRTCProviderManager : public Delegate
{
public:
WebRTCProviderManager()
: mOnConnectedCallback(OnDeviceConnected, this),
mOnConnectionFailureCallback(OnDeviceConnectionFailure, this) {}
WebRTCProviderManager() :
mOnConnectedCallback(OnDeviceConnected, this), mOnConnectionFailureCallback(OnDeviceConnectionFailure, this)
{}
~WebRTCProviderManager() { CloseConnection(); };
~WebRTCProviderManager() { CloseConnection(); };
void Init();
void Init();
void CloseConnection();
void CloseConnection();
void SetWebRTCTransportProvider(std::unique_ptr<WebRTCTransportProviderServer>
webRTCTransportProvider) override;
void SetWebRTCTransportProvider(WebRTCTransportProviderCluster * webRTCTransportProvider);
CHIP_ERROR HandleSolicitOffer(
const OfferRequestArgs &args,
chip::app::Clusters::WebRTCTransportProvider::WebRTCSessionStruct
&outSession,
bool &outDeferredOffer) override;
CHIP_ERROR HandleSolicitOffer(const OfferRequestArgs & args,
chip::app::Clusters::WebRTCTransportProvider::WebRTCSessionStruct & outSession,
bool & outDeferredOffer) override;
CHIP_ERROR
HandleProvideOffer(
const ProvideOfferRequestArgs &args,
chip::app::Clusters::WebRTCTransportProvider::WebRTCSessionStruct
&outSession) override;
CHIP_ERROR
HandleProvideOffer(const ProvideOfferRequestArgs & args,
chip::app::Clusters::WebRTCTransportProvider::WebRTCSessionStruct & outSession) override;
CHIP_ERROR HandleProvideAnswer(uint16_t sessionId,
const std::string &sdpAnswer) override;
CHIP_ERROR HandleProvideAnswer(uint16_t sessionId, const std::string & sdpAnswer) override;
CHIP_ERROR HandleProvideICECandidates(
uint16_t sessionId,
const std::vector<ICECandidateStruct> &candidates) override;
CHIP_ERROR HandleProvideICECandidates(uint16_t sessionId, const std::vector<ICECandidateStruct> & candidates) override;
CHIP_ERROR HandleEndSession(
uint16_t sessionId,
chip::app::Clusters::WebRTCTransportProvider::WebRTCEndReasonEnum
reasonCode,
chip::app::DataModel::Nullable<uint16_t> videoStreamID,
chip::app::DataModel::Nullable<uint16_t> audioStreamID) override;
CHIP_ERROR HandleEndSession(uint16_t sessionId, chip::app::Clusters::WebRTCTransportProvider::WebRTCEndReasonEnum reasonCode,
chip::app::DataModel::Nullable<uint16_t> videoStreamID,
chip::app::DataModel::Nullable<uint16_t> audioStreamID) override;
CHIP_ERROR ValidateStreamUsage(
StreamUsageEnum streamUsage,
chip::Optional<chip::app::DataModel::Nullable<uint16_t>> &videoStreamId,
chip::Optional<chip::app::DataModel::Nullable<uint16_t>> &audioStreamId)
override;
CHIP_ERROR ValidateStreamUsage(StreamUsageEnum streamUsage,
chip::Optional<chip::app::DataModel::Nullable<uint16_t>> & videoStreamId,
chip::Optional<chip::app::DataModel::Nullable<uint16_t>> & audioStreamId) override;
void SetCameraDevice(CameraDeviceInterface *aCameraDevice);
void SetCameraDevice(CameraDeviceInterface * aCameraDevice);
CHIP_ERROR ValidateVideoStreamID(uint16_t videoStreamId) override;
CHIP_ERROR ValidateVideoStreamID(uint16_t videoStreamId) override;
CHIP_ERROR ValidateAudioStreamID(uint16_t audioStreamId) override;
CHIP_ERROR ValidateAudioStreamID(uint16_t audioStreamId) override;
CHIP_ERROR IsStreamUsageSupported(StreamUsageEnum streamUsage) override;
CHIP_ERROR IsStreamUsageSupported(StreamUsageEnum streamUsage) override;
CHIP_ERROR IsHardPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsHardPrivacyModeActive(bool & isActive) override;
CHIP_ERROR IsSoftRecordingPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsSoftRecordingPrivacyModeActive(bool & isActive) override;
CHIP_ERROR IsSoftLivestreamPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsSoftLivestreamPrivacyModeActive(bool & isActive) override;
bool HasAllocatedVideoStreams() override;
bool HasAllocatedVideoStreams() override;
bool HasAllocatedAudioStreams() override;
bool HasAllocatedAudioStreams() override;
CHIP_ERROR ValidateSFrameConfig(uint16_t cipherSuite, size_t baseKeyLength) override;
CHIP_ERROR ValidateSFrameConfig(uint16_t cipherSuite, size_t baseKeyLength) override;
CHIP_ERROR IsUTCTimeNull(bool & isNull) override;
CHIP_ERROR IsUTCTimeNull(bool & isNull) override;
void LiveStreamPrivacyModeChanged(bool privacyModeEnabled);
void LiveStreamPrivacyModeChanged(bool privacyModeEnabled);
WebrtcTransport *GetTransport(uint16_t sessionId);
WebrtcTransport * GetTransport(uint16_t sessionId);
private:
void ScheduleOfferSend(uint16_t sessionId);
void ScheduleOfferSend(uint16_t sessionId);
void ScheduleICECandidatesSend(uint16_t sessionId);
void ScheduleICECandidatesSend(uint16_t sessionId);
void ScheduleAnswerSend(uint16_t sessionId);
void ScheduleAnswerSend(uint16_t sessionId);
void ScheduleEndSend(uint16_t sessionId);
void ScheduleEndSend(uint16_t sessionId);
void RegisterWebrtcTransport(uint16_t sessionId);
void RegisterWebrtcTransport(uint16_t sessionId);
void UnregisterWebrtcTransport(uint16_t sessionId);
void UnregisterWebrtcTransport(uint16_t sessionId);
CHIP_ERROR SendOfferCommand(chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle,
uint16_t sessionId);
CHIP_ERROR SendOfferCommand(chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle,
uint16_t sessionId);
CHIP_ERROR SendAnswerCommand(chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle,
uint16_t sessionId);
CHIP_ERROR SendAnswerCommand(chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle,
uint16_t sessionId);
CHIP_ERROR
SendICECandidatesCommand(chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle,
uint16_t sessionId);
CHIP_ERROR
SendICECandidatesCommand(chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle,
uint16_t sessionId);
CHIP_ERROR SendEndCommand(chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle,
uint16_t sessionId, WebRTCEndReasonEnum endReason);
CHIP_ERROR SendEndCommand(chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle,
uint16_t sessionId, WebRTCEndReasonEnum endReason);
CHIP_ERROR AcquireAudioVideoStreams(uint16_t sessionId);
CHIP_ERROR AcquireAudioVideoStreams(uint16_t sessionId);
CHIP_ERROR ReleaseAudioVideoStreams(uint16_t sessionId);
CHIP_ERROR ReleaseAudioVideoStreams(uint16_t sessionId);
static void OnDeviceConnected(void *context,
chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle);
static void OnDeviceConnected(void * context, chip::Messaging::ExchangeManager & exchangeMgr,
const chip::SessionHandle & sessionHandle);
static void OnDeviceConnectionFailure(void *context,
const chip::ScopedNodeId &peerId,
CHIP_ERROR error);
static void OnDeviceConnectionFailure(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error);
// WebRTC Callbacks
void OnLocalDescription(const std::string &sdp, SDPType type,
const uint16_t sessionId);
void OnConnectionStateChanged(bool connected, const uint16_t sessionId);
// WebRTC Callbacks
void OnLocalDescription(const std::string & sdp, SDPType type, const uint16_t sessionId);
void OnConnectionStateChanged(bool connected, const uint16_t sessionId);
chip::Callback::Callback<chip::OnDeviceConnected> mOnConnectedCallback;
chip::Callback::Callback<chip::OnDeviceConnectionFailure>
mOnConnectionFailureCallback;
chip::Callback::Callback<chip::OnDeviceConnected> mOnConnectedCallback;
chip::Callback::Callback<chip::OnDeviceConnectionFailure> mOnConnectionFailureCallback;
std::unordered_map<uint16_t, std::unique_ptr<WebrtcTransport>>
mWebrtcTransportMap;
// This is to retrieve the sessionIds for a given NodeId
std::map<ScopedNodeId, uint16_t> mSessionIdMap;
std::unordered_map<uint16_t, std::unique_ptr<WebrtcTransport>> mWebrtcTransportMap;
// This is to retrieve the sessionIds for a given NodeId
std::map<ScopedNodeId, uint16_t> mSessionIdMap;
std::unique_ptr<WebRTCTransportProviderServer> mWebRTCTransportProvider =
nullptr;
WebRTCTransportProviderCluster * mWebRTCTransportProvider = nullptr;
// Handle to the Camera Device interface. For accessing other
// clusters, if required.
CameraDeviceInterface *mCameraDevice = nullptr;
// Handle to the Camera Device interface. For accessing other
// clusters, if required.
CameraDeviceInterface * mCameraDevice = nullptr;
bool mSoftLiveStreamPrivacyEnabled = false;
bool mSoftLiveStreamPrivacyEnabled = false;
};
} // namespace WebRTCTransportProvider
} // namespace Clusters
} // namespace app
} // namespace chip
} // namespace chip
+195 -187
View File
@@ -1,4 +1,22 @@
/*
*
* 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.
*/
#include "camera-app.h"
#include "esp_matter_data_model_provider.h"
using namespace chip;
using namespace chip::app;
@@ -9,235 +27,225 @@ using namespace chip::app::Clusters::CameraAvStreamManagement;
static constexpr uint32_t kBitsPerMegabit = 1000000;
template <typename T> using List = chip::app::DataModel::List<T>;
template <typename T>
using List = chip::app::DataModel::List<T>;
using Status = Protocols::InteractionModel::Status;
CameraApp::CameraApp(chip::EndpointId aClustersEndpoint,
CameraDeviceInterface *aCameraDevice) {
mEndpoint = aClustersEndpoint;
mCameraDevice = aCameraDevice;
CameraApp::CameraApp(chip::EndpointId aClustersEndpoint, CameraDeviceInterface * aCameraDevice)
{
mEndpoint = aClustersEndpoint;
mCameraDevice = aCameraDevice;
// Instantiate WebRTCTransport Provider
mWebRTCTransportProviderPtr = std::make_unique<WebRTCTransportProviderServer>(
mCameraDevice->GetWebRTCProviderDelegate(), mEndpoint);
// Fetch all initialization parameters for CameraAVStreamMgmt Server
BitFlags<CameraAvStreamManagement::Feature> avsmFeatures;
BitFlags<CameraAvStreamManagement::OptionalAttribute> avsmOptionalAttrs;
avsmFeatures.Set(CameraAvStreamManagement::Feature::kSnapshot);
avsmFeatures.Set(CameraAvStreamManagement::Feature::kVideo);
// Fetch all initialization parameters for CameraAVStreamMgmt Server
BitFlags<CameraAvStreamManagement::Feature> avsmFeatures;
BitFlags<CameraAvStreamManagement::OptionalAttribute> avsmOptionalAttrs;
avsmFeatures.Set(CameraAvStreamManagement::Feature::kSnapshot);
avsmFeatures.Set(CameraAvStreamManagement::Feature::kVideo);
// Enable the Watermark and OSD features if camera supports
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsWatermark())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kWatermark);
}
// Enable the Watermark and OSD features if camera supports
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsWatermark()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kWatermark);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsOSD())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kOnScreenDisplay);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsOSD()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kOnScreenDisplay);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsSoftPrivacy())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kPrivacy);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsSoftPrivacy()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kPrivacy);
}
// Check microphone support to set Audio feature
if (mCameraDevice->GetCameraHALInterface().HasMicrophone())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kAudio);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kMicrophoneAGCEnabled);
}
// Check microphone support to set Audio feature
if (mCameraDevice->GetCameraHALInterface().HasMicrophone()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kAudio);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kMicrophoneAGCEnabled);
}
if (mCameraDevice->GetCameraHALInterface().HasLocalStorage())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kLocalStorage);
}
if (mCameraDevice->GetCameraHALInterface().HasLocalStorage()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kLocalStorage);
}
// Check if camera has speaker
if (mCameraDevice->GetCameraHALInterface().HasSpeaker())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kSpeaker);
}
// Check if camera has speaker
if (mCameraDevice->GetCameraHALInterface().HasSpeaker()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kSpeaker);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsHDR())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kHighDynamicRange);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsHDR()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kHighDynamicRange);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsNightVision())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kNightVision);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kNightVisionIllum);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsNightVision()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kNightVision);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kNightVisionIllum);
}
if (mCameraDevice->GetCameraHALInterface().HasHardPrivacySwitch())
{
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kHardPrivacyModeOn);
}
if (mCameraDevice->GetCameraHALInterface().HasHardPrivacySwitch()) {
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kHardPrivacyModeOn);
}
if (mCameraDevice->GetCameraHALInterface().HasStatusLight())
{
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kStatusLightEnabled);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kStatusLightBrightness);
}
if (mCameraDevice->GetCameraHALInterface().HasStatusLight()) {
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kStatusLightEnabled);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kStatusLightBrightness);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsImageControl())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kImageControl);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kImageFlipVertical);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kImageFlipHorizontal);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kImageRotation);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsImageControl()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kImageControl);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kImageFlipVertical);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kImageFlipHorizontal);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kImageRotation);
}
uint32_t maxConcurrentVideoEncoders = mCameraDevice->GetCameraHALInterface().GetMaxConcurrentEncoders();
uint32_t maxEncodedPixelRate = mCameraDevice->GetCameraHALInterface().GetMaxEncodedPixelRate();
VideoSensorParamsStruct sensorParams = mCameraDevice->GetCameraHALInterface().GetVideoSensorParams();
bool nightVisionUsesInfrared = mCameraDevice->GetCameraHALInterface().GetNightVisionUsesInfrared();
VideoResolutionStruct minViewport = mCameraDevice->GetCameraHALInterface().GetMinViewport();
std::vector<RateDistortionTradeOffStruct> rateDistortionTradeOffPoints =
mCameraDevice->GetCameraHALInterface().GetRateDistortionTradeOffPoints();
uint32_t maxConcurrentVideoEncoders =
mCameraDevice->GetCameraHALInterface().GetMaxConcurrentEncoders();
uint32_t maxEncodedPixelRate =
mCameraDevice->GetCameraHALInterface().GetMaxEncodedPixelRate();
VideoSensorParamsStruct sensorParams =
mCameraDevice->GetCameraHALInterface().GetVideoSensorParams();
bool nightVisionUsesInfrared =
mCameraDevice->GetCameraHALInterface().GetNightVisionUsesInfrared();
VideoResolutionStruct minViewport =
mCameraDevice->GetCameraHALInterface().GetMinViewport();
std::vector<RateDistortionTradeOffStruct> rateDistortionTradeOffPoints =
mCameraDevice->GetCameraHALInterface().GetRateDistortionTradeOffPoints();
uint32_t maxContentBufferSize = mCameraDevice->GetCameraHALInterface().GetMaxContentBufferSize();
AudioCapabilitiesStruct micCapabilities = mCameraDevice->GetCameraHALInterface().GetMicrophoneCapabilities();
AudioCapabilitiesStruct spkrCapabilities = mCameraDevice->GetCameraHALInterface().GetSpeakerCapabilities();
TwoWayTalkSupportTypeEnum twowayTalkSupport =
mCameraDevice->GetCameraHALInterface().HasMicrophone() && mCameraDevice->GetCameraHALInterface().HasSpeaker()
? TwoWayTalkSupportTypeEnum::kFullDuplex
: TwoWayTalkSupportTypeEnum::kNotSupported;
std::vector<SnapshotCapabilitiesStruct> snapshotCapabilities = mCameraDevice->GetCameraHALInterface().GetSnapshotCapabilities();
uint32_t maxNetworkBandwidth = mCameraDevice->GetCameraHALInterface().GetMaxNetworkBandwidth() * kBitsPerMegabit;
std::vector<StreamUsageEnum> supportedStreamUsages = mCameraDevice->GetCameraHALInterface().GetSupportedStreamUsages();
std::vector<StreamUsageEnum> streamUsagePriorities = mCameraDevice->GetCameraHALInterface().GetStreamUsagePriorities();
uint32_t maxContentBufferSize =
mCameraDevice->GetCameraHALInterface().GetMaxContentBufferSize();
AudioCapabilitiesStruct micCapabilities =
mCameraDevice->GetCameraHALInterface().GetMicrophoneCapabilities();
AudioCapabilitiesStruct spkrCapabilities =
mCameraDevice->GetCameraHALInterface().GetSpeakerCapabilities();
TwoWayTalkSupportTypeEnum twowayTalkSupport =
mCameraDevice->GetCameraHALInterface().HasMicrophone() &&
mCameraDevice->GetCameraHALInterface().HasSpeaker()
? TwoWayTalkSupportTypeEnum::kFullDuplex
: TwoWayTalkSupportTypeEnum::kNotSupported;
std::vector<SnapshotCapabilitiesStruct> snapshotCapabilities =
mCameraDevice->GetCameraHALInterface().GetSnapshotCapabilities();
uint32_t maxNetworkBandwidth =
mCameraDevice->GetCameraHALInterface().GetMaxNetworkBandwidth() *
kBitsPerMegabit;
std::vector<StreamUsageEnum> supportedStreamUsages =
mCameraDevice->GetCameraHALInterface().GetSupportedStreamUsages();
std::vector<StreamUsageEnum> streamUsagePriorities =
mCameraDevice->GetCameraHALInterface().GetStreamUsagePriorities();
// Instantiate the CameraAVStreamMgmt Server
mAVStreamMgmtServerPtr = std::make_unique<CameraAVStreamMgmtServer>(
mCameraDevice->GetCameraAVStreamMgmtDelegate(), mEndpoint, avsmFeatures,
avsmOptionalAttrs, maxConcurrentVideoEncoders, maxEncodedPixelRate,
sensorParams, nightVisionUsesInfrared, minViewport,
rateDistortionTradeOffPoints, maxContentBufferSize, micCapabilities,
spkrCapabilities, twowayTalkSupport, snapshotCapabilities,
maxNetworkBandwidth, supportedStreamUsages, streamUsagePriorities);
// Instantiate the CameraAVStreamMgmt Server
mAVStreamMgmtServerPtr = std::make_unique<CameraAVStreamManagementCluster>(
mCameraDevice->GetCameraAVStreamMgmtDelegate(), mEndpoint, avsmFeatures, avsmOptionalAttrs, maxConcurrentVideoEncoders,
maxEncodedPixelRate, sensorParams, nightVisionUsesInfrared, minViewport, rateDistortionTradeOffPoints, maxContentBufferSize,
micCapabilities, spkrCapabilities, twowayTalkSupport, snapshotCapabilities, maxNetworkBandwidth, supportedStreamUsages,
streamUsagePriorities);
}
void CameraApp::InitializeCameraAVStreamMgmt() {
// Set the attribute defaults
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsHDR()) {
mAVStreamMgmtServerPtr->SetHDRModeEnabled(
mCameraDevice->GetCameraHALInterface().GetHDRMode());
}
void CameraApp::InitializeCameraAVStreamMgmt()
{
// Set the attribute defaults
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsHDR())
{
mAVStreamMgmtServerPtr->SetHDRModeEnabled(mCameraDevice->GetCameraHALInterface().GetHDRMode());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsSoftPrivacy()) {
mAVStreamMgmtServerPtr->SetSoftRecordingPrivacyModeEnabled(
mCameraDevice->GetCameraHALInterface()
.GetSoftRecordingPrivacyModeEnabled());
mAVStreamMgmtServerPtr->SetSoftLivestreamPrivacyModeEnabled(
mCameraDevice->GetCameraHALInterface()
.GetSoftLivestreamPrivacyModeEnabled());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsSoftPrivacy())
{
mAVStreamMgmtServerPtr->SetSoftRecordingPrivacyModeEnabled(
mCameraDevice->GetCameraHALInterface().GetSoftRecordingPrivacyModeEnabled());
mAVStreamMgmtServerPtr->SetSoftLivestreamPrivacyModeEnabled(
mCameraDevice->GetCameraHALInterface().GetSoftLivestreamPrivacyModeEnabled());
}
if (mCameraDevice->GetCameraHALInterface().HasHardPrivacySwitch()) {
mAVStreamMgmtServerPtr->SetHardPrivacyModeOn(
mCameraDevice->GetCameraHALInterface().GetHardPrivacyMode());
}
if (mCameraDevice->GetCameraHALInterface().HasHardPrivacySwitch())
{
mAVStreamMgmtServerPtr->SetHardPrivacyModeOn(mCameraDevice->GetCameraHALInterface().GetHardPrivacyMode());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsNightVision()) {
mAVStreamMgmtServerPtr->SetNightVision(
mCameraDevice->GetCameraHALInterface().GetNightVision());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsNightVision())
{
mAVStreamMgmtServerPtr->SetNightVision(mCameraDevice->GetCameraHALInterface().GetNightVision());
}
mAVStreamMgmtServerPtr->SetViewport(
mCameraDevice->GetCameraHALInterface().GetViewport());
mAVStreamMgmtServerPtr->SetViewport(mCameraDevice->GetCameraHALInterface().GetViewport());
if (mCameraDevice->GetCameraHALInterface().HasSpeaker()) {
mAVStreamMgmtServerPtr->SetSpeakerMuted(
mCameraDevice->GetCameraHALInterface().GetSpeakerMuted());
mAVStreamMgmtServerPtr->SetSpeakerVolumeLevel(
mCameraDevice->GetCameraHALInterface().GetSpeakerVolume());
mAVStreamMgmtServerPtr->SetSpeakerMaxLevel(
mCameraDevice->GetCameraHALInterface().GetSpeakerMaxLevel());
mAVStreamMgmtServerPtr->SetSpeakerMinLevel(
mCameraDevice->GetCameraHALInterface().GetSpeakerMinLevel());
}
if (mCameraDevice->GetCameraHALInterface().HasSpeaker())
{
mAVStreamMgmtServerPtr->SetSpeakerMuted(mCameraDevice->GetCameraHALInterface().GetSpeakerMuted());
mAVStreamMgmtServerPtr->SetSpeakerVolumeLevel(mCameraDevice->GetCameraHALInterface().GetSpeakerVolume());
mAVStreamMgmtServerPtr->SetSpeakerMaxLevel(mCameraDevice->GetCameraHALInterface().GetSpeakerMaxLevel());
mAVStreamMgmtServerPtr->SetSpeakerMinLevel(mCameraDevice->GetCameraHALInterface().GetSpeakerMinLevel());
}
if (mCameraDevice->GetCameraHALInterface().HasMicrophone()) {
mAVStreamMgmtServerPtr->SetMicrophoneMuted(
mCameraDevice->GetCameraHALInterface().GetMicrophoneMuted());
mAVStreamMgmtServerPtr->SetMicrophoneVolumeLevel(
mCameraDevice->GetCameraHALInterface().GetMicrophoneVolume());
mAVStreamMgmtServerPtr->SetMicrophoneMaxLevel(
mCameraDevice->GetCameraHALInterface().GetMicrophoneMaxLevel());
mAVStreamMgmtServerPtr->SetMicrophoneMinLevel(
mCameraDevice->GetCameraHALInterface().GetMicrophoneMinLevel());
}
if (mCameraDevice->GetCameraHALInterface().HasMicrophone())
{
mAVStreamMgmtServerPtr->SetMicrophoneMuted(mCameraDevice->GetCameraHALInterface().GetMicrophoneMuted());
mAVStreamMgmtServerPtr->SetMicrophoneVolumeLevel(mCameraDevice->GetCameraHALInterface().GetMicrophoneVolume());
mAVStreamMgmtServerPtr->SetMicrophoneMaxLevel(mCameraDevice->GetCameraHALInterface().GetMicrophoneMaxLevel());
mAVStreamMgmtServerPtr->SetMicrophoneMinLevel(mCameraDevice->GetCameraHALInterface().GetMicrophoneMinLevel());
}
// Video and Snapshot features are already enabled.
if (mCameraDevice->GetCameraHALInterface().HasLocalStorage()) {
mAVStreamMgmtServerPtr->SetLocalVideoRecordingEnabled(
mCameraDevice->GetCameraHALInterface().GetLocalVideoRecordingEnabled());
mAVStreamMgmtServerPtr->SetLocalSnapshotRecordingEnabled(
mCameraDevice->GetCameraHALInterface()
.GetLocalSnapshotRecordingEnabled());
}
// Video and Snapshot features are already enabled.
if (mCameraDevice->GetCameraHALInterface().HasLocalStorage())
{
mAVStreamMgmtServerPtr->SetLocalVideoRecordingEnabled(
mCameraDevice->GetCameraHALInterface().GetLocalVideoRecordingEnabled());
mAVStreamMgmtServerPtr->SetLocalSnapshotRecordingEnabled(
mCameraDevice->GetCameraHALInterface().GetLocalSnapshotRecordingEnabled());
}
if (mCameraDevice->GetCameraHALInterface().HasStatusLight()) {
mAVStreamMgmtServerPtr->SetStatusLightEnabled(
mCameraDevice->GetCameraHALInterface().GetStatusLightEnabled());
}
if (mCameraDevice->GetCameraHALInterface().HasStatusLight())
{
mAVStreamMgmtServerPtr->SetStatusLightEnabled(mCameraDevice->GetCameraHALInterface().GetStatusLightEnabled());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsImageControl()) {
mAVStreamMgmtServerPtr->SetImageRotation(
mCameraDevice->GetCameraHALInterface().GetImageRotation());
mAVStreamMgmtServerPtr->SetImageFlipVertical(
mCameraDevice->GetCameraHALInterface().GetImageFlipVertical());
mAVStreamMgmtServerPtr->SetImageFlipHorizontal(
mCameraDevice->GetCameraHALInterface().GetImageFlipHorizontal());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsImageControl())
{
mAVStreamMgmtServerPtr->SetImageRotation(mCameraDevice->GetCameraHALInterface().GetImageRotation());
mAVStreamMgmtServerPtr->SetImageFlipVertical(mCameraDevice->GetCameraHALInterface().GetImageFlipVertical());
mAVStreamMgmtServerPtr->SetImageFlipHorizontal(mCameraDevice->GetCameraHALInterface().GetImageFlipHorizontal());
}
mAVStreamMgmtServerPtr->Init();
mAVStreamMgmtServerPtr->Init();
}
void CameraApp::InitCameraDeviceClusters() {
// Initialize Cluster Servers
mWebRTCTransportProviderPtr->Init();
mCameraDevice->GetWebRTCProviderController().SetWebRTCTransportProvider(
std::move(mWebRTCTransportProviderPtr));
InitializeCameraAVStreamMgmt();
void CameraApp::InitCameraDeviceClusters()
{
// Initialize Cluster Servers
mWebRTCTransportProviderServer.Create(mEndpoint, mCameraDevice->GetWebRTCProviderDelegate());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(mWebRTCTransportProviderServer.Registration());
if (err != CHIP_NO_ERROR)
{
ChipLogError(Camera,
"Failed to register WebRTCTransportProvider on endpoint %u: "
"%" CHIP_ERROR_FORMAT,
mEndpoint, err.Format());
}
InitializeCameraAVStreamMgmt();
}
void CameraApp::ShutdownCameraDeviceClusters() {
ChipLogDetail(Camera,
"CameraAppShutdown: Shutting down Camera device clusters");
mWebRTCTransportProviderPtr->Shutdown();
void CameraApp::ShutdownCameraDeviceClusters()
{
ChipLogDetail(Camera, "CameraAppShutdown: Shutting down Camera device clusters");
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&mWebRTCTransportProviderServer.Cluster());
if (err != CHIP_NO_ERROR)
{
ChipLogError(Camera, "WebRTCTransportProvider unregister error: %" CHIP_ERROR_FORMAT, err.Format());
}
mWebRTCTransportProviderServer.Destroy();
}
static constexpr EndpointId kCameraEndpointId = 1;
std::unique_ptr<CameraApp> gCameraApp;
void CameraAppInit(CameraDeviceInterface *cameraDevice) {
void CameraAppInit(CameraDeviceInterface * cameraDevice)
{
gCameraApp = std::make_unique<CameraApp>(kCameraEndpointId, cameraDevice);
gCameraApp = std::make_unique<CameraApp>(kCameraEndpointId, cameraDevice);
gCameraApp.get()->InitCameraDeviceClusters();
gCameraApp.get()->InitCameraDeviceClusters();
ChipLogDetail(Camera, "CameraAppInit: Initialized Camera clusters");
ChipLogDetail(Camera, "CameraAppInit: Initialized Camera clusters");
}
void CameraAppShutdown() {
ChipLogDetail(Camera, "CameraAppShutdown: Shutting down Camera app");
gCameraApp.get()->ShutdownCameraDeviceClusters();
gCameraApp = nullptr;
void CameraAppShutdown()
{
ChipLogDetail(Camera, "CameraAppShutdown: Shutting down Camera app");
gCameraApp.get()->ShutdownCameraDeviceClusters();
gCameraApp = nullptr;
}
+36 -24
View File
@@ -1,3 +1,20 @@
/*
*
* 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-common/zap-generated/cluster-objects.h>
@@ -5,43 +22,38 @@
#include "camera-device-interface.h"
#include <app/util/config.h>
#include <cstring>
#include <data-model-providers/codegen/CodegenDataModelProvider.h>
#include <protocols/interaction_model/StatusCode.h>
#include <utility>
// Camera App defines all the cluster servers needed for a particular device
class CameraApp {
class CameraApp
{
public:
// This class is responsible for initialising all the camera clusters and
// managing the interactions between them
CameraApp(chip::EndpointId aClustersEndpoint,
CameraDeviceInterface *cameraDevice);
// This class is responsible for initialising all the camera clusters and
// managing the interactions between them
CameraApp(chip::EndpointId aClustersEndpoint, CameraDeviceInterface * cameraDevice);
// Initialize all the camera device clusters.
void InitCameraDeviceClusters();
// Initialize all the camera device clusters.
void InitCameraDeviceClusters();
// Shutdown all the camera device clusters
void ShutdownCameraDeviceClusters();
// Shutdown all the camera device clusters
void ShutdownCameraDeviceClusters();
private:
chip::EndpointId mEndpoint;
CameraDeviceInterface *mCameraDevice;
chip::EndpointId mEndpoint;
CameraDeviceInterface * mCameraDevice;
// SDK cluster servers
std::unique_ptr<chip::app::Clusters::WebRTCTransportProvider::
WebRTCTransportProviderServer>
mWebRTCTransportProviderPtr;
// std::unique_ptr<chip::app::Clusters::ChimeServer> mChimeServerPtr;
std::unique_ptr<
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamMgmtServer>
mAVStreamMgmtServerPtr;
// std::unique_ptr<chip::app::Clusters::CameraAvSettingsUserLevelManagement::CameraAvSettingsUserLevelMgmtServer>
// mAVSettingsUserLevelMgmtServerPtr;
// SDK cluster servers
chip::app::LazyRegisteredServerCluster<chip::app::Clusters::WebRTCTransportProvider::WebRTCTransportProviderCluster>
mWebRTCTransportProviderServer;
std::unique_ptr<chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementCluster> mAVStreamMgmtServerPtr;
// Helper to set attribute defaults for CameraAVStreamMgmt
void InitializeCameraAVStreamMgmt();
// Helper to set attribute defaults for CameraAVStreamMgmt
void InitializeCameraAVStreamMgmt();
};
void CameraAppInit(CameraDeviceInterface *cameraDevice);
void CameraAppInit(CameraDeviceInterface * cameraDevice);
void CameraAppShutdown();
@@ -1,6 +1,6 @@
#pragma once
#include <app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h>
#include <app/clusters/camera-av-stream-management-server/CameraAVStreamManagementCluster.h>
namespace chip {
namespace app {
@@ -1,18 +1,18 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "camera-avstream-controller.h"
// #include <media-controller.h>
#include "webrtc-provider-controller.h"
// #include
// <app/clusters/camera-av-settings-user-level-management-server/camera-av-settings-user-level-management-server.h>
#include <app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h>
// #include <app/clusters/chime-server/chime-server.h>
#include <app/clusters/webrtc-transport-provider-server/webrtc-transport-provider-server.h>
#include <app/clusters/camera-av-stream-management-server/CameraAVStreamManagementCluster.h>
#include <app/clusters/webrtc-transport-provider-server/WebRTCTransportProviderCluster.h>
using chip::app::Clusters::CameraAvStreamManagement::AudioCapabilitiesStruct;
using chip::app::Clusters::CameraAvStreamManagement::AudioStreamStruct;
using chip::app::Clusters::CameraAvStreamManagement::ImageSnapshot;
using chip::app::Clusters::CameraAvStreamManagement::
RateDistortionTradeOffStruct;
using chip::app::Clusters::CameraAvStreamManagement::RateDistortionTradeOffStruct;
using chip::app::Clusters::CameraAvStreamManagement::SnapshotCapabilitiesStruct;
using chip::app::Clusters::CameraAvStreamManagement::SnapshotStreamStruct;
using chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum;
@@ -21,312 +21,290 @@ using chip::app::Clusters::CameraAvStreamManagement::VideoSensorParamsStruct;
using chip::app::Clusters::CameraAvStreamManagement::VideoStreamStruct;
using chip::app::Clusters::Globals::StreamUsageEnum;
struct VideoStream {
VideoStreamStruct videoStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated.
chip::app::Clusters::Globals::Structs::ViewportStruct::Type
viewport; // Stream specific viewport, defaults to the camera viewport
void *videoContext; // Platform-specific context object associated with
// video stream;
struct VideoStream
{
VideoStreamStruct videoStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated.
chip::app::Clusters::Globals::Structs::ViewportStruct::Type
viewport; // Stream specific viewport, defaults to the camera viewport
void * videoContext; // Platform-specific context object associated with
// video stream;
bool IsCompatible(const VideoStreamStruct &inputParams) const {
return (videoStreamParams.videoCodec == inputParams.videoCodec &&
videoStreamParams.minFrameRate <= inputParams.minFrameRate &&
videoStreamParams.maxFrameRate >= inputParams.maxFrameRate &&
videoStreamParams.minResolution.width <=
inputParams.minResolution.width &&
videoStreamParams.minResolution.height <=
inputParams.minResolution.height &&
videoStreamParams.maxResolution.width >=
inputParams.maxResolution.width &&
videoStreamParams.maxResolution.height >=
inputParams.maxResolution.height &&
videoStreamParams.minBitRate <= inputParams.minBitRate &&
videoStreamParams.maxBitRate >= inputParams.maxBitRate &&
videoStreamParams.keyFrameInterval == inputParams.keyFrameInterval);
}
bool IsCompatible(const VideoStreamStruct & inputParams) const
{
return (videoStreamParams.videoCodec == inputParams.videoCodec &&
videoStreamParams.minFrameRate >= inputParams.minFrameRate &&
videoStreamParams.maxFrameRate <= inputParams.maxFrameRate &&
videoStreamParams.minResolution.width <= inputParams.minResolution.width &&
videoStreamParams.minResolution.height <= inputParams.minResolution.height &&
videoStreamParams.maxResolution.width >= inputParams.maxResolution.width &&
videoStreamParams.maxResolution.height >= inputParams.maxResolution.height &&
videoStreamParams.minBitRate <= inputParams.minBitRate && videoStreamParams.maxBitRate >= inputParams.maxBitRate &&
videoStreamParams.keyFrameInterval == inputParams.keyFrameInterval);
}
};
struct AudioStream {
AudioStreamStruct audioStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated.
void *audioContext; // Platform-specific context object associated with
// video stream;
struct AudioStream
{
AudioStreamStruct audioStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated.
void * audioContext; // Platform-specific context object associated with
// video stream;
bool IsCompatible(const AudioStreamStruct &inputParams) const {
return (audioStreamParams.audioCodec == inputParams.audioCodec &&
audioStreamParams.channelCount == inputParams.channelCount &&
audioStreamParams.sampleRate == inputParams.sampleRate &&
audioStreamParams.bitDepth == inputParams.bitDepth);
}
bool IsCompatible(const AudioStreamStruct & inputParams) const
{
return (audioStreamParams.audioCodec == inputParams.audioCodec &&
audioStreamParams.channelCount == inputParams.channelCount &&
audioStreamParams.sampleRate == inputParams.sampleRate && audioStreamParams.bitDepth == inputParams.bitDepth);
}
};
struct SnapshotStream {
SnapshotStreamStruct snapshotStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated
void *snapshotContext; // Platform-specific context object associated with
// snapshot stream;
struct SnapshotStream
{
SnapshotStreamStruct snapshotStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated
void * snapshotContext; // Platform-specific context object associated with
// snapshot stream;
bool IsCompatible(const chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamMgmtDelegate::SnapshotStreamAllocateArgs
&inputParams) const {
return (snapshotStreamParams.imageCodec == inputParams.imageCodec &&
snapshotStreamParams.quality == inputParams.quality &&
snapshotStreamParams.frameRate <= inputParams.maxFrameRate &&
snapshotStreamParams.minResolution.width <=
inputParams.minResolution.width &&
snapshotStreamParams.minResolution.height <=
inputParams.minResolution.height &&
snapshotStreamParams.maxResolution.width >=
inputParams.maxResolution.width &&
snapshotStreamParams.maxResolution.height >=
inputParams.maxResolution.height);
}
bool
IsCompatible(const chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate::SnapshotStreamAllocateArgs &
inputParams) const
{
return (snapshotStreamParams.imageCodec == inputParams.imageCodec && snapshotStreamParams.quality == inputParams.quality &&
snapshotStreamParams.frameRate <= inputParams.maxFrameRate &&
snapshotStreamParams.minResolution.width <= inputParams.minResolution.width &&
snapshotStreamParams.minResolution.height <= inputParams.minResolution.height &&
snapshotStreamParams.maxResolution.width >= inputParams.maxResolution.width &&
snapshotStreamParams.maxResolution.height >= inputParams.maxResolution.height);
}
};
// Enumeration for common camera errors
enum class CameraError {
SUCCESS,
ERROR_INIT_FAILED,
ERROR_VIDEO_STREAM_START_FAILED,
ERROR_VIDEO_STREAM_STOP_FAILED,
ERROR_AUDIO_STREAM_START_FAILED,
ERROR_AUDIO_STREAM_STOP_FAILED,
ERROR_SNAPSHOT_STREAM_START_FAILED,
ERROR_SNAPSHOT_STREAM_STOP_FAILED,
ERROR_CAPTURE_SNAPSHOT_FAILED,
ERROR_CONFIG_FAILED,
ERROR_RESOURCE_EXHAUSTED,
ERROR_NOT_IMPLEMENTED, // For features not supported on a platform
enum class CameraError
{
SUCCESS,
ERROR_INIT_FAILED,
ERROR_VIDEO_STREAM_START_FAILED,
ERROR_VIDEO_STREAM_STOP_FAILED,
ERROR_AUDIO_STREAM_START_FAILED,
ERROR_AUDIO_STREAM_STOP_FAILED,
ERROR_SNAPSHOT_STREAM_START_FAILED,
ERROR_SNAPSHOT_STREAM_STOP_FAILED,
ERROR_CAPTURE_SNAPSHOT_FAILED,
ERROR_CONFIG_FAILED,
ERROR_RESOURCE_EXHAUSTED,
ERROR_NOT_IMPLEMENTED, // For features not supported on a platform
};
// Camera Device Interface defines all the clusters that need to be implemented
// for a Camera Device
class CameraDeviceInterface {
class CameraDeviceInterface
{
public:
virtual ~CameraDeviceInterface() = default;
virtual ~CameraDeviceInterface() = default;
// Getter for WebRTCProvider Delegate
virtual chip::app::Clusters::WebRTCTransportProvider::Delegate &
GetWebRTCProviderDelegate() = 0;
// Getter for WebRTCProvider Delegate
virtual chip::app::Clusters::WebRTCTransportProvider::Delegate & GetWebRTCProviderDelegate() = 0;
// Getter for WebRTCProvider Controller
virtual chip::app::Clusters::WebRTCTransportProvider::
WebRTCTransportProviderController &
GetWebRTCProviderController() = 0;
// Set the WebRTC Transport Provider server instance
virtual void
SetWebRTCTransportProvider(chip::app::Clusters::WebRTCTransportProvider::WebRTCTransportProviderCluster * provider) = 0;
// Getter for CameraAVStreamManagement Delegate
virtual chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamMgmtDelegate &
GetCameraAVStreamMgmtDelegate() = 0;
// Getter for CameraAVStreamManagement Delegate
virtual chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate & GetCameraAVStreamMgmtDelegate() = 0;
// Getter for CameraAVStreamManagement Controller
virtual chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamController &
GetCameraAVStreamMgmtController() = 0;
// Getter for CameraAVStreamManagement Controller
virtual chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamController & GetCameraAVStreamMgmtController() = 0;
// Class defining the Camera HAL interface
class CameraHALInterface {
public:
// Virtual destructor
virtual ~CameraHALInterface() = default;
// Class defining the Camera HAL interface
class CameraHALInterface
{
public:
// Virtual destructor
virtual ~CameraHALInterface() = default;
// Initialize the camera hardware
virtual CameraError InitializeCameraDevice() = 0;
// Initialize the camera hardware
virtual CameraError InitializeCameraDevice() = 0;
virtual CameraError InitializeStreams() = 0;
virtual CameraError InitializeStreams() = 0;
virtual std::vector<VideoStream> &GetAvailableVideoStreams() = 0;
virtual std::vector<VideoStream> & GetAvailableVideoStreams() = 0;
virtual std::vector<AudioStream> &GetAvailableAudioStreams() = 0;
virtual std::vector<AudioStream> & GetAvailableAudioStreams() = 0;
virtual std::vector<SnapshotStream> &GetAvailableSnapshotStreams() = 0;
virtual std::vector<SnapshotStream> & GetAvailableSnapshotStreams() = 0;
// Capture a snapshot image
virtual CameraError
CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct &resolution,
ImageSnapshot &outImageSnapshot) = 0;
// Capture a snapshot image
virtual CameraError CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct & resolution, ImageSnapshot & outImageSnapshot) = 0;
// Allocate snapshot stream
virtual CameraError AllocateSnapshotStream(
const chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamMgmtDelegate::SnapshotStreamAllocateArgs &args,
uint16_t &outStreamID) = 0;
// Allocate snapshot stream
virtual CameraError AllocateSnapshotStream(
const chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate::SnapshotStreamAllocateArgs &
args,
uint16_t & outStreamID) = 0;
// Get the maximum number of concurrent encoders supported by camera.
virtual uint8_t GetMaxConcurrentEncoders() = 0;
// Get the maximum number of concurrent encoders supported by camera.
virtual uint8_t GetMaxConcurrentEncoders() = 0;
// Get the maximum data rate in encoded pixels per second that the
// camera can produce given the hardware encoders it has.
virtual uint32_t GetMaxEncodedPixelRate() = 0;
// Get the maximum data rate in encoded pixels per second that the
// camera can produce given the hardware encoders it has.
virtual uint32_t GetMaxEncodedPixelRate() = 0;
// Get the Video sensor params(sensor dimensions, framerate, HDR
// capabilities)
virtual VideoSensorParamsStruct &GetVideoSensorParams() = 0;
// Get the Video sensor params(sensor dimensions, framerate, HDR
// capabilities)
virtual VideoSensorParamsStruct & GetVideoSensorParams() = 0;
// Get indication whether camera supports high dynamic range for video
virtual bool GetCameraSupportsHDR() = 0;
// Get indication whether camera supports high dynamic range for video
virtual bool GetCameraSupportsHDR() = 0;
// Get indication whether camera supports night vision
virtual bool GetCameraSupportsNightVision() = 0;
// Get indication whether camera supports night vision
virtual bool GetCameraSupportsNightVision() = 0;
// Get indication whether camera night vision using infrared
virtual bool GetNightVisionUsesInfrared() = 0;
// Get indication whether camera night vision using infrared
virtual bool GetNightVisionUsesInfrared() = 0;
// Get indication whether camera supports image control
virtual bool GetCameraSupportsImageControl() = 0;
// Get indication whether camera supports image control
virtual bool GetCameraSupportsImageControl() = 0;
// Get indication whether camera supports watermark for video and snapshot
virtual bool GetCameraSupportsWatermark() = 0;
// Get indication whether camera supports watermark for video and snapshot
virtual bool GetCameraSupportsWatermark() = 0;
// Get indication whether camera supports on-screen display for video and
// snapshot
virtual bool GetCameraSupportsOSD() = 0;
// Get indication whether camera supports on-screen display for video and
// snapshot
virtual bool GetCameraSupportsOSD() = 0;
// Get indication whether camera supports soft recording and livestream
// privacy modes
virtual bool GetCameraSupportsSoftPrivacy() = 0;
// Get indication whether camera supports soft recording and livestream
// privacy modes
virtual bool GetCameraSupportsSoftPrivacy() = 0;
// Get indication of the min resolution(pixels) that camera allows for
// its viewport.
virtual VideoResolutionStruct &GetMinViewport() = 0;
// Get indication of the min resolution(pixels) that camera allows for
// its viewport.
virtual VideoResolutionStruct & GetMinViewport() = 0;
// Get the rate distortion tradeoff points(min bitrate for resolutions) for
// video codecs.
virtual std::vector<RateDistortionTradeOffStruct> &
GetRateDistortionTradeOffPoints() = 0;
// Get the rate distortion tradeoff points(min bitrate for resolutions) for
// video codecs.
virtual std::vector<RateDistortionTradeOffStruct> & GetRateDistortionTradeOffPoints() = 0;
// Get the maximum size of content buffer in bytes. This buffer holds
// compressed and/or raw audio/video content.
virtual uint32_t GetMaxContentBufferSize() = 0;
// Get the maximum size of content buffer in bytes. This buffer holds
// compressed and/or raw audio/video content.
virtual uint32_t GetMaxContentBufferSize() = 0;
// Get microphone capabilities.
virtual AudioCapabilitiesStruct &GetMicrophoneCapabilities() = 0;
// Get microphone capabilities.
virtual AudioCapabilitiesStruct & GetMicrophoneCapabilities() = 0;
// Get speaker capabilities.
virtual AudioCapabilitiesStruct &GetSpeakerCapabilities() = 0;
// Get speaker capabilities.
virtual AudioCapabilitiesStruct & GetSpeakerCapabilities() = 0;
// Get snapshot capabilities
virtual std::vector<SnapshotCapabilitiesStruct> &
GetSnapshotCapabilities() = 0;
// Get snapshot capabilities
virtual std::vector<SnapshotCapabilitiesStruct> & GetSnapshotCapabilities() = 0;
// Get the maximum network bandwidth(mbps) that the camera would consume
// for transmission of its media streams.
virtual uint32_t GetMaxNetworkBandwidth() = 0;
// Get the maximum network bandwidth(mbps) that the camera would consume
// for transmission of its media streams.
virtual uint32_t GetMaxNetworkBandwidth() = 0;
// Get the current frame rate of the camera sensor.
virtual uint16_t GetCurrentFrameRate() = 0;
// Get the current frame rate of the camera sensor.
virtual uint16_t GetCurrentFrameRate() = 0;
// Enable/Disable High Dynamic Range mode.
virtual CameraError SetHDRMode(bool hdrMode) = 0;
// Enable/Disable High Dynamic Range mode.
virtual CameraError SetHDRMode(bool hdrMode) = 0;
// Get the current camera HDR mode.
virtual bool GetHDRMode() = 0;
// Get the current camera HDR mode.
virtual bool GetHDRMode() = 0;
// Get Supported Stream usages; Typically set by manudacturer.
// This also sets the default priority of the stream usages.
virtual std::vector<StreamUsageEnum> &GetSupportedStreamUsages() = 0;
// Get Supported Stream usages; Typically set by manudacturer.
// This also sets the default priority of the stream usages.
virtual std::vector<StreamUsageEnum> & GetSupportedStreamUsages() = 0;
// Get stream usage priorities as an ordered list. This is expected to
// be a subset of the SupportedStreamUsages.
virtual std::vector<StreamUsageEnum> &GetStreamUsagePriorities() = 0;
virtual CameraError SetStreamUsagePriorities(
std::vector<StreamUsageEnum> streamUsagePriorities) = 0;
// Get stream usage priorities as an ordered list. This is expected to
// be a subset of the SupportedStreamUsages.
virtual std::vector<StreamUsageEnum> & GetStreamUsagePriorities() = 0;
virtual CameraError SetStreamUsagePriorities(std::vector<StreamUsageEnum> streamUsagePriorities) = 0;
// Get/Set soft recording privacy mode
virtual CameraError
SetSoftRecordingPrivacyModeEnabled(bool softRecordingPrivacyMode) = 0;
virtual bool GetSoftRecordingPrivacyModeEnabled() = 0;
// Get/Set soft recording privacy mode
virtual CameraError SetSoftRecordingPrivacyModeEnabled(bool softRecordingPrivacyMode) = 0;
virtual bool GetSoftRecordingPrivacyModeEnabled() = 0;
// Get/Set soft livestream privacy mode
virtual CameraError
SetSoftLivestreamPrivacyModeEnabled(bool softLivestreamPrivacyMode) = 0;
virtual bool GetSoftLivestreamPrivacyModeEnabled() = 0;
// Get/Set soft livestream privacy mode
virtual CameraError SetSoftLivestreamPrivacyModeEnabled(bool softLivestreamPrivacyMode) = 0;
virtual bool GetSoftLivestreamPrivacyModeEnabled() = 0;
// Does camera have a hard privacy switch
virtual bool HasHardPrivacySwitch() = 0;
// Does camera have a hard privacy switch
virtual bool HasHardPrivacySwitch() = 0;
// Get/Set hard privacy mode
virtual CameraError SetHardPrivacyMode(bool hardPrivacyMode) = 0;
virtual bool GetHardPrivacyMode() = 0;
// Get/Set hard privacy mode
virtual CameraError SetHardPrivacyMode(bool hardPrivacyMode) = 0;
virtual bool GetHardPrivacyMode() = 0;
// Get/Set night vision
virtual CameraError SetNightVision(TriStateAutoEnum nightVision) = 0;
virtual TriStateAutoEnum GetNightVision() = 0;
// Get/Set night vision
virtual CameraError SetNightVision(TriStateAutoEnum nightVision) = 0;
virtual TriStateAutoEnum GetNightVision() = 0;
// Set the viewport for all streams
virtual CameraError SetViewport(
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type
&viewPort) = 0;
// Set the viewport for all streams
virtual CameraError SetViewport(const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & viewPort) = 0;
// Get the current camera viewport.
virtual const chip::app::Clusters::Globals::Structs::ViewportStruct::Type &
GetViewport() = 0;
// Get the current camera viewport.
virtual const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & GetViewport() = 0;
// Set the viewport for a specific stream
virtual CameraError SetViewport(
VideoStream &stream,
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type
&viewPort) = 0;
// Set the viewport for a specific stream
virtual CameraError SetViewport(VideoStream & stream,
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & viewPort) = 0;
// Does camera have a speaker
virtual bool HasSpeaker() = 0;
// Does camera have a speaker
virtual bool HasSpeaker() = 0;
// Mute/Unmute speaker.
virtual bool GetSpeakerMuted() = 0;
virtual CameraError SetSpeakerMuted(bool muteSpeaker) = 0;
// Mute/Unmute speaker.
virtual bool GetSpeakerMuted() = 0;
virtual CameraError SetSpeakerMuted(bool muteSpeaker) = 0;
// Get/Set speaker volume level.
virtual uint8_t GetSpeakerVolume() = 0;
virtual CameraError SetSpeakerVolume(uint8_t speakerVol) = 0;
// Get/Set speaker volume level.
virtual uint8_t GetSpeakerVolume() = 0;
virtual CameraError SetSpeakerVolume(uint8_t speakerVol) = 0;
// Get the speaker max and min levels.
virtual uint8_t GetSpeakerMaxLevel() = 0;
virtual uint8_t GetSpeakerMinLevel() = 0;
// Get the speaker max and min levels.
virtual uint8_t GetSpeakerMaxLevel() = 0;
virtual uint8_t GetSpeakerMinLevel() = 0;
// Does camera have a microphone
virtual bool HasMicrophone() = 0;
// Does camera have a microphone
virtual bool HasMicrophone() = 0;
// Mute/Unmute microphone.
virtual CameraError SetMicrophoneMuted(bool muteMicrophone) = 0;
virtual bool GetMicrophoneMuted() = 0;
// Mute/Unmute microphone.
virtual CameraError SetMicrophoneMuted(bool muteMicrophone) = 0;
virtual bool GetMicrophoneMuted() = 0;
// Set microphone volume level.
virtual CameraError SetMicrophoneVolume(uint8_t microphoneVol) = 0;
virtual uint8_t GetMicrophoneVolume() = 0;
// Set microphone volume level.
virtual CameraError SetMicrophoneVolume(uint8_t microphoneVol) = 0;
virtual uint8_t GetMicrophoneVolume() = 0;
// Get the microphone max and min levels.
virtual uint8_t GetMicrophoneMaxLevel() = 0;
virtual uint8_t GetMicrophoneMinLevel() = 0;
// Get the microphone max and min levels.
virtual uint8_t GetMicrophoneMaxLevel() = 0;
virtual uint8_t GetMicrophoneMinLevel() = 0;
// Get/Set image control attributes
virtual CameraError SetImageRotation(uint16_t imageRotation) = 0;
virtual uint16_t GetImageRotation() = 0;
// Get/Set image control attributes
virtual CameraError SetImageRotation(uint16_t imageRotation) = 0;
virtual uint16_t GetImageRotation() = 0;
virtual CameraError SetImageFlipHorizontal(bool imageFlipHorizontal) = 0;
virtual bool GetImageFlipHorizontal() = 0;
virtual CameraError SetImageFlipHorizontal(bool imageFlipHorizontal) = 0;
virtual bool GetImageFlipHorizontal() = 0;
virtual CameraError SetImageFlipVertical(bool imageFlipVertical) = 0;
virtual bool GetImageFlipVertical() = 0;
virtual CameraError SetImageFlipVertical(bool imageFlipVertical) = 0;
virtual bool GetImageFlipVertical() = 0;
// Does camera have local storage
virtual bool HasLocalStorage() = 0;
// Does camera have local storage
virtual bool HasLocalStorage() = 0;
virtual CameraError
SetLocalVideoRecordingEnabled(bool localVideoRecordingEnabled) = 0;
virtual bool GetLocalVideoRecordingEnabled() = 0;
virtual CameraError SetLocalVideoRecordingEnabled(bool localVideoRecordingEnabled) = 0;
virtual bool GetLocalVideoRecordingEnabled() = 0;
virtual CameraError
SetLocalSnapshotRecordingEnabled(bool localSnapshotRecordingEnabled) = 0;
virtual bool GetLocalSnapshotRecordingEnabled() = 0;
virtual CameraError SetLocalSnapshotRecordingEnabled(bool localSnapshotRecordingEnabled) = 0;
virtual bool GetLocalSnapshotRecordingEnabled() = 0;
// Does camera have a status light
virtual bool HasStatusLight() = 0;
// Does camera have a status light
virtual bool HasStatusLight() = 0;
virtual CameraError SetStatusLightEnabled(bool statusLightEnabled) = 0;
virtual bool GetStatusLightEnabled();
};
virtual CameraError SetStatusLightEnabled(bool statusLightEnabled) = 0;
virtual bool GetStatusLightEnabled();
};
virtual CameraHALInterface &GetCameraHALInterface() = 0;
virtual CameraHALInterface & GetCameraHALInterface() = 0;
};
@@ -1,6 +1,6 @@
#pragma once
#include <app/clusters/webrtc-transport-provider-server/webrtc-transport-provider-server.h>
#include <app/clusters/webrtc-transport-provider-server/WebRTCTransportProviderCluster.h>
namespace chip {
namespace app {
@@ -14,9 +14,7 @@ class WebRTCTransportProviderController {
public:
virtual ~WebRTCTransportProviderController() = default;
virtual void
SetWebRTCTransportProvider(std::unique_ptr<WebRTCTransportProviderServer>
webRTCTransportProvider) = 0;
virtual void SetWebRTCTransportProvider(WebRTCTransportProviderCluster *webRTCTransportProvider) = 0;
};
} // namespace WebRTCTransportProvider
+50 -29
View File
@@ -1,3 +1,20 @@
/*
*
* 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 <functional>
@@ -9,46 +26,50 @@
class WebRTCPeerConnection;
class WebRTCTrack;
enum class SDPType : uint8_t { Offer, Answer, Pranswer, Rollback };
enum class MediaType : uint8_t {
Audio,
Video,
enum class SDPType : uint8_t
{
Offer,
Answer,
Pranswer,
Rollback
};
using OnLocalDescriptionCallback =
std::function<void(const std::string &sdp, SDPType type)>;
using OnICECandidateCallback =
std::function<void(const std::string &candidate)>;
using OnConnectionStateCallback = std::function<void(bool connected)>;
using OnTrackCallback = std::function<void(std::shared_ptr<WebRTCTrack> track)>;
enum class MediaType : uint8_t
{
Audio,
Video,
};
using OnLocalDescriptionCallback = std::function<void(const std::string & sdp, SDPType type)>;
using OnICECandidateCallback = std::function<void(const std::string & candidate)>;
using OnConnectionStateCallback = std::function<void(bool connected)>;
using OnTrackCallback = std::function<void(std::shared_ptr<WebRTCTrack> track)>;
// Abstract track interface
class WebRTCTrack {
class WebRTCTrack
{
public:
virtual ~WebRTCTrack() = default;
virtual ~WebRTCTrack() = default;
virtual void SendData(const char *data, size_t size) = 0;
virtual bool IsReady() = 0;
virtual std::string GetType() = 0; // "video" or "audio"
virtual void SendData(const char * data, size_t size) = 0;
virtual bool IsReady() = 0;
virtual std::string GetType() = 0; // "video" or "audio"
};
// Abstract peer connection interface
class WebRTCPeerConnection {
class WebRTCPeerConnection
{
public:
virtual ~WebRTCPeerConnection() = default;
virtual ~WebRTCPeerConnection() = default;
virtual void SetCallbacks(OnLocalDescriptionCallback onLocalDescription,
OnICECandidateCallback onICECandidate,
OnConnectionStateCallback onConnectionState,
OnTrackCallback onTrack) = 0;
virtual void Close() = 0;
virtual void CreateOffer(uint16_t sessionId) = 0;
virtual void CreateAnswer() = 0;
virtual void SetRemoteDescription(const std::string &sdp, SDPType type) = 0;
virtual void AddRemoteCandidate(const std::string &candidate,
const std::string &mid) = 0;
virtual std::shared_ptr<WebRTCTrack> AddTrack(MediaType mediaType) = 0;
virtual void SetCallbacks(OnLocalDescriptionCallback onLocalDescription, OnICECandidateCallback onICECandidate,
OnConnectionStateCallback onConnectionState, OnTrackCallback onTrack) = 0;
virtual void Close() = 0;
virtual void CreateOffer(uint16_t sessionId) = 0;
virtual void CreateAnswer() = 0;
virtual void SetRemoteDescription(const std::string & sdp, SDPType type) = 0;
virtual void AddRemoteCandidate(const std::string & candidate, const std::string & mid) = 0;
virtual std::shared_ptr<WebRTCTrack> AddTrack(MediaType mediaType) = 0;
};
std::shared_ptr<WebRTCPeerConnection> CreateWebRTCPeerConnection();
+133 -107
View File
@@ -1,157 +1,183 @@
/*
*
* 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.
*/
#include "webrtc-abstract.h"
#include <lib/support/logging/CHIPLogging.h>
#include <webrtc-transport.h>
WebrtcTransport::WebrtcTransport() {
ChipLogProgress(Camera, "WebrtcTransport created");
mRequestArgs = {0, 0, 0, 0, 0, 0}; // Initialize request arguments to zero
WebrtcTransport::WebrtcTransport()
{
ChipLogProgress(Camera, "WebrtcTransport created");
mRequestArgs = { 0, 0, 0, 0, 0, 0 }; // Initialize request arguments to zero
}
WebrtcTransport::~WebrtcTransport() {
ClosePeerConnection();
ChipLogProgress(Camera, "WebrtcTransport destroyed for sessionID: [%u]",
mRequestArgs.sessionId);
WebrtcTransport::~WebrtcTransport()
{
ClosePeerConnection();
ChipLogProgress(Camera, "WebrtcTransport destroyed for sessionID: [%u]", mRequestArgs.sessionId);
}
void WebrtcTransport::SetCallbacks(
OnTransportLocalDescriptionCallback onLocalDescription,
OnTransportConnectionStateCallback onConnectionState) {
mOnLocalDescription = onLocalDescription;
mOnConnectionState = onConnectionState;
void WebrtcTransport::SetCallbacks(OnTransportLocalDescriptionCallback onLocalDescription,
OnTransportConnectionStateCallback onConnectionState)
{
mOnLocalDescription = onLocalDescription;
mOnConnectionState = onConnectionState;
}
void WebrtcTransport::SetRequestArgs(const RequestArgs &args) {
mRequestArgs = args;
void WebrtcTransport::SetRequestArgs(const RequestArgs & args)
{
mRequestArgs = args;
}
WebrtcTransport::RequestArgs &WebrtcTransport::GetRequestArgs() {
return mRequestArgs;
WebrtcTransport::RequestArgs & WebrtcTransport::GetRequestArgs()
{
return mRequestArgs;
}
const char *WebrtcTransport::GetStateStr() const {
switch (mState) {
case State::Idle:
return "Idle";
const char * WebrtcTransport::GetStateStr() const
{
switch (mState)
{
case State::Idle:
return "Idle";
case State::SendingOffer:
return "SendingOffer";
case State::SendingOffer:
return "SendingOffer";
case State::SendingAnswer:
return "SendingAnswer";
case State::SendingAnswer:
return "SendingAnswer";
case State::SendingICECandidates:
return "SendingICECandidates";
case State::SendingICECandidates:
return "SendingICECandidates";
case State::SendingEnd:
return "SendingEnd";
}
return "N/A";
case State::SendingEnd:
return "SendingEnd";
}
return "N/A";
}
void WebrtcTransport::MoveToState(const State targetState) {
mState = targetState;
ChipLogProgress(Camera, "WebrtcTransport moving to [ %s ]", GetStateStr());
void WebrtcTransport::MoveToState(const State targetState)
{
mState = targetState;
ChipLogProgress(Camera, "WebrtcTransport moving to [ %s ]", GetStateStr());
}
void WebrtcTransport::SetCommandType(const CommandType commandtype) {
mCommandType = commandtype;
void WebrtcTransport::SetCommandType(const CommandType commandtype)
{
mCommandType = commandtype;
}
void WebrtcTransport::Start() {
if (mPeerConnection.get()) {
ChipLogProgress(Camera, "Start, mPeerConnection is already created");
return;
}
void WebrtcTransport::Start()
{
if (mPeerConnection.get())
{
ChipLogProgress(Camera, "Start, mPeerConnection is already created");
return;
}
mPeerConnection = CreateWebRTCPeerConnection();
mPeerConnection = CreateWebRTCPeerConnection();
mPeerConnection->SetCallbacks(
[this](const std::string &sdp, SDPType type) {
this->OnLocalDescription(sdp, type);
},
[this](const std::string &candidate) { this->OnICECandidate(candidate); },
[this](bool connected) { this->OnConnectionStateChanged(connected); },
[this](std::shared_ptr<WebRTCTrack> track) { this->OnTrack(track); });
mPeerConnection->SetCallbacks([this](const std::string & sdp, SDPType type) { this->OnLocalDescription(sdp, type); },
[this](const std::string & candidate) { this->OnICECandidate(candidate); },
[this](bool connected) { this->OnConnectionStateChanged(connected); },
[this](std::shared_ptr<WebRTCTrack> track) { this->OnTrack(track); });
}
void WebrtcTransport::Stop() {
mVideoTrack = nullptr;
mAudioTrack = nullptr;
if (mPeerConnection != nullptr) {
// KVSWebRTC close is handled by the KVSWebRTCManager.
// mPeerConnection->Close();
}
void WebrtcTransport::Stop()
{
mVideoTrack = nullptr;
mAudioTrack = nullptr;
}
void WebrtcTransport::AddTracks() {
if (mPeerConnection != nullptr) {
mVideoTrack = mPeerConnection->AddTrack(MediaType::Video);
mAudioTrack = mPeerConnection->AddTrack(MediaType::Audio);
}
void WebrtcTransport::AddTracks()
{
if (mPeerConnection != nullptr)
{
mVideoTrack = mPeerConnection->AddTrack(MediaType::Video);
mAudioTrack = mPeerConnection->AddTrack(MediaType::Audio);
}
}
// Implementation of SetVideoTrack method
void WebrtcTransport::SetVideoTrack(std::shared_ptr<WebRTCTrack> videoTrack) {
ChipLogProgress(Camera, "Setting video track for sessionID: %u",
mRequestArgs.sessionId);
mVideoTrack = videoTrack;
void WebrtcTransport::SetVideoTrack(std::shared_ptr<WebRTCTrack> videoTrack)
{
ChipLogProgress(Camera, "Setting video track for sessionID: %u", mRequestArgs.sessionId);
mVideoTrack = videoTrack;
}
// Implementation of SetAudioTrack method
void WebrtcTransport::SetAudioTrack(std::shared_ptr<WebRTCTrack> audioTrack) {
ChipLogProgress(Camera, "Setting audio track for sessionID: %u",
mRequestArgs.sessionId);
mAudioTrack = audioTrack;
void WebrtcTransport::SetAudioTrack(std::shared_ptr<WebRTCTrack> audioTrack)
{
ChipLogProgress(Camera, "Setting audio track for sessionID: %u", mRequestArgs.sessionId);
mAudioTrack = audioTrack;
}
void WebrtcTransport::AddRemoteCandidate(const std::string &candidate,
const std::string &mid) {
ChipLogProgress(Camera, "Adding remote candidate for sessionID: %u",
mRequestArgs.sessionId);
mPeerConnection->AddRemoteCandidate(candidate, mid);
void WebrtcTransport::AddRemoteCandidate(const std::string & candidate, const std::string & mid)
{
ChipLogProgress(Camera, "Adding remote candidate for sessionID: %u", mRequestArgs.sessionId);
mPeerConnection->AddRemoteCandidate(candidate, mid);
}
// WebRTC Callbacks
void WebrtcTransport::OnLocalDescription(const std::string &sdp, SDPType type) {
ChipLogProgress(Camera, "Local description received for sessionID: %u",
mRequestArgs.sessionId);
mLocalSdp = sdp;
mLocalSdpType = type;
if (mOnLocalDescription)
mOnLocalDescription(sdp, type, mRequestArgs.sessionId);
void WebrtcTransport::OnLocalDescription(const std::string & sdp, SDPType type)
{
ChipLogProgress(Camera, "Local description received for sessionID: %u", mRequestArgs.sessionId);
mLocalSdp = sdp;
mLocalSdpType = type;
if (mOnLocalDescription)
mOnLocalDescription(sdp, type, mRequestArgs.sessionId);
}
bool WebrtcTransport::ClosePeerConnection() {
if (mPeerConnection == nullptr) {
return false;
}
// KVSWebRTC close is handled by the KVSWebRTCManager.
return true;
bool WebrtcTransport::ClosePeerConnection()
{
if (mPeerConnection == nullptr)
{
return false;
}
// KVSWebRTC close is handled by the KVSWebRTCManager.
return true;
}
void WebrtcTransport::OnICECandidate(const std::string &candidate) {
ChipLogProgress(Camera, "ICE Candidate received for sessionID: %u",
mRequestArgs.sessionId);
mLocalCandidates.push_back(candidate);
ChipLogProgress(Camera, "Local Candidate:");
ChipLogProgress(Camera, "%s", candidate.c_str());
void WebrtcTransport::OnICECandidate(const std::string & candidate)
{
ChipLogProgress(Camera, "ICE Candidate received for sessionID: %u", mRequestArgs.sessionId);
mLocalCandidates.push_back(candidate);
ChipLogProgress(Camera, "Local Candidate:");
ChipLogProgress(Camera, "%s", candidate.c_str());
}
void WebrtcTransport::OnConnectionStateChanged(bool connected) {
ChipLogProgress(Camera, "Connection state changed for sessionID: %u",
mRequestArgs.sessionId);
if (mOnConnectionState)
mOnConnectionState(connected, mRequestArgs.sessionId);
void WebrtcTransport::OnConnectionStateChanged(bool connected)
{
ChipLogProgress(Camera, "Connection state changed for sessionID: %u", mRequestArgs.sessionId);
if (mOnConnectionState)
mOnConnectionState(connected, mRequestArgs.sessionId);
}
void WebrtcTransport::OnTrack(std::shared_ptr<WebRTCTrack> track) {
ChipLogProgress(Camera, "Track received for sessionID: %u, type: %s",
mRequestArgs.sessionId, track->GetType().c_str());
if (track->GetType() == "video") {
ChipLogProgress(Camera, "Video track updated from remote peer");
SetVideoTrack(track);
} else if (track->GetType() == "audio") {
ChipLogProgress(Camera, "audio track updated from remote peer");
SetAudioTrack(track);
}
void WebrtcTransport::OnTrack(std::shared_ptr<WebRTCTrack> track)
{
ChipLogProgress(Camera, "Track received for sessionID: %u, type: %s", mRequestArgs.sessionId, track->GetType().c_str());
if (track->GetType() == "video")
{
ChipLogProgress(Camera, "Video track updated from remote peer");
SetVideoTrack(track);
}
else if (track->GetType() == "audio")
{
ChipLogProgress(Camera, "audio track updated from remote peer");
SetAudioTrack(track);
}
}
+90 -76
View File
@@ -1,112 +1,126 @@
/*
*
* 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 "webrtc-abstract.h"
#include <lib/core/DataModelTypes.h>
#include <lib/core/ScopedNodeId.h>
using OnTransportLocalDescriptionCallback = std::function<void(
const std::string &sdp, SDPType type, const int16_t sessionId)>;
using OnTransportConnectionStateCallback =
std::function<void(bool connected, const int16_t sessionId)>;
using OnTransportLocalDescriptionCallback = std::function<void(const std::string & sdp, SDPType type, const int16_t sessionId)>;
using OnTransportConnectionStateCallback = std::function<void(bool connected, const int16_t sessionId)>;
class WebrtcTransport {
class WebrtcTransport
{
public:
enum class CommandType : uint8_t {
kUndefined = 0,
kOffer = 1,
kAnswer = 2,
kICECandidates = 3,
kEnd = 4,
};
enum class CommandType : uint8_t
{
kUndefined = 0,
kOffer = 1,
kAnswer = 2,
kICECandidates = 3,
kEnd = 4,
};
enum class State : uint8_t {
Idle, ///< Default state, no communication initiated yet
SendingOffer, ///< Sending Offer command from camera
SendingAnswer, ///< Sending Answer command from camera
SendingICECandidates, ///< Sending ICECandidates command from camera
SendingEnd, ///< Sending End command from camera
};
enum class State : uint8_t
{
Idle, ///< Default state, no communication initiated yet
SendingOffer, ///< Sending Offer command from camera
SendingAnswer, ///< Sending Answer command from camera
SendingICECandidates, ///< Sending ICECandidates command from camera
SendingEnd, ///< Sending End command from camera
};
struct RequestArgs {
uint16_t sessionId;
uint16_t videoStreamId;
uint16_t audioStreamId;
chip::NodeId peerNodeId;
chip::FabricIndex fabricIndex;
chip::EndpointId originatingEndpointId;
chip::ScopedNodeId peerId;
};
struct RequestArgs
{
uint16_t sessionId;
uint16_t videoStreamId;
uint16_t audioStreamId;
chip::NodeId peerNodeId;
chip::FabricIndex fabricIndex;
chip::EndpointId originatingEndpointId;
chip::ScopedNodeId peerId;
};
WebrtcTransport();
WebrtcTransport();
~WebrtcTransport();
~WebrtcTransport();
void SetCallbacks(OnTransportLocalDescriptionCallback onLocalDescription,
OnTransportConnectionStateCallback onConnectionState);
void SetCallbacks(OnTransportLocalDescriptionCallback onLocalDescription, OnTransportConnectionStateCallback onConnectionState);
void MoveToState(const State targetState);
const char *GetStateStr() const;
void MoveToState(const State targetState);
const char * GetStateStr() const;
State GetState() { return mState; }
State GetState() { return mState; }
// Takes care of creation WebRTC peer connection and registering the necessary
// callbacks
void Start();
// Takes care of creation WebRTC peer connection and registering the necessary
// callbacks
void Start();
// Stops WebRTC peer connection and cleanup
void Stop();
// Stops WebRTC peer connection and cleanup
void Stop();
void AddTracks();
void AddTracks();
// Set video track for the transport
void SetVideoTrack(std::shared_ptr<WebRTCTrack> videoTrack);
// Set video track for the transport
void SetVideoTrack(std::shared_ptr<WebRTCTrack> videoTrack);
// Set audio track for the transport
void SetAudioTrack(std::shared_ptr<WebRTCTrack> audioTrack);
// Set audio track for the transport
void SetAudioTrack(std::shared_ptr<WebRTCTrack> audioTrack);
std::shared_ptr<WebRTCPeerConnection> GetPeerConnection() {
return mPeerConnection;
}
std::shared_ptr<WebRTCPeerConnection> GetPeerConnection() { return mPeerConnection; }
std::string GetLocalDescription() { return mLocalSdp; }
std::string GetLocalDescription() { return mLocalSdp; }
void SetSdpAnswer(std::string localSdp) { mLocalSdp = localSdp; }
void SetSdpAnswer(std::string localSdp) { mLocalSdp = localSdp; }
std::vector<std::string> GetCandidates() { return mLocalCandidates; }
std::vector<std::string> GetCandidates() { return mLocalCandidates; }
void SetCandidates(std::vector<std::string> candidates) {
mLocalCandidates = candidates;
}
void SetCandidates(std::vector<std::string> candidates) { mLocalCandidates = candidates; }
void AddRemoteCandidate(const std::string &candidate, const std::string &mid);
void AddRemoteCandidate(const std::string & candidate, const std::string & mid);
bool ClosePeerConnection();
bool ClosePeerConnection();
void SetCommandType(const CommandType commandtype);
void SetCommandType(const CommandType commandtype);
CommandType GetCommandType() { return mCommandType; }
CommandType GetCommandType() { return mCommandType; }
// WebRTC Callbacks
void OnLocalDescription(const std::string &sdp, SDPType type);
void OnICECandidate(const std::string &candidate);
void OnConnectionStateChanged(bool connected);
void OnTrack(std::shared_ptr<WebRTCTrack> track);
// WebRTC Callbacks
void OnLocalDescription(const std::string & sdp, SDPType type);
void OnICECandidate(const std::string & candidate);
void OnConnectionStateChanged(bool connected);
void OnTrack(std::shared_ptr<WebRTCTrack> track);
void SetRequestArgs(const RequestArgs &args);
RequestArgs &GetRequestArgs();
void SetRequestArgs(const RequestArgs & args);
RequestArgs & GetRequestArgs();
private:
CommandType mCommandType = CommandType::kUndefined;
State mState = State::Idle;
CommandType mCommandType = CommandType::kUndefined;
State mState = State::Idle;
std::shared_ptr<WebRTCPeerConnection> mPeerConnection;
std::shared_ptr<WebRTCTrack> mVideoTrack;
std::shared_ptr<WebRTCTrack> mAudioTrack;
std::string mLocalSdp;
SDPType mLocalSdpType;
std::vector<std::string> mLocalCandidates;
std::shared_ptr<WebRTCPeerConnection> mPeerConnection;
std::shared_ptr<WebRTCTrack> mVideoTrack;
std::shared_ptr<WebRTCTrack> mAudioTrack;
std::string mLocalSdp;
SDPType mLocalSdpType;
std::vector<std::string> mLocalCandidates;
RequestArgs mRequestArgs;
OnTransportLocalDescriptionCallback mOnLocalDescription = nullptr;
OnTransportConnectionStateCallback mOnConnectionState = nullptr;
RequestArgs mRequestArgs;
OnTransportLocalDescriptionCallback mOnLocalDescription = nullptr;
OnTransportConnectionStateCallback mOnConnectionState = nullptr;
};
+1 -1
View File
@@ -18,7 +18,7 @@ set(EXTRA_COMPONENT_DIRS
project(controller)
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H;-Wno-overloaded-virtual" APPEND)
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H;-Wno-overloaded-virtual;-Wno-error=unused-result" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND)
# We don't need Thread Network Commissioning Driver
-2
View File
@@ -16,8 +16,6 @@
#include <app_reset.h>
#include <app/clusters/ota-provider/CodegenIntegration.h>
#include <app/clusters/ota-provider/ota-provider-cluster.h>
#include <app/server/Server.h>
#include <credentials/FabricTable.h>
#include <platform/CHIPDeviceLayer.h>
+1 -1
View File
@@ -63,7 +63,7 @@ export ZAP_INSTALL_PATH=${MATTER_PATH}/.environment/cipd/packages/zap
if [ $NO_BOOTSTRAP = false ]; then
echo_log "Running Matter Setup"
cd ${MATTER_PATH}
source ${MATTER_PATH}/scripts/bootstrap.sh
source ${MATTER_PATH}/scripts/bootstrap.sh -p all,esp32
cd ${ESP_MATTER_PATH}
else
echo_log "Skipping Matter Setup"
+1 -1
View File
@@ -58,7 +58,7 @@ RUN set -x \
&& git fetch origin --depth=1 ${CHIP_CHECKOUT_REF} \
&& git checkout FETCH_HEAD \
&& ./scripts/checkout_submodules.py --platform esp32 linux --shallow \
&& bash -c "source scripts/bootstrap.sh" \
&& bash -c "source scripts/bootstrap.sh -p all,esp32" \
&& ./scripts/build_python.sh --enable_ble true --chip_detail_logging true -i out/py-env \
&& bash -c "source out/py-env/bin/activate" \
&& ./scripts/examples/gn_build_example.sh examples/chip-tool out/host \