Resolve comments

This commit is contained in:
chendejin
2024-09-27 10:35:37 +08:00
parent 367f6658dc
commit bcd364fa80
7 changed files with 140 additions and 190 deletions
+8
View File
@@ -1,3 +1,11 @@
# 15-Oct-2024
API Change
```
esp_err_t get_bounds(attribute_t *attribute, esp_matter_attr_bounds_t *bounds);
```
- Above API returns the `esp_err_t` and has parameter `bounds`.
# 28-Aug-2024
- Removed the configurability of the NameSupport attribute of the Groups cluster and enabled
+1 -1
View File
@@ -88,7 +88,7 @@ typedef enum attribute_flags {
will not be written to flash immediately. A timer will be started and the attribute value will be written after
timeout. */
ATTRIBUTE_FLAG_DEFERRED = ATTRIBUTE_FLAG_NULLABLE << 2, /* 0x100 */
/** The attribute is managed internally and is not stored in the ESP Matter database.
/** The attribute is managed internally and is not stored in the ESP Matter database.
If not set, ATTRIBUTE_FLAG_EXTERNAL_STORAGE flag will be enabled. */
ATTRIBUTE_FLAG_MANAGED_INTERNALLY = ATTRIBUTE_FLAG_NULLABLE << 3, /* 0x200 */
} attribute_flags_t;
+77 -80
View File
@@ -42,9 +42,7 @@ void DispatchSingleClusterCommandCommon(const ConcreteCommandPath &command_path,
uint32_t command_id = command_path.mCommandId;
ESP_LOGI(TAG, "Received command 0x%08" PRIX32 " for endpoint 0x%04" PRIX16 "'s cluster 0x%08" PRIX32 "", command_id, endpoint_id, cluster_id);
node_t *node = node::get();
endpoint_t *endpoint = endpoint::get(node, endpoint_id);
cluster_t *cluster = cluster::get(endpoint, cluster_id);
cluster_t *cluster = cluster::get(endpoint_id, cluster_id);
if (!cluster) {
return;
}
@@ -57,29 +55,28 @@ void DispatchSingleClusterCommandCommon(const ConcreteCommandPath &command_path,
esp_err_t err = ESP_OK;
TLVReader tlv_reader;
tlv_reader.Init(tlv_data);
if ((err == ESP_OK) && standard_callback) {
err = standard_callback(command_path, tlv_data, opaque_ptr);
if (standard_callback) {
standard_callback(command_path, tlv_data, opaque_ptr);
}
if (!command) {
return;
}
callback_t callback = get_user_callback(command);
if (callback) {
err = callback(command_path, tlv_reader, opaque_ptr);
}
callback = get_callback(command);
if ((err == ESP_OK) && callback) {
err = callback(command_path, tlv_data, opaque_ptr);
}
int flags = get_flags(command);
if (flags & COMMAND_FLAG_CUSTOM) {
chip::app::CommandHandler *command_obj = (chip::app::CommandHandler *)opaque_ptr;
if (!command_obj) {
ESP_LOGE(TAG, "Command Object cannot be NULL");
return;
if (command) {
callback_t callback = get_user_callback(command);
if (callback) {
err = callback(command_path, tlv_reader, opaque_ptr);
}
callback = get_callback(command);
if ((err == ESP_OK) && callback) {
err = callback(command_path, tlv_data, opaque_ptr);
}
int flags = get_flags(command);
if (flags & COMMAND_FLAG_CUSTOM) {
chip::app::CommandHandler *command_obj = (chip::app::CommandHandler *)opaque_ptr;
if (!command_obj) {
ESP_LOGE(TAG, "Command Object cannot be NULL");
return;
}
command_obj->AddStatus(command_path, err == ESP_OK ? chip::Protocols::InteractionModel::Status::Success :
chip::Protocols::InteractionModel::Status::Failure);
}
command_obj->AddStatus(command_path, err == ESP_OK ? chip::Protocols::InteractionModel::Status::Success :
chip::Protocols::InteractionModel::Status::Failure);
}
}
@@ -1594,12 +1591,12 @@ command_t *create_reset_counts(cluster_t *cluster)
namespace ethernet_network_diagnostics {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{EthernetNetworkDiagnostics::Commands::ResetCounts::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_ethernet_reset_counts},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_reset_counts(cluster_t *cluster)
{
@@ -1613,12 +1610,12 @@ command_t *create_reset_counts(cluster_t *cluster)
namespace diagnostic_logs {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{DiagnosticLogs::Commands::RetrieveLogsRequest::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_retrieve_logs_request},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{DiagnosticLogs::Commands::RetrieveLogsResponse::Id, COMMAND_FLAG_GENERATED, NULL},
};
@@ -1640,14 +1637,14 @@ command_t *create_retrieve_logs_response(cluster_t *cluster)
namespace general_diagnostics {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{GeneralDiagnostics::Commands::TestEventTrigger::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_test_event_trigger},
{GeneralDiagnostics::Commands::TimeSnapshot::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_time_snap_shot},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{GeneralDiagnostics::Commands::TimeSnapshotResponse::Id, COMMAND_FLAG_GENERATED, NULL},
};
@@ -1687,14 +1684,14 @@ command_t *create_reset_watermarks(cluster_t *cluster)
namespace group_key_management {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{GroupKeyManagement::Commands::KeySetWrite::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_key_set_write},
{GroupKeyManagement::Commands::KeySetRead::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_key_set_read},
{GroupKeyManagement::Commands::KeySetRemove::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_key_set_remove},
{GroupKeyManagement::Commands::KeySetReadAllIndices::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_key_set_read_all_indices},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{GroupKeyManagement::Commands::KeySetReadResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::Id, COMMAND_FLAG_GENERATED, NULL},
};
@@ -1741,7 +1738,7 @@ command_t *create_key_set_read_all_indices_response(cluster_t *cluster)
namespace general_commissioning {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{GeneralCommissioning::Commands::ArmFailSafe::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_arm_fail_safe},
{GeneralCommissioning::Commands::SetRegulatoryConfig::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_set_regulatory_config},
@@ -1749,7 +1746,7 @@ constexpr const command_list_t accepted_command_list[] = {
esp_matter_command_callback_commissioning_complete},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{GeneralCommissioning::Commands::ArmFailSafeResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{GeneralCommissioning::Commands::SetRegulatoryConfigResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{GeneralCommissioning::Commands::CommissioningCompleteResponse::Id, COMMAND_FLAG_GENERATED, NULL},
@@ -1797,14 +1794,14 @@ command_t *create_commissioning_complete_response(cluster_t *cluster)
namespace network_commissioning {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{NetworkCommissioning::Commands::ScanNetworks::Id, COMMAND_FLAG_ACCEPTED, NULL},
{NetworkCommissioning::Commands::RemoveNetwork::Id, COMMAND_FLAG_ACCEPTED, NULL},
{NetworkCommissioning::Commands::ConnectNetwork::Id, COMMAND_FLAG_ACCEPTED, NULL},
{NetworkCommissioning::Commands::ReorderNetwork::Id, COMMAND_FLAG_ACCEPTED, NULL},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{NetworkCommissioning::Commands::ScanNetworksResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{NetworkCommissioning::Commands::NetworkConfigResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{NetworkCommissioning::Commands::ConnectNetworkResponse::Id, COMMAND_FLAG_GENERATED, NULL},
@@ -1870,14 +1867,14 @@ command_t *create_connect_network_response(cluster_t *cluster)
namespace administrator_commissioning {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{AdministratorCommissioning::Commands::OpenCommissioningWindow::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_open_commissioning_window},
{AdministratorCommissioning::Commands::RevokeCommissioning::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_revoke_commissioning},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_open_commissioning_window(cluster_t *cluster)
{
@@ -1904,7 +1901,7 @@ command_t *create_revoke_commissioning(cluster_t *cluster)
namespace operational_credentials {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{OperationalCredentials::Commands::AttestationRequest::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_attestation_request},
{OperationalCredentials::Commands::CertificateChainRequest::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_certificate_chain_request},
{OperationalCredentials::Commands::CSRRequest::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_csr_request},
@@ -1915,7 +1912,7 @@ constexpr const command_list_t accepted_command_list[] = {
{OperationalCredentials::Commands::AddTrustedRootCertificate::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_add_trusted_root_certificate},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{OperationalCredentials::Commands::AttestationResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{OperationalCredentials::Commands::CertificateChainResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{OperationalCredentials::Commands::CSRResponse::Id, COMMAND_FLAG_GENERATED, NULL},
@@ -2000,7 +1997,7 @@ command_t *create_noc_response(cluster_t *cluster)
namespace ota_provider {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{OtaSoftwareUpdateProvider::Commands::QueryImage::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_query_image},
{OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id, COMMAND_FLAG_ACCEPTED,
@@ -2009,7 +2006,7 @@ constexpr const command_list_t accepted_command_list[] = {
esp_matter_command_callback_notify_update_applied},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{OtaSoftwareUpdateProvider::Commands::QueryImageResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{OtaSoftwareUpdateProvider::Commands::ApplyUpdateResponse::Id, COMMAND_FLAG_GENERATED, NULL},
};
@@ -2050,12 +2047,12 @@ command_t *create_apply_update_response(cluster_t *cluster)
namespace ota_requestor {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{OtaSoftwareUpdateRequestor::Commands::AnnounceOTAProvider::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_announce_ota_provider},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_announce_ota_provider(cluster_t *cluster)
{
@@ -2069,11 +2066,11 @@ command_t *create_announce_ota_provider(cluster_t *cluster)
namespace identify {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{Identify::Commands::Identify::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_identify},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_identify(cluster_t *cluster)
{
@@ -2093,7 +2090,7 @@ command_t *create_trigger_effect(cluster_t *cluster)
namespace groups {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{Groups::Commands::AddGroup::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_add_group},
{Groups::Commands::ViewGroup::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_view_group},
{Groups::Commands::GetGroupMembership::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_get_group_membership},
@@ -2103,7 +2100,7 @@ constexpr const command_list_t accepted_command_list[] = {
esp_matter_command_callback_add_group_if_identifying},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{Groups::Commands::AddGroupResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{Groups::Commands::ViewGroupResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{Groups::Commands::GetGroupMembershipResponse::Id, COMMAND_FLAG_GENERATED, NULL},
@@ -2203,7 +2200,7 @@ command_t *create_stay_active_request(cluster_t *cluster)
namespace scenes_management {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{ScenesManagement::Commands::AddScene::Id, COMMAND_FLAG_ACCEPTED, NULL},
{ScenesManagement::Commands::ViewScene::Id, COMMAND_FLAG_ACCEPTED, NULL},
{ScenesManagement::Commands::RemoveScene::Id, COMMAND_FLAG_ACCEPTED, NULL},
@@ -2213,7 +2210,7 @@ constexpr const command_list_t accepted_command_list[] = {
{ScenesManagement::Commands::GetSceneMembership::Id, COMMAND_FLAG_ACCEPTED, NULL},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{ScenesManagement::Commands::AddSceneResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{ScenesManagement::Commands::ViewSceneResponse::Id, COMMAND_FLAG_GENERATED, NULL},
{ScenesManagement::Commands::RemoveSceneResponse::Id, COMMAND_FLAG_GENERATED, NULL},
@@ -2306,11 +2303,11 @@ command_t *create_copy_scene_response(cluster_t *cluster)
namespace on_off {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{OnOff::Commands::Off::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_off},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_off(cluster_t *cluster)
{
@@ -2354,7 +2351,7 @@ command_t *create_on_with_timed_off(cluster_t *cluster)
namespace level_control {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{LevelControl::Commands::MoveToLevel::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_move_to_level},
{LevelControl::Commands::Move::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_move},
{LevelControl::Commands::Step::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_step},
@@ -2369,7 +2366,7 @@ constexpr const command_list_t accepted_command_list[] = {
esp_matter_command_callback_stop_with_on_off},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_move_to_level(cluster_t *cluster)
{
@@ -2551,12 +2548,12 @@ command_t *create_color_loop_set(cluster_t *cluster)
namespace thermostat {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{Thermostat::Commands::SetpointRaiseLower::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_setpoint_raise_lower},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_setpoint_raise_lower(cluster_t *cluster)
{
@@ -2636,12 +2633,12 @@ command_t *create_self_test_request(cluster_t *cluster)
namespace door_lock {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{DoorLock::Commands::LockDoor::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_lock_door},
{DoorLock::Commands::UnlockDoor::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_unlock_door},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_lock_door(cluster_t *cluster)
{
@@ -2799,13 +2796,13 @@ command_t *create_unbolt_door(cluster_t *cluster)
namespace window_covering {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{WindowCovering::Commands::UpOrOpen::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_up_or_open},
{WindowCovering::Commands::DownOrClose::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_down_or_close},
{WindowCovering::Commands::StopMotion::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_stop_motion},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_up_or_open(cluster_t *cluster)
{
@@ -2855,11 +2852,11 @@ command_t *create_go_to_tilt_percentage(cluster_t *cluster)
namespace mode_select {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{ModeSelect::Commands::ChangeToMode::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_change_to_mode},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_change_to_mode(cluster_t *cluster)
{
@@ -2872,12 +2869,12 @@ command_t *create_change_to_mode(cluster_t *cluster)
namespace temperature_control {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{TemperatureControl::Commands::SetTemperature::Id, COMMAND_FLAG_ACCEPTED,
esp_matter_command_callback_set_temperature},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_set_temperature(cluster_t *cluster)
{
@@ -2939,11 +2936,11 @@ command_t *create_change_to_mode_response(cluster_t *cluster)
namespace keypad_input {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{KeypadInput::Commands::SendKey::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_send_key},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{KeypadInput::Commands::SendKeyResponse::Id, COMMAND_FLAG_GENERATED, NULL},
};
@@ -2978,12 +2975,12 @@ command_t *create_enable_disable_alarm(cluster_t *cluster)
namespace energy_evse {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{EnergyEvse::Commands::Disable::Id, COMMAND_FLAG_ACCEPTED, NULL},
{EnergyEvse::Commands::EnableCharging::Id, COMMAND_FLAG_ACCEPTED, NULL},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_disable(cluster_t *cluster)
{
@@ -3031,11 +3028,11 @@ command_t *create_get_targets_response(cluster_t *cluster)
namespace microwave_oven_control {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{MicrowaveOvenControl::Commands::SetCookingParameters::Id, COMMAND_FLAG_ACCEPTED, NULL},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_set_cooking_parameters(cluster_t *cluster)
{
@@ -3053,12 +3050,12 @@ command_t *create_add_more_time(cluster_t *cluster)
namespace valve_configuration_and_control {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{ValveConfigurationAndControl::Commands::Open::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_open},
{ValveConfigurationAndControl::Commands::Close::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_close},
};
constexpr const command_list_t generated_command_list[] = {};
constexpr const command_entry_t generated_command_list[] = {};
command_t *create_open(cluster_t *cluster)
{
@@ -3121,13 +3118,13 @@ command_t *create_cancel_request(cluster_t *cluster)
namespace thread_border_router_management {
namespace command {
constexpr const command_list_t accepted_command_list[] = {
constexpr const command_entry_t accepted_command_list[] = {
{ThreadBorderRouterManagement::Commands::GetActiveDatasetRequest::Id, COMMAND_FLAG_ACCEPTED, NULL},
{ThreadBorderRouterManagement::Commands::GetPendingDatasetRequest::Id, COMMAND_FLAG_ACCEPTED, NULL},
{ThreadBorderRouterManagement::Commands::SetActiveDatasetRequest::Id, COMMAND_FLAG_ACCEPTED, NULL},
};
constexpr const command_list_t generated_command_list[] = {
constexpr const command_entry_t generated_command_list[] = {
{ThreadBorderRouterManagement::Commands::DatasetResponse::Id, COMMAND_FLAG_GENERATED, NULL},
};
@@ -3169,13 +3166,13 @@ command_t *create_set_pending_dataset_request(cluster_t *cluster)
namespace esp_matter {
namespace command {
#define GET_ACCEPTED_COMMAND_COUNT(cluster) sizeof(cluster::command::accepted_command_list) / sizeof(command_list_t)
#define GET_ACCEPTED_COMMAND_COUNT(cluster) sizeof(cluster::command::accepted_command_list) / sizeof(command_entry_t)
#define GET_ACCEPTED_COMMAND_LIST(cluster) \
static_cast<const command_list_t *>(&cluster::command::accepted_command_list[0])
static_cast<const command_entry_t *>(&cluster::command::accepted_command_list[0])
#define GET_GENERATED_COMMAND_COUNT(cluster) sizeof(cluster::command::generated_command_list) / sizeof(command_list_t)
#define GET_GENERATED_COMMAND_COUNT(cluster) sizeof(cluster::command::generated_command_list) / sizeof(command_entry_t)
#define GET_GENERATED_COMMAND_LIST(cluster) \
static_cast<const command_list_t *>(&cluster::command::generated_command_list[0])
static_cast<const command_entry_t *>(&cluster::command::generated_command_list[0])
#define GET_COMMAND_COUNT_LIST(cluster) \
GET_ACCEPTED_COMMAND_COUNT(cluster), GET_GENERATED_COMMAND_COUNT(cluster), GET_ACCEPTED_COMMAND_LIST(cluster), \
@@ -3211,7 +3208,7 @@ constexpr const cluster_command_t cluster_command_table[] = {
};
#if defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTER_ENABLE_DATA_MODEL)
const command_list_t *get_cluster_accepted_command_list(uint32_t cluster_id)
const command_entry_t *get_cluster_accepted_command_list(uint32_t cluster_id)
{
for (auto const &cluster_command : cluster_command_table) {
if (cluster_command.cluster_id == cluster_id) {
@@ -3231,7 +3228,7 @@ size_t get_cluster_accepted_command_count(uint32_t cluster_id)
return 0;
}
const command_list_t *get_cluster_generated_command_list(uint32_t cluster_id)
const command_entry_t *get_cluster_generated_command_list(uint32_t cluster_id)
{
for (auto const &cluster_command : cluster_command_table) {
if (cluster_command.cluster_id == cluster_id) {
+3 -3
View File
@@ -17,7 +17,7 @@
#include <esp_matter.h>
namespace esp_matter {
struct command_list_t {
struct command_entry_t {
uint32_t command_id;
uint8_t flags;
command::callback_t callback;
@@ -27,8 +27,8 @@ struct cluster_command_t {
uint32_t cluster_id;
size_t accepted_command_count;
size_t generated_command_count;
const command_list_t *accepted_command_list;
const command_list_t *generated_command_list;
const command_entry_t *accepted_command_list;
const command_entry_t *generated_command_list;
};
namespace cluster {
+40 -98
View File
@@ -157,13 +157,14 @@ FabricDelegateImpl s_fabric_delegate;
struct _attribute_base_t {
uint16_t flags; // This struct is for attributes managed internally.
uint16_t index;
uint32_t attribute_id;
struct _attribute_base_t *next;
};
struct _attribute_t : public _attribute_base_t {
uint32_t cluster_id; // This struct is for attributes not managed internally.
uint16_t endpoint_id;
uint16_t index;
esp_matter_attr_val_t val;
attribute::callback_t override_callback;
};
@@ -304,14 +305,14 @@ static int get_count(_cluster_t *current)
namespace command {
#if defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTER_ENABLE_DATA_MODEL)
command_list_t *get_cluster_accepted_command_list(uint32_t cluster_id);
command_entry_t *get_cluster_accepted_command_list(uint32_t cluster_id);
size_t get_cluster_accepted_command_count(uint32_t cluster_id);
command_list_t *get_cluster_generated_command_list(uint32_t cluster_id);
command_entry_t *get_cluster_generated_command_list(uint32_t cluster_id);
size_t get_cluster_generated_command_count(uint32_t cluster_id);
#else
command_list_t *get_cluster_accepted_command_list(uint32_t cluster_id) { return nullptr; }
command_entry_t *get_cluster_accepted_command_list(uint32_t cluster_id) { return nullptr; }
size_t get_cluster_accepted_command_count(uint32_t cluster_id) { return 0; }
command_list_t *get_cluster_generated_command_list(uint32_t cluster_id) { return nullptr; }
command_entry_t *get_cluster_generated_command_list(uint32_t cluster_id) { return nullptr; }
size_t get_cluster_generated_command_count(uint32_t cluster_id) {return 0; }
#endif // defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTER_ENABLE_DATA_MODEL)
@@ -363,15 +364,7 @@ static EmberAfAttributeMetadata *get_external_attribute_metadata(_attribute_t *
if (NULL == attribute || (attribute->flags & ATTRIBUTE_FLAG_MANAGED_INTERNALLY)) {
return NULL;
}
node_t *node = node::get();
if (NULL == node) {
return NULL;
}
endpoint_t *endpoint = endpoint::get(node, attribute->endpoint_id);
if (NULL == endpoint) {
return NULL;
}
_cluster_t *cluster = (_cluster_t *)cluster::get(endpoint, attribute->cluster_id);
_cluster_t *cluster = (_cluster_t *)cluster::get(attribute->endpoint_id, attribute->cluster_id);
if (NULL == cluster) {
return NULL;
}
@@ -394,21 +387,13 @@ static esp_err_t free_default_value(attribute_t *attribute)
/* Free value if data is more than 2 bytes or if it is min max attribute */
if (current_attribute->flags & ATTRIBUTE_FLAG_MIN_MAX) {
if (matter_attribute->size > 2) {
if (matter_attribute->defaultValue.ptrToMinMaxValue->defaultValue.ptrToDefaultValue) {
esp_matter_mem_free((void *)matter_attribute->defaultValue.ptrToMinMaxValue->defaultValue.ptrToDefaultValue);
}
if (matter_attribute->defaultValue.ptrToMinMaxValue->minValue.ptrToDefaultValue) {
esp_matter_mem_free((void *)matter_attribute->defaultValue.ptrToMinMaxValue->minValue.ptrToDefaultValue);
}
if (matter_attribute->defaultValue.ptrToMinMaxValue->maxValue.ptrToDefaultValue) {
esp_matter_mem_free((void *)matter_attribute->defaultValue.ptrToMinMaxValue->maxValue.ptrToDefaultValue);
}
esp_matter_mem_free((void *)matter_attribute->defaultValue.ptrToMinMaxValue->defaultValue.ptrToDefaultValue);
esp_matter_mem_free((void *)matter_attribute->defaultValue.ptrToMinMaxValue->minValue.ptrToDefaultValue);
esp_matter_mem_free((void *)matter_attribute->defaultValue.ptrToMinMaxValue->maxValue.ptrToDefaultValue);
}
esp_matter_mem_free((void *)matter_attribute->defaultValue.ptrToMinMaxValue);
} else if (matter_attribute->size > 2) {
if (matter_attribute->defaultValue.ptrToDefaultValue) {
esp_matter_mem_free((void *)matter_attribute->defaultValue.ptrToDefaultValue);
}
esp_matter_mem_free((void *)matter_attribute->defaultValue.ptrToDefaultValue);
}
return ESP_OK;
}
@@ -586,7 +571,7 @@ esp_err_t enable(endpoint_t *endpoint)
CommandId *accepted_command_ids = NULL;
CommandId *generated_command_ids = NULL;
_command_t *command = NULL;
command_list_t *command_list = NULL;
command_entry_t *command_list = NULL;
uint32_t cluster_id = kInvalidClusterId;
int command_count = 0;
int command_index = 0;
@@ -735,44 +720,25 @@ esp_err_t enable(endpoint_t *endpoint)
return err;
cleanup:
if (generated_command_ids) {
esp_matter_mem_free(generated_command_ids);
}
if (accepted_command_ids) {
esp_matter_mem_free(accepted_command_ids);
}
if (event_ids) {
esp_matter_mem_free(event_ids);
}
esp_matter_mem_free(generated_command_ids);
esp_matter_mem_free(accepted_command_ids);
esp_matter_mem_free(event_ids);
if (current_endpoint->endpoint_type->cluster) {
for (int cluster_index = 0; cluster_index < cluster_count; cluster_index++) {
/* Free attributes */
if (current_endpoint->endpoint_type->cluster[cluster_index].attributes) {
esp_matter_mem_free((void *)current_endpoint->endpoint_type->cluster[cluster_index].attributes);
}
esp_matter_mem_free((void *)current_endpoint->endpoint_type->cluster[cluster_index].attributes);
/* Free commands */
if (current_endpoint->endpoint_type->cluster[cluster_index].acceptedCommandList) {
esp_matter_mem_free((void *)current_endpoint->endpoint_type->cluster[cluster_index].acceptedCommandList);
}
if (current_endpoint->endpoint_type->cluster[cluster_index].generatedCommandList) {
esp_matter_mem_free((void *)current_endpoint->endpoint_type->cluster[cluster_index].generatedCommandList);
}
esp_matter_mem_free((void *)current_endpoint->endpoint_type->cluster[cluster_index].acceptedCommandList);
esp_matter_mem_free((void *)current_endpoint->endpoint_type->cluster[cluster_index].generatedCommandList);
/* Free events */
if (current_endpoint->endpoint_type->cluster[cluster_index].eventList) {
esp_matter_mem_free((void *)current_endpoint->endpoint_type->cluster[cluster_index].eventList);
}
esp_matter_mem_free((void *)current_endpoint->endpoint_type->cluster[cluster_index].eventList);
}
}
if (data_versions_ptr) {
esp_matter_mem_free(data_versions_ptr);
current_endpoint->data_versions_ptr = NULL;
}
if (device_types_ptr) {
esp_matter_mem_free(device_types_ptr);
current_endpoint->device_types_ptr = NULL;
}
esp_matter_mem_free(data_versions_ptr);
current_endpoint->data_versions_ptr = NULL;
esp_matter_mem_free(device_types_ptr);
current_endpoint->device_types_ptr = NULL;
return err;
}
@@ -1074,8 +1040,7 @@ attribute_t *create(cluster_t *cluster, uint32_t attribute_id, uint16_t flags, e
return existing_attribute;
}
node_t *node = node::get();
endpoint_t *endpoint = endpoint::get(node, current_cluster->endpoint_id);
endpoint_t *endpoint = endpoint::get(current_cluster->endpoint_id);
_endpoint_t *current_endpoint = (_endpoint_t *)endpoint;
/* Matter attributes */
@@ -1099,15 +1064,13 @@ attribute_t *create(cluster_t *cluster, uint32_t attribute_id, uint16_t flags, e
/* esp-matter uses uint16_t as the flags for the extras, EmberAfAttributeMetadata uses uint8_t as the mask.
The conversion from uint16 to uint8 is as expected for that the extra flags are only used in esp-matter. */
matter_attribute->mask = flags;
matter_attribute->mask = static_cast<uint8_t>(flags);
if (!(flags & ATTRIBUTE_FLAG_MANAGED_INTERNALLY)) {
matter_attribute->mask |= ATTRIBUTE_FLAG_EXTERNAL_STORAGE;
}
matter_attribute->attributeType = 0;
matter_attribute->size = 0;
_attribute_t *attribute = NULL;
if (!(flags & ATTRIBUTE_FLAG_MANAGED_INTERNALLY)) {
/* Allocate */
attribute = (_attribute_t *)esp_matter_mem_calloc(1, sizeof(_attribute_t));
@@ -1116,6 +1079,7 @@ attribute_t *create(cluster_t *cluster, uint32_t attribute_id, uint16_t flags, e
return NULL;
}
attribute->index = attribute_count - 1;
attribute->attribute_id = attribute_id;
attribute->cluster_id = matter_clusters->clusterId;
attribute->endpoint_id = current_cluster->endpoint_id;
attribute->flags = flags;
@@ -1158,6 +1122,8 @@ attribute_t *create(cluster_t *cluster, uint32_t attribute_id, uint16_t flags, e
matter_clusters->clusterSize += matter_attribute->size;
} else {
attribute = (_attribute_t *)esp_matter_mem_calloc(1, sizeof(_attribute_base_t));
attribute->attribute_id = attribute_id;
attribute->index = attribute_count - 1;
attribute->flags = flags;
}
@@ -1206,7 +1172,7 @@ static esp_err_t destroy(attribute_t *attribute)
/* Erase the persistent data */
if (attribute::get_flags(attribute) & ATTRIBUTE_FLAG_NONVOLATILE) {
erase_val_in_nvs(current_attribute->endpoint_id, current_attribute->cluster_id, attribute::get_id(attribute));
erase_val_in_nvs(current_attribute->endpoint_id, current_attribute->cluster_id, current_attribute->attribute_id);
}
/* Free */
@@ -1221,24 +1187,9 @@ attribute_t *get(cluster_t *cluster, uint32_t attribute_id)
return NULL;
}
_cluster_t *current_cluster = (_cluster_t *)cluster;
node_t *node = node::get();
endpoint_t *endpoint = endpoint::get(node, current_cluster->endpoint_id);
_endpoint_t *current_endpoint = (_endpoint_t *)endpoint;
int attribute_index = 0;
for (attribute_index = 0; attribute_index < current_endpoint->endpoint_type->cluster[current_cluster->index].attributeCount; attribute_index++) {
if (current_cluster->matter_attributes[attribute_index].attributeId == attribute_id) {
break;
}
}
if (attribute_index == current_endpoint->endpoint_type->cluster[current_cluster->index].attributeCount) {
ESP_LOGD(TAG, "Attribute not found");
return NULL;
}
_attribute_base_t *current_attribute = current_cluster->attribute_list;
while (current_attribute) {
if ((current_attribute->flags & ATTRIBUTE_FLAG_EXTERNAL_STORAGE) && (static_cast<_attribute_t *>(current_attribute)->index == attribute_index)) {
if (current_attribute->attribute_id == attribute_id) {
break;
}
current_attribute = current_attribute->next;
@@ -1280,13 +1231,7 @@ uint32_t get_id(attribute_t *attribute)
return kInvalidAttributeId;
}
_attribute_t *current_attribute = (_attribute_t *)attribute;
EmberAfAttributeMetadata *matter_attribute= get_external_attribute_metadata(current_attribute);
if (!matter_attribute) {
ESP_LOGE(TAG, "Attribute Metadata is not found");
return kInvalidAttributeId;
}
return matter_attribute->attributeId;
return current_attribute->attribute_id;
}
constexpr uint16_t k_deferred_attribute_persistence_time_ms = CONFIG_ESP_MATTER_DEFERRED_ATTR_PERSISTENCE_TIME_MS;
@@ -1295,8 +1240,8 @@ static void deferred_attribute_write(chip::System::Layer *layer, void *attribute
{
_attribute_t *current_attribute = (_attribute_t *)attribute_ptr;
ESP_LOGI(TAG, "Store the deferred attribute 0x%" PRIx32 " of cluster 0x%" PRIX32 " on endpoint 0x%" PRIx16,
attribute::get_id((attribute_t *)attribute_ptr), current_attribute->cluster_id, current_attribute->endpoint_id);
store_val_in_nvs(current_attribute->endpoint_id, current_attribute->cluster_id, attribute::get_id((attribute_t *)attribute_ptr),
current_attribute->attribute_id, current_attribute->cluster_id, current_attribute->endpoint_id);
store_val_in_nvs(current_attribute->endpoint_id, current_attribute->cluster_id, current_attribute->attribute_id,
current_attribute->val);
}
@@ -1346,7 +1291,7 @@ esp_err_t set_val(attribute_t *attribute, esp_matter_attr_val_t *val)
}
} else {
store_val_in_nvs(current_attribute->endpoint_id, current_attribute->cluster_id,
attribute::get_id(attribute), current_attribute->val);
current_attribute->attribute_id, current_attribute->val);
}
}
return ESP_OK;
@@ -1461,9 +1406,7 @@ esp_err_t set_override_callback(attribute_t *attribute, callback_t callback)
ESP_RETURN_ON_FALSE(!(current_attribute->flags & ATTRIBUTE_FLAG_MANAGED_INTERNALLY), ESP_ERR_NOT_SUPPORTED, TAG,
"Attribute is not managed by esp matter data model");
node_t *node = node::get();
endpoint_t *endpoint = endpoint::get(node, current_attribute->endpoint_id);
cluster_t *cluster = cluster::get(endpoint, current_attribute->cluster_id);
cluster_t *cluster = cluster::get(current_attribute->endpoint_id, current_attribute->cluster_id);
if (current_attribute->val.type == ESP_MATTER_VAL_TYPE_ARRAY ||
current_attribute->val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING ||
@@ -1473,7 +1416,7 @@ esp_err_t set_override_callback(attribute_t *attribute, callback_t callback)
// The override callback might allocate memory and we have no way to free the memory
// TODO: Add memory-safe override callback for these attribute types
ESP_LOGE(TAG, "Cannot set override callback for attribute 0x%" PRIX32 " on cluster 0x%" PRIX32,
attribute::get_id(attribute), cluster::get_id(cluster));
current_attribute->attribute_id, cluster::get_id(cluster));
return ESP_ERR_NOT_SUPPORTED;
}
current_attribute->override_callback = callback;
@@ -1788,7 +1731,8 @@ cluster_t *create(endpoint_t *endpoint, uint32_t cluster_id, uint8_t flags)
if (existing_cluster) {
/* If a server already exists, do not create it again */
_cluster_t *_existing_cluster = (_cluster_t *)existing_cluster;
uint16_t *cluster_flags = (uint16_t *)&current_endpoint->endpoint_type->cluster[_existing_cluster->index].mask;
// The member EmberAfCluster * in EmberAfEndpointType is const, do a non-const cast to change the mask.
EmberAfClusterMask *cluster_flags = (EmberAfClusterMask *)&current_endpoint->endpoint_type->cluster[_existing_cluster->index].mask;
if ((*cluster_flags & CLUSTER_FLAG_SERVER) && (flags & CLUSTER_FLAG_SERVER)) {
ESP_LOGW(TAG, "Server Cluster 0x%08" PRIX32 " on endpoint 0x%04" PRIx16 " already exists. Not creating again.", cluster_id,
current_endpoint->endpoint_id);
@@ -1956,8 +1900,7 @@ uint32_t get_id(cluster_t *cluster)
return kInvalidClusterId;
}
_cluster_t *current_cluster = (_cluster_t *)cluster;
node_t *node = node::get();
endpoint_t *endpoint = endpoint::get(node, current_cluster->endpoint_id);
endpoint_t *endpoint = endpoint::get(current_cluster->endpoint_id);
_endpoint_t *current_endpoint = (_endpoint_t *)endpoint;
return current_endpoint->endpoint_type->cluster[current_cluster->index].clusterId;
}
@@ -2044,8 +1987,7 @@ esp_err_t add_function_list(cluster_t *cluster, const function_generic_t *functi
}
_cluster_t *current_cluster = (_cluster_t *)cluster;
node_t *node = node::get();
endpoint_t *endpoint = endpoint::get(node, current_cluster->endpoint_id);
endpoint_t *endpoint = endpoint::get(current_cluster->endpoint_id);
_endpoint_t *current_endpoint = (_endpoint_t *)endpoint;
EmberAfCluster *matter_clusters = (EmberAfCluster *)current_endpoint->endpoint_type->cluster;
matter_clusters[current_cluster->index].mask |= function_flags;
+8 -8
View File
@@ -560,7 +560,7 @@ attribute_t *create(cluster_t *cluster, uint32_t attribute_id, uint16_t flags, e
* @param[in] attribute_id Attribute ID for the attribute.
*
* @return Attribute handle on success.
* @return NULL in case of failure or for attributes managed internally.
* @return NULL in case of failure.
*/
attribute_t *get(cluster_t *cluster, uint32_t attribute_id);
@@ -613,7 +613,7 @@ uint32_t get_id(attribute_t *attribute);
/** Set attribute val
*
* Set/Update the value of the attribute in the database.
* Set/Update the value of the attribute (has `ATTRIBUTE_FLAG_EXTERNAL_STORAGE` flag) in the database.
*
* @note: Once `esp_matter::start()` is done, `attribute::update()` should be used to update the attribute value.
*
@@ -627,7 +627,7 @@ esp_err_t set_val(attribute_t *attribute, esp_matter_attr_val_t *val);
/** Get attribute val
*
* Get the value of the attribute from the database.
* Get the value of the attribute (has `ATTRIBUTE_FLAG_EXTERNAL_STORAGE` flag) from the database.
*
* @param[in] attribute Attribute handle.
* @param[out] val Pointer to `esp_matter_attr_val_t`. Use appropriate elements as per the value type.
@@ -655,7 +655,7 @@ esp_err_t get_val_raw(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attrib
/** Add attribute bounds
*
* Add bounds to the attribute. Bounds cannot be added to string/array type attributes.
* Add bounds to the attribute (has `ATTRIBUTE_FLAG_EXTERNAL_STORAGE` flag). Bounds cannot be added to string/array type attributes.
*
* @param[in] attribute Attribute handle.
* @param[in] min Minimum allowed value.
@@ -668,7 +668,7 @@ esp_err_t add_bounds(attribute_t *attribute, esp_matter_attr_val_t min, esp_matt
/** Get attribute bounds
*
* Get the bounds which have been added to the attribute.
* Get the bounds which have been added to the attribute (has `ATTRIBUTE_FLAG_EXTERNAL_STORAGE` flag).
*
* @param[in] attribute Attribute handle.
* @param[in] bounds Pointer to `esp_matter_attr_bounds_t`.
@@ -690,7 +690,7 @@ uint16_t get_flags(attribute_t *attribute);
/** Set attribute override
*
* Set the override callback for the attribute. For attribute read and write calls, instead of doing that from the
* Set the override callback for the attribute (has `ATTRIBUTE_FLAG_EXTERNAL_STORAGE` flag). For attribute read and write calls, instead of doing that from the
* common database, this callback will be called.
*
* This can be used if the application or some component wants to maintain the attribute's value in the application or
@@ -707,7 +707,7 @@ esp_err_t set_override_callback(attribute_t *attribute, callback_t callback);
/** Get attribute override
*
* Get the override callback for the attribute.
* Get the override callback for the attribute (has `ATTRIBUTE_FLAG_EXTERNAL_STORAGE` flag).
*
* @param[in] attribute Attribute handle.
*
@@ -715,7 +715,7 @@ esp_err_t set_override_callback(attribute_t *attribute, callback_t callback);
*/
callback_t get_override_callback(attribute_t *attribute);
/** Set attribute deferred persistence
/** Set attribute (has `ATTRIBUTE_FLAG_EXTERNAL_STORAGE` flag) deferred persistence
*
* Only non-volatile attributes can be set with deferred presistence. If an attribute is configured with deferred
* presistence, any modifications to it will be enacted in its persistent storage with a specific delay
@@ -75,3 +75,6 @@ CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER=y
CONFIG_ENABLE_ESP32_DEVICE_INSTANCE_INFO_PROVIDER=y
CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER=y
CONFIG_SEC_CERT_DAC_PROVIDER=y
# Enable Newlib nano format for flash optimization
CONFIG_NEWLIB_NANO_FORMAT=y