Skip to content

Commit b037340

Browse files
committed
Merge branch 'bugfix/ps' into 'main'
Fix type of min, max values for power source cluster See merge request app-frameworks/esp-matter!627
2 parents 16caf82 + 06683ba commit b037340

File tree

4 files changed

+66
-59
lines changed

4 files changed

+66
-59
lines changed

components/esp_matter/esp_matter_attribute.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -3712,25 +3712,25 @@ attribute_t *create_description(cluster_t *cluster, const char * value, uint16_t
37123712
return esp_matter::attribute::create(cluster, PowerSource::Attributes::Description::Id, ATTRIBUTE_FLAG_NONE, esp_matter_char_str((char *)value, length));
37133713
}
37143714

3715-
attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max)
3715+
attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
37163716
{
37173717
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedInputVoltage::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
37183718
if (!attribute) {
37193719
ESP_LOGE(TAG, "Could not create attribute");
37203720
return NULL;
37213721
}
3722-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
3722+
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
37233723
return attribute;
37243724
}
37253725

3726-
attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable<uint16_t> value, uint16_t min, uint16_t max)
3726+
attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max)
37273727
{
37283728
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedInputFrequency::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value));
37293729
if (!attribute) {
37303730
ESP_LOGE(TAG, "Could not create attribute");
37313731
return NULL;
37323732
}
3733-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(max));
3733+
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint16(min), esp_matter_nullable_uint16(max));
37343734
return attribute;
37353735
}
37363736

@@ -3739,14 +3739,14 @@ attribute_t *create_wired_current_type(cluster_t *cluster, const uint8_t value)
37393739
return esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredCurrentType::Id, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value));
37403740
}
37413741

3742-
attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max)
3742+
attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
37433743
{
37443744
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::WiredAssessedCurrent::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
37453745
if (!attribute) {
37463746
ESP_LOGE(TAG, "Could not create attribute");
37473747
return NULL;
37483748
}
3749-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
3749+
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
37503750
return attribute;
37513751
}
37523752

@@ -3786,36 +3786,36 @@ attribute_t *create_active_wired_faults(cluster_t *cluster, uint8_t * value, uin
37863786
return esp_matter::attribute::create(cluster, PowerSource::Attributes::ActiveWiredFaults::Id, ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count));
37873787
}
37883788

3789-
attribute_t *create_bat_voltage(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max)
3789+
attribute_t *create_bat_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
37903790
{
37913791
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatVoltage::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
37923792
if (!attribute) {
37933793
ESP_LOGE(TAG, "Could not create attribute");
37943794
return NULL;
37953795
}
3796-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
3796+
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
37973797
return attribute;
37983798
}
37993799

3800-
attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t> value, uint8_t min, uint8_t max)
3800+
attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t> value, nullable<uint8_t> min, nullable<uint8_t> max)
38013801
{
38023802
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatPercentRemaining::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint8(value));
38033803
if (!attribute) {
38043804
ESP_LOGE(TAG, "Could not create attribute");
38053805
return NULL;
38063806
}
3807-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint8(min), esp_matter_uint8(max));
3807+
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint8(min), esp_matter_nullable_uint8(max));
38083808
return attribute;
38093809
}
38103810

3811-
attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max)
3811+
attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
38123812
{
38133813
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatTimeRemaining::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
38143814
if (!attribute) {
38153815
ESP_LOGE(TAG, "Could not create attribute");
38163816
return NULL;
38173817
}
3818-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
3818+
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
38193819
return attribute;
38203820
}
38213821

@@ -3924,14 +3924,14 @@ attribute_t *create_bat_charge_state(cluster_t *cluster, uint8_t value)
39243924
return esp_matter::attribute::create(cluster, PowerSource::Attributes::BatChargeState::Id, ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value));
39253925
}
39263926

3927-
attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max)
3927+
attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
39283928
{
39293929
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatTimeToFullCharge::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
39303930
if (!attribute) {
39313931
ESP_LOGE(TAG, "Could not create attribute");
39323932
return NULL;
39333933
}
3934-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
3934+
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
39353935
return attribute;
39363936
}
39373937

@@ -3940,14 +3940,14 @@ attribute_t *create_bat_functional_while_charging(cluster_t *cluster, bool value
39403940
return esp_matter::attribute::create(cluster, PowerSource::Attributes::BatFunctionalWhileCharging::Id, ATTRIBUTE_FLAG_NONE, esp_matter_bool(value));
39413941
}
39423942

