Skip to content

Commit 21717e4

Browse files
committed
Add logic to handle the oven-mode change
1 parent 6b996be commit 21717e4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

examples/oven-app/silabs/include/OvenManager.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <app-common/zap-generated/ids/Attributes.h>
4141
#include <app/clusters/mode-base-server/mode-base-cluster-objects.h>
4242
#include <app/clusters/on-off-server/on-off-server.h>
43+
#include <app/clusters/mode-base-server/mode-base-cluster-objects.h>
4344
#include <lib/core/DataModelTypes.h>
4445
#include <lib/support/TypeTraits.h>
4546
#include <platform/CHIPDeviceLayer.h>
@@ -111,6 +112,14 @@ class OvenManager
111112
* @param size Size of the new value.
112113
*/
113114
void OnOffAttributeChangeHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value, uint16_t size);
115+
void OvenModeAttributeChangeHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value, uint16_t size);
116+
117+
/**
118+
* @brief Central handler for OvenMode delegate requests. Applies validation, blocked-transition policy,
119+
* and writes the CurrentMode attribute if allowed.
120+
*/
121+
void ProcessOvenModeChange(chip::EndpointId endpointId, uint8_t newMode,
122+
chip::app::Clusters::ModeBase::Commands::ChangeToModeResponse::Type & response);
114123

115124
/**
116125
* @brief Handles oven mode attribute changes.

examples/oven-app/silabs/src/OvenManager.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include "CookTopEndpoint.h"
2323
#include "OvenEndpoint.h"
2424

25+
#include <app-common/zap-generated/cluster-objects.h>
26+
#include <app-common/zap-generated/attributes/Accessors.h>
27+
#include <app/clusters/mode-base-server/mode-base-cluster-objects.h>
28+
2529
#include "AppConfig.h"
2630
#include "AppTask.h"
2731

@@ -67,6 +71,24 @@ void OvenManager::Init()
6771

6872
VerifyOrReturn(mCookTopEndpoint.Init() == CHIP_NO_ERROR, ChipLogError(AppServer, "CookTopEndpoint Init failed"));
6973

74+
// Initialize TemperatureControl cluster numeric temperature attributes for endpoint 2 (silent on failure)
75+
{
76+
Status tcStatus = TemperatureControl::Attributes::TemperatureSetpoint::Set(kTemperatureControlledCabinetEndpoint2, 0);
77+
VerifyOrReturn(tcStatus == Status::Success,
78+
ChipLogError(AppServer, "Endpoint2 TemperatureSetpoint init failed"));
79+
80+
tcStatus = TemperatureControl::Attributes::MinTemperature::Set(kTemperatureControlledCabinetEndpoint2, 0);
81+
VerifyOrReturn(tcStatus == Status::Success,
82+
ChipLogError(AppServer, "Endpoint2 MinTemperature init failed"));
83+
84+
tcStatus = TemperatureControl::Attributes::MaxTemperature::Set(kTemperatureControlledCabinetEndpoint2, 30000);
85+
VerifyOrReturn(tcStatus == Status::Success,
86+
ChipLogError(AppServer, "Endpoint2 MaxTemperature init failed"));
87+
88+
tcStatus = TemperatureControl::Attributes::Step::Set(kTemperatureControlledCabinetEndpoint2, 500);
89+
VerifyOrReturn(tcStatus == Status::Success, ChipLogError(AppServer, "Endpoint2 Step init failed"));
90+
}
91+
7092
// Register the shared TemperatureLevelsDelegate for all the cooksurface endpoints
7193
TemperatureControl::SetInstance(&mTemperatureControlDelegate);
7294

0 commit comments

Comments
 (0)