Skip to content

Commit

Permalink
OvenMode example Implementation (#30983)
Browse files Browse the repository at this point in the history
* Adding oven op state

* Python regen

* Fixing alignment

* regenerate with oven device.

* regenerated zap and chiptool

* oven opState first pass

builds and runs, but running tests results in a lot of failure messages.

* tentative updates based on RVC

* updated cluster name & fix build

* regen zap

* linux builds with oven mode update.

* remove duplicate ovencacvity Entries

* remove duplicate oven cavity entry

* Revert "remove duplicate ovencacvity Entries"

This reverts commit 87e891e.

* cleanup for ovenMode

* cleanup: remove operationalState changes

* update config-data. Regen.

* Restyled by clang-format

* Reverting files.gni, settings.json

* adding to emberAf function to get it compiled

* adding oven-modes.cpp to more make files.

* Adding to 2 more make files

* removed "server" init(), struck from init list

* removed references to ovenCavityOperationalState

* Regenerated Zap

* zap regen after rebase

* updating name of dryer control endpoint count

* fixing merge for telink

* cleanup auto-format changes

* Fix zap file merge error

---------

Co-authored-by: abeck-riis <98488327+abeck-riis@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
3 people authored and pull[bot] committed Apr 4, 2024
1 parent 5165b9f commit 2ab69d6
Show file tree
Hide file tree
Showing 22 changed files with 448 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,62 @@ cluster BooleanState = 69 {
readonly attribute int16u clusterRevision = 65533;
}

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

enum ModeTag : enum16 {
kBake = 16384;
kConvection = 16385;
kGrill = 16386;
kRoast = 16387;
kClean = 16388;
kConvectionBake = 16389;
kConvectionRoast = 16390;
kWarming = 16391;
kProofing = 16392;
}

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;
}

/** This cluster supports remotely monitoring and controling the different typs of
functionality available to a drying device, such as a laundry dryer. */
cluster LaundryDryerControls = 74 {
Expand Down Expand Up @@ -7080,6 +7136,17 @@ endpoint 1 {
ram attribute clusterRevision default = 1;
}

server cluster OvenMode {
callback attribute supportedModes;
ram attribute currentMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
}

server cluster LaundryDryerControls {
callback attribute supportedDrynessLevels;
ram attribute selectedDrynessLevel;
Expand Down
152 changes: 145 additions & 7 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -8408,6 +8408,145 @@
}
]
},
{
"name": "Oven Mode",
"code": 73,
"mfgCode": null,
"define": "OVEN_MODE_CLUSTER",
"side": "server",
"enabled": 1,
"apiMaturity": "provisional",
"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": "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": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"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": "Laundry Dryer Controls",
"code": 74,
Expand All @@ -8426,7 +8565,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -8458,7 +8597,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8474,7 +8613,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8490,7 +8629,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8506,7 +8645,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -22676,5 +22815,4 @@
}
],
"log": []
}

}
106 changes: 106 additions & 0 deletions examples/all-clusters-app/all-clusters-common/include/oven-modes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
*
* 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/af.h>
#include <app/util/config.h>
#include <cstring>
#include <utility>

namespace chip {
namespace app {
namespace Clusters {

namespace OvenMode {

const uint8_t ModeBake = 0;
const uint8_t ModeConvection = 1;
const uint8_t ModeGrill = 2;
const uint8_t ModeRoast = 3;
const uint8_t ModeClean = 4;
const uint8_t ModeConvectionBake = 5;
const uint8_t ModeConvectionRoast = 6;
const uint8_t ModeWarming = 7;
const uint8_t ModeProofing = 8;

/// This is an application level delegate to handle Oven commands according to the specific business logic.
class OvenModeDelegate : public ModeBase::Delegate
{
private:
using ModeTagStructType = detail::Structs::ModeTagStruct::Type;
ModeTagStructType ModeTagsBake[1] = { { .value = to_underlying(ModeTag::kBake) } };
ModeTagStructType ModeTagsConvection[1] = { { .value = to_underlying(ModeTag::kConvection) } };
ModeTagStructType ModeTagsGrill[1] = { { .value = to_underlying(ModeTag::kGrill) } };
ModeTagStructType ModeTagsRoast[1] = { { .value = to_underlying(ModeTag::kRoast) } };
ModeTagStructType ModeTagsClean[1] = { { .value = to_underlying(ModeTag::kClean) } };
ModeTagStructType ModeTagsConvectionBake[1] = { { .value = to_underlying(ModeTag::kConvectionBake) } };
ModeTagStructType ModeTagsConvectionRoast[1] = { { .value = to_underlying(ModeTag::kConvectionRoast) } };
ModeTagStructType ModeTagsWarming[1] = { { .value = to_underlying(ModeTag::kWarming) } };
ModeTagStructType ModeTagsProofing[1] = { { .value = to_underlying(ModeTag::kProofing) } };

const detail::Structs::ModeOptionStruct::Type kModeOptions[9] = {
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Bake"),
.mode = ModeBake,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsBake) },
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Convection"),
.mode = ModeConvection,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsConvection) },
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Grill"),
.mode = ModeGrill,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsGrill) },
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Roast"),
.mode = ModeRoast,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsRoast) },
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Clean"),
.mode = ModeClean,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsClean) },
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Convection Bake"),
.mode = ModeConvectionBake,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsConvectionBake) },
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Convection Roast"),
.mode = ModeConvectionRoast,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsConvectionRoast) },
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Warming"),
.mode = ModeWarming,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsWarming) },
detail::Structs::ModeOptionStruct::Type{ .label = CharSpan::fromCharString("Proofing"),
.mode = ModeProofing,
.modeTags = DataModel::List<const ModeTagStructType>(ModeTagsProofing) },
};

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:
~OvenModeDelegate() override = default;
};

ModeBase::Instance * Instance();

void Shutdown();

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

0 comments on commit 2ab69d6

Please sign in to comment.