-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fan Control Cluster updates for Fall 2023: TE1 (#26296)
* Updated fan-control-server with better support for feature checking, step command handler and checks around the supported attributes in the pre-callback * Updated fan-control-cluster.xml for TE1 for fall release and regenerated the generated code * Ensured status was always initialised before returning, added missing break in switch case * Update optional parameters of Step command and matched spec naming. Improved checking on Auto feature when receiving smart mode. * Added a stop-gap fan-stub.cpp so that the existing FanControl tests pass for TE1 * removed unused variable * fixed return after else warning * reordered files as per restyler
- Loading branch information
Showing
43 changed files
with
1,773 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* | ||
* 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 <app-common/zap-generated/attributes/Accessors.h> | ||
#include <app-common/zap-generated/cluster-objects.h> | ||
#include <app-common/zap-generated/ids/Attributes.h> | ||
#include <app-common/zap-generated/ids/Clusters.h> | ||
#include <app/AttributeAccessInterface.h> | ||
#include <app/util/attribute-storage.h> | ||
#include <lib/support/CodeUtils.h> | ||
#include <lib/support/logging/CHIPLogging.h> | ||
|
||
using namespace chip; | ||
using namespace chip::app; | ||
using namespace chip::app::Clusters; | ||
using namespace chip::app::Clusters::FanControl::Attributes; | ||
|
||
namespace { | ||
|
||
/* | ||
* TODO: This is a stop-gap solution to allow the existing fan control cluster tests to run after changes to | ||
* the cluster objects for TE1. This should be removed once #6496 is resolved as it will likely result in a | ||
* FanControl delegate added to the SDK. | ||
* | ||
* FYI... The previous implementation of the FanControl cluster set the speedCurrent/percentCurrent when it received | ||
* speedSetting/percentSetting. The new implementation of the FanControl cluster does not do this as this should | ||
* really be done by the application. | ||
*/ | ||
|
||
class FanAttrAccess : public AttributeAccessInterface | ||
{ | ||
public: | ||
// Register for the FanControl cluster on all endpoints. | ||
FanAttrAccess() : AttributeAccessInterface(Optional<EndpointId>::Missing(), FanControl::Id) {} | ||
|
||
CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; | ||
|
||
private: | ||
CHIP_ERROR ReadPercentCurrent(EndpointId endpoint, AttributeValueEncoder & aEncoder); | ||
CHIP_ERROR ReadSpeedCurrent(EndpointId endpoint, AttributeValueEncoder & aEncoder); | ||
}; | ||
|
||
CHIP_ERROR FanAttrAccess::ReadPercentCurrent(EndpointId endpoint, AttributeValueEncoder & aEncoder) | ||
{ | ||
// Return PercentSetting attribute value for now | ||
DataModel::Nullable<uint8_t> percentSetting; | ||
PercentSetting::Get(endpoint, percentSetting); | ||
uint8_t ret = 0; | ||
if (!percentSetting.IsNull()) | ||
{ | ||
ret = percentSetting.Value(); | ||
} | ||
|
||
return aEncoder.Encode(ret); | ||
} | ||
|
||
CHIP_ERROR FanAttrAccess::ReadSpeedCurrent(EndpointId endpoint, AttributeValueEncoder & aEncoder) | ||
{ | ||
// Return SpeedCurrent attribute value for now | ||
DataModel::Nullable<uint8_t> speedSetting; | ||
SpeedSetting::Get(endpoint, speedSetting); | ||
uint8_t ret = 0; | ||
if (!speedSetting.IsNull()) | ||
{ | ||
ret = speedSetting.Value(); | ||
} | ||
|
||
return aEncoder.Encode(ret); | ||
} | ||
|
||
FanAttrAccess gAttrAccess; | ||
|
||
CHIP_ERROR FanAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) | ||
{ | ||
VerifyOrDie(aPath.mClusterId == FanControl::Id); | ||
|
||
switch (aPath.mAttributeId) | ||
{ | ||
case SpeedCurrent::Id: | ||
return ReadSpeedCurrent(aPath.mEndpointId, aEncoder); | ||
case PercentCurrent::Id: | ||
return ReadPercentCurrent(aPath.mEndpointId, aEncoder); | ||
default: | ||
break; | ||
} | ||
return CHIP_NO_ERROR; | ||
} | ||
} // anonymous namespace | ||
|
||
void emberAfFanControlClusterInitCallback(EndpointId endpoint) | ||
{ | ||
uint32_t featureMap = 0; | ||
|
||
featureMap |= to_underlying(FanControl::Feature::kMultiSpeed); | ||
featureMap |= to_underlying(FanControl::Feature::kMultiSpeed); | ||
featureMap |= to_underlying(FanControl::Feature::kAuto); | ||
|
||
FeatureMap::Set(endpoint, featureMap); | ||
|
||
registerAttributeAccessOverride(&gAttrAccess); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.