3943-
attribute_t *create_bat_charging_current(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max)
3943+
attribute_t *create_bat_charging_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max)
39443944
{
39453945
attribute_t *attribute = esp_matter::attribute::create(cluster, PowerSource::Attributes::BatChargingCurrent::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
39463946
if (!attribute) {
39473947
ESP_LOGE(TAG, "Could not create attribute");
39483948
return NULL;
39493949
}
3950-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
3950+
esp_matter::attribute::add_bounds(attribute, esp_matter_nullable_uint32(min), esp_matter_nullable_uint32(max));
39513951
return attribute;
39523952
}
39533953

components/esp_matter/esp_matter_attribute.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -866,17 +866,17 @@ namespace attribute {
866866
attribute_t *create_status(cluster_t *cluster, uint8_t value);
867867
attribute_t *create_order(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max);
868868
attribute_t *create_description(cluster_t *cluster, const char * value, uint16_t length);
869-
attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max);
870-
attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable<uint16_t> value, uint16_t min, uint16_t max);
869+
attribute_t *create_wired_assessed_input_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
870+
attribute_t *create_wired_assessed_input_frequency(cluster_t *cluster, nullable<uint16_t> value, nullable<uint16_t> min, nullable<uint16_t> max);
871871
attribute_t *create_wired_current_type(cluster_t *cluster, const uint8_t value);
872-
attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max);
872+
attribute_t *create_wired_assessed_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
873873
attribute_t *create_wired_nominal_voltage(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max);
874874
attribute_t *create_wired_maximum_current(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max);
875875
attribute_t *create_wired_present(cluster_t *cluster, bool value);
876876
attribute_t *create_active_wired_faults(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
877-
attribute_t *create_bat_voltage(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max);
878-
attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t> value, uint8_t min, uint8_t max);
879-
attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, uint32_t min, uint32_t max);
877+
attribute_t *create_bat_voltage(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
878+
attribute_t *create_bat_percent_remaining(cluster_t *cluster, nullable<uint8_t> value, nullable<uint8_t> min, nullable<uint8_t> max);
879+
attribute_t *create_bat_time_remaining(cluster_t *cluster, nullable< uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
880880
attribute_t *create_bat_charge_level(cluster_t *cluster, uint8_t value);
881881
attribute_t *create_bat_replacement_needed(cluster_t *cluster, bool value);
882882
attribute_t *create_bat_replaceability(cluster_t *cluster, const uint8_t value);
@@ -890,9 +890,9 @@ attribute_t *create_bat_approved_chemistry(cluster_t *cluster, const uint8_t val
890890
attribute_t *create_bat_capacity(cluster_t *cluster, const uint32_t value, uint32_t min, uint32_t max);
891891
attribute_t *create_bat_quantity(cluster_t *cluster, const uint8_t value, uint8_t min, uint8_t max);
892892
attribute_t *create_bat_charge_state(cluster_t *cluster, uint8_t value);
893-
attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max);
893+
attribute_t *create_bat_time_to_full_charge(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
894894
attribute_t *create_bat_functional_while_charging(cluster_t *cluster, bool value);
895-
attribute_t *create_bat_charging_current(cluster_t *cluster, nullable<uint32_t> value, uint32_t min, uint32_t max);
895+
attribute_t *create_bat_charging_current(cluster_t *cluster, nullable<uint32_t> value, nullable<uint32_t> min, nullable<uint32_t> max);
896896
attribute_t *create_active_bat_charge_faults(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
897897
} /* attribute */
898898
} /* power_source */

examples/all_device_types_app/main/device_types.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ enum device_type_enum {
3838
ESP_MATTER_DISH_WASHER,
3939
ESP_MATTER_SMOKE_CO_ALARM,
4040
ESP_MATTER_WATER_LEAK_DETECTOR,
41+
ESP_MATTER_POWER_SOURCE,
4142
ESP_MATTER_DEVICE_TYPE_MAX
4243
};
4344

@@ -81,6 +82,7 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
8182
{"laundry_washer", ESP_MATTER_LAUNDRY_WASHER},
8283
{"dish_washer", ESP_MATTER_DISH_WASHER},
8384
{"smoke_co_alarm", ESP_MATTER_SMOKE_CO_ALARM},
84-
{"water_leak_detector", ESP_MATTER_WATER_LEAK_DETECTOR}
85+
{"water_leak_detector", ESP_MATTER_WATER_LEAK_DETECTOR},
86+
{"power_source", ESP_MATTER_POWER_SOURCE}
8587
};
8688
} /* namespace esp_matter */

examples/all_device_types_app/main/esp_matter_console_helpers.cpp

