/src/connectedhomeip/examples/thermostat/thermostat-common/include/thermostat-delegate-impl.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2024-2026 Project CHIP Authors |
3 | | * All rights reserved. |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | */ |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include "app/clusters/thermostat-server/Temperature.h" |
21 | | #include "lib/core/CHIPError.h" |
22 | | #include <app/persistence/AttributePersistenceProvider.h> |
23 | | #include <app/persistence/AttributePersistenceProviderInstance.h> |
24 | | |
25 | | #include <app/clusters/thermostat-server/ThermostatCluster.h> |
26 | | #include <app/clusters/thermostat-server/ThermostatDelegate.h> |
27 | | #include <credentials/FabricTable.h> |
28 | | |
29 | | namespace chip { |
30 | | |
31 | | namespace app { |
32 | | namespace Clusters { |
33 | | namespace Thermostat { |
34 | | |
35 | | /* |
36 | | * A simple implementation of ThermostatDelegate. |
37 | | * It reports and persists the basic state of the thermostat. |
38 | | */ |
39 | | class ThermostatDelegate : public Delegate |
40 | | { |
41 | | public: |
42 | | ThermostatDelegate(EndpointId endpoint, AttributePersistenceProvider * provider = nullptr, |
43 | | FabricTable * fabricTable = nullptr) : |
44 | 0 | mEndpointId(endpoint), |
45 | 0 | mProvider(provider), mFabricTable(fabricTable) |
46 | 0 | {} |
47 | | |
48 | | FabricTable & GetFabricTable() const override; |
49 | | |
50 | | CHIP_ERROR Startup(ServerClusterContext & context) override; |
51 | | |
52 | | SystemModeEnum GetSystemMode() const override; |
53 | | Protocols::InteractionModel::Status SetSystemMode(SystemModeEnum systemMode, bool & changed) override; |
54 | | |
55 | | Protocols::InteractionModel::Status GetRunningMode(ThermostatRunningModeEnum & runningMode) const override; |
56 | | Protocols::InteractionModel::Status SetRunningMode(ThermostatRunningModeEnum runningMode, bool & changed) override; |
57 | | |
58 | | Protocols::InteractionModel::Status GetRunningState(BitMask<RelayStateBitmap> & runningState) const override; |
59 | | Protocols::InteractionModel::Status SetRunningState(BitMask<RelayStateBitmap> runningState, bool & changed) override; |
60 | | |
61 | | ControlSequenceOfOperationEnum GetControlSequenceOfOperation() const override; |
62 | | Protocols::InteractionModel::Status SetControlSequenceOfOperation(ControlSequenceOfOperationEnum seq, bool & changed) override; |
63 | | |
64 | | DataModel::Nullable<temperature> GetLocalTemperature() const override; |
65 | | Protocols::InteractionModel::Status SetLocalTemperature(DataModel::Nullable<temperature> temp, bool & changed) override; |
66 | | |
67 | | Protocols::InteractionModel::Status GetOutdoorTemperature(DataModel::Nullable<temperature> & outdoorTemp) const override; |
68 | | |
69 | | int8_t GetLocalTemperatureCalibration() const override; |
70 | | Protocols::InteractionModel::Status SetLocalTemperatureCalibration(int8_t temp, bool & changed) override; |
71 | | |
72 | | Protocols::InteractionModel::Status GetRemoteSensing(BitMask<RemoteSensingBitmap> & remoteSensing) const override; |
73 | | Protocols::InteractionModel::Status SetRemoteSensing(BitMask<RemoteSensingBitmap> sensing, bool & changed) override; |
74 | | |
75 | | private: |
76 | | EndpointId mEndpointId; |
77 | | AttributePersistenceProvider * mProvider = nullptr; |
78 | | FabricTable * mFabricTable = nullptr; |
79 | | |
80 | | ControlSequenceOfOperationEnum mControlSequenceOfOperation = ControlSequenceOfOperationEnum::kCoolingAndHeating; |
81 | | |
82 | | SystemModeEnum mSystemMode = SystemModeEnum::kOff; |
83 | | ThermostatRunningModeEnum mRunningMode = ThermostatRunningModeEnum::kOff; |
84 | | BitMask<RelayStateBitmap> mRunningState = BitMask<RelayStateBitmap>(0); |
85 | | DataModel::Nullable<temperature> mLocalTemperature = DataModel::Nullable<int16_t>(); |
86 | | int8_t mLocalTemperatureCalibration = 0; |
87 | | |
88 | | BitMask<RemoteSensingBitmap> mRemoteSensing = BitMask<RemoteSensingBitmap>(0); |
89 | | }; |
90 | | |
91 | | } // namespace Thermostat |
92 | | } // namespace Clusters |
93 | | } // namespace app |
94 | | } // namespace chip |