@@ -47,7 +47,7 @@ void OvenManager::Init()
4747 DeviceLayer::PlatformMgr ().LockChipStack ();
4848
4949 // Initialize states
50- mCookTopState = kCookTopState_OffCompleted ;
50+ mCookTopState = kCookTopState_OffCompleted ;
5151 mCookSurfaceState1 = kCookSurfaceState_OffCompleted ;
5252 mCookSurfaceState2 = kCookSurfaceState_OffCompleted ;
5353
@@ -181,14 +181,15 @@ void OvenManager::OnOffAttributeChangeHandler(EndpointId endpointId, AttributeId
181181 case kCookSurfaceEndpoint1 :
182182 case kCookSurfaceEndpoint2 :
183183 // Handle On/Off attribute changes for the cook surface endpoints
184- InitiateCookSurfaceAction (AppEvent::kEventType_CookSurface , *value ? OvenManager::ON_ACTION : OvenManager::OFF_ACTION, value, endpointId);
184+ InitiateCookSurfaceAction (AppEvent::kEventType_CookSurface , *value ? OvenManager::ON_ACTION : OvenManager::OFF_ACTION,
185+ value, endpointId);
185186 {
186187 bool cookSurfaceEndpoint1State;
187188 bool cookSurfaceEndpoint2State;
188189 mCookSurfaceEndpoint1 .GetOnOffState (cookSurfaceEndpoint1State);
189190 mCookSurfaceEndpoint2 .GetOnOffState (cookSurfaceEndpoint2State);
190191 // Check if both cooksurfaces are off. If yes, turn off the cooktop (call cooktop.TurnOffCookTop)
191- if (cookSurfaceEndpoint1State == false && cookSurfaceEndpoint2State == false )
192+ if (cookSurfaceEndpoint1State == false && cookSurfaceEndpoint2State == false )
192193 {
193194 mCookTopEndpoint .SetOnOffState (false );
194195 }
@@ -287,11 +288,11 @@ bool OvenManager::InitiateCookSurfaceAction(int32_t aActor, Action_t aAction, ui
287288 *currentState = new_state;
288289
289290 AppEvent event;
290- event.Type = AppEvent::kEventType_CookSurface ;
291- event.OvenEvent .Context = this ;
292- event.OvenEvent .Action = aAction;
293- event.OvenEvent .Actor = endpointId; // Store endpoint ID in Actor field
294- event.Handler = ActuatorMovementHandler;
291+ event.Type = AppEvent::kEventType_CookSurface ;
292+ event.OvenEvent .Context = this ;
293+ event.OvenEvent .Action = aAction;
294+ event.OvenEvent .Actor = endpointId; // Store endpoint ID in Actor field
295+ event.Handler = ActuatorMovementHandler;
295296 AppTask::GetAppTask ().PostEvent (&event);
296297 }
297298
@@ -306,58 +307,56 @@ bool OvenManager::InitiateCookSurfaceAction(int32_t aActor, Action_t aAction, ui
306307void OvenManager::ActuatorMovementHandler (AppEvent * aEvent)
307308{
308309 Action_t actionCompleted = INVALID_ACTION;
309- OvenManager * oven = static_cast <OvenManager *>(aEvent->OvenEvent .Context );
310+ OvenManager * oven = static_cast <OvenManager *>(aEvent->OvenEvent .Context );
310311
311312 switch (aEvent->Type )
312313 {
313- case AppEvent::kEventType_CookTop :
314+ case AppEvent::kEventType_CookTop : {
315+ // Handle CookTop state transitions
316+ if (oven->mCookTopState == kCookTopState_OffInitiated )
314317 {
315- // Handle CookTop state transitions
316- if (oven->mCookTopState == kCookTopState_OffInitiated )
317- {
318- oven->mCookTopState = kCookTopState_OffCompleted ;
319- actionCompleted = OFF_ACTION;
320- }
321- else if (oven->mCookTopState == kCookTopState_OnInitiated )
322- {
323- oven->mCookTopState = kCookTopState_OnCompleted ;
324- actionCompleted = ON_ACTION;
325- }
318+ oven->mCookTopState = kCookTopState_OffCompleted ;
319+ actionCompleted = OFF_ACTION;
326320 }
327- break ;
328- case AppEvent::kEventType_CookSurface :
321+ else if (oven->mCookTopState == kCookTopState_OnInitiated )
329322 {
330- // Handle CookSurface state transitions
331- chip::EndpointId endpointId = static_cast <chip::EndpointId>(aEvent->OvenEvent .Actor );
332- State_t * currentState = nullptr ;
333-
334- // Get the appropriate state pointer based on endpoint
335- if (endpointId == kCookSurfaceEndpoint1 )
336- {
337- currentState = &oven->mCookSurfaceState1 ;
338- }
339- else if (endpointId == kCookSurfaceEndpoint2 )
340- {
341- currentState = &oven->mCookSurfaceState2 ;
342- }
343- else
344- {
345- ChipLogError (AppServer, " Invalid CookSurface endpoint ID" );
346- return ; // Invalid endpoint
347- }
323+ oven->mCookTopState = kCookTopState_OnCompleted ;
324+ actionCompleted = ON_ACTION;
325+ }
326+ }
327+ break ;
328+ case AppEvent::kEventType_CookSurface : {
329+ // Handle CookSurface state transitions
330+ chip::EndpointId endpointId = static_cast <chip::EndpointId>(aEvent->OvenEvent .Actor );
331+ State_t * currentState = nullptr ;
332+
333+ // Get the appropriate state pointer based on endpoint
334+ if (endpointId == kCookSurfaceEndpoint1 )
335+ {
336+ currentState = &oven->mCookSurfaceState1 ;
337+ }
338+ else if (endpointId == kCookSurfaceEndpoint2 )
339+ {
340+ currentState = &oven->mCookSurfaceState2 ;
341+ }
342+ else
343+ {
344+ ChipLogError (AppServer, " Invalid CookSurface endpoint ID" );
345+ return ; // Invalid endpoint
346+ }
348347
349- if (*currentState == kCookSurfaceState_OffInitiated )
350- {
351- *currentState = kCookSurfaceState_OffCompleted ;
352- actionCompleted = OFF_ACTION;
353- }
354- else if (*currentState == kCookSurfaceState_OnInitiated )
355- {
356- *currentState = kCookSurfaceState_OnCompleted ;
357- actionCompleted = ON_ACTION;
358- }
348+ if (*currentState == kCookSurfaceState_OffInitiated )
349+ {
350+ *currentState = kCookSurfaceState_OffCompleted ;
351+ actionCompleted = OFF_ACTION;
359352 }
360- break ;
353+ else if (*currentState == kCookSurfaceState_OnInitiated )
354+ {
355+ *currentState = kCookSurfaceState_OnCompleted ;
356+ actionCompleted = ON_ACTION;
357+ }
358+ }
359+ break ;
361360 default :
362361 break ;
363362 }
@@ -382,9 +381,12 @@ struct BlockedTransition
382381
383382// Disallowed OvenMode Transitions.
384383static constexpr BlockedTransition kBlockedTransitions [] = {
385- { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeGrill ), to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing ) },
386- { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing ), to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean ) },
387- { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean ), to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeBake ) },
384+ { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeGrill ),
385+ to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing ) },
386+ { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing ),
387+ to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean ) },
388+ { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean ),
389+ to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeBake ) },
388390};
389391
390392static bool IsTransitionBlocked (uint8_t fromMode, uint8_t toMode)
0 commit comments