+39-34
Original file line numberDiff line numberDiff line change
@@ -311,34 +311,34 @@ int create(uint8_t device_type_index)
311311
cluster::temperature_control::feature::temperature_number::add(cluster, &temperature_number_config);
312312
break;
313313
}
314-
case ESP_MATTER_AIR_PURIFIER: {
315-
esp_matter::endpoint::air_purifier::config_t air_purifier_config;
316-
endpoint = esp_matter::endpoint::air_purifier::create(node, &air_purifier_config, ENDPOINT_FLAG_NONE, NULL);
317-
break;
318-
}
319-
case ESP_MATTER_AIR_QUALITY_SENSOR: {
314+
case ESP_MATTER_AIR_PURIFIER: {
315+
esp_matter::endpoint::air_purifier::config_t air_purifier_config;
316+
endpoint = esp_matter::endpoint::air_purifier::create(node, &air_purifier_config, ENDPOINT_FLAG_NONE, NULL);
317+
break;
318+
}
319+
case ESP_MATTER_AIR_QUALITY_SENSOR: {
320320
esp_matter::endpoint::air_quality_sensor::config_t air_quality_sensor_config;
321-
endpoint = esp_matter::endpoint::air_quality_sensor::create(node, &air_quality_sensor_config, ENDPOINT_FLAG_NONE, NULL);
322-
break;
323-
}
324-
case ESP_MATTER_ROBOTIC_VACUUM_CLEANER: {
325-
esp_matter::endpoint::robotic_vacuum_cleaner::config_t robotic_vacuum_cleaner_config;
326-
endpoint = esp_matter::endpoint::robotic_vacuum_cleaner::create(node, &robotic_vacuum_cleaner_config, ENDPOINT_FLAG_NONE, NULL);
327-
break;
328-
}
329-
case ESP_MATTER_LAUNDRY_WASHER: {
330-
esp_matter::endpoint::laundry_washer::config_t laundry_washer_config;
331-
endpoint = esp_matter::endpoint::laundry_washer::create(node, &laundry_washer_config, ENDPOINT_FLAG_NONE, NULL);
332-
break;
333-
}
334-
case ESP_MATTER_DISH_WASHER: {
335-
esp_matter::endpoint::dish_washer::config_t dish_washer_config;
336-
endpoint = esp_matter::endpoint::dish_washer::create(node, &dish_washer_config, ENDPOINT_FLAG_NONE, NULL);
337-
break;
338-
}
339-
case ESP_MATTER_SMOKE_CO_ALARM: {
340-
esp_matter::endpoint::smoke_co_alarm::config_t smoke_co_alarm_config;
341-
endpoint = esp_matter::endpoint::smoke_co_alarm::create(node, &smoke_co_alarm_config, ENDPOINT_FLAG_NONE, NULL);
321+
endpoint = esp_matter::endpoint::air_quality_sensor::create(node, &air_quality_sensor_config, ENDPOINT_FLAG_NONE, NULL);
322+
break;
323+
}
324+
case ESP_MATTER_ROBOTIC_VACUUM_CLEANER: {
325+
esp_matter::endpoint::robotic_vacuum_cleaner::config_t robotic_vacuum_cleaner_config;
326+
endpoint = esp_matter::endpoint::robotic_vacuum_cleaner::create(node, &robotic_vacuum_cleaner_config, ENDPOINT_FLAG_NONE, NULL);
327+
break;
328+
}
329+
case ESP_MATTER_LAUNDRY_WASHER: {
330+
esp_matter::endpoint::laundry_washer::config_t laundry_washer_config;
331+
endpoint = esp_matter::endpoint::laundry_washer::create(node, &laundry_washer_config, ENDPOINT_FLAG_NONE, NULL);
332+
break;
333+
}
334+
case ESP_MATTER_DISH_WASHER: {
335+
esp_matter::endpoint::dish_washer::config_t dish_washer_config;
336+
endpoint = esp_matter::endpoint::dish_washer::create(node, &dish_washer_config, ENDPOINT_FLAG_NONE, NULL);
337+
break;
338+
}
339+
case ESP_MATTER_SMOKE_CO_ALARM: {
340+
esp_matter::endpoint::smoke_co_alarm::config_t smoke_co_alarm_config;
341+
endpoint = esp_matter::endpoint::smoke_co_alarm::create(node, &smoke_co_alarm_config, ENDPOINT_FLAG_NONE, NULL);
342342

343343
esp_matter::endpoint::power_source_device::config_t power_source_config;
344344
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)
347347
ESP_LOGE(TAG, "Matter create endpoint failed");
348348
return 1;
349349
}
350-
break;
351-
}
352-
case ESP_MATTER_WATER_LEAK_DETECTOR: {
353-
esp_matter::endpoint::water_leak_detector::config_t water_leak_detector_config;
354-
endpoint = esp_matter::endpoint::water_leak_detector::create(node, &water_leak_detector_config, ENDPOINT_FLAG_NONE, NULL);
355-
break;
356-
}
350+
break;
351+
}
352+
case ESP_MATTER_WATER_LEAK_DETECTOR: {
353+
esp_matter::endpoint::water_leak_detector::config_t water_leak_detector_config;
354+
endpoint = esp_matter::endpoint::water_leak_detector::create(node, &water_leak_detector_config, ENDPOINT_FLAG_NONE, NULL);
355+
break;
356+
}
357+
case ESP_MATTER_POWER_SOURCE: {
358+
esp_matter::endpoint::power_source_device::config_t power_source_device_config;
359+
endpoint = esp_matter::endpoint::power_source_device::create(node, &power_source_device_config, ENDPOINT_FLAG_NONE, NULL);
360+
break;
361+
}
357362
default: {
358363
ESP_LOGE(TAG, "Please input a valid device type");
359364
break;

0 commit comments

Comments
 (0)