Skip to content

Commit

Permalink
[relativehumidity] Fix MaxMeasuredValue (#17682)
Browse files Browse the repository at this point in the history
* [relativehumidity] Fix MaxMeasuredValue

Example apps used MaxMeasuredValue attribute of the
RelativeHumidityMeasurement cluster that was out of the
allowed range. Set correct and useful Min and Max.

* Make RelativeHumidity attributes nullable

* Restyled by clang-format

* Fix Android build

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jan 26, 2024
1 parent 2d22217 commit f485207
Show file tree
Hide file tree
Showing 31 changed files with 723 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2752,9 +2752,9 @@ server cluster PumpConfigurationAndControl = 512 {
}

server cluster RelativeHumidityMeasurement = 1029 {
readonly attribute int16u measuredValue = 0;
readonly attribute int16u minMeasuredValue = 1;
readonly attribute int16u maxMeasuredValue = 2;
readonly attribute nullable int16u measuredValue = 0;
readonly attribute nullable int16u minMeasuredValue = 1;
readonly attribute nullable int16u maxMeasuredValue = 2;
readonly attribute int16u tolerance = 3;
readonly attribute int16u clusterRevision = 65533;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6768,7 +6768,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "0",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand All @@ -6783,7 +6783,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "0x2710",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand Down Expand Up @@ -10808,7 +10808,7 @@
"incoming": 1,
"outgoing": 0
},
{
{
"name": "GetYearDaySchedule",
"code": 15,
"mfgCode": null,
Expand Down Expand Up @@ -14909,7 +14909,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "0",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand All @@ -14924,7 +14924,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": "0x2710",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand Down
12 changes: 6 additions & 6 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1917,9 +1917,9 @@ server cluster PumpConfigurationAndControl = 512 {
}

client cluster RelativeHumidityMeasurement = 1029 {
readonly attribute int16u measuredValue = 0;
readonly attribute int16u minMeasuredValue = 1;
readonly attribute int16u maxMeasuredValue = 2;
readonly attribute nullable int16u measuredValue = 0;
readonly attribute nullable int16u minMeasuredValue = 1;
readonly attribute nullable int16u maxMeasuredValue = 2;
readonly attribute int16u tolerance = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand All @@ -1928,9 +1928,9 @@ client cluster RelativeHumidityMeasurement = 1029 {
}

server cluster RelativeHumidityMeasurement = 1029 {
readonly attribute int16u measuredValue = 0;
readonly attribute int16u minMeasuredValue = 1;
readonly attribute int16u maxMeasuredValue = 2;
readonly attribute nullable int16u measuredValue = 0;
readonly attribute nullable int16u minMeasuredValue = 1;
readonly attribute nullable int16u maxMeasuredValue = 2;
readonly attribute int16u tolerance = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down
4 changes: 2 additions & 2 deletions examples/placeholder/linux/apps/app1/config.zap
Original file line number Diff line number Diff line change
Expand Up @@ -5554,7 +5554,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0xFFFF",
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -5569,7 +5569,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0xFFFF",
"defaultValue": "0x2710",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
12 changes: 6 additions & 6 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1917,9 +1917,9 @@ server cluster PumpConfigurationAndControl = 512 {
}

client cluster RelativeHumidityMeasurement = 1029 {
readonly attribute int16u measuredValue = 0;
readonly attribute int16u minMeasuredValue = 1;
readonly attribute int16u maxMeasuredValue = 2;
readonly attribute nullable int16u measuredValue = 0;
readonly attribute nullable int16u minMeasuredValue = 1;
readonly attribute nullable int16u maxMeasuredValue = 2;
readonly attribute int16u tolerance = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand All @@ -1928,9 +1928,9 @@ client cluster RelativeHumidityMeasurement = 1029 {
}

server cluster RelativeHumidityMeasurement = 1029 {
readonly attribute int16u measuredValue = 0;
readonly attribute int16u minMeasuredValue = 1;
readonly attribute int16u maxMeasuredValue = 2;
readonly attribute nullable int16u measuredValue = 0;
readonly attribute nullable int16u minMeasuredValue = 1;
readonly attribute nullable int16u maxMeasuredValue = 2;
readonly attribute int16u tolerance = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down
4 changes: 2 additions & 2 deletions examples/placeholder/linux/apps/app2/config.zap
Original file line number Diff line number Diff line change
Expand Up @@ -5554,7 +5554,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0xFFFF",
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -5569,7 +5569,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0xFFFF",
"defaultValue": "0x2710",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
6 changes: 3 additions & 3 deletions examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1671,9 +1671,9 @@ server cluster OperationalCredentials = 62 {
}

server cluster RelativeHumidityMeasurement = 1029 {
readonly attribute int16u measuredValue = 0;
readonly attribute int16u minMeasuredValue = 1;
readonly attribute int16u maxMeasuredValue = 2;
readonly attribute nullable int16u measuredValue = 0;
readonly attribute nullable int16u minMeasuredValue = 1;
readonly attribute nullable int16u maxMeasuredValue = 2;
readonly attribute int16u clusterRevision = 65533;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

private typealias ReadCallback = ChipClusters.IntegerAttributeCallback
private typealias PressureReadCallback =
ChipClusters.PressureMeasurementCluster.MeasuredValueAttributeCallback
private typealias TemperatureReadCallback =
ChipClusters.TemperatureMeasurementCluster.MeasuredValueAttributeCallback
ChipClusters.TemperatureMeasurementCluster.MeasuredValueAttributeCallback

private typealias PressureReadCallback =
ChipClusters.PressureMeasurementCluster.MeasuredValueAttributeCallback

private typealias RelativeHumidityReadCallback =
ChipClusters.RelativeHumidityMeasurementCluster.MeasuredValueAttributeCallback

class SensorClientFragment : Fragment() {
private lateinit var scope: CoroutineScope
Expand Down Expand Up @@ -243,49 +247,85 @@ class SensorClientFragment : Fragment() {
private const val MAX_DATA_POINTS = 60
private val CLUSTERS = mapOf(
"Temperature" to mapOf(
"read" to { device: Long, endpointId: Int, callback: TemperatureReadCallback ->
"read" to { device: Long, endpointId: Int, callback: ReadCallback ->
val cluster = ChipClusters.TemperatureMeasurementCluster(device, endpointId)
cluster.readMeasuredValueAttribute(callback)
cluster.readMeasuredValueAttribute(makeTemperatureReadCallback(callback))
},
"subscribe" to { device: Long, endpointId: Int, callback: TemperatureReadCallback ->
"subscribe" to { device: Long, endpointId: Int, callback: ReadCallback ->
val cluster = ChipClusters.TemperatureMeasurementCluster(device, endpointId)
cluster.subscribeMeasuredValueAttribute(callback,
MIN_REFRESH_PERIOD_S,
MAX_REFRESH_PERIOD_S)
cluster.subscribeMeasuredValueAttribute(makeTemperatureReadCallback(callback),
MIN_REFRESH_PERIOD_S,
MAX_REFRESH_PERIOD_S)
},
"unitValue" to 0.01,
"unitSymbol" to "\u00B0C"
),
"Pressure" to mapOf(
"read" to { device: Long, endpointId: Int, callback: PressureReadCallback ->
"read" to { device: Long, endpointId: Int, callback: ReadCallback ->
val cluster = ChipClusters.PressureMeasurementCluster(device, endpointId)
cluster.readMeasuredValueAttribute(callback)
cluster.readMeasuredValueAttribute(makePressureReadCallback(callback))
},
"subscribe" to { device: Long, endpointId: Int, callback: PressureReadCallback ->
"subscribe" to { device: Long, endpointId: Int, callback: ReadCallback ->
val cluster = ChipClusters.PressureMeasurementCluster(device, endpointId)
cluster.subscribeMeasuredValueAttribute(callback,
MIN_REFRESH_PERIOD_S,
MAX_REFRESH_PERIOD_S)
cluster.subscribeMeasuredValueAttribute(makePressureReadCallback(callback),
MIN_REFRESH_PERIOD_S,
MAX_REFRESH_PERIOD_S)
},
"unitValue" to 1.0,
"unitSymbol" to "hPa"
),
"Relative Humidity" to mapOf(
"read" to { device: Long, endpointId: Int, callback: ReadCallback ->
val cluster = ChipClusters.RelativeHumidityMeasurementCluster(device, endpointId)
cluster.readMeasuredValueAttribute(callback)
cluster.readMeasuredValueAttribute(makeHumidityReadCallback(callback))
},
"subscribe" to { device: Long, endpointId: Int, callback: ReadCallback ->
val cluster = ChipClusters.RelativeHumidityMeasurementCluster(device, endpointId)
cluster.subscribeMeasuredValueAttribute(callback,
MIN_REFRESH_PERIOD_S,
MAX_REFRESH_PERIOD_S)
cluster.subscribeMeasuredValueAttribute(makeHumidityReadCallback(callback),
MIN_REFRESH_PERIOD_S,
MAX_REFRESH_PERIOD_S)
},
"unitValue" to 0.01,
"unitSymbol" to "%"
)
)

private fun makeTemperatureReadCallback(callback: ReadCallback): TemperatureReadCallback {
return object : TemperatureReadCallback {
override fun onSuccess(value: Int?) {
value?.let { callback.onSuccess(it) }
}

override fun onError(error: java.lang.Exception?) {
callback.onError(error)
}
}
}

private fun makePressureReadCallback(callback: ReadCallback): PressureReadCallback {
return object : PressureReadCallback {
override fun onSuccess(value: Int?) {
value?.let { callback.onSuccess(it) }
}

override fun onError(error: java.lang.Exception?) {
callback.onError(error)
}
}
}

private fun makeHumidityReadCallback(callback: ReadCallback): RelativeHumidityReadCallback {
return object : RelativeHumidityReadCallback {
override fun onSuccess(value: Int?) {
value?.let { callback.onSuccess(it) }
}

override fun onError(error: java.lang.Exception?) {
callback.onError(error)
}
}
}

fun newInstance(): SensorClientFragment = SensorClientFragment()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ limitations under the License.
<define>RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER</define>
<client tick="false" init="false">true</client>
<server tick="false" tickFrequency="half" init="false">true</server>
<attribute side="server" code="0x0000" define="RELATIVE_HUMIDITY_MEASURED_VALUE" type="INT16U" writable="false" reportable="true" optional="false">measured value</attribute>
<attribute side="server" code="0x0001" define="RELATIVE_HUMIDITY_MIN_MEASURED_VALUE" type="INT16U" min="0x0000" max="0x270F" writable="false" default="0xFFFF" optional="false">min measured value</attribute>
<attribute side="server" code="0x0002" define="RELATIVE_HUMIDITY_MAX_MEASURED_VALUE" type="INT16U" min="0x0001" max="0x2710" writable="false" default="0xFFFF" optional="false">max measured value</attribute>
<attribute side="server" code="0x0000" define="RELATIVE_HUMIDITY_MEASURED_VALUE" type="INT16U" writable="false" reportable="true" optional="false" isNullable="true">measured value</attribute>
<attribute side="server" code="0x0001" define="RELATIVE_HUMIDITY_MIN_MEASURED_VALUE" type="INT16U" min="0x0000" max="0x270F" writable="false" optional="false" isNullable="true">min measured value</attribute>
<attribute side="server" code="0x0002" define="RELATIVE_HUMIDITY_MAX_MEASURED_VALUE" type="INT16U" min="0x0001" max="0x2710" writable="false" optional="false" isNullable="true">max measured value</attribute>
<attribute side="server" code="0x0003" define="RELATIVE_HUMIDITY_TOLERANCE" type="INT16U" min="0x0000" max="0x0800" writable="false" reportable="true" optional="true">tolerance</attribute>
</cluster>
</configurator>
6 changes: 3 additions & 3 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -3173,9 +3173,9 @@ client cluster PumpConfigurationAndControl = 512 {
}

client cluster RelativeHumidityMeasurement = 1029 {
readonly attribute int16u measuredValue = 0;
readonly attribute int16u minMeasuredValue = 1;
readonly attribute int16u maxMeasuredValue = 2;
readonly attribute nullable int16u measuredValue = 0;
readonly attribute nullable int16u minMeasuredValue = 1;
readonly attribute nullable int16u maxMeasuredValue = 2;
readonly attribute int16u tolerance = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down
45 changes: 33 additions & 12 deletions src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f485207

Please sign in to comment.