Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add water heater mode to sdk and all-clusters-app #34351

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9e16c36
Add water heater mode cluster
PeterC1965 Jul 16, 2024
963017e
Get all-clusters-app building with water-heater-mode
PeterC1965 Jul 16, 2024
5571e88
Restyled by clang-format
restyled-commits Jul 16, 2024
4b8b11b
Merge branch 'master' into add-water-heater-mode-sdk-code
jamesharrow Jul 17, 2024
a127cce
Added call to WaterHeaterMode::Shutdown() to fix IntrusiveList not be…
jamesharrow Jul 17, 2024
2d212a0
Added missing #include "water-heater-mode.h" to main-common.cpp
jamesharrow Jul 17, 2024
d5051ef
Merge branch 'upstream-master' into add-water-heater-mode-sdk-code
jamesharrow Jul 18, 2024
74f14e7
Merge branch 'master' into add-water-heater-mode-sdk-code
PeterC1965 Jul 18, 2024
a2983d2
Regenerated files
PeterC1965 Jul 18, 2024
ce728eb
Update following review comments from Andrei Litvin
PeterC1965 Jul 18, 2024
6acca68
Fix compilation error
PeterC1965 Jul 18, 2024
898dccb
Restyled by clang-format
restyled-commits Jul 18, 2024
ccd0f39
Update after review comment from Boris
PeterC1965 Jul 21, 2024
b57288f
WaterHeaterMode moved to future section
PeterC1965 Jul 21, 2024
1ea0072
Merge branch 'master' into add-water-heater-mode-sdk-code
PeterC1965 Jul 22, 2024
4c4a341
Update examples/all-clusters-app/all-clusters-common/include/water-he…
PeterC1965 Jul 25, 2024
eabbf55
Address final set of review comments from Andrei
PeterC1965 Jul 25, 2024
16198cd
Merge branch 'master' into add-water-heater-mode-sdk-code
PeterC1965 Jul 25, 2024
4ff2071
Merge branch 'master' into add-water-heater-mode-sdk-code
PeterC1965 Jul 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4582,6 +4582,56 @@ cluster EnergyEvseMode = 157 {
command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster WaterHeaterMode = 158 {
revision 1;

enum ModeTag : enum16 {
kOff = 16384;
kManual = 16385;
kTimed = 16386;
}

bitmap Feature : bitmap32 {
kOnOff = 0x1;
}

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

readonly attribute ModeOptionStruct supportedModes[] = 0;
readonly attribute int8u currentMode = 1;
attribute optional nullable int8u startUpMode = 2;
attribute optional nullable int8u onMode = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct ChangeToModeRequest {
int8u newMode = 0;
}

response struct ChangeToModeResponse = 1 {
enum8 status = 0;
optional char_string statusText = 1;
}

/** This command is used to change device modes.
On receipt of this command the device SHALL respond with a ChangeToModeResponse command. */
command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
provisional cluster DeviceEnergyManagementMode = 159 {
revision 1;
Expand Down Expand Up @@ -8479,6 +8529,22 @@ endpoint 1 {
handle command ChangeToModeResponse;
}

server cluster WaterHeaterMode {
callback attribute supportedModes;
callback attribute currentMode;
ram attribute startUpMode;
ram attribute onMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 1;

handle command ChangeToMode;
handle command ChangeToModeResponse;
}

server cluster DeviceEnergyManagementMode {
callback attribute supportedModes;
callback attribute currentMode;
Expand Down
188 changes: 188 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -14745,6 +14745,194 @@
}
]
},
{
"name": "Water Heater Mode",
"code": 158,
"mfgCode": null,
"define": "WATER_HEATER_MODE_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "ChangeToMode",
"code": 0,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "ChangeToModeResponse",
"code": 1,
"mfgCode": null,
"source": "server",
"isIncoming": 0,
"isEnabled": 1
}
],
"attributes": [
{
"name": "SupportedModes",
"code": 0,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "CurrentMode",
"code": 1,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "StartUpMode",
"code": 2,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "OnMode",
"code": 3,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AcceptedCommandList",
"code": 65529,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "EventList",
"code": 65530,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"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,
"mfgCode": null,
"side": "server",
"type": "bitmap32",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
}
]
},
{
"name": "Device Energy Management Mode",
"code": 159,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
*
* 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/clusters/mode-base-server/mode-base-server.h>
#include <app/util/config.h>
#include <cstring>
#include <utility>

namespace chip {
namespace app {
namespace Clusters {

namespace WaterHeaterMode {

constexpr uint8_t kModeOff = 0;
constexpr uint8_t kModeManual = 1;
constexpr uint8_t kModeTimed = 2;

/// This is an application level delegate to handle WaterHeaterMode commands according to the specific business logic.
class ExampleWaterHeaterModeDelegate : public ModeBase::Delegate
{
private:
using ModeTagStructType = detail::Structs::ModeTagStruct::Type;
ModeTagStructType modeTagsOff[1] = { { .value = to_underlying(ModeTag::kOff) } };
ModeTagStructType modeTagsManual[1] = { { .value = to_underlying(ModeTag::kManual) } };
ModeTagStructType modeTagsTimed[1] = { { .value = to_underlying(ModeTag::kTimed) } };

const detail::Structs::ModeOptionStruct::Type kModeOptions[3] = {
detail::Structs::ModeOptionStruct::Type{
.label = "Off"_span, .mode = kModeOff, .modeTags = DataModel::List<const ModeTagStructType>(modeTagsOff) },
detail::Structs::ModeOptionStruct::Type{
.label = "Manual"_span, .mode = kModeManual, .modeTags = DataModel::List<const ModeTagStructType>(modeTagsManual) },
detail::Structs::ModeOptionStruct::Type{
.label = "Timed"_span, .mode = kModeTimed, .modeTags = DataModel::List<const ModeTagStructType>(modeTagsTimed) }
};

CHIP_ERROR Init() override;
void HandleChangeToMode(uint8_t mode, ModeBase::Commands::ChangeToModeResponse::Type & response) override;

CHIP_ERROR GetModeLabelByIndex(uint8_t modeIndex, MutableCharSpan & label) override;
CHIP_ERROR GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) override;
CHIP_ERROR GetModeTagsByIndex(uint8_t modeIndex, DataModel::List<ModeTagStructType> & tags) override;

public:
~ExampleWaterHeaterModeDelegate() override = default;
};

ModeBase::Instance * Instance();

void Shutdown();

} // namespace WaterHeaterMode

} // namespace Clusters
} // namespace app
} // namespace chip
Loading
Loading