-
Notifications
You must be signed in to change notification settings - Fork 31
[SL-ONLY] Oven app commands implementation #693
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
base: main
Are you sure you want to change the base?
Changes from 29 commits
f24e3f0
90e0388
65a5c48
1a8dd8d
8c86d55
204d3a1
ec3943e
2b9505f
03aa29e
ebf324e
6d73e62
9f63524
d5f86e9
00952f3
df13ff4
3f5eaec
dde3035
c36c1ca
efdc6e3
f1aacf6
caad0fb
c9545d8
b1e9be0
0e0ee4e
3643d79
49a6cbb
17e72b9
5826f8f
232fe4f
50bfb9c
efceeac
d3cb6fa
ba72490
f68c4e2
fbc02c4
52cb237
1baad61
6d426f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2589,5 +2589,3 @@ endpoint 5 { | |
| ram attribute clusterRevision default = 4; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,14 +17,31 @@ | |
| */ | ||
|
|
||
| #include "CookSurfaceEndpoint.h" | ||
| #include <lib/core/CHIPError.h> | ||
| #include <app/clusters/on-off-server/on-off-server.h> | ||
| #include <protocols/interaction_model/StatusCode.h> | ||
|
|
||
| using namespace chip; | ||
| using namespace chip::app::Clusters; | ||
| using namespace chip::app::Clusters::CookSurface; | ||
|
|
||
| CHIP_ERROR CookSurfaceEndpoint::Init() | ||
| { | ||
| return CHIP_NO_ERROR; | ||
arun-silabs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| void CookSurfaceEndpoint::HandleOffCommand() {} | ||
| chip::Protocols::InteractionModel::Status CookSurfaceEndpoint::GetOnOffState(bool & state) | ||
| { | ||
| auto status = OnOffServer::Instance().getOnOffValue(mEndpointId, &state); | ||
| VerifyOrReturnValue(status == Protocols::InteractionModel::Status::Success, status, | ||
|
||
| ChipLogError(AppServer, "ERR: reading on/off %x", to_underlying(status))); | ||
| return status; | ||
| } | ||
|
|
||
| chip::Protocols::InteractionModel::Status CookSurfaceEndpoint::SetOnOffState(bool state) | ||
| { | ||
| CommandId commandId = state ? OnOff::Commands::On::Id : OnOff::Commands::Off::Id; | ||
| auto status = OnOffServer::Instance().setOnOffValue(mEndpointId, commandId, false); | ||
|
||
| VerifyOrReturnValue(status == Protocols::InteractionModel::Status::Success, status, | ||
|
||
| ChipLogError(AppServer, "ERR: updating on/off %x", to_underlying(status))); | ||
| return status; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,4 +27,11 @@ CHIP_ERROR CookTopEndpoint::Init() | |
| return CHIP_NO_ERROR; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again please add a comment as why this function is needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a placeholder function similar to one in CookSurface, added a comment. |
||
| } | ||
|
|
||
| void CookTopEndpoint::HandleOffCommand() {} | ||
| chip::Protocols::InteractionModel::Status CookTopEndpoint::SetOnOffState(bool state) | ||
| { | ||
| CommandId commandId = state ? OnOff::Commands::On::Id : OnOff::Commands::Off::Id; | ||
| auto status = OnOffServer::Instance().setOnOffValue(mEndpointId, commandId, false); | ||
| VerifyOrReturnValue(status == Protocols::InteractionModel::Status::Success, status, | ||
|
||
| ChipLogError(AppServer, "ERR: updating on/off %x", to_underlying(status))); | ||
| return status; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,10 @@ | |
| */ | ||
|
|
||
| #include "OvenEndpoint.h" | ||
| #include <app-common/zap-generated/attributes/Accessors.h> | ||
| #include <app-common/zap-generated/cluster-objects.h> | ||
|
|
||
| #include "OvenManager.h" | ||
| #include <app/clusters/mode-base-server/mode-base-cluster-objects.h> | ||
| #include <lib/core/CHIPError.h> | ||
| #include <lib/support/CodeUtils.h> | ||
|
|
@@ -92,8 +95,50 @@ CHIP_ERROR OvenModeDelegate::Init() | |
|
|
||
| void OvenModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands::ChangeToModeResponse::Type & response) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't we have a mode enum somewhere in another header file ? is so we should use it instead of the generic There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HandleChangeToMode is a function given by the delegate. In the delegate, it has uint8_t as the parameter type. |
||
| { | ||
| ChipLogProgress(Zcl, "OvenModeDelegate::HandleChangeToMode: NewMode=%d", NewMode); | ||
| // TODO: Implement logic to change the oven mode. | ||
| ChipLogProgress(Zcl, "OvenModeDelegate forwarding mode change to OvenManager (ep=%u newMode=%u)", mEndpointId, NewMode); | ||
| // Verify newMode is among supported modes | ||
| bool supported = IsSupportedMode(NewMode); | ||
| if (!supported) | ||
| { | ||
| response.status = to_underlying(ModeBase::StatusCode::kUnsupportedMode); | ||
| return; | ||
| } | ||
|
|
||
| // Read Current Oven Mode | ||
| uint8_t currentMode; | ||
| Status attrStatus = OvenMode::Attributes::CurrentMode::Get(mEndpointId, ¤tMode); | ||
| if (attrStatus != Status::Success) | ||
| { | ||
| ChipLogError(AppServer, "OvenManager: Failed to read CurrentMode"); | ||
| response.status = to_underlying(ModeBase::StatusCode::kGenericFailure); | ||
| response.statusText.SetValue(CharSpan::fromCharString("Read CurrentMode failed")); | ||
| return; | ||
| } | ||
|
|
||
| // No action needed if current mode is the same as new mode | ||
| if (currentMode == NewMode) | ||
| { | ||
| response.status = to_underlying(ModeBase::StatusCode::kSuccess); | ||
| return; | ||
| } | ||
|
|
||
| if (OvenManager::GetInstance().IsTransitionBlocked(currentMode, NewMode)) | ||
| { | ||
| ChipLogProgress(AppServer, "OvenManager: Blocked transition %u -> %u", currentMode, NewMode); | ||
| response.status = to_underlying(ModeBase::StatusCode::kGenericFailure); | ||
| response.statusText.SetValue(CharSpan::fromCharString("Transition blocked")); | ||
| return; | ||
| } | ||
|
|
||
| // Write new mode | ||
| Status writeStatus = OvenMode::Attributes::CurrentMode::Set(mEndpointId, NewMode); | ||
| if (writeStatus != Status::Success) | ||
| { | ||
| ChipLogError(AppServer, "OvenManager: Failed to write CurrentMode"); | ||
| response.status = to_underlying(ModeBase::StatusCode::kGenericFailure); | ||
| response.statusText.SetValue(CharSpan::fromCharString("Write CurrentMode failed")); | ||
| return; | ||
| } | ||
| response.status = to_underlying(ModeBase::StatusCode::kSuccess); | ||
| } | ||
|
|
||
|
|
@@ -135,3 +180,15 @@ CHIP_ERROR OvenEndpoint::Init() | |
| { | ||
| return CHIP_NO_ERROR; | ||
| } | ||
|
|
||
| bool OvenModeDelegate::IsSupportedMode(uint8_t mode) | ||
| { | ||
| for (auto const & opt : skModeOptions) | ||
| { | ||
| if (opt.mode == mode) | ||
| { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
|
|
||
| #include "AppEvent.h" | ||
| #include "BaseApplication.h" | ||
| #include "OvenManager.h" | ||
|
||
|
|
||
| #include "FreeRTOS.h" | ||
| #include "timers.h" // provides FreeRTOS timer support | ||
|
|
@@ -87,13 +88,4 @@ class AppTask : public BaseApplication | |
| * @return CHIP_ERROR | ||
| */ | ||
| CHIP_ERROR AppInit() override; | ||
|
|
||
| /** | ||
| * @brief PB0 Button event processing function | ||
| * Press and hold will trigger a factory reset timer start | ||
| * Press and release will restart BLEAdvertising if not commissioned | ||
| * | ||
| * @param aEvent button event being processed | ||
| */ | ||
| static void ButtonHandler(AppEvent * aEvent); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,11 +31,28 @@ | |
| #include "CookSurfaceEndpoint.h" | ||
| #include "CookTopEndpoint.h" | ||
| #include "OvenEndpoint.h" | ||
|
|
||
| #include "AppEvent.h" | ||
|
|
||
| #include <app-common/zap-generated/ids/Attributes.h> | ||
| #include <app/clusters/mode-base-server/mode-base-cluster-objects.h> | ||
| #include <app/clusters/on-off-server/on-off-server.h> | ||
| #include <lib/core/DataModelTypes.h> | ||
| #include <lib/support/TypeTraits.h> | ||
| #include <platform/CHIPDeviceLayer.h> | ||
|
|
||
| class OvenManager | ||
| { | ||
|
|
||
| public: | ||
| enum State_t | ||
| { | ||
| kCookTopState_Off = 0, | ||
| kCookTopState_On, | ||
| kCookSurfaceState_Off, | ||
arun-silabs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| kCookSurfaceState_On | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Initializes the OvenManager and its associated resources. | ||
| * | ||
|
|
@@ -52,11 +69,76 @@ class OvenManager | |
| CHIP_ERROR SetCookSurfaceInitialState(chip::EndpointId cookSurfaceEndpoint); | ||
|
|
||
| CHIP_ERROR SetTemperatureControlledCabinetInitialState(chip::EndpointId temperatureControlledCabinetEndpoint); | ||
| /** | ||
| * @brief Handles temperature control attribute changes. | ||
| * | ||
| * @param endpointId The ID of the endpoint. | ||
| * @param attributeId The ID of the attribute. | ||
| * @param value Pointer to the new value. | ||
| * @param size Size of the new value. | ||
| */ | ||
| void TempCtrlAttributeChangeHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value, uint16_t size); | ||
|
|
||
| /** | ||
| * @brief Handles on/off attribute changes. | ||
| * | ||
| * @param endpointId The ID of the endpoint. | ||
| * @param attributeId The ID of the attribute. | ||
| * @param value Pointer to the new value. | ||
| * @param size Size of the new value. | ||
| */ | ||
| void OnOffAttributeChangeHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value, uint16_t size); | ||
|
|
||
| /** | ||
| * @brief Handles oven mode attribute changes. | ||
| * | ||
| * @param endpointId The ID of the endpoint. | ||
| * @param attributeId The ID of the attribute. | ||
| * @param value Pointer to the new value. | ||
| * @param size Size of the new value. | ||
| */ | ||
| void OvenModeAttributeChangeHandler(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value, uint16_t size); | ||
|
|
||
| /** | ||
| * @brief Checks if a transition between two oven modes is blocked. | ||
| * | ||
| * @param fromMode The current mode. | ||
| * @param toMode The desired mode. | ||
| * @return True if the transition is blocked, false otherwise. | ||
| */ | ||
| bool IsTransitionBlocked(uint8_t fromMode, uint8_t toMode); | ||
|
|
||
| private: | ||
| struct BlockedTransition | ||
| { | ||
| uint8_t fromMode; | ||
| uint8_t toMode; | ||
| }; | ||
|
|
||
| // Disallowed OvenMode Transitions. | ||
| static constexpr BlockedTransition kBlockedTransitions[3] = { | ||
| { chip::to_underlying(chip::app::Clusters::TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeGrill), | ||
| chip::to_underlying(chip::app::Clusters::TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing) }, | ||
| { chip::to_underlying(chip::app::Clusters::TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing), | ||
| chip::to_underlying(chip::app::Clusters::TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean) }, | ||
| { chip::to_underlying(chip::app::Clusters::TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean), | ||
| chip::to_underlying(chip::app::Clusters::TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeBake) }, | ||
| }; | ||
arun-silabs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| static OvenManager sOvenMgr; | ||
| chip::app::Clusters::AppSupportedTemperatureLevelsDelegate mTemperatureControlDelegate; | ||
|
|
||
| State_t mCookTopState; | ||
| State_t mCookSurfaceState1; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need 2 SurfaceState ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. customer requirements mentioned 2 surfaces . so we added 2 surfaces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A cook-top can contain multiple cook-surfaces |
||
| State_t mCookSurfaceState2; | ||
|
|
||
| /** | ||
| * @brief Updates the oven hardware state and UI (LEDs, LCD) in response to an event. | ||
| * | ||
| * @param aEvent Pointer to the event structure. | ||
| */ | ||
| static void OvenActionHandler(AppEvent * aEvent); | ||
|
|
||
| // Define the endpoint ID for the Oven | ||
| static constexpr chip::EndpointId kOvenEndpoint = 1; | ||
| static constexpr chip::EndpointId kTemperatureControlledCabinetEndpoint = 2; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Extra blank line between documentation and function declaration. Remove the blank line on line 55 to maintain consistency with standard documentation formatting practices.