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.
Add support to all clusters app to support Thermostat presets attribu…
…tes and commands
- Loading branch information
1 parent
50fb5cc
commit fcb85a5
Showing
6 changed files
with
470 additions
and
3 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
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
100 changes: 100 additions & 0 deletions
100
examples/all-clusters-app/linux/include/thermostat-delegate-impl.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,100 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 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/clusters/thermostat-server/thermostat-delegate.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
namespace Clusters { | ||
namespace Thermostat { | ||
|
||
/** | ||
* The ThermostatDelegate class serves as the instance delegate for storing Presets related information and providing it to the | ||
* Thermostat server code. It also manages the presets attribute and provides methods to write to presets, edit presets, maintain a | ||
* pending presets list and either commit the presets when requested or discard the changes. It also provides APIs to get and set | ||
* the attribute values. | ||
* | ||
*/ | ||
|
||
static constexpr uint8_t kMaxNumberOfPresetTypes = 6; | ||
|
||
// TODO: #34556 Support multiple presets of each type. | ||
// We will support only one preset of each preset type. | ||
static constexpr uint8_t kMaxNumberOfPresetsOfEachType = 1; | ||
|
||
class ThermostatDelegate : public Delegate | ||
{ | ||
public: | ||
static inline ThermostatDelegate & GetInstance() { return sInstance; } | ||
|
||
CHIP_ERROR GetPresetTypeAtIndex(size_t index, Structs::PresetTypeStruct::Type & presetType) override; | ||
|
||
uint8_t GetNumberOfPresets() override; | ||
|
||
CHIP_ERROR GetPresetAtIndex(size_t index, PresetStructWithOwnedMembers & preset) override; | ||
|
||
CHIP_ERROR GetActivePresetHandle(MutableByteSpan & activePresetHandle) override; | ||
|
||
CHIP_ERROR SetActivePresetHandle(const DataModel::Nullable<ByteSpan> & newActivePresetHandle) override; | ||
|
||
CHIP_ERROR AppendToPendingPresetList(const Structs::PresetStruct::Type & preset) override; | ||
|
||
CHIP_ERROR GetPendingPresetAtIndex(size_t index, PresetStructWithOwnedMembers & preset) override; | ||
|
||
CHIP_ERROR ApplyPendingPresets() override; | ||
|
||
void ClearPendingPresetList() override; | ||
|
||
private: | ||
static ThermostatDelegate sInstance; | ||
|
||
ThermostatDelegate(); | ||
~ThermostatDelegate() = default; | ||
|
||
ThermostatDelegate(const ThermostatDelegate &) = delete; | ||
ThermostatDelegate & operator=(const ThermostatDelegate &) = delete; | ||
|
||
/** | ||
* @brief Initializes the preset types array with all preset types corresponding to PresetScenarioEnum. | ||
*/ | ||
void InitializePresetTypes(); | ||
|
||
/** | ||
* @brief Initializes the presets array with some sample presets for testing. | ||
*/ | ||
void InitializePresets(); | ||
|
||
uint8_t mNumberOfPresets; | ||
|
||
Structs::PresetTypeStruct::Type mPresetTypes[kMaxNumberOfPresetTypes]; | ||
PresetStructWithOwnedMembers mPresets[kMaxNumberOfPresetTypes * kMaxNumberOfPresetsOfEachType]; | ||
PresetStructWithOwnedMembers mPendingPresets[kMaxNumberOfPresetTypes * kMaxNumberOfPresetsOfEachType]; | ||
|
||
uint8_t mNextFreeIndexInPendingPresetsList; | ||
uint8_t mNextFreeIndexInPresetsList; | ||
|
||
uint8_t mActivePresetHandleData[kPresetHandleSize]; | ||
size_t mActivePresetHandleDataSize; | ||
}; | ||
|
||
} // namespace Thermostat | ||
} // 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
Oops, something went wrong.