Matter setting CarbonDioxideConcentrationMeasurement value.

Hello,

I am developing matter sensor and I would like to send data to `MeasuredValue` attribute of `CarbonDioxideConcentrationMeasurement` cluster. I followed this tutorial https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/protocols/matter/getting_started/adding_clusters.html. The only thing I changed is that I turned on CO2 cluster and its attribute `MeasuredValue`. I wanted to set the value with this piece of code:

Clusters::CarbonDioxideConcentrationMeasurement::Attributes::MeasuredValue::Set(cluster_id, co2_val);
, but it turned out `Set` function does not exist for `CarbonDioxideConcentrationMeasurement`.
All those `Set` functions are implemented in Accessors.h which is located in `sdk_path/modules/lib/mater/zzz_generated` and I wonder when was this folder generated and why it does contain `Set` functions for clusters used in the samples and not for others. I could implement my own "accessor" for the required cluster, but I would like to ask if I'm missing something, because there is no `Accessors.h` inside my src/zap-generated folder.
Thank you for your answer.
Best regards,
Filip Mrazek
Parents
  • Hi,

    did anybody have a time to take a look at my problem with settng measured data? I investigate it a little bit and I find out that it logs the following to the console at startup:

    <err> chip: [DMG]Endpoint 1, Cluster 0x0000_040D not found in IncreaseClusterDataVersion!

  • Hi Filip,

    Thank you for your patience.

    When I returned to this case today, I made sure to read the Matter specification along with it, and I found that the CarbonDioxideConcentrationMeasurement cluster should be more similar to the RelativeHumidityMeasurement you shared as an example. Neither cluster has write access for their MeasuredValue attribute, yet you are able to use Set on the Relative Humidity.

    I will contact the developers about this so we can find out what the proper functionality is.

    Best regards,

    Maria

  • Hi Maria,

    Thank you for your update.
    I tried to impelemnt Set function for sending MeasuredValue for CarbonDioxide cluster the same way as for Temperature measurement. here is the implemented function:

    EmberAfStatus Set(chip::EndpointId endpoint, float value)
    {
        using Traits = NumericAttributeTraits<float>;
        if (!Traits::CanRepresentValue(true, value))
        {
            return EMBER_ZCL_STATUS_CONSTRAINT_ERROR;
        }
        Traits::StorageType storageValue;
        Traits::WorkingToStorage(value, storageValue);
        uint8_t* writable = Traits::ToAttributeStoreRepresentation(storageValue);
        return emberAfWriteAttribute(endpoint, Clusters::CarbonDioxideConcentrationMeasurement::Id, Id, writable, ZCL_SINGLE_ATTRIBUTE_TYPE);
    }

    but the return value is EMBER_ZCL_STATUS_FAILURE. I'm not sure, but it looks like its returning the value from this line https://github.com/project-chip/connectedhomeip/blob/3718e996b56f36a553c1b4571f77728396590776/src/app/util/attribute-storage.cpp#L656.

    I noticed one interesting thing. In zap tool, The Storage option for MeasuredValue of CarbonDioxide measurement is grayed out and I cannot change that to RAM. 

  • Hi Filip,

    Regarding your implementation you shared on May 15th:

    The constructor you used is meant to be used when the kNumericMeasurement feature is not used. If you are using kNumericMeasurement you need to use the other Instance constructor.

    If you are not using kNumericMeasurement, you can check if the Init() function returns an error code.

    If both steps above are ok, the cases where SetMeasuredValue will not update the MeasuredValue attribute is when the input is the same as the current value or if the input value exceeds the limits for MeasuredValue (CheckConstraintMinMax).

    Best regards,

    Maria

  • Hi Maria,

    I'm not sure if I understand, but in the post I shared on May 15th I use the correct constructor with 4 arguments and the last one is measurement unit. In the post I used: `ConcentrationMeasurement::MeasurementUnitEnum::kPpm`. 

    However, I figured out that the Init() function returns `CHIP_ERROR_INCORRECT_STATE`, but cannot find out why.

    Ad MinMax constrain - I didn't set any MinValue or MaxValue, so they are Null and the function you suggested returns always true if they are Null

Reply
  • Hi Maria,

    I'm not sure if I understand, but in the post I shared on May 15th I use the correct constructor with 4 arguments and the last one is measurement unit. In the post I used: `ConcentrationMeasurement::MeasurementUnitEnum::kPpm`. 

    However, I figured out that the Init() function returns `CHIP_ERROR_INCORRECT_STATE`, but cannot find out why.

    Ad MinMax constrain - I didn't set any MinValue or MaxValue, so they are Null and the function you suggested returns always true if they are Null

Children
Related