Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing single data type attribute value handling. (CON-1051) #843

Closed
YOGYUI opened this issue Feb 16, 2024 · 2 comments
Closed

Missing single data type attribute value handling. (CON-1051) #843

YOGYUI opened this issue Feb 16, 2024 · 2 comments

Comments

@YOGYUI
Copy link
Contributor

YOGYUI commented Feb 16, 2024

Is your feature request related to a problem? Please describe.
When updating attribute value which data type is single (single precision floating point), error occurred.

Describe the solution you'd like
I think following codes should be added in esp_matter_attribute_utils.cpp

static esp_err_t get_attr_val_from_data(esp_matter_attr_val_t *val, EmberAfAttributeType attribute_type,
                                        uint16_t attribute_size, uint8_t *value,
                                        const EmberAfAttributeMetadata * attribute_metadata)
{
    switch (attribute_type) {
    /*
     * 
     */
    
    case ZCL_SINGLE_ATTRIBUTE_TYPE: {
        using Traits = chip::app::NumericAttributeTraits<float>;
        Traits::StorageType attribute_value;
        memcpy((float *)&attribute_value, value, sizeof(Traits::StorageType));
        if (attribute_metadata->IsNullable()) {
            if (Traits::IsNullValue(attribute_value)) {
                *val = esp_matter_nullable_float(nullable<float>());
            } else {
                *val = esp_matter_nullable_float(attribute_value);
            }
        } else {
            *val = esp_matter_float(attribute_value);
        }
        break;
    }
}

Additional context
I found that some attribute data types in esp-matter are not comply with matter specification.
Is there any reason?

[Example]
Cluster: Carbon Dioxide Concentration Measurement (id: 0x040C)
Attribute: Measured Value (id: 0x0000)
image
specification: single (nullable)
esp-matter code: uint16_t

namespace carbon_dioxide_concentration_measurement {
namespace attribute {
attribute_t *create_measured_value(cluster_t *cluster, nullable<uint16_t> value)
{
    return esp_matter::attribute::create(cluster, CarbonMonoxideConcentrationMeasurement::Attributes::MeasuredValue::Id,
					 ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value));
}

Almost all single type attributes (like MeasuredValue, MinMeasuredValue, MaxMeasuredValue) of concentration measurement clusters are implemented as integer.

@github-actions github-actions bot changed the title Missing single data type attribute value handling. Missing single data type attribute value handling. (CON-1051) Feb 16, 2024
@dhrishi
Copy link
Collaborator

dhrishi commented Feb 26, 2024

@YOGYUI Thanks for reporting the issue and the probable solution. We will soon have the fix available on Github

@YOGYUI
Copy link
Contributor Author

YOGYUI commented Feb 26, 2024

@dhrishi Thanks for reply.
Last week, I forked repo's main branch and created pull request to solve this issue. (CON-1056)
I'm now waiting for code review :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants