From 8268d66eb5fba74c45c56ec9d64086eaebe4d2b3 Mon Sep 17 00:00:00 2001 From: Li Ya Shuai Date: Fri, 28 Mar 2025 02:24:04 +0800 Subject: [PATCH] [v1.3]backport: components/esp_matter:add optional attributes for general diagnostic cluster --- .../esp_matter/esp_matter_attribute.cpp | 30 +++++++++++++++++++ components/esp_matter/esp_matter_attribute.h | 5 ++++ 2 files changed, 35 insertions(+) diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index 69ebda9f5..d39e26647 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -468,6 +468,36 @@ attribute_t *create_up_time(cluster_t *cluster, uint64_t value) ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint64(value)); } +attribute_t *create_total_operational_hours(cluster_t *cluster, uint32_t value) +{ + return esp_matter::attribute::create(cluster, GeneralDiagnostics::Attributes::TotalOperationalHours::Id, + ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint32(value)); +} + +attribute_t *create_boot_reason(cluster_t *cluster, uint8_t value) +{ + return esp_matter::attribute::create(cluster, GeneralDiagnostics::Attributes::BootReason::Id, + ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); +} + +attribute_t *create_active_hardware_faults(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) +{ + return esp_matter::attribute::create(cluster, GeneralDiagnostics::Attributes::ActiveHardwareFaults::Id, + ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); +} + +attribute_t *create_active_radio_faults(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) +{ + return esp_matter::attribute::create(cluster, GeneralDiagnostics::Attributes::ActiveRadioFaults::Id, + ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); +} + +attribute_t *create_active_network_faults(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count) +{ + return esp_matter::attribute::create(cluster, GeneralDiagnostics::Attributes::ActiveNetworkFaults::Id, + ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); +} + attribute_t *create_test_event_triggers_enabled(cluster_t *cluster, bool value) { return esp_matter::attribute::create(cluster, GeneralDiagnostics::Attributes::TestEventTriggersEnabled::Id, diff --git a/components/esp_matter/esp_matter_attribute.h b/components/esp_matter/esp_matter_attribute.h index 7af1a869d..ae48286ea 100644 --- a/components/esp_matter/esp_matter_attribute.h +++ b/components/esp_matter/esp_matter_attribute.h @@ -141,6 +141,11 @@ namespace attribute { attribute_t *create_network_interfaces(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); attribute_t *create_reboot_count(cluster_t *cluster, uint16_t value); attribute_t *create_up_time(cluster_t *cluster, uint64_t value); +attribute_t *create_total_operational_hours(cluster_t *cluster, uint32_t value); +attribute_t *create_boot_reason(cluster_t *cluster, uint8_t value); +attribute_t *create_active_hardware_faults(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_active_radio_faults(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); +attribute_t *create_active_network_faults(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count); attribute_t *create_test_event_triggers_enabled(cluster_t *cluster, bool value); } /* attribute */ } /* general_diagnostics */