Skip to content

Commit ff3f05a

Browse files
committed
Add required TODOs and optimize the skeleton code
1 parent ba8363d commit ff3f05a

18 files changed

+297
-446
lines changed

examples/oven-app/oven-app-common/include/CookSurfaceEndpoint.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace CookSurface {
3030
class CookSurfaceEndpoint
3131
{
3232
public:
33-
CookSurfaceEndpoint(EndpointId endpointId) {}
33+
CookSurfaceEndpoint(EndpointId endpointId) : mEndpointId(endpointId) {}
3434

3535
/**
3636
* @brief Initialize the CookSurface endpoint.
@@ -41,6 +41,10 @@ class CookSurfaceEndpoint
4141
* @brief Handle the "off" command for the CookSurface.
4242
*/
4343
void HandleOffCommand();
44+
45+
private:
46+
bool currentOnOffState = false;
47+
EndpointId mEndpointId = kInvalidEndpointId;
4448
};
4549

4650
} // namespace CookSurface

examples/oven-app/oven-app-common/include/CookTopEndpoint.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace CookTop {
2929
class CookTopEndpoint
3030
{
3131
public:
32-
CookTopEndpoint(EndpointId endpointId) {}
32+
CookTopEndpoint(EndpointId endpointId) : mEndpointId(endpointId) {}
3333

3434
/**
3535
* @brief Initialize the cooktop endpoint.
@@ -42,6 +42,10 @@ class CookTopEndpoint
4242
* @brief Handle the "off" command for the cooktop.
4343
*/
4444
void HandleOffCommand();
45+
46+
private:
47+
bool currentOnOffState = false;
48+
EndpointId mEndpointId = kInvalidEndpointId;
4549
};
4650

4751
} // namespace CookTop

examples/oven-app/oven-app-common/include/OvenEndpoint.h

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,87 @@
2121
#include <app-common/zap-generated/cluster-objects.h>
2222
#include <lib/core/CHIPError.h>
2323
#include <lib/core/DataModelTypes.h>
24+
#include <app/clusters/mode-base-server/mode-base-server.h>
25+
#include <app/clusters/temperature-control-server/supported-temperature-levels-manager.h>
26+
#include <app/data-model/List.h>
27+
#include <lib/support/Span.h>
2428

2529
namespace chip {
2630
namespace app {
2731
namespace Clusters {
28-
namespace Oven {
32+
namespace TemperatureControlledCabinet {
33+
class OvenModeDelegate : public ModeBase::Delegate
34+
{
35+
public:
36+
// Oven mode constants - made static and public for potential reuse
37+
static constexpr uint8_t kModeBake = 0;
38+
static constexpr uint8_t kModeConvection = 1;
39+
static constexpr uint8_t kModeGrill = 2;
40+
static constexpr uint8_t kModeRoast = 3;
41+
static constexpr uint8_t kModeClean = 4;
42+
static constexpr uint8_t kModeConvectionBake = 5;
43+
static constexpr uint8_t kModeConvectionRoast = 6;
44+
static constexpr uint8_t kModeWarming = 7;
45+
static constexpr uint8_t kModeProofing = 8;
46+
static constexpr uint8_t kModeCount = 9;
47+
48+
OvenModeDelegate(EndpointId endpointId) : mEndpointId(endpointId) {}
49+
50+
// ModeBase::Delegate interface
51+
CHIP_ERROR Init() override;
52+
void HandleChangeToMode(uint8_t mode, ModeBase::Commands::ChangeToModeResponse::Type & response) override;
53+
CHIP_ERROR GetModeLabelByIndex(uint8_t modeIndex, MutableCharSpan & label) override;
54+
CHIP_ERROR GetModeValueByIndex(uint8_t modeIndex, uint8_t & value) override;
55+
CHIP_ERROR GetModeTagsByIndex(uint8_t modeIndex, DataModel::List<detail::Structs::ModeTagStruct::Type> & tags) override;
56+
57+
private:
58+
EndpointId mEndpointId;
59+
60+
// Static arrays moved to implementation file to reduce header size
61+
static const detail::Structs::ModeTagStruct::Type sModeTagsBake[];
62+
static const detail::Structs::ModeTagStruct::Type sModeTagsConvection[];
63+
static const detail::Structs::ModeTagStruct::Type sModeTagsGrill[];
64+
static const detail::Structs::ModeTagStruct::Type sModeTagsRoast[];
65+
static const detail::Structs::ModeTagStruct::Type sModeTagsClean[];
66+
static const detail::Structs::ModeTagStruct::Type sModeTagsConvectionBake[];
67+
static const detail::Structs::ModeTagStruct::Type sModeTagsConvectionRoast[];
68+
static const detail::Structs::ModeTagStruct::Type sModeTagsWarming[];
69+
static const detail::Structs::ModeTagStruct::Type sModeTagsProofing[];
70+
71+
static const detail::Structs::ModeOptionStruct::Type skModeOptions[];
72+
};
73+
74+
class TemperatureControlledCabinetEndpoint
75+
{
76+
public:
77+
TemperatureControlledCabinetEndpoint(EndpointId endpointId) :
78+
mEndpointId(endpointId), mOvenModeDelegate(endpointId), mOvenModeInstance(&mOvenModeDelegate, mEndpointId, OvenMode::Id, 0)
79+
{}
80+
81+
/**
82+
* Initialize the temperature controlled cabinet endpoint.
83+
*/
84+
CHIP_ERROR Init();
85+
86+
private:
87+
EndpointId mEndpointId = kInvalidEndpointId;
88+
OvenModeDelegate mOvenModeDelegate;
89+
ModeBase::Instance mOvenModeInstance;
90+
};
2991

92+
} // namespace TemperatureControlledCabinet
93+
94+
namespace Oven {
3095
/**
3196
* @brief Base oven endpoint placeholder.
3297
*/
3398
class OvenEndpoint
3499
{
35100
public:
36-
OvenEndpoint(EndpointId endpointId) {}
101+
OvenEndpoint() {}
37102

38103
/**
39104
* @brief Initialize the oven endpoint.
40-
*
41-
* @return CHIP_ERROR indicating success or failure of the initialization.
42105
*/
43106
CHIP_ERROR Init();
44107
};

examples/oven-app/oven-app-common/include/OvenModeDelegate.h

Lines changed: 0 additions & 77 deletions
This file was deleted.

examples/oven-app/oven-app-common/include/TemperatureControlledCabinetEndpoint.h

Lines changed: 0 additions & 52 deletions
This file was deleted.

examples/oven-app/oven-app-common/src/CookSurfaceEndpoint.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ using namespace chip::app::Clusters::CookSurface;
2424

2525
CHIP_ERROR CookSurfaceEndpoint::Init()
2626
{
27-
ChipLogProgress(AppServer, "CookSurfaceEndpoint::Init()");
28-
// TODO: Add Endpoint initialization logic
2927
return CHIP_NO_ERROR;
3028
}
3129

examples/oven-app/oven-app-common/src/CookTopEndpoint.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ using namespace chip::app::Clusters::CookTop;
2424

2525
CHIP_ERROR CookTopEndpoint::Init()
2626
{
27-
// TODO: Add CookTop Endpoint Initialization logic
2827
return CHIP_NO_ERROR;
2928
}
3029

0 commit comments

Comments
 (0)