forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
FanControl
] Adding Delegate to allow application to handle Step
…
…command (project-chip#28000) * Added support for a basic FanControl::Delegate class that the application can implement to handle the Step Command. Added Set and Get functions and a class definition with a virtual function that can be implemented. * Extended the fan-stub class to also inherit the Delegate and wrote an example handler for the Step function * Turned on the available features for the ci tests * Restyled by whitespace * Included optional header so can use std::optional * Removing use of optional as it is not building on certain platforms in CI * Simplified the HandleStep callback and also added support for when Speed is Null * Initialising uninitialised value in HandleStep --------- Co-authored-by: Restyled.io <[email protected]>
- Loading branch information
Showing
5 changed files
with
254 additions
and
35 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
61 changes: 61 additions & 0 deletions
61
src/app/clusters/fan-control-server/fan-control-delegate.h
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,61 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* 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 <app-common/zap-generated/cluster-objects.h> | ||
#include <app/AttributeAccessInterface.h> | ||
#include <app/CommandResponseHelper.h> | ||
#include <app/util/af.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
namespace Clusters { | ||
namespace FanControl { | ||
|
||
/** @brief | ||
* Defines methods for implementing application-specific logic for the FanControl Cluster. | ||
*/ | ||
class Delegate | ||
{ | ||
public: | ||
/** | ||
* @brief | ||
* This method handles the step command. This will happen as fast as possible. | ||
* | ||
* @param[in] direction direction in which to step | ||
* @param[in] wrap whether the step command wraps or not | ||
* @param[in] wrap whether the step command wraps or not | ||
* | ||
* @return Success On success. | ||
* @return Other Value indicating it failed to execute the command. | ||
*/ | ||
virtual Protocols::InteractionModel::Status HandleStep(StepDirectionEnum direction, bool wrap, bool off) = 0; | ||
|
||
Delegate(EndpointId endpoint) : mEndpoint(endpoint) {} | ||
|
||
virtual ~Delegate() = default; | ||
|
||
protected: | ||
EndpointId mEndpoint = 0; | ||
}; | ||
|
||
} // namespace FanControl | ||
} // namespace Clusters | ||
} // namespace app | ||
} // namespace chip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* | ||
* 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "fan-control-delegate.h" | ||
#include <app-common/zap-generated/cluster-objects.h> | ||
#include <app-common/zap-generated/enums.h> | ||
#include <app/util/af-types.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
namespace Clusters { | ||
namespace FanControl { | ||
|
||
void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate); | ||
Delegate * GetDelegate(EndpointId endpoint); | ||
|
||
} // namespace FanControl | ||
} // namespace Clusters | ||
} // namespace app | ||
} // namespace chip |
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