From ce2bbc076606c21d1e1ab8a6035e6c460d2dbebc Mon Sep 17 00:00:00 2001 From: erwinpan1 Date: Tue, 5 Dec 2023 23:22:35 +0800 Subject: [PATCH 1/5] Fix AirQualitySensor to support RPC write 1. Support Write Attributes through RPC 2. Support Multiple Endpoints for AirQuality / Concentration Measurement Clusters 3. Fix comformance issues caught by TC_DeviceConformance.py --- examples/chef/common/chef-air-quality.cpp | 48 ++- examples/chef/common/chef-air-quality.h | 29 ++ .../common/chef-concentration-measurement.cpp | 314 +++++++++++++----- .../common/chef-concentration-measurement.h | 38 +++ examples/chef/common/stubs.cpp | 95 ++++++ ...ootnode_airqualitysensor_e63187f6c9.matter | 30 +- .../rootnode_airqualitysensor_e63187f6c9.zap | 60 +--- 7 files changed, 466 insertions(+), 148 deletions(-) create mode 100644 examples/chef/common/chef-air-quality.h create mode 100644 examples/chef/common/chef-concentration-measurement.h diff --git a/examples/chef/common/chef-air-quality.cpp b/examples/chef/common/chef-air-quality.cpp index a9869963b5217a..b6031f9fe7bfc8 100644 --- a/examples/chef/common/chef-air-quality.cpp +++ b/examples/chef/common/chef-air-quality.cpp @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include #include #include @@ -30,10 +31,53 @@ using namespace chip::app::Clusters::AirQuality; static chip::BitMask airQualityFeatures(Feature::kFair, Feature::kModerate, Feature::kVeryPoor, Feature::kExtremelyPoor); -static Instance gAirQualityClusterInstance = Instance(1, airQualityFeatures); +static std::map gAirQualityClusterInstance{}; void emberAfAirQualityClusterInitCallback(chip::EndpointId endpointId) { - gAirQualityClusterInstance.Init(); + Instance * clusterInstance = new Instance(1, airQualityFeatures); + clusterInstance->Init(); + gAirQualityClusterInstance[1] = clusterInstance; +} + +EmberAfStatus chefAirQualityWriteCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer) +{ + EmberAfStatus ret = EMBER_ZCL_STATUS_SUCCESS; + + if (gAirQualityClusterInstance.find(endpoint) == gAirQualityClusterInstance.end()) { + ChipLogError(DeviceLayer, "Invalid Endpoind ID: %d", endpoint); + return EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT; + } + + Instance * clusterInstance = gAirQualityClusterInstance[endpoint]; + AttributeId attributeId = attributeMetadata->attributeId; + + switch (attributeId) { + case chip::app::Clusters::AirQuality::Attributes::AirQuality::Id: { + AirQualityEnum m = static_cast(buffer[0]); + Protocols::InteractionModel::Status status = clusterInstance->UpdateAirQuality(m); + if (Protocols::InteractionModel::Status::Success == status) { + break; + } + ret = EMBER_ZCL_STATUS_UNSUPPORTED_WRITE; + ChipLogError(DeviceLayer, "Invalid Attribute Update status: %d", static_cast(status)); + } + break; + default: + ret = EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; + ChipLogError(DeviceLayer, "Unsupported Attribute ID: %d", static_cast(attributeId)); + break; + } + + return ret; +} + +EmberAfStatus chefAirQualityReadCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer, uint16_t maxReadLength) +{ + EmberAfStatus ret = EMBER_ZCL_STATUS_SUCCESS; + + return ret; } #endif diff --git a/examples/chef/common/chef-air-quality.h b/examples/chef/common/chef-air-quality.h new file mode 100644 index 00000000000000..3ae6c4fd8a39c8 --- /dev/null +++ b/examples/chef/common/chef-air-quality.h @@ -0,0 +1,29 @@ +/* + * + * Copyright (c) 2023 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 +#include +#include +#include +#include +#include + +#ifdef EMBER_AF_PLUGIN_AIR_QUALITY_SERVER +EmberAfStatus chefAirQualityWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer); +EmberAfStatus chefAirQualityReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer, uint16_t maxReadLength); +#endif diff --git a/examples/chef/common/chef-concentration-measurement.cpp b/examples/chef/common/chef-concentration-measurement.cpp index b769013288eb4c..8735ecad765311 100644 --- a/examples/chef/common/chef-concentration-measurement.cpp +++ b/examples/chef/common/chef-concentration-measurement.cpp @@ -14,14 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include #include #include #include #include +#include using namespace chip; using namespace chip::app; +using namespace chip::app::DataModel; using namespace chip::app::Clusters; #if defined(EMBER_AF_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ @@ -36,125 +39,284 @@ using namespace chip::app::Clusters; defined(EMBER_AF_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER) #include using namespace chip::app::Clusters::ConcentrationMeasurement; -#endif -#ifdef EMBER_AF_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER -static Instance gCarbonDioxideConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), CarbonDioxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); +static std::map *> gCarbonMonoxideConcentrationMeasurementInstance{}; +static std::map *> gCarbonDioxideConcentrationMeasurementInstance{}; -void emberAfCarbonDioxideConcentrationMeasurementClusterInitCallback(EndpointId endpoint) +static std::map *> gNitrogenDioxideConcentrationMeasurementInstance{}; +static std::map *> gOzoneConcentrationMeasurementInstance{}; +static std::map *> gPm25ConcentrationMeasurementInstance{}; +static std::map *> gFormaldehydeConcentrationMeasurementInstance{}; +static std::map *> gPm1ConcentrationMeasurementInstance{}; +static std::map *> gPm10ConcentrationMeasurementInstance{}; +static std::map *> gRadonConcentrationMeasurementInstance{}; +static std::map *> gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance{}; + +template +EmberAfStatus chefConcentrationMeasurementWriteCallback(std::map *>& map, AttributeId measuredValueId, + chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer) +{ + EmberAfStatus ret = EMBER_ZCL_STATUS_SUCCESS; + + if (map.find(endpoint) == map.end()) { + ChipLogError(DeviceLayer, "Invalid Endpoind ID: %d", endpoint); + return EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT; + } + + Instance * clusterInstance = map[endpoint]; + AttributeId attributeId = attributeMetadata->attributeId; + + if (attributeId == measuredValueId) { + float newValue = 0; + uint16_t tlvLen = *(uint16_t *)buffer; + chip::TLV::TLVReader reader; + reader.Init(buffer + sizeof(uint16_t), tlvLen); + reader.Next(); + reader.Get(newValue); + + ChipLogDetail(DeviceLayer,"TLV Type %d, Length %d \n", static_cast(reader.GetType()), tlvLen); + // 2 bytes buf length + 5 bytes TLV for float + ChipLogDetail(DeviceLayer,"buffer: %02x%02x%02x%02x%02x%02x%02x \n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6]); + + CHIP_ERROR err = clusterInstance->SetMeasuredValue(MakeNullable(newValue)); + if (CHIP_NO_ERROR == err) { + ChipLogDetail(DeviceLayer, "Updated EP:%d, Cluster: 0x%04x to MeasuredValue: %f", endpoint, clusterId, newValue); + } else { + ret = EMBER_ZCL_STATUS_UNSUPPORTED_WRITE; + ChipLogError(DeviceLayer, "Invalid Attribute Update status: %" CHIP_ERROR_FORMAT, err.Format()); + } + } else { + ret = EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; + ChipLogError(DeviceLayer, "Unsupported Attribute ID: %d", static_cast(attributeId)); + } + + return ret; +} + + +EmberAfStatus chefConcentrationMeasurementWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer) +{ + EmberAfStatus ret = EMBER_ZCL_STATUS_SUCCESS; + + + switch (clusterId) { + case Clusters::CarbonMonoxideConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gCarbonMonoxideConcentrationMeasurementInstance, CarbonMonoxideConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + case Clusters::CarbonDioxideConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gCarbonDioxideConcentrationMeasurementInstance, CarbonDioxideConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + case Clusters::NitrogenDioxideConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gNitrogenDioxideConcentrationMeasurementInstance, NitrogenDioxideConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + case Clusters::OzoneConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gOzoneConcentrationMeasurementInstance, OzoneConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + case Clusters::Pm25ConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gPm25ConcentrationMeasurementInstance, Pm25ConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + case Clusters::FormaldehydeConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gFormaldehydeConcentrationMeasurementInstance, FormaldehydeConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + case Clusters::Pm1ConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gPm1ConcentrationMeasurementInstance, Pm1ConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + case Clusters::Pm10ConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gPm10ConcentrationMeasurementInstance, Pm10ConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + case Clusters::RadonConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gRadonConcentrationMeasurementInstance, RadonConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + case Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id: + ret = chefConcentrationMeasurementWriteCallback(gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance, TotalVolatileOrganicCompoundsConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; + + default: + break; + } + + + return ret; +} + +EmberAfStatus chefConcentrationMeasurementReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer, uint16_t maxReadLength) { - VerifyOrDie(1 == endpoint); - gCarbonDioxideConcentrationMeasurementInstance.Init(); + EmberAfStatus ret = EMBER_ZCL_STATUS_SUCCESS; + + return ret; } #endif #ifdef EMBER_AF_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER -static Instance gCarbonMonoxideConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), CarbonMonoxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); - void emberAfCarbonMonoxideConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - VerifyOrDie(1 == endpoint); - gCarbonMonoxideConcentrationMeasurementInstance.Init(); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), CarbonMonoxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpb); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(401.0f)); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(50.0f)); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(1500.0f)); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(511.0f)); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(3600); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(213.0f)); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(3600); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(10.0f); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kHigh); } #endif -#ifdef EMBER_AF_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER -static Instance gNitrogenDioxideConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), NitrogenDioxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); - -void emberAfNitrogenDioxideConcentrationMeasurementClusterInitCallback(EndpointId endpoint) +#ifdef EMBER_AF_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER +void emberAfCarbonDioxideConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - VerifyOrDie(1 == endpoint); - gNitrogenDioxideConcentrationMeasurementInstance.Init(); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), CarbonDioxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(458.0f)); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(300.0f)); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(2000.0f)); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(523.0f)); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(3600); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(421.0f)); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(3600); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(5.0f); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kLow); } #endif -#ifdef EMBER_AF_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER -static Instance gPm1ConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), Pm1ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); - -void emberAfPm1ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) +#ifdef EMBER_AF_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER +void emberAfNitrogenDioxideConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - VerifyOrDie(1 == endpoint); - gPm1ConcentrationMeasurementInstance.Init(); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), NitrogenDioxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpb); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(3.0f)); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(1.0f)); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(150.0f)); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(3.0f)); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(120); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(3.0f)); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(120); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(1.0f); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kLow); } #endif -#ifdef EMBER_AF_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER -static Instance gPm10ConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), Pm10ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); - -void emberAfPm10ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) +#ifdef EMBER_AF_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER +void emberAfOzoneConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - VerifyOrDie(1 == endpoint); - gPm10ConcentrationMeasurementInstance.Init(); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), OzoneConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(10.0f)); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(3.0f)); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(300.0f)); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(50.0f)); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(3600); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(20.0f)); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(3600); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(0.0f); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kLow); } #endif #ifdef EMBER_AF_PLUGIN_PM2__5_CONCENTRATION_MEASUREMENT_SERVER -static Instance gPm25ConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), Pm25ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); - void emberAfPm25ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - VerifyOrDie(1 == endpoint); - gPm25ConcentrationMeasurementInstance.Init(); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), Pm25ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kUgm3); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(42.0f)); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(1.0f)); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(400.0f)); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(90.0f)); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(3600); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(35.0f)); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(3600); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(4.0f); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kMedium); } #endif -#ifdef EMBER_AF_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER -static Instance gRadonConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), RadonConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); - -void emberAfRadonConcentrationMeasurementClusterInitCallback(EndpointId endpoint) +#ifdef EMBER_AF_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER +void emberAfFormaldehydeConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - VerifyOrDie(1 == endpoint); - gRadonConcentrationMeasurementInstance.Init(); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), FormaldehydeConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kMgm3); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(10.0f)); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(0.0f)); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(200.0f)); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(10.0f)); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(7200); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(2.0f)); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(7200); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(0.0f); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kMedium); } #endif -#ifdef EMBER_AF_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER -static Instance gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), TotalVolatileOrganicCompoundsConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, - MeasurementUnitEnum::kPpm); - -void emberAfTotalVolatileOrganicCompoundsConcentrationMeasurementClusterInitCallback(EndpointId endpoint) +#ifdef EMBER_AF_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER +void emberAfPm1ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - VerifyOrDie(1 == endpoint); - gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance.Init(); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), Pm1ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kUgm3); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(39.0f)); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(1.0f)); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(400.0f)); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(70.0f)); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(3600); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(41.0f)); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(3600); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(4.0f); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kLow); } #endif -#ifdef EMBER_AF_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER -static Instance gOzoneConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), OzoneConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); - -void emberAfOzoneConcentrationMeasurementClusterInitCallback(EndpointId endpoint) +#ifdef EMBER_AF_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER +void emberAfPm10ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - VerifyOrDie(1 == endpoint); - gOzoneConcentrationMeasurementInstance.Init(); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), Pm10ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpt); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(7.0f)); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(2.0f)); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(400.0f)); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(49.0f)); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(3600); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(43.0f)); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(3600); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(10.0f); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kLow); } #endif -#ifdef EMBER_AF_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER -static Instance gFormaldehydeConcentrationMeasurementInstance = - CreateNumericMeasurementAndLevelIndicationConcentrationCluster( - EndpointId(1), FormaldehydeConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); +#ifdef EMBER_AF_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER +void emberAfRadonConcentrationMeasurementClusterInitCallback(EndpointId endpoint) +{ + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), RadonConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(10.0f)); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(5.0f)); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(100.0f)); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(36.0f)); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(3600); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(20.0f)); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(3600); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(0.0f); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kHigh); +} +#endif -void emberAfFormaldehydeConcentrationMeasurementClusterInitCallback(EndpointId endpoint) +#ifdef EMBER_AF_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER +void emberAfTotalVolatileOrganicCompoundsConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - VerifyOrDie(1 == endpoint); - gFormaldehydeConcentrationMeasurementInstance.Init(); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), TotalVolatileOrganicCompoundsConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpb); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(5.0f)); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(1.0f)); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(100.0f)); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(8.0f)); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(3600); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(2.0f)); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(3600); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(1.0f); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kLow); } #endif diff --git a/examples/chef/common/chef-concentration-measurement.h b/examples/chef/common/chef-concentration-measurement.h new file mode 100644 index 00000000000000..f2127ceecbef52 --- /dev/null +++ b/examples/chef/common/chef-concentration-measurement.h @@ -0,0 +1,38 @@ +/* + * + * Copyright (c) 2023 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 +#include +#include +#include +#include +#include + +#if defined(EMBER_AF_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM2__5_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER) +EmberAfStatus chefConcentrationMeasurementWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer); +EmberAfStatus chefConcentrationMeasurementReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer, uint16_t maxReadLength); +#endif diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index b5878496182a0b..0cd3e40907b7bc 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -3,11 +3,106 @@ #include #include #include +#ifdef EMBER_AF_PLUGIN_AIR_QUALITY_SERVER +#include "chef-air-quality.h" +#endif // EMBER_AF_PLUGIN_AIR_QUALITY_SERVER +#if defined(EMBER_AF_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM2__5_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER) +#include "chef-concentration-measurement.h" +#endif using chip::app::DataModel::Nullable; using namespace chip; +EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer, uint16_t maxReadLength) +{ + switch (clusterId) { +#ifdef EMBER_AF_PLUGIN_AIR_QUALITY_SERVER + case chip::app::Clusters::AirQuality::Id: + return chefAirQualityReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength); +#endif +#if defined(EMBER_AF_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM2__5_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER) + case chip::app::Clusters::CarbonMonoxideConcentrationMeasurement::Id: + case chip::app::Clusters::CarbonDioxideConcentrationMeasurement::Id: + case chip::app::Clusters::NitrogenDioxideConcentrationMeasurement::Id: + case chip::app::Clusters::OzoneConcentrationMeasurement::Id: + case chip::app::Clusters::FormaldehydeConcentrationMeasurement::Id: + case chip::app::Clusters::Pm1ConcentrationMeasurement::Id: + case chip::app::Clusters::Pm25ConcentrationMeasurement::Id: + case chip::app::Clusters::Pm10ConcentrationMeasurement::Id: + case chip::app::Clusters::RadonConcentrationMeasurement::Id: + case chip::app::Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id: + return chefConcentrationMeasurementReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength); +#endif + default: + } + return EMBER_ZCL_STATUS_SUCCESS; +} + +/* + * +Thread 3 "rootnode_airqua" hit Breakpoint 1, emberAfExternalAttributeWriteCallback (endpoint=1, clusterId=91, + attributeMetadata=0x555555791f30 <(anonymous namespace)::generatedAttributes+1904>, buffer=0x7ffff68464ac "\001") + at /home/erwinpan/matter/erwinpan1/master_1124_airqualitysensor/examples/chef/common/stubs.cpp:22 +(gdb) p *attributeMetadata +$1 = {defaultValue = {ptrToDefaultValue = 0x0, defaultValue = 0, ptrToMinMaxValue = 0x0}, attributeId = 0, size = 1, attributeType = 48 '0', mask = 16 '\020'} +(gdb) +*/ + +EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer) +{ + switch (clusterId) { +#ifdef EMBER_AF_PLUGIN_AIR_QUALITY_SERVER + case chip::app::Clusters::AirQuality::Id: + return chefAirQualityWriteCallback(endpoint, clusterId, attributeMetadata, buffer); +#endif +#if defined(EMBER_AF_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM2__5_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER) + case chip::app::Clusters::CarbonMonoxideConcentrationMeasurement::Id: + case chip::app::Clusters::CarbonDioxideConcentrationMeasurement::Id: + case chip::app::Clusters::NitrogenDioxideConcentrationMeasurement::Id: + case chip::app::Clusters::OzoneConcentrationMeasurement::Id: + case chip::app::Clusters::FormaldehydeConcentrationMeasurement::Id: + case chip::app::Clusters::Pm1ConcentrationMeasurement::Id: + case chip::app::Clusters::Pm25ConcentrationMeasurement::Id: + case chip::app::Clusters::Pm10ConcentrationMeasurement::Id: + case chip::app::Clusters::RadonConcentrationMeasurement::Id: + case chip::app::Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id: + return chefConcentrationMeasurementWriteCallback(endpoint, clusterId, attributeMetadata, buffer); +#endif + default: + } + return EMBER_ZCL_STATUS_SUCCESS; +} + // Include door lock callbacks only when the server is enabled #ifdef EMBER_AF_PLUGIN_DOOR_LOCK_SERVER #include diff --git a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter index 71173b45a89cae..d651d0269a7e74 100644 --- a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter +++ b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter @@ -445,8 +445,6 @@ server cluster TimeFormatLocalization = 44 { } attribute access(write: manage) HourFormatEnum hourFormat = 0; - attribute access(write: manage) CalendarTypeEnum activeCalendarType = 1; - readonly attribute CalendarTypeEnum supportedCalendarTypes[] = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -906,12 +904,7 @@ server cluster AdministratorCommissioning = 60 { octet_string<32> salt = 4; } - request struct OpenBasicCommissioningWindowRequest { - int16u commissioningTimeout = 0; - } - timed command access(invoke: administer) OpenCommissioningWindow(OpenCommissioningWindowRequest): DefaultSuccess = 0; - timed command access(invoke: administer) OpenBasicCommissioningWindow(OpenBasicCommissioningWindowRequest): DefaultSuccess = 1; timed command access(invoke: administer) RevokeCommissioning(): DefaultSuccess = 2; } @@ -1837,8 +1830,6 @@ endpoint 0 { server cluster TimeFormatLocalization { persist attribute hourFormat default = 0; - persist attribute activeCalendarType default = 0; - callback attribute supportedCalendarTypes; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; } @@ -1928,7 +1919,6 @@ endpoint 0 { ram attribute clusterRevision default = 0x0001; handle command OpenCommissioningWindow; - handle command OpenBasicCommissioningWindow; handle command RevokeCommissioning; } @@ -2019,9 +2009,9 @@ endpoint 1 { } server cluster TemperatureMeasurement { - persist attribute measuredValue default = 0; - persist attribute minMeasuredValue; - persist attribute maxMeasuredValue default = 0x8000; + persist attribute measuredValue default = 0x800; + persist attribute minMeasuredValue default = 0x800; + persist attribute maxMeasuredValue default = 0x800; persist attribute tolerance default = 0; callback attribute generatedCommandList; callback attribute acceptedCommandList; @@ -2225,17 +2215,17 @@ endpoint 1 { } server cluster RadonConcentrationMeasurement { - callback attribute measuredValue default = 5; - callback attribute minMeasuredValue default = 1; + callback attribute measuredValue default = 10; + callback attribute minMeasuredValue default = 5; callback attribute maxMeasuredValue default = 100; - callback attribute peakMeasuredValue default = 8; + callback attribute peakMeasuredValue default = 36; callback attribute peakMeasuredValueWindow default = 3600; - callback attribute averageMeasuredValue default = 2; + callback attribute averageMeasuredValue default = 20; callback attribute averageMeasuredValueWindow default = 3600; - callback attribute uncertainty default = 1; - callback attribute measurementUnit default = 1; + callback attribute uncertainty default = 0; + callback attribute measurementUnit default = 0; callback attribute measurementMedium default = 0; - callback attribute levelValue default = 1; + callback attribute levelValue default = 3; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; diff --git a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap index df07c599f92608..ef499417b2063b 100644 --- a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap +++ b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap @@ -1026,38 +1026,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "ActiveCalendarType", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "CalendarTypeEnum", - "included": 1, - "storageOption": "NVM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "SupportedCalendarTypes", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "FeatureMap", "code": 65532, @@ -1913,14 +1881,6 @@ "isIncoming": 1, "isEnabled": 1 }, - { - "name": "OpenBasicCommissioningWindow", - "code": 1, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, { "name": "RevokeCommissioning", "code": 2, @@ -2950,7 +2910,7 @@ "storageOption": "NVM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "0x800", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2966,7 +2926,7 @@ "storageOption": "NVM", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "0x800", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2982,7 +2942,7 @@ "storageOption": "NVM", "singleton": 0, "bounded": 0, - "defaultValue": "0x8000", + "defaultValue": "0x800", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5828,7 +5788,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "5", + "defaultValue": "10", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5844,7 +5804,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "5", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5876,7 +5836,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "8", + "defaultValue": "36", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5908,7 +5868,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "20", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5940,7 +5900,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5956,7 +5916,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5988,7 +5948,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "3", "reportable": 1, "minInterval": 1, "maxInterval": 65534, From a54ac0f0ea56e4c471fb3c3bf4baf90075629bf6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 5 Dec 2023 15:28:41 +0000 Subject: [PATCH 2/5] Restyled by whitespace --- examples/chef/common/chef-concentration-measurement.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chef/common/chef-concentration-measurement.cpp b/examples/chef/common/chef-concentration-measurement.cpp index 8735ecad765311..9eccf001a8e0fb 100644 --- a/examples/chef/common/chef-concentration-measurement.cpp +++ b/examples/chef/common/chef-concentration-measurement.cpp @@ -69,7 +69,7 @@ EmberAfStatus chefConcentrationMeasurementWriteCallback(std::mapattributeId; if (attributeId == measuredValueId) { - float newValue = 0; + float newValue = 0; uint16_t tlvLen = *(uint16_t *)buffer; chip::TLV::TLVReader reader; reader.Init(buffer + sizeof(uint16_t), tlvLen); From 8bdea343a0f13b7746342dc72b82990204e51dc2 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 5 Dec 2023 15:28:42 +0000 Subject: [PATCH 3/5] Restyled by clang-format --- examples/chef/common/chef-air-quality.cpp | 28 +-- examples/chef/common/chef-air-quality.h | 11 +- .../common/chef-concentration-measurement.cpp | 164 +++++++++++------- .../common/chef-concentration-measurement.h | 11 +- examples/chef/common/stubs.cpp | 19 +- 5 files changed, 144 insertions(+), 89 deletions(-) diff --git a/examples/chef/common/chef-air-quality.cpp b/examples/chef/common/chef-air-quality.cpp index b6031f9fe7bfc8..f74f4ea546753f 100644 --- a/examples/chef/common/chef-air-quality.cpp +++ b/examples/chef/common/chef-air-quality.cpp @@ -14,12 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include #include #include #include #include #include +#include using namespace chip; using namespace chip::app; @@ -40,24 +40,27 @@ void emberAfAirQualityClusterInitCallback(chip::EndpointId endpointId) gAirQualityClusterInstance[1] = clusterInstance; } -EmberAfStatus chefAirQualityWriteCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer) +EmberAfStatus chefAirQualityWriteCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer) { EmberAfStatus ret = EMBER_ZCL_STATUS_SUCCESS; - if (gAirQualityClusterInstance.find(endpoint) == gAirQualityClusterInstance.end()) { + if (gAirQualityClusterInstance.find(endpoint) == gAirQualityClusterInstance.end()) + { ChipLogError(DeviceLayer, "Invalid Endpoind ID: %d", endpoint); return EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT; } Instance * clusterInstance = gAirQualityClusterInstance[endpoint]; - AttributeId attributeId = attributeMetadata->attributeId; + AttributeId attributeId = attributeMetadata->attributeId; - switch (attributeId) { + switch (attributeId) + { case chip::app::Clusters::AirQuality::Attributes::AirQuality::Id: { - AirQualityEnum m = static_cast(buffer[0]); - Protocols::InteractionModel::Status status = clusterInstance->UpdateAirQuality(m); - if (Protocols::InteractionModel::Status::Success == status) { + AirQualityEnum m = static_cast(buffer[0]); + Protocols::InteractionModel::Status status = clusterInstance->UpdateAirQuality(m); + if (Protocols::InteractionModel::Status::Success == status) + { break; } ret = EMBER_ZCL_STATUS_UNSUPPORTED_WRITE; @@ -67,14 +70,15 @@ EmberAfStatus chefAirQualityWriteCallback(EndpointId endpoint, ClusterId cluster default: ret = EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; ChipLogError(DeviceLayer, "Unsupported Attribute ID: %d", static_cast(attributeId)); - break; + break; } return ret; } -EmberAfStatus chefAirQualityReadCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer, uint16_t maxReadLength) +EmberAfStatus chefAirQualityReadCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, + uint16_t maxReadLength) { EmberAfStatus ret = EMBER_ZCL_STATUS_SUCCESS; diff --git a/examples/chef/common/chef-air-quality.h b/examples/chef/common/chef-air-quality.h index 3ae6c4fd8a39c8..0749d4d1afe662 100644 --- a/examples/chef/common/chef-air-quality.h +++ b/examples/chef/common/chef-air-quality.h @@ -14,16 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include #include #include #include +#include #include #include #ifdef EMBER_AF_PLUGIN_AIR_QUALITY_SERVER -EmberAfStatus chefAirQualityWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer); -EmberAfStatus chefAirQualityReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer, uint16_t maxReadLength); +EmberAfStatus chefAirQualityWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer); +EmberAfStatus chefAirQualityReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, + uint16_t maxReadLength); #endif diff --git a/examples/chef/common/chef-concentration-measurement.cpp b/examples/chef/common/chef-concentration-measurement.cpp index 9eccf001a8e0fb..90c6f85d3b99d1 100644 --- a/examples/chef/common/chef-concentration-measurement.cpp +++ b/examples/chef/common/chef-concentration-measurement.cpp @@ -14,13 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include #include #include #include #include #include #include +#include using namespace chip; using namespace chip::app; @@ -50,44 +50,57 @@ static std::map *> gFormaldehy static std::map *> gPm1ConcentrationMeasurementInstance{}; static std::map *> gPm10ConcentrationMeasurementInstance{}; static std::map *> gRadonConcentrationMeasurementInstance{}; -static std::map *> gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance{}; +static std::map *> + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance{}; template -EmberAfStatus chefConcentrationMeasurementWriteCallback(std::map *>& map, AttributeId measuredValueId, - chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer) +EmberAfStatus chefConcentrationMeasurementWriteCallback( + std::map *> & map, + AttributeId measuredValueId, chip::EndpointId endpoint, chip::ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer) { EmberAfStatus ret = EMBER_ZCL_STATUS_SUCCESS; - if (map.find(endpoint) == map.end()) { + if (map.find(endpoint) == map.end()) + { ChipLogError(DeviceLayer, "Invalid Endpoind ID: %d", endpoint); return EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT; } - Instance * clusterInstance = map[endpoint]; - AttributeId attributeId = attributeMetadata->attributeId; + Instance * clusterInstance = map[endpoint]; + AttributeId attributeId = attributeMetadata->attributeId; - if (attributeId == measuredValueId) { - float newValue = 0; - uint16_t tlvLen = *(uint16_t *)buffer; - chip::TLV::TLVReader reader; - reader.Init(buffer + sizeof(uint16_t), tlvLen); - reader.Next(); + if (attributeId == measuredValueId) + { + float newValue = 0; + uint16_t tlvLen = *(uint16_t *) buffer; + chip::TLV::TLVReader reader; + reader.Init(buffer + sizeof(uint16_t), tlvLen); + reader.Next(); reader.Get(newValue); - ChipLogDetail(DeviceLayer,"TLV Type %d, Length %d \n", static_cast(reader.GetType()), tlvLen); + ChipLogDetail(DeviceLayer, "TLV Type %d, Length %d \n", static_cast(reader.GetType()), tlvLen); // 2 bytes buf length + 5 bytes TLV for float - ChipLogDetail(DeviceLayer,"buffer: %02x%02x%02x%02x%02x%02x%02x \n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6]); + ChipLogDetail(DeviceLayer, "buffer: %02x%02x%02x%02x%02x%02x%02x \n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], + buffer[5], buffer[6]); CHIP_ERROR err = clusterInstance->SetMeasuredValue(MakeNullable(newValue)); - if (CHIP_NO_ERROR == err) { + if (CHIP_NO_ERROR == err) + { ChipLogDetail(DeviceLayer, "Updated EP:%d, Cluster: 0x%04x to MeasuredValue: %f", endpoint, clusterId, newValue); - } else { + } + else + { ret = EMBER_ZCL_STATUS_UNSUPPORTED_WRITE; ChipLogError(DeviceLayer, "Invalid Attribute Update status: %" CHIP_ERROR_FORMAT, err.Format()); } - } else { + } + else + { ret = EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; ChipLogError(DeviceLayer, "Unsupported Attribute ID: %d", static_cast(attributeId)); } @@ -95,55 +108,75 @@ EmberAfStatus chefConcentrationMeasurementWriteCallback(std::map(gCarbonMonoxideConcentrationMeasurementInstance, CarbonMonoxideConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gCarbonMonoxideConcentrationMeasurementInstance, CarbonMonoxideConcentrationMeasurement::Attributes::MeasuredValue::Id, + endpoint, clusterId, attributeMetadata, buffer); + break; case Clusters::CarbonDioxideConcentrationMeasurement::Id: - ret = chefConcentrationMeasurementWriteCallback(gCarbonDioxideConcentrationMeasurementInstance, CarbonDioxideConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gCarbonDioxideConcentrationMeasurementInstance, CarbonDioxideConcentrationMeasurement::Attributes::MeasuredValue::Id, + endpoint, clusterId, attributeMetadata, buffer); + break; case Clusters::NitrogenDioxideConcentrationMeasurement::Id: - ret = chefConcentrationMeasurementWriteCallback(gNitrogenDioxideConcentrationMeasurementInstance, NitrogenDioxideConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gNitrogenDioxideConcentrationMeasurementInstance, + NitrogenDioxideConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); + break; case Clusters::OzoneConcentrationMeasurement::Id: - ret = chefConcentrationMeasurementWriteCallback(gOzoneConcentrationMeasurementInstance, OzoneConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gOzoneConcentrationMeasurementInstance, OzoneConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, + clusterId, attributeMetadata, buffer); + break; case Clusters::Pm25ConcentrationMeasurement::Id: - ret = chefConcentrationMeasurementWriteCallback(gPm25ConcentrationMeasurementInstance, Pm25ConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gPm25ConcentrationMeasurementInstance, Pm25ConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, + attributeMetadata, buffer); + break; case Clusters::FormaldehydeConcentrationMeasurement::Id: - ret = chefConcentrationMeasurementWriteCallback(gFormaldehydeConcentrationMeasurementInstance, FormaldehydeConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gFormaldehydeConcentrationMeasurementInstance, FormaldehydeConcentrationMeasurement::Attributes::MeasuredValue::Id, + endpoint, clusterId, attributeMetadata, buffer); + break; case Clusters::Pm1ConcentrationMeasurement::Id: - ret = chefConcentrationMeasurementWriteCallback(gPm1ConcentrationMeasurementInstance, Pm1ConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gPm1ConcentrationMeasurementInstance, Pm1ConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, + attributeMetadata, buffer); + break; case Clusters::Pm10ConcentrationMeasurement::Id: - ret = chefConcentrationMeasurementWriteCallback(gPm10ConcentrationMeasurementInstance, Pm10ConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gPm10ConcentrationMeasurementInstance, Pm10ConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, + attributeMetadata, buffer); + break; case Clusters::RadonConcentrationMeasurement::Id: - ret = chefConcentrationMeasurementWriteCallback(gRadonConcentrationMeasurementInstance, RadonConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gRadonConcentrationMeasurementInstance, RadonConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, + clusterId, attributeMetadata, buffer); + break; case Clusters::TotalVolatileOrganicCompoundsConcentrationMeasurement::Id: - ret = chefConcentrationMeasurementWriteCallback(gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance, TotalVolatileOrganicCompoundsConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, attributeMetadata, buffer); - break; + ret = chefConcentrationMeasurementWriteCallback( + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance, + TotalVolatileOrganicCompoundsConcentrationMeasurement::Attributes::MeasuredValue::Id, endpoint, clusterId, + attributeMetadata, buffer); + break; default: - break; + break; } - return ret; } -EmberAfStatus chefConcentrationMeasurementReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer, uint16_t maxReadLength) +EmberAfStatus chefConcentrationMeasurementReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, + uint16_t maxReadLength) { EmberAfStatus ret = EMBER_ZCL_STATUS_SUCCESS; @@ -154,7 +187,8 @@ EmberAfStatus chefConcentrationMeasurementReadCallback(chip::EndpointId endpoint #ifdef EMBER_AF_PLUGIN_CARBON_MONOXIDE_CONCENTRATION_MEASUREMENT_SERVER void emberAfCarbonMonoxideConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), CarbonMonoxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpb); + gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance( + EndpointId(endpoint), CarbonMonoxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpb); gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(401.0f)); gCarbonMonoxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(50.0f)); @@ -171,7 +205,8 @@ void emberAfCarbonMonoxideConcentrationMeasurementClusterInitCallback(EndpointId #ifdef EMBER_AF_PLUGIN_CARBON_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER void emberAfCarbonDioxideConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), CarbonDioxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); + gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance( + EndpointId(endpoint), CarbonDioxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(458.0f)); gCarbonDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(300.0f)); @@ -188,7 +223,8 @@ void emberAfCarbonDioxideConcentrationMeasurementClusterInitCallback(EndpointId #ifdef EMBER_AF_PLUGIN_NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_SERVER void emberAfNitrogenDioxideConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), NitrogenDioxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpb); + gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance( + EndpointId(endpoint), NitrogenDioxideConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpb); gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(3.0f)); gNitrogenDioxideConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(1.0f)); @@ -205,7 +241,8 @@ void emberAfNitrogenDioxideConcentrationMeasurementClusterInitCallback(EndpointI #ifdef EMBER_AF_PLUGIN_OZONE_CONCENTRATION_MEASUREMENT_SERVER void emberAfOzoneConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), OzoneConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); + gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance( + EndpointId(endpoint), OzoneConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(10.0f)); gOzoneConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(3.0f)); @@ -222,7 +259,8 @@ void emberAfOzoneConcentrationMeasurementClusterInitCallback(EndpointId endpoint #ifdef EMBER_AF_PLUGIN_PM2__5_CONCENTRATION_MEASUREMENT_SERVER void emberAfPm25ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), Pm25ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kUgm3); + gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance( + EndpointId(endpoint), Pm25ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kUgm3); gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(42.0f)); gPm25ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(1.0f)); @@ -239,7 +277,8 @@ void emberAfPm25ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) #ifdef EMBER_AF_PLUGIN_FORMALDEHYDE_CONCENTRATION_MEASUREMENT_SERVER void emberAfFormaldehydeConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), FormaldehydeConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kMgm3); + gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance( + EndpointId(endpoint), FormaldehydeConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kMgm3); gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(10.0f)); gFormaldehydeConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(0.0f)); @@ -256,7 +295,8 @@ void emberAfFormaldehydeConcentrationMeasurementClusterInitCallback(EndpointId e #ifdef EMBER_AF_PLUGIN_PM1_CONCENTRATION_MEASUREMENT_SERVER void emberAfPm1ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), Pm1ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kUgm3); + gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance( + EndpointId(endpoint), Pm1ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kUgm3); gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(39.0f)); gPm1ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(1.0f)); @@ -273,7 +313,8 @@ void emberAfPm1ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) #ifdef EMBER_AF_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER void emberAfPm10ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), Pm10ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpt); + gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance( + EndpointId(endpoint), Pm10ConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpt); gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(7.0f)); gPm10ConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(2.0f)); @@ -290,7 +331,8 @@ void emberAfPm10ConcentrationMeasurementClusterInitCallback(EndpointId endpoint) #ifdef EMBER_AF_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER void emberAfRadonConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gRadonConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), RadonConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); + gRadonConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance( + EndpointId(endpoint), RadonConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpm); gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(10.0f)); gRadonConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(5.0f)); @@ -307,14 +349,18 @@ void emberAfRadonConcentrationMeasurementClusterInitCallback(EndpointId endpoint #ifdef EMBER_AF_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER void emberAfTotalVolatileOrganicCompoundsConcentrationMeasurementClusterInitCallback(EndpointId endpoint) { - gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)] = new Instance(EndpointId(endpoint), TotalVolatileOrganicCompoundsConcentrationMeasurement::Id, MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpb); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)] = + new Instance(EndpointId(endpoint), + TotalVolatileOrganicCompoundsConcentrationMeasurement::Id, + MeasurementMediumEnum::kAir, MeasurementUnitEnum::kPpb); gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->Init(); gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMeasuredValue(MakeNullable(5.0f)); gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMinMeasuredValue(MakeNullable(1.0f)); gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetMaxMeasuredValue(MakeNullable(100.0f)); gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValue(MakeNullable(8.0f)); gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetPeakMeasuredValueWindow(3600); - gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue(MakeNullable(2.0f)); + gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValue( + MakeNullable(2.0f)); gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetAverageMeasuredValueWindow(3600); gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetUncertainty(1.0f); gTotalVolatileOrganicCompoundsConcentrationMeasurementInstance[EndpointId(endpoint)]->SetLevelValue(LevelValueEnum::kLow); diff --git a/examples/chef/common/chef-concentration-measurement.h b/examples/chef/common/chef-concentration-measurement.h index f2127ceecbef52..ea874314814f22 100644 --- a/examples/chef/common/chef-concentration-measurement.h +++ b/examples/chef/common/chef-concentration-measurement.h @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include #include #include #include +#include #include #include @@ -31,8 +31,9 @@ defined(EMBER_AF_PLUGIN_PM10_CONCENTRATION_MEASUREMENT_SERVER) || \ defined(EMBER_AF_PLUGIN_TOTAL_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_MEASUREMENT_SERVER) || \ defined(EMBER_AF_PLUGIN_RADON_CONCENTRATION_MEASUREMENT_SERVER) -EmberAfStatus chefConcentrationMeasurementWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer); -EmberAfStatus chefConcentrationMeasurementReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer, uint16_t maxReadLength); +EmberAfStatus chefConcentrationMeasurementWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer); +EmberAfStatus chefConcentrationMeasurementReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, + uint16_t maxReadLength); #endif diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 0cd3e40907b7bc..d778ec642dc98a 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -23,10 +23,12 @@ using chip::app::DataModel::Nullable; using namespace chip; -EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer, uint16_t maxReadLength) +EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, + uint16_t maxReadLength) { - switch (clusterId) { + switch (clusterId) + { #ifdef EMBER_AF_PLUGIN_AIR_QUALITY_SERVER case chip::app::Clusters::AirQuality::Id: return chefAirQualityReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength); @@ -64,14 +66,15 @@ Thread 3 "rootnode_airqua" hit Breakpoint 1, emberAfExternalAttributeWriteCallba attributeMetadata=0x555555791f30 <(anonymous namespace)::generatedAttributes+1904>, buffer=0x7ffff68464ac "\001") at /home/erwinpan/matter/erwinpan1/master_1124_airqualitysensor/examples/chef/common/stubs.cpp:22 (gdb) p *attributeMetadata -$1 = {defaultValue = {ptrToDefaultValue = 0x0, defaultValue = 0, ptrToMinMaxValue = 0x0}, attributeId = 0, size = 1, attributeType = 48 '0', mask = 16 '\020'} -(gdb) +$1 = {defaultValue = {ptrToDefaultValue = 0x0, defaultValue = 0, ptrToMinMaxValue = 0x0}, attributeId = 0, size = 1, attributeType = +48 '0', mask = 16 '\020'} (gdb) */ -EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, - uint8_t * buffer) +EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer) { - switch (clusterId) { + switch (clusterId) + { #ifdef EMBER_AF_PLUGIN_AIR_QUALITY_SERVER case chip::app::Clusters::AirQuality::Id: return chefAirQualityWriteCallback(endpoint, clusterId, attributeMetadata, buffer); From 68a3edb2df732b4310941f4cebb931bf30434579 Mon Sep 17 00:00:00 2001 From: erwinpan1 Date: Tue, 5 Dec 2023 23:57:34 +0800 Subject: [PATCH 4/5] Update ZAP version and fix compilation issues --- examples/chef/common/stubs.cpp | 2 ++ ...ootnode_airqualitysensor_e63187f6c9.matter | 34 ++++++++++++------- .../rootnode_airqualitysensor_e63187f6c9.zap | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index d778ec642dc98a..5d30646020801a 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -56,6 +56,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI return chefConcentrationMeasurementReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength); #endif default: + break; } return EMBER_ZCL_STATUS_SUCCESS; } @@ -102,6 +103,7 @@ EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, Cluster return chefConcentrationMeasurementWriteCallback(endpoint, clusterId, attributeMetadata, buffer); #endif default: + break; } return EMBER_ZCL_STATUS_SUCCESS; } diff --git a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter index 685dce23edfa76..23bb5d48d49694 100644 --- a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter +++ b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.matter @@ -459,7 +459,8 @@ cluster TimeFormatLocalization = 44 { } attribute access(write: manage) HourFormatEnum hourFormat = 0; - air_quality_support_write_throught_rpc + attribute access(write: manage) optional CalendarTypeEnum activeCalendarType = 1; + readonly attribute optional CalendarTypeEnum supportedCalendarTypes[] = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -954,7 +955,15 @@ cluster AdministratorCommissioning = 60 { octet_string<32> salt = 4; } + request struct OpenBasicCommissioningWindowRequest { + int16u commissioningTimeout = 0; + } + + /** This command is used by a current Administrator to instruct a Node to go into commissioning mode using enhanced commissioning method. */ timed command access(invoke: administer) OpenCommissioningWindow(OpenCommissioningWindowRequest): DefaultSuccess = 0; + /** This command is used by a current Administrator to instruct a Node to go into commissioning mode using basic commissioning method, if the node supports it. */ + timed command access(invoke: administer) OpenBasicCommissioningWindow(OpenBasicCommissioningWindowRequest): DefaultSuccess = 1; + /** This command is used by a current Administrator to instruct a Node to revoke any active Open Commissioning Window or Open Basic Commissioning Window command. */ timed command access(invoke: administer) RevokeCommissioning(): DefaultSuccess = 2; } @@ -2277,18 +2286,17 @@ endpoint 1 { } server cluster RadonConcentrationMeasurement { - callback attribute measuredValue default = 10; - callback attribute minMeasuredValue default = 5; - callback attribute maxMeasuredValue default = 100; - callback attribute peakMeasuredValue default = 36; - callback attribute peakMeasuredValueWindow default = 3600; - callback attribute averageMeasuredValue default = 20; - callback attribute averageMeasuredValueWindow default = 3600; - callback attribute uncertainty default = 0; - callback attribute measurementUnit default = 0; - callback attribute measurementMedium default = 0; - callback attribute levelValue default = 3; - + callback attribute measuredValue; + callback attribute minMeasuredValue; + callback attribute maxMeasuredValue; + callback attribute peakMeasuredValue; + callback attribute peakMeasuredValueWindow; + callback attribute averageMeasuredValue; + callback attribute averageMeasuredValueWindow; + callback attribute uncertainty; + callback attribute measurementUnit; + callback attribute measurementMedium; + callback attribute levelValue; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute eventList; diff --git a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap index 35061fd77d9621..7eb4f3081dc3d2 100644 --- a/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap +++ b/examples/chef/devices/rootnode_airqualitysensor_e63187f6c9.zap @@ -6071,4 +6071,4 @@ "networkId": 0 } ] -} \ No newline at end of file +} From 869cd44490d764c51e9bb337cbc71f90552d2116 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 5 Dec 2023 15:58:22 +0000 Subject: [PATCH 5/5] Restyled by clang-format --- examples/chef/common/stubs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 5d30646020801a..bfd5e370cba136 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -56,7 +56,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI return chefConcentrationMeasurementReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength); #endif default: - break; + break; } return EMBER_ZCL_STATUS_SUCCESS; } @@ -103,7 +103,7 @@ EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, Cluster return chefConcentrationMeasurementWriteCallback(endpoint, clusterId, attributeMetadata, buffer); #endif default: - break; + break; } return EMBER_ZCL_STATUS_SUCCESS; }