Skip to content

Commit

Permalink
Merge branch 'bugfix/ps' into 'main'
Browse files Browse the repository at this point in the history
Fix type of min, max values for power source cluster

See merge request app-frameworks/esp-matter!627
  • Loading branch information
dhrishi committed Feb 26, 2024
2 parents 16caf82 + 06683ba commit b037340
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 59 deletions.
32 changes: 16 additions & 16 deletions components/esp_matter/esp_matter_attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3712,25 +3712,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<uint32_t> value, uint32_t min, uint32_t max)
attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> 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<uint16_t> value, uint16_t min, uint16_t max)
attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> 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;
}

Expand All @@ -3739,14 +3739,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<uint32_t> value, uint32_t min, uint32_t max)
attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> 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;
}

Expand Down Expand Up @@ -3786,36 +3786,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<uint32_t> value, uint32_t min, uint32_t max)
attribute_t *create_bat_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> 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<uint8_t> value, uint8_t min, uint8_t max)
attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t> value, nullable<uint8_t> min, nullable<uint8_t> 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<uint32_t> value, uint32_t min, uint32_t max)
attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> 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;
}

Expand Down Expand Up @@ -3924,14 +3924,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<uint32_t> value, uint32_t min, uint32_t max)
attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> 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;
}

Expand All @@ -3940,14 +3940,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<uint32_t> value, uint32_t min, uint32_t max)
attribute_t *create_bat_charging_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> 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;
}

Expand Down
16 changes: 8 additions & 8 deletions components/esp_matter/esp_matter_attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -866,17 +866,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<uint32_t> value, uint32_t min, uint32_t max);
attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable<uint16_t> value, uint16_t min, uint16_t max);
attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max);
attribute_t *create_wired_current_type(cluster_t *cluster, const uint8_t value);
attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max);
attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> 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<uint32_t> value, uint32_t min, uint32_t max);
attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t> 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<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t> value, nullable<uint8_t> min, nullable<uint8_t> max);
attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> 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);
Expand All @@ -890,9 +890,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<uint32_t> value, uint32_t min, uint32_t max);
attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
attribute_t *create_bat_functional_while_charging(cluster_t *cluster, bool value);
attribute_t *create_bat_charging_current(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max);
attribute_t *create_bat_charging_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
attribute_t *create_active_bat_charge_faults(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
} /* attribute */
} /* power_source */
Expand Down
4 changes: 3 additions & 1 deletion examples/all_device_types_app/main/device_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -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 */
73 changes: 39 additions & 34 deletions examples/all_device_types_app/main/esp_matter_console_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit b037340

Please sign in to comment.