From c0be967e8a74b378245e13b43457fa40a8650720 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Thu, 20 May 2021 15:43:38 +0200 Subject: [PATCH 01/23] format endpointClusterWithInit for easier pull requests --- src/app/zap-templates/templates/app/helper.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/zap-templates/templates/app/helper.js b/src/app/zap-templates/templates/app/helper.js index 2cc69780681bf6..8459ae1e20e0b6 100644 --- a/src/app/zap-templates/templates/app/helper.js +++ b/src/app/zap-templates/templates/app/helper.js @@ -195,8 +195,15 @@ function asChipUnderlyingType(label, type) // These helpers only works within the endpoint_config iterator // List of all cluster with generated functions -var endpointClusterWithInit = - [ 'Basic', 'Identify', 'Groups', 'Scenes', 'Occupancy Sensing', 'On/off', 'Level Control', 'Color Control', 'IAS Zone' ]; +var endpointClusterWithInit = [ 'Basic', + 'Identify', + 'Groups', + 'Scenes', + 'Occupancy Sensing', + 'On/off', + 'Level Control', + 'Color Control', + 'IAS Zone' ]; var endpointClusterWithAttributeChanged = [ 'Identify', 'Door Lock' ]; var endpointClusterWithPreAttribute = [ 'IAS Zone' ]; var endpointClusterWithMessageSent = [ 'IAS Zone' ]; From 81bf8ab662be726b1fff90e3613dd7214e98a5cc Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Wed, 19 May 2021 11:51:06 +0200 Subject: [PATCH 02/23] add air pressure measurement clsuter definition to zap tool --- .../zcl/air-pressure-measurement.xml | 19 +++++++++++++++++++ src/app/zap-templates/zcl/zcl.json | 1 + 2 files changed, 20 insertions(+) create mode 100644 src/app/zap-templates/zcl/air-pressure-measurement.xml diff --git a/src/app/zap-templates/zcl/air-pressure-measurement.xml b/src/app/zap-templates/zcl/air-pressure-measurement.xml new file mode 100644 index 00000000000000..84ee79aaaa9260 --- /dev/null +++ b/src/app/zap-templates/zcl/air-pressure-measurement.xml @@ -0,0 +1,19 @@ + + + + + Measurement & Sensing + Air Pressure Measurement + 0x0407 + AIR_PRESSURE_MEASUREMENT_CLUSTER + true + true + Air pressure measurement cluster in hPA with 1 digit fixed point resolution + measured value + altitude + + set altitud for air pressure measurements + + + + diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 617f0587e80e60..5033ec1789fcd4 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -3,6 +3,7 @@ "xmlRoot": [".", "./data-model/silabs/"], "xmlFile": [ "test-cluster.xml", + "air-pressure-measurement.xml", "account-login-cluster.xml", "application-launcher-cluster.xml", "audio-output-cluster.xml", From 425f47666f6515a8fc60a3e015758a8073a249d1 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Thu, 20 May 2021 16:00:02 +0200 Subject: [PATCH 03/23] add support for emberAfAirPressureMeasurementClusterServerInitCallback --- src/app/zap-templates/templates/app/helper.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/zap-templates/templates/app/helper.js b/src/app/zap-templates/templates/app/helper.js index 8459ae1e20e0b6..b07d6e44afdf12 100644 --- a/src/app/zap-templates/templates/app/helper.js +++ b/src/app/zap-templates/templates/app/helper.js @@ -196,6 +196,7 @@ function asChipUnderlyingType(label, type) // List of all cluster with generated functions var endpointClusterWithInit = [ 'Basic', + 'Air Pressure Measurement', 'Identify', 'Groups', 'Scenes', From 97a66f47b723b5dff3b934fbb72eaefd9d7c1ed2 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Thu, 20 May 2021 17:30:58 +0200 Subject: [PATCH 04/23] add air pressure measurement cluster to controller-clusters.zap --- .../data_model/controller-clusters.zap | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index 5fb4d5af9d2991..42ee9c867efdaa 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -5230,6 +5230,97 @@ } ] }, + { + "name": "Air Pressure Measurement", + "code": 1031, + "mfgCode": null, + "define": "AIR_PRESSURE_MEASUREMENT_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "altitude", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Air Pressure Measurement", + "code": 1031, + "mfgCode": null, + "define": "AIR_PRESSURE_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "measured value", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "10132", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "altitude", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "IAS Zone", "code": 1280, From 442c6c1c3c0bb0207e7b176c42801677957002e9 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Wed, 19 May 2021 14:38:13 +0200 Subject: [PATCH 05/23] add impl. for air pressure measurement cluster on the server side --- .../air-pressure-measurement-server.cpp | 99 +++++++++++++++++++ .../air-pressure-measurement-server.h | 24 +++++ 2 files changed, 123 insertions(+) create mode 100644 src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp create mode 100644 src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp new file mode 100644 index 00000000000000..442e2d97675b31 --- /dev/null +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp @@ -0,0 +1,99 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "air-pressure-measurement-server.h" + +#include + +#include "gen/att-storage.h" +#include "gen/attribute-id.h" +#include "gen/attribute-type.h" +#include "gen/cluster-id.h" +#include "gen/command-id.h" + +EmberAfStatus emberAfAirPressureMeasurementClusterGetMeasuredValue(chip::EndpointId endpoint, uint16_t* measuredValue) +{ + return emberAfReadAttribute(endpoint, + ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, + CLUSTER_MASK_SERVER, + (uint8_t*)measuredValue, + sizeof(*measuredValue), + NULL); +} + +static EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeCallback(chip::EndpointId endpoint, int16_t altitude) +{ + EmberAfStatus status = emberAfWriteAttribute(endpoint, + ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, + CLUSTER_MASK_SERVER, + (uint8_t *)&altitude, + ZCL_INT16S_ATTRIBUTE_TYPE); + if (EMBER_ZCL_STATUS_SUCCESS != status) + { + // emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); + } + + return status; +} + +void emberAfAirPressureMeasurementClusterServerInitCallback(chip::EndpointId endpoint) +{ + uint16_t measuredValue = 0; + EmberAfStatus status = emberAfAirPressureMeasurementClusterGetMeasuredValue(endpoint, &measuredValue); + + if (EMBER_ZCL_STATUS_SUCCESS != status) + { + (void)emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(endpoint, 10132); + } + + int16_t altitude = 0; + status = emberAfAirPressureMeasurementClusterGetAltitudeValue(endpoint, &altitude); + + if (EMBER_ZCL_STATUS_SUCCESS != status) + { + (void)emberAfAirPressureMeasurementClusterSetAltitudeCallback(endpoint, 0); + } +} + +EmberAfStatus emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(chip::EndpointId endpoint, uint16_t measuredValue) +{ + EmberAfStatus status = emberAfWriteAttribute(endpoint, + ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, + CLUSTER_MASK_SERVER, + (uint8_t *)&measuredValue, + ZCL_INT16U_ATTRIBUTE_TYPE); + if (EMBER_ZCL_STATUS_SUCCESS != status) + { + // emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); + } + + return status; +} + +EmberAfStatus emberAfAirPressureMeasurementClusterGetAltitudeValue(chip::EndpointId endpoint, int16_t* altitude) +{ + return emberAfReadAttribute(endpoint, + ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, + CLUSTER_MASK_SERVER, + (uint8_t*)altitude, + sizeof(*altitude), + NULL); +} diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h new file mode 100644 index 00000000000000..81274389d7d5fe --- /dev/null +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h @@ -0,0 +1,24 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +EmberAfStatus emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(chip::EndpointId endpoint, uint16_t measuredValue); +EmberAfStatus emberAfAirPressureMeasurementClusterGetMeasuredValue(chip::EndpointId endpoint, uint16_t* measuredValue); +EmberAfStatus emberAfAirPressureMeasurementClusterGetAltitudeValue(chip::EndpointId endpoint, int16_t* altitude); From d2ff9e1ff3706425719ee009dcd4c1f881a68e6f Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 20 May 2021 11:53:09 +0200 Subject: [PATCH 06/23] Add new clusters to zap_cluster_list.py --- src/app/zap_cluster_list.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py index dc2ce3a5439031..d39db9cf220bfe 100755 --- a/src/app/zap_cluster_list.py +++ b/src/app/zap_cluster_list.py @@ -9,6 +9,7 @@ # List of directories in src/app/clusters to build for server clusters. SERVER_CLUSTERS: typing.Dict[str, typing.List[str]] = { + 'AIR_PRESSURE_MEASUREMENT_CLUSTER': ['air-pressure-measurement-server'], 'ALARM_CLUSTER': [], 'APPLICATION_BASIC_CLUSTER': [], 'ACCOUNT_LOGIN_CLUSTER': [], @@ -16,6 +17,7 @@ 'AUDIO_OUTPUT_CLUSTER': [], 'BARRIER_CONTROL_CLUSTER': ['barrier-control-server'], 'BASIC_CLUSTER': ['basic'], + 'BINARY_INPUT_BASIC_CLUSTER': ['binary-input-server'], 'BINDING_CLUSTER': ['bindings'], 'BRIDGED_DEVICE_BASIC_CLUSTER': [], 'COLOR_CONTROL_CLUSTER': ['color-control-server'], @@ -65,6 +67,7 @@ # List of directories in src/app/clusters to build for client clusters. CLIENT_CLUSTERS: typing.Dict[str, typing.List[str]] = { + 'AIR_PRESSURE_MEASUREMENT_CLUSTER': [], 'ALARM_CLUSTER': [], 'ACCOUNT_LOGIN_CLUSTER': [], 'APPLICATION_LAUNCHER_CLUSTER': [], @@ -72,6 +75,7 @@ 'APPLICATION_BASIC_CLUSTER': [], 'BARRIER_CONTROL_CLUSTER': [], 'BASIC_CLUSTER': [], + 'BINARY_INPUT_BASIC_CLUSTER': [], 'BINDING_CLUSTER': [], 'BRIDGED_DEVICE_BASIC_CLUSTER': [], 'COLOR_CONTROL_CLUSTER': [], From 27a13ea7a5e4f8951c8fa6c446363ac5a1f4c241 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 21 May 2021 08:29:34 +0000 Subject: [PATCH 07/23] Restyled by clang-format --- .../air-pressure-measurement-server.cpp | 50 +++++++------------ .../air-pressure-measurement-server.h | 4 +- src/app/zap-templates/templates/app/helper.js | 14 ++---- 3 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp index 442e2d97675b31..c4a788978a51a6 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp @@ -25,25 +25,18 @@ #include "gen/cluster-id.h" #include "gen/command-id.h" -EmberAfStatus emberAfAirPressureMeasurementClusterGetMeasuredValue(chip::EndpointId endpoint, uint16_t* measuredValue) +EmberAfStatus emberAfAirPressureMeasurementClusterGetMeasuredValue(chip::EndpointId endpoint, uint16_t * measuredValue) { - return emberAfReadAttribute(endpoint, - ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, - ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, - (uint8_t*)measuredValue, - sizeof(*measuredValue), - NULL); + return emberAfReadAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, + (uint8_t *) measuredValue, sizeof(*measuredValue), NULL); } static EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeCallback(chip::EndpointId endpoint, int16_t altitude) { - EmberAfStatus status = emberAfWriteAttribute(endpoint, - ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, - ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, - (uint8_t *)&altitude, - ZCL_INT16S_ATTRIBUTE_TYPE); + EmberAfStatus status = + emberAfWriteAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, + CLUSTER_MASK_SERVER, (uint8_t *) &altitude, ZCL_INT16S_ATTRIBUTE_TYPE); if (EMBER_ZCL_STATUS_SUCCESS != status) { // emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); @@ -55,30 +48,27 @@ static EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeCallback(chi void emberAfAirPressureMeasurementClusterServerInitCallback(chip::EndpointId endpoint) { uint16_t measuredValue = 0; - EmberAfStatus status = emberAfAirPressureMeasurementClusterGetMeasuredValue(endpoint, &measuredValue); + EmberAfStatus status = emberAfAirPressureMeasurementClusterGetMeasuredValue(endpoint, &measuredValue); if (EMBER_ZCL_STATUS_SUCCESS != status) { - (void)emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(endpoint, 10132); + (void) emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(endpoint, 10132); } int16_t altitude = 0; - status = emberAfAirPressureMeasurementClusterGetAltitudeValue(endpoint, &altitude); + status = emberAfAirPressureMeasurementClusterGetAltitudeValue(endpoint, &altitude); if (EMBER_ZCL_STATUS_SUCCESS != status) { - (void)emberAfAirPressureMeasurementClusterSetAltitudeCallback(endpoint, 0); + (void) emberAfAirPressureMeasurementClusterSetAltitudeCallback(endpoint, 0); } } EmberAfStatus emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(chip::EndpointId endpoint, uint16_t measuredValue) { - EmberAfStatus status = emberAfWriteAttribute(endpoint, - ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, - ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, - (uint8_t *)&measuredValue, - ZCL_INT16U_ATTRIBUTE_TYPE); + EmberAfStatus status = emberAfWriteAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, + (uint8_t *) &measuredValue, ZCL_INT16U_ATTRIBUTE_TYPE); if (EMBER_ZCL_STATUS_SUCCESS != status) { // emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); @@ -87,13 +77,9 @@ EmberAfStatus emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(chip: return status; } -EmberAfStatus emberAfAirPressureMeasurementClusterGetAltitudeValue(chip::EndpointId endpoint, int16_t* altitude) +EmberAfStatus emberAfAirPressureMeasurementClusterGetAltitudeValue(chip::EndpointId endpoint, int16_t * altitude) { - return emberAfReadAttribute(endpoint, - ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, - ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, - (uint8_t*)altitude, - sizeof(*altitude), - NULL); + return emberAfReadAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, (uint8_t *) altitude, + sizeof(*altitude), NULL); } diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h index 81274389d7d5fe..200945cab45d5d 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h @@ -20,5 +20,5 @@ #include EmberAfStatus emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(chip::EndpointId endpoint, uint16_t measuredValue); -EmberAfStatus emberAfAirPressureMeasurementClusterGetMeasuredValue(chip::EndpointId endpoint, uint16_t* measuredValue); -EmberAfStatus emberAfAirPressureMeasurementClusterGetAltitudeValue(chip::EndpointId endpoint, int16_t* altitude); +EmberAfStatus emberAfAirPressureMeasurementClusterGetMeasuredValue(chip::EndpointId endpoint, uint16_t * measuredValue); +EmberAfStatus emberAfAirPressureMeasurementClusterGetAltitudeValue(chip::EndpointId endpoint, int16_t * altitude); diff --git a/src/app/zap-templates/templates/app/helper.js b/src/app/zap-templates/templates/app/helper.js index b07d6e44afdf12..e2baf2d3cd8946 100644 --- a/src/app/zap-templates/templates/app/helper.js +++ b/src/app/zap-templates/templates/app/helper.js @@ -195,16 +195,10 @@ function asChipUnderlyingType(label, type) // These helpers only works within the endpoint_config iterator // List of all cluster with generated functions -var endpointClusterWithInit = [ 'Basic', - 'Air Pressure Measurement', - 'Identify', - 'Groups', - 'Scenes', - 'Occupancy Sensing', - 'On/off', - 'Level Control', - 'Color Control', - 'IAS Zone' ]; +var endpointClusterWithInit = [ + 'Basic', 'Air Pressure Measurement', 'Identify', 'Groups', 'Scenes', 'Occupancy Sensing', 'On/off', 'Level Control', + 'Color Control', 'IAS Zone' +]; var endpointClusterWithAttributeChanged = [ 'Identify', 'Door Lock' ]; var endpointClusterWithPreAttribute = [ 'IAS Zone' ]; var endpointClusterWithMessageSent = [ 'IAS Zone' ]; From 310b63066b26f007ee9299b78aed4140633f1165 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Tue, 25 May 2021 14:59:09 +0200 Subject: [PATCH 08/23] apply fixes - replace emberAfReadAttribute with emberAfReadServerAttribute - replace emberAfWriteAttribute with emberAfWriteServerAttribute - add emberAfAirPressureMeasurementClusterPrintln - let the caller do the logging --- .../air-pressure-measurement-server.cpp | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp index c4a788978a51a6..632a4c87faac02 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp @@ -25,61 +25,60 @@ #include "gen/cluster-id.h" #include "gen/command-id.h" +#include + +#ifndef emberAfAirPressureMeasurementClusterPrintln +#define emberAfAirPressureMeasurementClusterPrintln(...) ChipLogProgress(Zcl, __VA_ARGS__); +#endif + EmberAfStatus emberAfAirPressureMeasurementClusterGetMeasuredValue(chip::EndpointId endpoint, uint16_t * measuredValue) { - return emberAfReadAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, - ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, - (uint8_t *) measuredValue, sizeof(*measuredValue), NULL); + return emberAfReadServerAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, (uint8_t *) measuredValue, + sizeof(*measuredValue)); } static EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeCallback(chip::EndpointId endpoint, int16_t altitude) { - EmberAfStatus status = - emberAfWriteAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, (uint8_t *) &altitude, ZCL_INT16S_ATTRIBUTE_TYPE); - if (EMBER_ZCL_STATUS_SUCCESS != status) - { - // emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); - } - - return status; + return emberAfWriteServerAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, (uint8_t *) &altitude, + ZCL_INT16S_ATTRIBUTE_TYPE); } void emberAfAirPressureMeasurementClusterServerInitCallback(chip::EndpointId endpoint) { uint16_t measuredValue = 0; EmberAfStatus status = emberAfAirPressureMeasurementClusterGetMeasuredValue(endpoint, &measuredValue); - if (EMBER_ZCL_STATUS_SUCCESS != status) { - (void) emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(endpoint, 10132); + status = emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(endpoint, 10132); + if (EMBER_ZCL_STATUS_SUCCESS != status) + { + emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); + } } int16_t altitude = 0; status = emberAfAirPressureMeasurementClusterGetAltitudeValue(endpoint, &altitude); - if (EMBER_ZCL_STATUS_SUCCESS != status) { - (void) emberAfAirPressureMeasurementClusterSetAltitudeCallback(endpoint, 0); + status = emberAfAirPressureMeasurementClusterSetAltitudeCallback(endpoint, 0); + if (EMBER_ZCL_STATUS_SUCCESS != status) + { + emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); + } } } EmberAfStatus emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(chip::EndpointId endpoint, uint16_t measuredValue) { - EmberAfStatus status = emberAfWriteAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, - ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, - (uint8_t *) &measuredValue, ZCL_INT16U_ATTRIBUTE_TYPE); - if (EMBER_ZCL_STATUS_SUCCESS != status) - { - // emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); - } - - return status; + return emberAfWriteServerAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID, (uint8_t *) &measuredValue, + ZCL_INT16U_ATTRIBUTE_TYPE); } EmberAfStatus emberAfAirPressureMeasurementClusterGetAltitudeValue(chip::EndpointId endpoint, int16_t * altitude) { - return emberAfReadAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, - ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, (uint8_t *) altitude, - sizeof(*altitude), NULL); + return emberAfReadServerAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, + ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, (uint8_t *) altitude, sizeof(*altitude)); } From 5e1e86b5c47958e4530a086d52df0cc2dfd75e14 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Wed, 26 May 2021 17:47:47 +0200 Subject: [PATCH 09/23] remove emberAfAirPressureMeasurementClusterServerInitCallback impl. The default values are populated by the attribute storage. --- .../air-pressure-measurement-server.cpp | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp index 632a4c87faac02..7fa94a22d7c927 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp @@ -47,27 +47,10 @@ static EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeCallback(chi void emberAfAirPressureMeasurementClusterServerInitCallback(chip::EndpointId endpoint) { - uint16_t measuredValue = 0; - EmberAfStatus status = emberAfAirPressureMeasurementClusterGetMeasuredValue(endpoint, &measuredValue); - if (EMBER_ZCL_STATUS_SUCCESS != status) - { - status = emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(endpoint, 10132); - if (EMBER_ZCL_STATUS_SUCCESS != status) - { - emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); - } - } - - int16_t altitude = 0; - status = emberAfAirPressureMeasurementClusterGetAltitudeValue(endpoint, &altitude); - if (EMBER_ZCL_STATUS_SUCCESS != status) - { - status = emberAfAirPressureMeasurementClusterSetAltitudeCallback(endpoint, 0); - if (EMBER_ZCL_STATUS_SUCCESS != status) - { - emberAfAirPressureMeasurementClusterPrintln("ERR: writing present value %x", status); - } - } + /** + * nothing to do here - default values set by attribute storage + */ + (void) endpoint; } EmberAfStatus emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(chip::EndpointId endpoint, uint16_t measuredValue) From c01614eb38069815339276670e3f26f2f8978b16 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Wed, 26 May 2021 17:47:59 +0200 Subject: [PATCH 10/23] fix year in copyright --- .../air-pressure-measurement-server.cpp | 2 +- .../air-pressure-measurement-server.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp index 7fa94a22d7c927..29e66bc3334a8e 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h index 200945cab45d5d..493f714f15444d 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From b6daa01338494410ef4ea78a0ab39033afae5197 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Wed, 26 May 2021 17:48:18 +0200 Subject: [PATCH 11/23] remove unrelated clusters in zap_cluster_list.py --- src/app/zap_cluster_list.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py index d39db9cf220bfe..b1ce098d121652 100755 --- a/src/app/zap_cluster_list.py +++ b/src/app/zap_cluster_list.py @@ -17,7 +17,6 @@ 'AUDIO_OUTPUT_CLUSTER': [], 'BARRIER_CONTROL_CLUSTER': ['barrier-control-server'], 'BASIC_CLUSTER': ['basic'], - 'BINARY_INPUT_BASIC_CLUSTER': ['binary-input-server'], 'BINDING_CLUSTER': ['bindings'], 'BRIDGED_DEVICE_BASIC_CLUSTER': [], 'COLOR_CONTROL_CLUSTER': ['color-control-server'], @@ -75,7 +74,6 @@ 'APPLICATION_BASIC_CLUSTER': [], 'BARRIER_CONTROL_CLUSTER': [], 'BASIC_CLUSTER': [], - 'BINARY_INPUT_BASIC_CLUSTER': [], 'BINDING_CLUSTER': [], 'BRIDGED_DEVICE_BASIC_CLUSTER': [], 'COLOR_CONTROL_CLUSTER': [], From d7082b4bccad501c1bef9918a603d68ee0a5c340 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Thu, 27 May 2021 16:46:16 +0200 Subject: [PATCH 12/23] remove altitude command The altitude attribute is writable so it is possible to write to the attribute without a command. --- src/app/zap-templates/zcl/air-pressure-measurement.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/app/zap-templates/zcl/air-pressure-measurement.xml b/src/app/zap-templates/zcl/air-pressure-measurement.xml index 84ee79aaaa9260..b4175ed7c206bc 100644 --- a/src/app/zap-templates/zcl/air-pressure-measurement.xml +++ b/src/app/zap-templates/zcl/air-pressure-measurement.xml @@ -11,9 +11,5 @@ Air pressure measurement cluster in hPA with 1 digit fixed point resolution measured value altitude - - set altitud for air pressure measurements - - From 14cb6690c3b5dad92f8762fe12376d0c11f15d18 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Fri, 28 May 2021 10:35:40 +0200 Subject: [PATCH 13/23] add air pressure measurement to all-cluster-app.zap --- .../all-clusters-common/all-clusters-app.zap | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 9f3de610c34da6..0ccf3b65e3550c 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -5106,6 +5106,97 @@ } ] }, + { + "name": "Air Pressure Measurement", + "code": 1031, + "mfgCode": null, + "define": "AIR_PRESSURE_MEASUREMENT_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "altitude", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Air Pressure Measurement", + "code": 1031, + "mfgCode": null, + "define": "AIR_PRESSURE_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "measured value", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "10132", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "altitude", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "IAS Zone", "code": 1280, From 2b6f7b9b8955eeab626091e6437e08f249532952 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Fri, 28 May 2021 11:20:54 +0200 Subject: [PATCH 14/23] fix includes in air-pressure-measurement-cluster.cpp --- .../air-pressure-measurement-server.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp index 29e66bc3334a8e..19e217ff843fb9 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp @@ -19,11 +19,11 @@ #include -#include "gen/att-storage.h" -#include "gen/attribute-id.h" -#include "gen/attribute-type.h" -#include "gen/cluster-id.h" -#include "gen/command-id.h" +#include +#include +#include +#include +#include #include From 7b326ee57d0f73cb3942d35abafd0ad007e26ba8 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Fri, 28 May 2021 11:21:22 +0200 Subject: [PATCH 15/23] expose emberAfAirPressureMeasurementClusterSetAltitudeValue --- .../air-pressure-measurement-server.cpp | 2 +- .../air-pressure-measurement-server.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp index 19e217ff843fb9..fca8b73c401489 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp @@ -38,7 +38,7 @@ EmberAfStatus emberAfAirPressureMeasurementClusterGetMeasuredValue(chip::Endpoin sizeof(*measuredValue)); } -static EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeCallback(chip::EndpointId endpoint, int16_t altitude) +EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeValue(chip::EndpointId endpoint, int16_t altitude) { return emberAfWriteServerAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID, (uint8_t *) &altitude, diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h index 493f714f15444d..b97e301b86ee6c 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.h @@ -21,4 +21,5 @@ EmberAfStatus emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(chip::EndpointId endpoint, uint16_t measuredValue); EmberAfStatus emberAfAirPressureMeasurementClusterGetMeasuredValue(chip::EndpointId endpoint, uint16_t * measuredValue); +EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeValue(chip::EndpointId endpoint, int16_t altitude); EmberAfStatus emberAfAirPressureMeasurementClusterGetAltitudeValue(chip::EndpointId endpoint, int16_t * altitude); From 4660f5b258e65b6613e2645480359d5cd1d67d93 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Fri, 28 May 2021 11:22:35 +0200 Subject: [PATCH 16/23] try to fix all-cluster-app/esp32 --- examples/all-clusters-app/esp32/main/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 847b61bf2be92e..8cb5308f7a3904 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -49,6 +49,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/door-lock-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/air-pressure-measurement-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ias-zone-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/relative-humidity-measurement-server" From 268ca65222131eeabe5fdcc50fa4b4aa6f6c5cdb Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Fri, 28 May 2021 15:42:22 +0200 Subject: [PATCH 17/23] another try to fix all-cluster-app/esp32 --- examples/all-clusters-app/esp32/main/component.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/all-clusters-app/esp32/main/component.mk b/examples/all-clusters-app/esp32/main/component.mk index 2224513b02b4f7..36e21af0afd717 100644 --- a/examples/all-clusters-app/esp32/main/component.mk +++ b/examples/all-clusters-app/esp32/main/component.mk @@ -56,6 +56,7 @@ COMPONENT_SRCDIRS := ../third_party/connectedhomeip/src/app/clusters/bindings \ ../third_party/connectedhomeip/src/app/reporting \ ../third_party/connectedhomeip/src/app/clusters/door-lock-server \ + ../third_party/connectedhomeip/src/app/clusters/air-pressure-measurement-server \ ../third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server \ ../third_party/connectedhomeip/src/app/clusters/ias-zone-server \ ../third_party/connectedhomeip/src/app/clusters/relative-humidity-measurement-server \ From 5418e13a1ccf506f7c8917b129cd8885d996e3d4 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Mon, 31 May 2021 11:56:46 +0200 Subject: [PATCH 18/23] move air pressure measurement cluster to endpoint 1 --- .../all-clusters-common/all-clusters-app.zap | 97 ++++++++++++++++--- 1 file changed, 85 insertions(+), 12 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 0ccf3b65e3550c..bde87d0096d60c 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1,5 +1,5 @@ { - "featureLevel": 29, + "featureLevel": 35, "creator": "zap", "keyValuePairs": [ { @@ -5113,16 +5113,7 @@ "define": "AIR_PRESSURE_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [ - { - "name": "altitude", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - } - ], + "commands": [], "attributes": [ { "name": "cluster revision", @@ -5147,7 +5138,7 @@ "mfgCode": null, "define": "AIR_PRESSURE_MEASUREMENT_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "commands": [], "attributes": [ { @@ -10433,6 +10424,88 @@ } ] }, + { + "name": "Air Pressure Measurement", + "code": 1031, + "mfgCode": null, + "define": "AIR_PRESSURE_MEASUREMENT_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Air Pressure Measurement", + "code": 1031, + "mfgCode": null, + "define": "AIR_PRESSURE_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "measured value", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "10132", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "altitude", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "IAS Zone", "code": 1280, From eefa01ba559bfcf23e5aabbeaa37ce7e5b5b0b65 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Mon, 31 May 2021 11:58:42 +0200 Subject: [PATCH 19/23] disable generation of emberAfAirPressureMeasurementClusterServerInitCallback --- .../air-pressure-measurement-server.cpp | 8 -------- src/app/zap-templates/templates/app/helper.js | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp index fca8b73c401489..11dcd2a12e2753 100644 --- a/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp +++ b/src/app/clusters/air-pressure-measurement-server/air-pressure-measurement-server.cpp @@ -45,14 +45,6 @@ EmberAfStatus emberAfAirPressureMeasurementClusterSetAltitudeValue(chip::Endpoin ZCL_INT16S_ATTRIBUTE_TYPE); } -void emberAfAirPressureMeasurementClusterServerInitCallback(chip::EndpointId endpoint) -{ - /** - * nothing to do here - default values set by attribute storage - */ - (void) endpoint; -} - EmberAfStatus emberAfAirPressureMeasurementClusterSetMeasuredValueCallback(chip::EndpointId endpoint, uint16_t measuredValue) { return emberAfWriteServerAttribute(endpoint, ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, diff --git a/src/app/zap-templates/templates/app/helper.js b/src/app/zap-templates/templates/app/helper.js index e2baf2d3cd8946..f37a444020596c 100644 --- a/src/app/zap-templates/templates/app/helper.js +++ b/src/app/zap-templates/templates/app/helper.js @@ -196,7 +196,7 @@ function asChipUnderlyingType(label, type) // List of all cluster with generated functions var endpointClusterWithInit = [ - 'Basic', 'Air Pressure Measurement', 'Identify', 'Groups', 'Scenes', 'Occupancy Sensing', 'On/off', 'Level Control', + 'Basic', 'Identify', 'Groups', 'Scenes', 'Occupancy Sensing', 'On/off', 'Level Control', 'Color Control', 'IAS Zone' ]; var endpointClusterWithAttributeChanged = [ 'Identify', 'Door Lock' ]; From c587937d5f826da2851b3af39c028f7dd4782434 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Mon, 31 May 2021 12:13:16 +0200 Subject: [PATCH 20/23] adapt description in air-pressure-measurment.xml --- src/app/zap-templates/zcl/air-pressure-measurement.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/zap-templates/zcl/air-pressure-measurement.xml b/src/app/zap-templates/zcl/air-pressure-measurement.xml index b4175ed7c206bc..337e6fdc6fafe9 100644 --- a/src/app/zap-templates/zcl/air-pressure-measurement.xml +++ b/src/app/zap-templates/zcl/air-pressure-measurement.xml @@ -8,7 +8,7 @@ AIR_PRESSURE_MEASUREMENT_CLUSTER true true - Air pressure measurement cluster in hPA with 1 digit fixed point resolution + Air pressure measurement cluster in daPA measured value altitude From 70f5a63384361940ed26c505cc0eac5fb689b2f9 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Mon, 31 May 2021 12:24:23 +0200 Subject: [PATCH 21/23] extend value range of min / max of air pressure measurement --- src/app/zap-templates/zcl/air-pressure-measurement.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/zap-templates/zcl/air-pressure-measurement.xml b/src/app/zap-templates/zcl/air-pressure-measurement.xml index 337e6fdc6fafe9..e48297cbad7fc2 100644 --- a/src/app/zap-templates/zcl/air-pressure-measurement.xml +++ b/src/app/zap-templates/zcl/air-pressure-measurement.xml @@ -9,7 +9,7 @@ true true Air pressure measurement cluster in daPA - measured value + measured value altitude From 22af3916a050b2091435810df5ea26b178730690 Mon Sep 17 00:00:00 2001 From: Dimitri Mizenko Date: Mon, 31 May 2021 12:25:48 +0200 Subject: [PATCH 22/23] regen all --- .../gen/call-command-handler.cpp | 5 + .../all-clusters-common/gen/callback-stub.cpp | 8 + .../all-clusters-common/gen/callback.h | 80 ++++++++ .../all-clusters-common/gen/endpoint_config.h | 50 +++-- .../all-clusters-common/gen/gen_config.h | 6 + .../chip-tool/commands/clusters/Commands.h | 191 ++++++++++++++++++ src/app/common/gen/attribute-id.h | 8 + src/app/common/gen/cluster-id.h | 3 + src/app/common/gen/print-cluster.h | 8 + .../data_model/gen/CHIPClusters.cpp | 41 ++++ src/controller/data_model/gen/CHIPClusters.h | 16 ++ .../data_model/gen/call-command-handler.cpp | 5 + .../data_model/gen/callback-stub.cpp | 8 + src/controller/data_model/gen/callback.h | 80 ++++++++ .../data_model/gen/chip-zcl-zpro-codec-api.h | 47 +++++ src/controller/data_model/gen/encoder.cpp | 64 ++++++ .../data_model/gen/endpoint_config.h | 44 ++-- src/controller/data_model/gen/gen_config.h | 5 + .../python/chip/clusters/CHIPClusters.cpp | 32 +++ .../python/chip/clusters/CHIPClusters.py | 23 +++ .../Framework/CHIP/gen/CHIPClustersObjc.h | 13 ++ .../Framework/CHIP/gen/CHIPClustersObjc.mm | 121 +++++++++++ .../Framework/CHIPTests/CHIPClustersTests.m | 76 +++++++ 23 files changed, 894 insertions(+), 40 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp index 8d8f4ab7b8daa7..f360f863810eb3 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp @@ -29,6 +29,7 @@ using namespace chip; EmberAfStatus emberAfAccountLoginClusterServerCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfAirPressureMeasurementClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfApplicationBasicClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfApplicationLauncherClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfAudioOutputClusterServerCommandParse(EmberAfClusterCommand * cmd); @@ -118,6 +119,10 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) // No commands are enabled for cluster Account Login result = status(false, true, cmd->mfgSpecific); break; + case ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID: + // No commands are enabled for cluster Air Pressure Measurement + result = status(false, true, cmd->mfgSpecific); + break; case ZCL_APPLICATION_BASIC_CLUSTER_ID: // No commands are enabled for cluster Application Basic result = status(false, true, cmd->mfgSpecific); diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp index f5bbc99d4912ac..ce40211519504a 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp @@ -32,6 +32,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_ACCOUNT_LOGIN_CLUSTER_ID: emberAfAccountLoginClusterInitCallback(endpoint); break; + case ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID: + emberAfAirPressureMeasurementClusterInitCallback(endpoint); + break; case ZCL_APPLICATION_BASIC_CLUSTER_ID: emberAfApplicationBasicClusterInitCallback(endpoint); break; @@ -178,6 +181,11 @@ void __attribute__((weak)) emberAfAccountLoginClusterInitCallback(EndpointId end // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfAirPressureMeasurementClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfApplicationBasicClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback.h b/examples/all-clusters-app/all-clusters-common/gen/callback.h index 9ea9b7aee14b1f..a8a5c1303dd99d 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -48,6 +48,14 @@ void emberAfClusterInitCallback(chip::EndpointId endpoint, chip::ClusterId clust */ void emberAfAccountLoginClusterInitCallback(chip::EndpointId endpoint); +/** @brief Air Pressure Measurement Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfAirPressureMeasurementClusterInitCallback(chip::EndpointId endpoint); + /** @brief Application Basic Cluster Init * * Cluster Init @@ -480,6 +488,78 @@ EmberAfStatus emberAfAccountLoginClusterServerPreAttributeChangedCallback(chip:: */ void emberAfAccountLoginClusterServerTickCallback(chip::EndpointId endpoint); +// +// Air Pressure Measurement Cluster server +// + +/** @brief Air Pressure Measurement Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfAirPressureMeasurementClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Air Pressure Measurement Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfAirPressureMeasurementClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Air Pressure Measurement Cluster Server Manufacturer Specific Attribute Changed + * + * Server Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfAirPressureMeasurementClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Air Pressure Measurement Cluster Server Message Sent + * + * Server Message Sent + * + * @param type The type of message sent + * @param destination The destination to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfAirPressureMeasurementClusterServerMessageSentCallback(EmberOutgoingMessageType type, + chip::MessageSendDestination destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Air Pressure Measurement Cluster Server Pre Attribute Changed + * + * server Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfAirPressureMeasurementClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, + uint16_t size, uint8_t * value); + +/** @brief Air Pressure Measurement Cluster Server Tick + * + * server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfAirPressureMeasurementClusterServerTickCallback(chip::EndpointId endpoint); + // // Application Basic Cluster server // diff --git a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h index 8d06b294e3a6e6..064cca040087fd 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h @@ -1649,7 +1649,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 311 +#define GENERATED_ATTRIBUTE_COUNT 314 #define GENERATED_ATTRIBUTES \ { \ \ @@ -1986,6 +1986,11 @@ { 0x0002, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* max measured value */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \ \ + /* Endpoint: 1, Cluster: Air Pressure Measurement (server) */ \ + { 0x0000, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(10132) }, /* measured value */ \ + { 0x0001, ZAP_TYPE(INT16S), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0) }, /* altitude */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + \ /* Endpoint: 1, Cluster: IAS Zone (server) */ \ { 0x0000, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* zone state */ \ { 0x0001, ZAP_TYPE(ENUM16), 2, 0, ZAP_EMPTY_DEFAULT() }, /* zone type */ \ @@ -2125,7 +2130,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 50 +#define GENERATED_CLUSTER_COUNT 51 #define GENERATED_CLUSTERS \ { \ { \ @@ -2251,63 +2256,66 @@ { \ 0x0405, ZAP_ATTRIBUTE_INDEX(245), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Relative Humidity Measurement (server) */ \ + { \ + 0x0407, ZAP_ATTRIBUTE_INDEX(249), 3, 6, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Air Pressure Measurement (server) */ \ { 0x0500, \ - ZAP_ATTRIBUTE_INDEX(249), \ + ZAP_ATTRIBUTE_INDEX(252), \ 6, \ 16, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION) | \ ZAP_CLUSTER_MASK(MESSAGE_SENT_FUNCTION), \ chipFuncArrayIasZoneServer }, /* Endpoint: 1, Cluster: IAS Zone (server) */ \ { \ - 0x0503, ZAP_ATTRIBUTE_INDEX(255), 2, 34, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0503, ZAP_ATTRIBUTE_INDEX(258), 2, 34, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Wake on LAN (server) */ \ { \ - 0x0504, ZAP_ATTRIBUTE_INDEX(257), 4, 320, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0504, ZAP_ATTRIBUTE_INDEX(260), 4, 320, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: TV Channel (server) */ \ { \ - 0x0505, ZAP_ATTRIBUTE_INDEX(261), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0505, ZAP_ATTRIBUTE_INDEX(264), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Target Navigator (server) */ \ { \ - 0x0506, ZAP_ATTRIBUTE_INDEX(263), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0506, ZAP_ATTRIBUTE_INDEX(266), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Media Playback (server) */ \ { \ - 0x0507, ZAP_ATTRIBUTE_INDEX(264), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0507, ZAP_ATTRIBUTE_INDEX(267), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Media Input (server) */ \ { \ - 0x0508, ZAP_ATTRIBUTE_INDEX(266), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0508, ZAP_ATTRIBUTE_INDEX(269), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Low Power (server) */ \ { \ - 0x0509, ZAP_ATTRIBUTE_INDEX(267), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0509, ZAP_ATTRIBUTE_INDEX(270), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Keypad Input (server) */ \ { \ - 0x050A, ZAP_ATTRIBUTE_INDEX(268), 3, 510, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050A, ZAP_ATTRIBUTE_INDEX(271), 3, 510, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Content Launch (server) */ \ { \ - 0x050B, ZAP_ATTRIBUTE_INDEX(271), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050B, ZAP_ATTRIBUTE_INDEX(274), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Audio Output (server) */ \ { \ - 0x050C, ZAP_ATTRIBUTE_INDEX(273), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050C, ZAP_ATTRIBUTE_INDEX(276), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Application Launcher (server) */ \ { \ - 0x050D, ZAP_ATTRIBUTE_INDEX(275), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050D, ZAP_ATTRIBUTE_INDEX(278), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Application Basic (server) */ \ { \ - 0x050E, ZAP_ATTRIBUTE_INDEX(283), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050E, ZAP_ATTRIBUTE_INDEX(286), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Account Login (server) */ \ { \ - 0x050F, ZAP_ATTRIBUTE_INDEX(284), 20, 579, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050F, ZAP_ATTRIBUTE_INDEX(287), 20, 579, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Test Cluster (server) */ \ { \ - 0xF000, ZAP_ATTRIBUTE_INDEX(304), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF000, ZAP_ATTRIBUTE_INDEX(307), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Binding (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(305), \ + ZAP_ATTRIBUTE_INDEX(308), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/off (server) */ \ { 0x0406, \ - ZAP_ATTRIBUTE_INDEX(307), \ + ZAP_ATTRIBUTE_INDEX(310), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ @@ -2319,7 +2327,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 14, 3744 }, { ZAP_CLUSTER_INDEX(14), 34, 5160 }, { ZAP_CLUSTER_INDEX(48), 2, 8 }, \ + { ZAP_CLUSTER_INDEX(0), 14, 3744 }, { ZAP_CLUSTER_INDEX(14), 35, 5166 }, { ZAP_CLUSTER_INDEX(49), 2, 8 }, \ } // Largest attribute size is needed for various buffers @@ -2329,7 +2337,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (1730) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (8912) +#define ATTRIBUTE_MAX_SIZE (8918) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (3) diff --git a/examples/all-clusters-app/all-clusters-common/gen/gen_config.h b/examples/all-clusters-app/all-clusters-common/gen/gen_config.h index 5a0dd41e1db78c..39b706591157d2 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/gen_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/gen_config.h @@ -30,6 +30,7 @@ /**** Cluster endpoint counts ****/ #define EMBER_AF_ACCOUNT_LOGIN_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_AIR_PRESSURE_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_AUDIO_OUTPUT_CLUSTER_SERVER_ENDPOINT_COUNT (1) @@ -83,6 +84,11 @@ #define EMBER_AF_PLUGIN_ACCOUNT_LOGIN_SERVER #define EMBER_AF_PLUGIN_ACCOUNT_LOGIN +// Use this macro to check if the server side of the Air Pressure Measurement cluster is included +#define ZCL_USING_AIR_PRESSURE_MEASUREMENT_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_AIR_PRESSURE_MEASUREMENT_SERVER +#define EMBER_AF_PLUGIN_AIR_PRESSURE_MEASUREMENT + // Use this macro to check if the server side of the Application Basic cluster is included #define ZCL_USING_APPLICATION_BASIC_CLUSTER_SERVER #define EMBER_AF_PLUGIN_APPLICATION_BASIC_SERVER diff --git a/examples/chip-tool/commands/clusters/Commands.h b/examples/chip-tool/commands/clusters/Commands.h index b8dc4a87255e5d..12a31f72b225ec 100644 --- a/examples/chip-tool/commands/clusters/Commands.h +++ b/examples/chip-tool/commands/clusters/Commands.h @@ -964,6 +964,7 @@ static void OnTestClusterListStructOctetStringListAttributeResponse(void * conte | Cluster Name | ID | |---------------------------------------------------------------------+--------| | AccountLogin | 0x050E | +| AirPressureMeasurement | 0x0407 | | ApplicationBasic | 0x050D | | ApplicationLauncher | 0x050C | | AudioOutput | 0x050B | @@ -1006,6 +1007,7 @@ static void OnTestClusterListStructOctetStringListAttributeResponse(void * conte \*----------------------------------------------------------------------------*/ constexpr chip::ClusterId kAccountLoginClusterId = 0x050E; +constexpr chip::ClusterId kAirPressureMeasurementClusterId = 0x0407; constexpr chip::ClusterId kApplicationBasicClusterId = 0x050D; constexpr chip::ClusterId kApplicationLauncherClusterId = 0x050C; constexpr chip::ClusterId kAudioOutputClusterId = 0x050B; @@ -1195,6 +1197,182 @@ class ReadAccountLoginClusterRevision : public ModelCommand new chip::Callback::Callback(OnDefaultFailureResponse, this); }; +/*----------------------------------------------------------------------------*\ +| Cluster AirPressureMeasurement | 0x0407 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * MeasuredValue | 0x0000 | +| * Altitude | 0x0001 | +| * ClusterRevision | 0xFFFD | +\*----------------------------------------------------------------------------*/ + +/* + * Discover Attributes + */ +class DiscoverAirPressureMeasurementAttributes : public ModelCommand +{ +public: + DiscoverAirPressureMeasurementAttributes() : ModelCommand("discover") { ModelCommand::AddArguments(); } + + ~DiscoverAirPressureMeasurementAttributes() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x0C) on endpoint %" PRIu16, endpointId); + + chip::Controller::AirPressureMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.DiscoverAttributes(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnDefaultSuccessResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute MeasuredValue + */ +class ReadAirPressureMeasurementMeasuredValue : public ModelCommand +{ +public: + ReadAirPressureMeasurementMeasuredValue() : ModelCommand("read") + { + AddArgument("attr-name", "measured-value"); + ModelCommand::AddArguments(); + } + + ~ReadAirPressureMeasurementMeasuredValue() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0407) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::AirPressureMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeMeasuredValue(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute Altitude + */ +class ReadAirPressureMeasurementAltitude : public ModelCommand +{ +public: + ReadAirPressureMeasurementAltitude() : ModelCommand("read") + { + AddArgument("attr-name", "altitude"); + ModelCommand::AddArguments(); + } + + ~ReadAirPressureMeasurementAltitude() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0407) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::AirPressureMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeAltitude(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16sAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +class WriteAirPressureMeasurementAltitude : public ModelCommand +{ +public: + WriteAirPressureMeasurementAltitude() : ModelCommand("write") + { + AddArgument("attr-name", "altitude"); + AddArgument("attr-value", INT16_MIN, INT16_MAX, &mValue); + ModelCommand::AddArguments(); + } + + ~WriteAirPressureMeasurementAltitude() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0407) command (0x01) on endpoint %" PRIu16, endpointId); + + chip::Controller::AirPressureMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.WriteAttributeAltitude(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mValue); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnDefaultSuccessResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); + int16_t mValue; +}; + +/* + * Attribute ClusterRevision + */ +class ReadAirPressureMeasurementClusterRevision : public ModelCommand +{ +public: + ReadAirPressureMeasurementClusterRevision() : ModelCommand("read") + { + AddArgument("attr-name", "cluster-revision"); + ModelCommand::AddArguments(); + } + + ~ReadAirPressureMeasurementClusterRevision() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0407) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::AirPressureMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeClusterRevision(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + /*----------------------------------------------------------------------------*\ | Cluster ApplicationBasic | 0x050D | |------------------------------------------------------------------------------| @@ -17370,6 +17548,18 @@ void registerClusterAccountLogin(Commands & commands) commands.Register(clusterName, clusterCommands); } +void registerClusterAirPressureMeasurement(Commands & commands) +{ + const char * clusterName = "AirPressureMeasurement"; + + commands_list clusterCommands = { + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), + }; + + commands.Register(clusterName, clusterCommands); +} void registerClusterApplicationBasic(Commands & commands) { const char * clusterName = "ApplicationBasic"; @@ -18109,6 +18299,7 @@ void registerClusterWindowCovering(Commands & commands) void registerClusters(Commands & commands) { registerClusterAccountLogin(commands); + registerClusterAirPressureMeasurement(commands); registerClusterApplicationBasic(commands); registerClusterApplicationLauncher(commands); registerClusterAudioOutput(commands); diff --git a/src/app/common/gen/attribute-id.h b/src/app/common/gen/attribute-id.h index 72a50016e6cade..2172bec9b1aee2 100644 --- a/src/app/common/gen/attribute-id.h +++ b/src/app/common/gen/attribute-id.h @@ -972,6 +972,14 @@ #define ZCL_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_DELAY_ATTRIBUTE_ID (0x0031) #define ZCL_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_ATTRIBUTE_ID (0x0032) +// Attribute ids for cluster: Air Pressure Measurement + +// Client attributes + +// Server attributes +#define ZCL_AIR_PRESSURE_MEASUREMENT_MEASURED_VALUE_ATTRIBUTE_ID (0x0000) +#define ZCL_AIR_PRESSURE_MEASUREMENT_ALTITUDE_ATTRIBUTE_ID (0x0001) + // Attribute ids for cluster: Carbon Monoxide Concentration Measurement // Client attributes diff --git a/src/app/common/gen/cluster-id.h b/src/app/common/gen/cluster-id.h index 15097b69737e87..5889b2403f3632 100644 --- a/src/app/common/gen/cluster-id.h +++ b/src/app/common/gen/cluster-id.h @@ -182,6 +182,9 @@ // Definitions for cluster: Occupancy Sensing #define ZCL_OCCUPANCY_SENSING_CLUSTER_ID (0x0406) +// Definitions for cluster: Air Pressure Measurement +#define ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID (0x0407) + // Definitions for cluster: Carbon Monoxide Concentration Measurement #define ZCL_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER_ID (0x040C) diff --git a/src/app/common/gen/print-cluster.h b/src/app/common/gen/print-cluster.h index 8a4b85a79e52ae..a1e8ed74fc4091 100644 --- a/src/app/common/gen/print-cluster.h +++ b/src/app/common/gen/print-cluster.h @@ -355,6 +355,13 @@ #define CHIP_PRINTCLUSTER_OCCUPANCY_SENSING_CLUSTER #endif +#if defined(ZCL_USING_AIR_PRESSURE_MEASUREMENT_CLUSTER_SERVER) || defined(ZCL_USING_AIR_PRESSURE_MEASUREMENT_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_AIR_PRESSURE_MEASUREMENT_CLUSTER \ + { ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID, 1031, "Air Pressure Measurement" }, +#else +#define CHIP_PRINTCLUSTER_AIR_PRESSURE_MEASUREMENT_CLUSTER +#endif + #if defined(ZCL_USING_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER_SERVER) || \ defined(ZCL_USING_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER \ @@ -986,6 +993,7 @@ CHIP_PRINTCLUSTER_FLOW_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_OCCUPANCY_SENSING_CLUSTER \ + CHIP_PRINTCLUSTER_AIR_PRESSURE_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_ETHYLENE_CONCENTRATION_MEASUREMENT_CLUSTER \ diff --git a/src/controller/data_model/gen/CHIPClusters.cpp b/src/controller/data_model/gen/CHIPClusters.cpp index e98f78e4cbfc2f..6c9691ab017584 100644 --- a/src/controller/data_model/gen/CHIPClusters.cpp +++ b/src/controller/data_model/gen/CHIPClusters.cpp @@ -131,6 +131,47 @@ CHIP_ERROR AccountLoginCluster::ReadAttributeClusterRevision(Callback::Cancelabl return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); } +// AirPressureMeasurement Cluster Commands +// AirPressureMeasurement Cluster Attributes +CHIP_ERROR AirPressureMeasurementCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeAirPressureMeasurementClusterDiscoverAttributes(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} +CHIP_ERROR AirPressureMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeAirPressureMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} + +CHIP_ERROR AirPressureMeasurementCluster::ReadAttributeAltitude(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeAirPressureMeasurementClusterReadAltitudeAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} + +CHIP_ERROR AirPressureMeasurementCluster::WriteAttributeAltitude(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback, int16_t value) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeAirPressureMeasurementClusterWriteAltitudeAttribute(seqNum, mEndpoint, value); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} + +CHIP_ERROR AirPressureMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeAirPressureMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} + // ApplicationBasic Cluster Commands // ApplicationBasic Cluster Attributes CHIP_ERROR ApplicationBasicCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, diff --git a/src/controller/data_model/gen/CHIPClusters.h b/src/controller/data_model/gen/CHIPClusters.h index 4e817983958556..746adc03a60c3c 100644 --- a/src/controller/data_model/gen/CHIPClusters.h +++ b/src/controller/data_model/gen/CHIPClusters.h @@ -28,6 +28,7 @@ namespace chip { namespace Controller { constexpr ClusterId kAccountLoginClusterId = 0x050E; +constexpr ClusterId kAirPressureMeasurementClusterId = 0x0407; constexpr ClusterId kApplicationBasicClusterId = 0x050D; constexpr ClusterId kApplicationLauncherClusterId = 0x050C; constexpr ClusterId kAudioOutputClusterId = 0x050B; @@ -89,6 +90,21 @@ class DLL_EXPORT AccountLoginCluster : public ClusterBase static constexpr CommandId kLoginCommandId = 0x01; }; +class DLL_EXPORT AirPressureMeasurementCluster : public ClusterBase +{ +public: + AirPressureMeasurementCluster() : ClusterBase(kAirPressureMeasurementClusterId) {} + ~AirPressureMeasurementCluster() {} + + // Cluster Attributes + CHIP_ERROR DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeAltitude(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR WriteAttributeAltitude(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, + int16_t value); +}; + class DLL_EXPORT ApplicationBasicCluster : public ClusterBase { public: diff --git a/src/controller/data_model/gen/call-command-handler.cpp b/src/controller/data_model/gen/call-command-handler.cpp index 2a18b911128bd3..4ea2daecf4f542 100644 --- a/src/controller/data_model/gen/call-command-handler.cpp +++ b/src/controller/data_model/gen/call-command-handler.cpp @@ -29,6 +29,7 @@ using namespace chip; EmberAfStatus emberAfAccountLoginClusterClientCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfAirPressureMeasurementClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfApplicationBasicClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfApplicationLauncherClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfAudioOutputClusterClientCommandParse(EmberAfClusterCommand * cmd); @@ -101,6 +102,10 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) case ZCL_ACCOUNT_LOGIN_CLUSTER_ID: result = emberAfAccountLoginClusterClientCommandParse(cmd); break; + case ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID: + // No commands are enabled for cluster Air Pressure Measurement + result = status(false, true, cmd->mfgSpecific); + break; case ZCL_APPLICATION_BASIC_CLUSTER_ID: // No commands are enabled for cluster Application Basic result = status(false, true, cmd->mfgSpecific); diff --git a/src/controller/data_model/gen/callback-stub.cpp b/src/controller/data_model/gen/callback-stub.cpp index 5380678e5dbe18..97b97e842c2bb1 100644 --- a/src/controller/data_model/gen/callback-stub.cpp +++ b/src/controller/data_model/gen/callback-stub.cpp @@ -32,6 +32,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_ACCOUNT_LOGIN_CLUSTER_ID: emberAfAccountLoginClusterInitCallback(endpoint); break; + case ZCL_AIR_PRESSURE_MEASUREMENT_CLUSTER_ID: + emberAfAirPressureMeasurementClusterInitCallback(endpoint); + break; case ZCL_APPLICATION_BASIC_CLUSTER_ID: emberAfApplicationBasicClusterInitCallback(endpoint); break; @@ -160,6 +163,11 @@ void __attribute__((weak)) emberAfAccountLoginClusterInitCallback(EndpointId end // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfAirPressureMeasurementClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfApplicationBasicClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/src/controller/data_model/gen/callback.h b/src/controller/data_model/gen/callback.h index d5b955d625e531..cb610fd3543733 100644 --- a/src/controller/data_model/gen/callback.h +++ b/src/controller/data_model/gen/callback.h @@ -48,6 +48,14 @@ void emberAfClusterInitCallback(chip::EndpointId endpoint, chip::ClusterId clust */ void emberAfAccountLoginClusterInitCallback(chip::EndpointId endpoint); +/** @brief Air Pressure Measurement Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfAirPressureMeasurementClusterInitCallback(chip::EndpointId endpoint); + /** @brief Application Basic Cluster Init * * Cluster Init @@ -432,6 +440,78 @@ EmberAfStatus emberAfAccountLoginClusterClientPreAttributeChangedCallback(chip:: */ void emberAfAccountLoginClusterClientTickCallback(chip::EndpointId endpoint); +// +// Air Pressure Measurement Cluster client +// + +/** @brief Air Pressure Measurement Cluster Client Init + * + * Client Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfAirPressureMeasurementClusterClientInitCallback(chip::EndpointId endpoint); + +/** @brief Air Pressure Measurement Cluster Client Attribute Changed + * + * Client Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfAirPressureMeasurementClusterClientAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Air Pressure Measurement Cluster Client Manufacturer Specific Attribute Changed + * + * Client Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfAirPressureMeasurementClusterClientManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Air Pressure Measurement Cluster Client Message Sent + * + * Client Message Sent + * + * @param type The type of message sent + * @param destination The destination to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfAirPressureMeasurementClusterClientMessageSentCallback(EmberOutgoingMessageType type, + chip::MessageSendDestination destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Air Pressure Measurement Cluster Client Pre Attribute Changed + * + * client Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfAirPressureMeasurementClusterClientPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, + uint16_t size, uint8_t * value); + +/** @brief Air Pressure Measurement Cluster Client Tick + * + * client Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfAirPressureMeasurementClusterClientTickCallback(chip::EndpointId endpoint); + // // Application Basic Cluster client // diff --git a/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h b/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h index 9a598fbbe12543..cdc3a953d8dc6d 100644 --- a/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h +++ b/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h @@ -29,6 +29,7 @@ | Cluster Name | ID | |---------------------------------------------------------------------+--------| | AccountLogin | 0x050E | +| AirPressureMeasurement | 0x0407 | | ApplicationBasic | 0x050D | | ApplicationLauncher | 0x050C | | AudioOutput | 0x050B | @@ -94,6 +95,52 @@ chip::System::PacketBufferHandle encodeAccountLoginClusterDiscoverAttributes(uin chip::System::PacketBufferHandle encodeAccountLoginClusterReadClusterRevisionAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); +/*----------------------------------------------------------------------------*\ +| Cluster AirPressureMeasurement | 0x0407 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * MeasuredValue | 0x0000 | +| * Altitude | 0x0001 | +| * ClusterRevision | 0xFFFD | +\*----------------------------------------------------------------------------*/ + +/** + * @brief + * Encode a Air Pressure Measurement server discover command into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeAirPressureMeasurementClusterDiscoverAttributes(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Air Pressure Measurement server read command for the measured value attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle +encodeAirPressureMeasurementClusterReadMeasuredValueAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Air Pressure Measurement server read command for the altitude attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeAirPressureMeasurementClusterReadAltitudeAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Air Pressure Measurement server write command for the altitude attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle +encodeAirPressureMeasurementClusterWriteAltitudeAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint, int16_t altitude); + +/** + * @brief + * Encode a Air Pressure Measurement server read command for the cluster revision attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle +encodeAirPressureMeasurementClusterReadClusterRevisionAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + /*----------------------------------------------------------------------------*\ | Cluster ApplicationBasic | 0x050D | |------------------------------------------------------------------------------| diff --git a/src/controller/data_model/gen/encoder.cpp b/src/controller/data_model/gen/encoder.cpp index d10182363451d1..ffb9d4c3fe15b5 100644 --- a/src/controller/data_model/gen/encoder.cpp +++ b/src/controller/data_model/gen/encoder.cpp @@ -55,6 +55,7 @@ using namespace chip::Encoding::LittleEndian; | Cluster Name | ID | |---------------------------------------------------------------------+--------| | AccountLogin | 0x050E | +| AirPressureMeasurement | 0x0407 | | ApplicationBasic | 0x050D | | ApplicationLauncher | 0x050C | | AudioOutput | 0x050B | @@ -126,6 +127,8 @@ using namespace chip::Encoding::LittleEndian; #define ZCL_GET_SETUP_PIN_COMMAND_ID (0x00) #define ZCL_LOGIN_COMMAND_ID (0x01) +#define AIR_PRESSURE_MEASUREMENT_CLUSTER_ID 0x0407 + #define APPLICATION_BASIC_CLUSTER_ID 0x050D #define APPLICATION_LAUNCHER_CLUSTER_ID 0x050C @@ -375,6 +378,67 @@ PacketBufferHandle encodeAccountLoginClusterReadClusterRevisionAttribute(uint8_t COMMAND_FOOTER(); } +/*----------------------------------------------------------------------------*\ +| Cluster AirPressureMeasurement | 0x0407 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * MeasuredValue | 0x0000 | +| * Altitude | 0x0001 | +| * ClusterRevision | 0xFFFD | +\*----------------------------------------------------------------------------*/ + +PacketBufferHandle encodeAirPressureMeasurementClusterDiscoverAttributes(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("DiscoverAirPressureMeasurementAttributes", AIR_PRESSURE_MEASUREMENT_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID).Put16(0x0000).Put8(0xFF); + COMMAND_FOOTER(); +} + +/* + * Attribute MeasuredValue + */ +PacketBufferHandle encodeAirPressureMeasurementClusterReadMeasuredValueAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadAirPressureMeasurementMeasuredValue", AIR_PRESSURE_MEASUREMENT_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0000); + COMMAND_FOOTER(); +} + +/* + * Attribute Altitude + */ +PacketBufferHandle encodeAirPressureMeasurementClusterReadAltitudeAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadAirPressureMeasurementAltitude", AIR_PRESSURE_MEASUREMENT_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0001); + COMMAND_FOOTER(); +} + +PacketBufferHandle encodeAirPressureMeasurementClusterWriteAltitudeAttribute(uint8_t seqNum, EndpointId destinationEndpoint, + int16_t altitude) +{ + COMMAND_HEADER("WriteAirPressureMeasurementAltitude", AIR_PRESSURE_MEASUREMENT_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put8(ZCL_WRITE_ATTRIBUTES_COMMAND_ID) + .Put16(0x0001) + .Put8(41) + .Put16(static_cast(altitude)); + COMMAND_FOOTER(); +} + +/* + * Attribute ClusterRevision + */ +PacketBufferHandle encodeAirPressureMeasurementClusterReadClusterRevisionAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadAirPressureMeasurementClusterRevision", AIR_PRESSURE_MEASUREMENT_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0xFFFD); + COMMAND_FOOTER(); +} + /*----------------------------------------------------------------------------*\ | Cluster ApplicationBasic | 0x050D | |------------------------------------------------------------------------------| diff --git a/src/controller/data_model/gen/endpoint_config.h b/src/controller/data_model/gen/endpoint_config.h index 94fae2afea240b..75c51f2323e1ba 100644 --- a/src/controller/data_model/gen/endpoint_config.h +++ b/src/controller/data_model/gen/endpoint_config.h @@ -63,7 +63,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 40 +#define GENERATED_ATTRIBUTE_COUNT 41 #define GENERATED_ATTRIBUTES \ { \ \ @@ -144,6 +144,9 @@ /* Endpoint: 1, Cluster: Relative Humidity Measurement (client) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \ \ + /* Endpoint: 1, Cluster: Air Pressure Measurement (client) */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + \ /* Endpoint: 1, Cluster: Wake on LAN (client) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ \ @@ -197,7 +200,7 @@ #define GENERATED_FUNCTION_ARRAYS #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 40 +#define GENERATED_CLUSTER_COUNT 41 #define GENERATED_CLUSTERS \ { \ { 0x0003, ZAP_ATTRIBUTE_INDEX(0), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Identify (client) */ \ @@ -264,49 +267,52 @@ 0x0405, ZAP_ATTRIBUTE_INDEX(24), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Relative Humidity Measurement (client) */ \ { \ - 0x0503, ZAP_ATTRIBUTE_INDEX(25), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0407, ZAP_ATTRIBUTE_INDEX(25), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + }, /* Endpoint: 1, Cluster: Air Pressure Measurement (client) */ \ + { \ + 0x0503, ZAP_ATTRIBUTE_INDEX(26), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Wake on LAN (client) */ \ { \ - 0x0504, ZAP_ATTRIBUTE_INDEX(26), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0504, ZAP_ATTRIBUTE_INDEX(27), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: TV Channel (client) */ \ { \ - 0x0505, ZAP_ATTRIBUTE_INDEX(27), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0505, ZAP_ATTRIBUTE_INDEX(28), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Target Navigator (client) */ \ { \ - 0x0506, ZAP_ATTRIBUTE_INDEX(28), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0506, ZAP_ATTRIBUTE_INDEX(29), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Media Playback (client) */ \ { \ - 0x0507, ZAP_ATTRIBUTE_INDEX(29), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0507, ZAP_ATTRIBUTE_INDEX(30), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Media Input (client) */ \ { \ - 0x0508, ZAP_ATTRIBUTE_INDEX(30), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0508, ZAP_ATTRIBUTE_INDEX(31), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Low Power (client) */ \ { \ - 0x0509, ZAP_ATTRIBUTE_INDEX(31), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0509, ZAP_ATTRIBUTE_INDEX(32), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Keypad Input (client) */ \ { \ - 0x050A, ZAP_ATTRIBUTE_INDEX(32), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050A, ZAP_ATTRIBUTE_INDEX(33), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Content Launch (client) */ \ { \ - 0x050B, ZAP_ATTRIBUTE_INDEX(33), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050B, ZAP_ATTRIBUTE_INDEX(34), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Audio Output (client) */ \ { \ - 0x050C, ZAP_ATTRIBUTE_INDEX(34), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050C, ZAP_ATTRIBUTE_INDEX(35), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Application Launcher (client) */ \ { \ - 0x050D, ZAP_ATTRIBUTE_INDEX(35), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050D, ZAP_ATTRIBUTE_INDEX(36), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Application Basic (client) */ \ { \ - 0x050E, ZAP_ATTRIBUTE_INDEX(36), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050E, ZAP_ATTRIBUTE_INDEX(37), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Account Login (client) */ \ { \ - 0x050F, ZAP_ATTRIBUTE_INDEX(37), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050F, ZAP_ATTRIBUTE_INDEX(38), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Test Cluster (client) */ \ { \ - 0xF000, ZAP_ATTRIBUTE_INDEX(38), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0xF000, ZAP_ATTRIBUTE_INDEX(39), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Binding (client) */ \ { \ - 0xF004, ZAP_ATTRIBUTE_INDEX(39), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0xF004, ZAP_ATTRIBUTE_INDEX(40), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Group Key Management (client) */ \ } @@ -315,7 +321,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 40, 80 }, \ + { ZAP_CLUSTER_INDEX(0), 41, 82 }, \ } // Largest attribute size is needed for various buffers @@ -325,7 +331,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (4) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (80) +#define ATTRIBUTE_MAX_SIZE (82) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) diff --git a/src/controller/data_model/gen/gen_config.h b/src/controller/data_model/gen/gen_config.h index 73309031c43ff2..78c042c9e1e08b 100644 --- a/src/controller/data_model/gen/gen_config.h +++ b/src/controller/data_model/gen/gen_config.h @@ -30,6 +30,7 @@ /**** Cluster endpoint counts ****/ #define EMBER_AF_ACCOUNT_LOGIN_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_AIR_PRESSURE_MEASUREMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_APPLICATION_BASIC_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_APPLICATION_LAUNCHER_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_AUDIO_OUTPUT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) @@ -76,6 +77,10 @@ #define ZCL_USING_ACCOUNT_LOGIN_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_ACCOUNT_LOGIN_CLIENT +// Use this macro to check if the client side of the Air Pressure Measurement cluster is included +#define ZCL_USING_AIR_PRESSURE_MEASUREMENT_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_AIR_PRESSURE_MEASUREMENT_CLIENT + // Use this macro to check if the client side of the Application Basic cluster is included #define ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_APPLICATION_BASIC_CLIENT diff --git a/src/controller/python/chip/clusters/CHIPClusters.cpp b/src/controller/python/chip/clusters/CHIPClusters.cpp index 0b2e85ad54e9a2..4d999349570da1 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.cpp +++ b/src/controller/python/chip/clusters/CHIPClusters.cpp @@ -121,6 +121,38 @@ CHIP_ERROR chip_ime_ReadAttribute_AccountLogin_ClusterRevision(chip::Controller: } // End of Cluster AccountLogin +// Cluster AirPressureMeasurement + +CHIP_ERROR chip_ime_ReadAttribute_AirPressureMeasurement_MeasuredValue(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::AirPressureMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeMeasuredValue(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_AirPressureMeasurement_Altitude(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::AirPressureMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeAltitude(gInt16sAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_AirPressureMeasurement_ClusterRevision(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::AirPressureMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeClusterRevision(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +// End of Cluster AirPressureMeasurement // Cluster ApplicationBasic CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_VendorName(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 011ebdd1f53d22..51c97ec2cd221d 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -47,6 +47,8 @@ def ListClusterCommands(self): "setupPIN": "str", }, }, + "AirPressureMeasurement": { + }, "ApplicationBasic": { }, "ApplicationLauncher": { @@ -644,6 +646,11 @@ def ListClusterAttributes(self): "AccountLogin": [ "ClusterRevision", ], + "AirPressureMeasurement": [ + "MeasuredValue", + "Altitude", + "ClusterRevision", + ], "ApplicationBasic": [ "VendorName", "VendorId", @@ -1506,6 +1513,12 @@ def ClusterWindowCovering_CommandWindowCoveringUpOpen(self, device: ctypes.c_voi def ClusterAccountLogin_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): return self._chipLib.chip_ime_ReadAttribute_AccountLogin_ClusterRevision(device, ZCLendpoint, ZCLgroupid) + def ClusterAirPressureMeasurement_ReadAttributeMeasuredValue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_AirPressureMeasurement_MeasuredValue(device, ZCLendpoint, ZCLgroupid) + def ClusterAirPressureMeasurement_ReadAttributeAltitude(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_AirPressureMeasurement_Altitude(device, ZCLendpoint, ZCLgroupid) + def ClusterAirPressureMeasurement_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_AirPressureMeasurement_ClusterRevision(device, ZCLendpoint, ZCLgroupid) def ClusterApplicationBasic_ReadAttributeVendorName(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): return self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_VendorName(device, ZCLendpoint, ZCLgroupid) def ClusterApplicationBasic_ReadAttributeVendorId(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): @@ -1960,6 +1973,16 @@ def InitLib(self, chipLib): # Cluster AccountLogin ReadAttribute ClusterRevision self._chipLib.chip_ime_ReadAttribute_AccountLogin_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_ReadAttribute_AccountLogin_ClusterRevision.restype = ctypes.c_uint32 + # Cluster AirPressureMeasurement + # Cluster AirPressureMeasurement ReadAttribute MeasuredValue + self._chipLib.chip_ime_ReadAttribute_AirPressureMeasurement_MeasuredValue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_AirPressureMeasurement_MeasuredValue.restype = ctypes.c_uint32 + # Cluster AirPressureMeasurement ReadAttribute Altitude + self._chipLib.chip_ime_ReadAttribute_AirPressureMeasurement_Altitude.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_AirPressureMeasurement_Altitude.restype = ctypes.c_uint32 + # Cluster AirPressureMeasurement ReadAttribute ClusterRevision + self._chipLib.chip_ime_ReadAttribute_AirPressureMeasurement_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_AirPressureMeasurement_ClusterRevision.restype = ctypes.c_uint32 # Cluster ApplicationBasic # Cluster ApplicationBasic ReadAttribute VendorName self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_VendorName.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h index 7c2c2a1776fa0d..1d61240a134302 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h @@ -55,6 +55,19 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Air Pressure Measurement + * + */ +@interface CHIPAirPressureMeasurement : CHIPCluster + +- (void)readAttributeMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeAltitudeWithResponseHandler:(ResponseHandler)responseHandler; +- (void)writeAttributeAltitudeWithValue:(int16_t)value responseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler; + +@end + /** * Cluster Application Basic * diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm index 664040caa7d0db..40096aa8ecc08f 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm @@ -3442,6 +3442,127 @@ - (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)respons @end +@interface CHIPAirPressureMeasurement () +@property (readonly) Controller::AirPressureMeasurementCluster cppCluster; +@end + +@implementation CHIPAirPressureMeasurement + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)readAttributeMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeAltitudeWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeAltitude(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeAltitudeWithValue:(int16_t)value responseHandler:(ResponseHandler)responseHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.WriteAttributeAltitude(onSuccess->Cancel(), onFailure->Cancel(), value); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +@end + @interface CHIPApplicationBasic () @property (readonly) Controller::ApplicationBasicCluster cppCluster; @end diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index dcba4914bd5689..66fef6aac11b15 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -227,6 +227,82 @@ - (void)testSendClusterAccountLoginReadAttributeClusterRevisionWithResponseHandl [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterAirPressureMeasurementReadAttributeMeasuredValueWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"AirPressureMeasurementReadAttributeMeasuredValueWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPAirPressureMeasurement * cluster = [[CHIPAirPressureMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeMeasuredValueWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"AirPressureMeasurement MeasuredValue Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterAirPressureMeasurementReadAttributeAltitudeWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"AirPressureMeasurementReadAttributeAltitudeWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPAirPressureMeasurement * cluster = [[CHIPAirPressureMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeAltitudeWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"AirPressureMeasurement Altitude Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterAirPressureMeasurementWriteAttributeAltitudeWithValue +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"AirPressureMeasurementWriteAttributeAltitudeWithValue"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPAirPressureMeasurement * cluster = [[CHIPAirPressureMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + int16_t value = -32768; + [cluster writeAttributeAltitudeWithValue:value + responseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"AirPressureMeasurement Altitude Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterAirPressureMeasurementReadAttributeClusterRevisionWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"AirPressureMeasurementReadAttributeClusterRevisionWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPAirPressureMeasurement * cluster = [[CHIPAirPressureMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeClusterRevisionWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"AirPressureMeasurement ClusterRevision Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterApplicationBasicReadAttributeVendorNameWithResponseHandler { XCTestExpectation * expectation = From fdbb482238341937e97e076528b4d87146579fff Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 31 May 2021 10:33:36 +0000 Subject: [PATCH 23/23] Restyled by clang-format --- src/app/zap-templates/templates/app/helper.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/zap-templates/templates/app/helper.js b/src/app/zap-templates/templates/app/helper.js index f37a444020596c..2cc69780681bf6 100644 --- a/src/app/zap-templates/templates/app/helper.js +++ b/src/app/zap-templates/templates/app/helper.js @@ -195,10 +195,8 @@ function asChipUnderlyingType(label, type) // These helpers only works within the endpoint_config iterator // List of all cluster with generated functions -var endpointClusterWithInit = [ - 'Basic', 'Identify', 'Groups', 'Scenes', 'Occupancy Sensing', 'On/off', 'Level Control', - 'Color Control', 'IAS Zone' -]; +var endpointClusterWithInit = + [ 'Basic', 'Identify', 'Groups', 'Scenes', 'Occupancy Sensing', 'On/off', 'Level Control', 'Color Control', 'IAS Zone' ]; var endpointClusterWithAttributeChanged = [ 'Identify', 'Door Lock' ]; var endpointClusterWithPreAttribute = [ 'IAS Zone' ]; var endpointClusterWithMessageSent = [ 'IAS Zone' ];