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

Part 3: feature/air pressure measurement cluster #7030

Closed
wants to merge 23 commits into from
Closed

Part 3: feature/air pressure measurement cluster #7030

wants to merge 23 commits into from

Conversation

ghost
Copy link

@ghost ghost commented May 21, 2021

Problem

The matter project has only a pressure measurement cluster which is not suitable for air pressure. The value range is too big. To solve this we introduce a cluster which is specific to air pressure measurement.

Change overview

  • added support for zap tool
  • added emberAfAirPressureMeasurementClusterServerInitCallback support
  • added air pressure measurement cluster support to chip-device-clt
  • added air-pressure-measurement-server.cpp impl.

Testing

Tested on custom accessory with air pressure sensor. Test setup was similar to TE2.

HW Platform

Nordic nRF52840

Notes

Related PRs

@bzbarsky-apple
Copy link
Contributor

This sounds like a spec issue, no? That is, the new cluster would need to be added to the spec.

@CamWms in case there is an existing ZCL cluster that is appropriate here.

@ghost
Copy link
Author

ghost commented May 25, 2021

@bzbarsky-apple It's not only the value range of pressure measurement. We have also added altitude to the air pressure measurement cluster to correlate the air pressure according to the height above / below see level.

@bzbarsky-apple
Copy link
Contributor

Right, that all sounds like it needs to go into the cluster library spec.

src/app/zap_cluster_list.py Outdated Show resolved Hide resolved
src/app/zap_cluster_list.py Outdated Show resolved Hide resolved
src/app/zap_cluster_list.py Outdated Show resolved Hide resolved
src/app/zap_cluster_list.py Outdated Show resolved Hide resolved
sizeof(*measuredValue));
}

static EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeCallback(chip::EndpointId endpoint, int16_t altitude)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetAltitude-> SetAltitudeValue ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be consisted with AIR_PRESSURE_MEASUREMENT_ALTITUDE I did not name it SetAltitudeValue. But I can change it on both sides if requried?

<description>Air pressure measurement cluster in hPA with 1 digit fixed point resolution</description>
<attribute side="server" code="0x0000" define="AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE" type="INT16U" min="8700" max="11000" writable="false" default="10132" optional="false">measured value</attribute>
<attribute side="server" code="0x0001" define="AIR_PRESSURE_MEASUREMENT_ALTITUDE" type="INT16S" min="-32768" max="32767" writable="true" default="0" optional="false">altitude</attribute>
<command source="client" code="0x0000" name="altitude" optional="false">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a command to just update a single attribute? Can't we use the generic "ZCL write" message? In case we do, please rename it to "SetAltitude" to make it more consistent with other commands.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the device cannot measure the altitude by itself. And the altitude measurement available on some devices is indeed using an air pressure sensor which derives the altitude from the air pressure value and data from the internet.
So the controller has to set the altitude to get correct air pressure readings. Typically this value can be auto-generated on the controller by getting it from some internet services based on the geo-location. If this is not possible then the User has to specify the altitude value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Damian-Nordic I have removed the command. The fact that the attribute is writable is sufficient.

Copy link
Contributor

@vivien-apple vivien-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for TE3.

It seems like the result of this PR is mostly to expose a set of accessors to facilitate the manipulation of the Binary input (Basic) cluster attributes.
It makes perfect sense to facilitate it imho, but I would rather prefer to autogenerate helpers code such as what is proposed in #7183, instead of having a lot of new clusters introduced into src/app/clusters.

src/app/zap-templates/templates/app/helper.js Outdated Show resolved Hide resolved
<cluster>
<domain>Measurement &amp; Sensing</domain>
<name>Air Pressure Measurement</name>
<code>0x0407</code>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the ZCL cluster id for the "Leaf Wetness" cluster. This needs a different ID. Please speak to @CamWms about one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in talks with @CamWms regarding this issue. Will update it when I've got the correct cluster id.

<client init="false" tick="false">true</client>
<server init="false" tick="false">true</server>
<description>Air pressure measurement cluster in hPA with 1 digit fixed point resolution</description>
<attribute side="server" code="0x0000" define="AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE" type="INT16U" min="8700" max="11000" writable="false" default="10132" optional="false">measured value</attribute>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 8700 is suspiciously close to "the lowest we've measured in a hurricane recently". Is that really what the min should be in the spec? Do we ever expect one of these sensors to be in a tornado?

11000 seems to assume this will never be used in any sort of submersible?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting to remove the min / max values and just use the value range of the INT16U as min / max values? The min / max values where intended to indicate the possible value range of the atmospheric pressure. I would agree that maybe changing them a bit lower / higher would be beneficial to compensate some sensor measurement tolerances. So I would e.g. suggest 8000 for min and 12000 for max.

The intention of this cluster was to measure air pressure / atmospheric pressure. I don't know how this could be related to submersible applications? Could you provide an example.

src/app/zap-templates/zcl/air-pressure-measurement.xml Outdated Show resolved Hide resolved
src/app/zap_cluster_list.py Outdated Show resolved Hide resolved
src/app/zap_cluster_list.py Outdated Show resolved Hide resolved
Dimitri Mizenko and others added 21 commits May 31, 2021 11:43
- replace emberAfReadAttribute with emberAfReadServerAttribute
- replace emberAfWriteAttribute with emberAfWriteServerAttribute
- add emberAfAirPressureMeasurementClusterPrintln
- let the caller do the logging
The default values are populated by the attribute storage.
The altitude attribute is writable so it is possible to write to the attribute without a command.
@CamWms
Copy link

CamWms commented Jun 1, 2021

I think that we need to keep the Pressure Measurement quite simple and generic. The client that gets pressure and altitude can do the calculation for the application solution, not the sensor. For pressure measurement we should use the pattern of the Concentration Measurement cluster (ZCL8) where we use the same cluster, but use Alias cluster IDs that add semantics to measurement: Air Pressure, Water Pressure, etc.

@bzbarsky-apple
Copy link
Contributor

The min / max values where intended to indicate the possible value range of the atmospheric pressure.

Right, I understand the intent. I am asking:

  1. What are the deployment situations expected for this cluster?
  2. Do these values make sense given those deployment situations?

So I would e.g. suggest 8000 for min and 12000 for max.

Would you expect these sensors to be used in airplane cabins? If so, would you expect their altitude to be changed as the plane's pressurization setpoint changes, or would you expect them to read the "actual" pressure (which I understand can be below 800 millibars)?

I don't know how this could be related to submersible applications? Could you provide an example.

Air pressure sensor in a submarine, say. Which are generally kept at 1 atmosphere or so, but I'm not sure how much variation is within spec there.

@ghost
Copy link
Author

ghost commented Jun 1, 2021

We will withdraw the current air pressure measurement cluster for TE3, due to time constrains and some concerns state here. We will consider the pressure measurement cluster as suggested by @CamWms and see if this will fit our needs.

@ghost ghost closed this Jun 1, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants