blob: 604496f886b3c2b7a84fdaa92cd5d5dd4e540521 [file] [log] [blame]
William4eaace42023-07-21 13:15:35 +01001/*
2 *
3 * Copyright (c) 2023 Project CHIP Authors
4 * All rights reserved.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#pragma once
20
21#include <app/clusters/mode-base-server/mode-base-server.h>
22#include <app/util/af.h>
23#include <app/util/config.h>
24#include <cstring>
25#include <utility>
26
27namespace chip {
28namespace app {
29namespace Clusters {
30
31namespace DishwasherMode {
32
33const uint8_t ModeNormal = 0;
34const uint8_t ModeHeavy = 1;
35const uint8_t ModeLight = 2;
36
37/// This is an application level delegate to handle DishwasherMode commands according to the specific business logic.
38class DishwasherModeDelegate : public ModeBase::Delegate
39{
40private:
41 using ModeTagStructType = detail::Structs::ModeTagStruct::Type;
42 ModeTagStructType modeTagsNormal[1] = { { .value = to_underlying(ModeTag::kNormal) } };
43 ModeTagStructType modeTagsHeavy[2] = { { .value = to_underlying(ModeBase::ModeTag::kMax) },
Karsten Sperling38d6a482023-09-29 15:50:08 +130044 { .value = to_underlying(ModeTag::kHeavy) } };
William4eaace42023-07-21 13:15:35 +010045 ModeTagStructType modeTagsLight[3] = { { .value = to_underlying(ModeTag::kLight) },
Karsten Sperling38d6a482023-09-29 15:50:08 +130046 { .value = to_underlying(ModeBase::ModeTag::kNight) },
47 { .value = to_underlying(ModeBase::ModeTag::kQuiet) } };
William4eaace42023-07-21 13:15:35 +010048
49 const detail::Structs::ModeOptionStruct::Type kModeOptions[3] = {
50 detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Normal"),
51 .mode = ModeNormal,
52 .modeTags = DataModel::List<const ModeTagStructType>(modeTagsNormal) },
53 detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Heavy"),
54 .mode = ModeHeavy,
55 .modeTags = DataModel::List<const ModeTagStructType>(modeTagsHeavy) },
56 detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Light"),
57 .mode = ModeLight,
58 .modeTags = DataModel::List<const ModeTagStructType>(modeTagsLight) }
59 };
60
61 CHIP_ERROR Init() override;
62 void HandleChangeToMode(uint8_t mode, ModeBase::Commands::ChangeToModeResponse::Type & response) override;
63
64 CHIP_ERROR GetModeLabelByIndex(uint8_t modeIndex, MutableCharSpan & label) override;
65 CHIP_ERROR GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) override;
66 CHIP_ERROR GetModeTagsByIndex(uint8_t modeIndex, DataModel::List<ModeTagStructType> & tags) override;
67
68public:
69 ~DishwasherModeDelegate() override = default;
70};
71
joonhaengHeob8479e12023-08-25 22:05:59 +090072ModeBase::Instance * Instance();
73
William7b6cbc52023-07-25 11:07:22 +010074void Shutdown();
75
William4eaace42023-07-21 13:15:35 +010076} // namespace DishwasherMode
77
78} // namespace Clusters
79} // namespace app
80} // namespace chip