From 06683ba66dbb60803d99698d76dc8d84700a47a8 Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Tue, 6 Feb 2024 20:38:55 +0530 Subject: [PATCH] Fix type of min, max values for power source cluster --- .../esp_matter/esp_matter_attribute.cpp | 32 ++++---- components/esp_matter/esp_matter_attribute.h | 16 ++-- .../all_device_types_app/main/device_types.h | 4 +- .../main/esp_matter_console_helpers.cpp | 73 ++++++++++--------- 4 files changed, 66 insertions(+), 59 deletions(-) diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index 867f02c9e..def021917 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -3694,25 +3694,25 @@ attribute_t *create_description(cluster_t *cluster, const char * value, uint16_t return esp_matter::attribute::create(cluster, PowerSource::Attributes::Description::Id, ATTRIBUTE_FLAG_NONE, esp_matter_char_str((char *)value, length)); } -attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable value, uint32_t min, uint32_t max) +attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable value, nullable min, nullable max) { attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedInputVoltage::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); return attribute; } -attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable value, uint16_t min, uint16_t max) +attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable value, nullable min, nullable max) { attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedInputFrequency::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max)); return attribute; } @@ -3721,14 +3721,14 @@ attribute_t *create_wired_current_type(cluster_t *cluster, const uint8_t value) return esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredCurrentType::Id, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); } -attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable value, uint32_t min, uint32_t max) +attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable value, nullable min, nullable max) { attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedCurrent::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); return attribute; } @@ -3768,36 +3768,36 @@ attribute_t *create_active_wired_faults(cluster_t *cluster, uint8_t * value, uin return esp_matter::attribute::create(cluster, PowerSource::Attributes::ActiveWiredFaults::Id, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count)); } -attribute_t *create_bat_voltage(cluster_t *cluster, nullable value, uint32_t min, uint32_t max) +attribute_t *create_bat_voltage(cluster_t *cluster, nullable value, nullable min, nullable max) { attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatVoltage::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); return attribute; } -attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable value, uint8_t min, uint8_t max) +attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable value, nullable min, nullable max) { attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatPercentRemaining::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint8(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(min), esp_matter_uint8(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max)); return attribute; } -attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable value, uint32_t min, uint32_t max) +attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, nullable min, nullable max) { attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatTimeRemaining::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); return attribute; } @@ -3906,14 +3906,14 @@ attribute_t *create_bat_charge_state(cluster_t *cluster, uint8_t value) return esp_matter::attribute::create(cluster, PowerSource::Attributes::BatChargeState::Id, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value)); } -attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable value, uint32_t min, uint32_t max) +attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable value, nullable min, nullable max) { attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatTimeToFullCharge::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); return attribute; } @@ -3922,14 +3922,14 @@ attribute_t *create_bat_functional_while_charging(cluster_t *cluster, bool value return esp_matter::attribute::create(cluster, PowerSource::Attributes::BatFunctionalWhileCharging::Id, ATTRIBUTE_FLAG_NONE, esp_matter_bool(value)); } -attribute_t *create_bat_charging_current(cluster_t *cluster, nullable value, uint32_t min, uint32_t max) +attribute_t *create_bat_charging_current(cluster_t *cluster, nullable value, nullable min, nullable max) { attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatChargingCurrent::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); if (!attribute) { ESP_LOGE(TAG, "Could not create attribute"); return NULL; } - esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max)); + esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max)); return attribute; } diff --git a/components/esp_matter/esp_matter_attribute.h b/components/esp_matter/esp_matter_attribute.h index 5fbf438b8..f1e655813 100644 --- a/components/esp_matter/esp_matter_attribute.h +++ b/components/esp_matter/esp_matter_attribute.h @@ -863,17 +863,17 @@ namespace attribute { attribute_t *create_status(cluster_t *cluster, uint8_t value); attribute_t *create_order(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max); attribute_t *create_description(cluster_t *cluster, const char * value, uint16_t length); -attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable value, uint32_t min, uint32_t max); -attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable value, uint16_t min, uint16_t max); +attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable value, nullable min, nullable max); +attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable value, nullable min, nullable max); attribute_t *create_wired_current_type(cluster_t *cluster, const uint8_t value); -attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable value, uint32_t min, uint32_t max); +attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable value, nullable min, nullable max); attribute_t *create_wired_nominal_voltage(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max); attribute_t *create_wired_maximum_current(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max); attribute_t *create_wired_present(cluster_t *cluster, bool value); attribute_t *create_active_wired_faults(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count); -attribute_t *create_bat_voltage(cluster_t *cluster, nullable value, uint32_t min, uint32_t max); -attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable value, uint8_t min, uint8_t max); -attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, uint32_t min, uint32_t max); +attribute_t *create_bat_voltage(cluster_t *cluster, nullable value, nullable min, nullable max); +attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable value, nullable min, nullable max); +attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, nullable min, nullable max); attribute_t *create_bat_charge_level(cluster_t *cluster, uint8_t value); attribute_t *create_bat_replacement_needed(cluster_t *cluster, bool value); attribute_t *create_bat_replaceability(cluster_t *cluster, const uint8_t value); @@ -887,9 +887,9 @@ attribute_t *create_bat_approved_chemistry(cluster_t *cluster, const uint8_t val attribute_t *create_bat_capacity(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max); attribute_t *create_bat_quantity(cluster_t *cluster, const uint8_t value, uint8_t min, uint8_t max); attribute_t *create_bat_charge_state(cluster_t *cluster, uint8_t value); -attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable value, uint32_t min, uint32_t max); +attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable value, nullable min, nullable max); attribute_t *create_bat_functional_while_charging(cluster_t *cluster, bool value); -attribute_t *create_bat_charging_current(cluster_t *cluster, nullable value, uint32_t min, uint32_t max); +attribute_t *create_bat_charging_current(cluster_t *cluster, nullable value, nullable min, nullable max); attribute_t *create_active_bat_charge_faults(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count); } /* attribute */ } /* power_source */ diff --git a/examples/all_device_types_app/main/device_types.h b/examples/all_device_types_app/main/device_types.h index 2e1c2f52a..f28a5bb7c 100644 --- a/examples/all_device_types_app/main/device_types.h +++ b/examples/all_device_types_app/main/device_types.h @@ -38,6 +38,7 @@ enum device_type_enum { ESP_MATTER_DISH_WASHER, ESP_MATTER_SMOKE_CO_ALARM, ESP_MATTER_WATER_LEAK_DETECTOR, + ESP_MATTER_POWER_SOURCE, ESP_MATTER_DEVICE_TYPE_MAX }; @@ -81,6 +82,7 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = { {"laundry_washer", ESP_MATTER_LAUNDRY_WASHER}, {"dish_washer", ESP_MATTER_DISH_WASHER}, {"smoke_co_alarm", ESP_MATTER_SMOKE_CO_ALARM}, - {"water_leak_detector", ESP_MATTER_WATER_LEAK_DETECTOR} + {"water_leak_detector", ESP_MATTER_WATER_LEAK_DETECTOR}, + {"power_source", ESP_MATTER_POWER_SOURCE} }; } /* namespace esp_matter */ diff --git a/examples/all_device_types_app/main/esp_matter_console_helpers.cpp b/examples/all_device_types_app/main/esp_matter_console_helpers.cpp index e88f60da7..97a929a3e 100644 --- a/examples/all_device_types_app/main/esp_matter_console_helpers.cpp +++ b/examples/all_device_types_app/main/esp_matter_console_helpers.cpp @@ -311,34 +311,34 @@ int create(uint8_t device_type_index) cluster::temperature_control::feature::temperature_number::add(cluster, &temperature_number_config); break; } - case ESP_MATTER_AIR_PURIFIER: { - esp_matter::endpoint::air_purifier::config_t air_purifier_config; - endpoint = esp_matter::endpoint::air_purifier::create(node, &air_purifier_config, ENDPOINT_FLAG_NONE, NULL); - break; - } - case ESP_MATTER_AIR_QUALITY_SENSOR: { + case ESP_MATTER_AIR_PURIFIER: { + esp_matter::endpoint::air_purifier::config_t air_purifier_config; + endpoint = esp_matter::endpoint::air_purifier::create(node, &air_purifier_config, ENDPOINT_FLAG_NONE, NULL); + break; + } + case ESP_MATTER_AIR_QUALITY_SENSOR: { esp_matter::endpoint::air_quality_sensor::config_t air_quality_sensor_config; - endpoint = esp_matter::endpoint::air_quality_sensor::create(node, &air_quality_sensor_config, ENDPOINT_FLAG_NONE, NULL); - break; - } - case ESP_MATTER_ROBOTIC_VACUUM_CLEANER: { - esp_matter::endpoint::robotic_vacuum_cleaner::config_t robotic_vacuum_cleaner_config; - endpoint = esp_matter::endpoint::robotic_vacuum_cleaner::create(node, &robotic_vacuum_cleaner_config, ENDPOINT_FLAG_NONE, NULL); - break; - } - case ESP_MATTER_LAUNDRY_WASHER: { - esp_matter::endpoint::laundry_washer::config_t laundry_washer_config; - endpoint = esp_matter::endpoint::laundry_washer::create(node, &laundry_washer_config, ENDPOINT_FLAG_NONE, NULL); - break; - } - case ESP_MATTER_DISH_WASHER: { - esp_matter::endpoint::dish_washer::config_t dish_washer_config; - endpoint = esp_matter::endpoint::dish_washer::create(node, &dish_washer_config, ENDPOINT_FLAG_NONE, NULL); - break; - } - case ESP_MATTER_SMOKE_CO_ALARM: { - esp_matter::endpoint::smoke_co_alarm::config_t smoke_co_alarm_config; - endpoint = esp_matter::endpoint::smoke_co_alarm::create(node, &smoke_co_alarm_config, ENDPOINT_FLAG_NONE, NULL); + endpoint = esp_matter::endpoint::air_quality_sensor::create(node, &air_quality_sensor_config, ENDPOINT_FLAG_NONE, NULL); + break; + } + case ESP_MATTER_ROBOTIC_VACUUM_CLEANER: { + esp_matter::endpoint::robotic_vacuum_cleaner::config_t robotic_vacuum_cleaner_config; + endpoint = esp_matter::endpoint::robotic_vacuum_cleaner::create(node, &robotic_vacuum_cleaner_config, ENDPOINT_FLAG_NONE, NULL); + break; + } + case ESP_MATTER_LAUNDRY_WASHER: { + esp_matter::endpoint::laundry_washer::config_t laundry_washer_config; + endpoint = esp_matter::endpoint::laundry_washer::create(node, &laundry_washer_config, ENDPOINT_FLAG_NONE, NULL); + break; + } + case ESP_MATTER_DISH_WASHER: { + esp_matter::endpoint::dish_washer::config_t dish_washer_config; + endpoint = esp_matter::endpoint::dish_washer::create(node, &dish_washer_config, ENDPOINT_FLAG_NONE, NULL); + break; + } + case ESP_MATTER_SMOKE_CO_ALARM: { + esp_matter::endpoint::smoke_co_alarm::config_t smoke_co_alarm_config; + endpoint = esp_matter::endpoint::smoke_co_alarm::create(node, &smoke_co_alarm_config, ENDPOINT_FLAG_NONE, NULL); esp_matter::endpoint::power_source_device::config_t power_source_config; esp_matter::endpoint_t *ps_endpoint = esp_matter::endpoint::power_source_device::create(node, &power_source_config, ENDPOINT_FLAG_NONE, NULL); @@ -347,13 +347,18 @@ int create(uint8_t device_type_index) ESP_LOGE(TAG, "Matter create endpoint failed"); return 1; } - break; - } - case ESP_MATTER_WATER_LEAK_DETECTOR: { - esp_matter::endpoint::water_leak_detector::config_t water_leak_detector_config; - endpoint = esp_matter::endpoint::water_leak_detector::create(node, &water_leak_detector_config, ENDPOINT_FLAG_NONE, NULL); - break; - } + break; + } + case ESP_MATTER_WATER_LEAK_DETECTOR: { + esp_matter::endpoint::water_leak_detector::config_t water_leak_detector_config; + endpoint = esp_matter::endpoint::water_leak_detector::create(node, &water_leak_detector_config, ENDPOINT_FLAG_NONE, NULL); + break; + } + case ESP_MATTER_POWER_SOURCE: { + esp_matter::endpoint::power_source_device::config_t power_source_device_config; + endpoint = esp_matter::endpoint::power_source_device::create(node, &power_source_device_config, ENDPOINT_FLAG_NONE, NULL); + break; + } default: { ESP_LOGE(TAG, "Please input a valid device type"); break;