@@ -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
@@ -161,14 +161,15 @@ void OvenManager::OnOffAttributeChangeHandler(EndpointId endpointId, AttributeId
161161 case kCookSurfaceEndpoint1 :
162162 case kCookSurfaceEndpoint2 :
163163 // Handle On/Off attribute changes for the cook surface endpoints
164- InitiateCookSurfaceAction (AppEvent::kEventType_CookSurface , *value ? OvenManager::ON_ACTION : OvenManager::OFF_ACTION, value, endpointId);
164+ InitiateCookSurfaceAction (AppEvent::kEventType_CookSurface , *value ? OvenManager::ON_ACTION : OvenManager::OFF_ACTION,
165+ value, endpointId);
165166 {
166167 bool cookSurfaceEndpoint1State;
167168 bool cookSurfaceEndpoint2State;
168169 mCookSurfaceEndpoint1 .GetOnOffState (cookSurfaceEndpoint1State);
169170 mCookSurfaceEndpoint2 .GetOnOffState (cookSurfaceEndpoint2State);
170171 // Check if both cooksurfaces are off. If yes, turn off the cooktop (call cooktop.TurnOffCookTop)
171- if (cookSurfaceEndpoint1State == false && cookSurfaceEndpoint2State == false )
172+ if (cookSurfaceEndpoint1State == false && cookSurfaceEndpoint2State == false )
172173 {
173174 mCookTopEndpoint .SetOnOffState (false );
174175 }
@@ -267,11 +268,11 @@ bool OvenManager::InitiateCookSurfaceAction(int32_t aActor, Action_t aAction, ui
267268 *currentState = new_state;
268269
269270 AppEvent event;
270- event.Type = AppEvent::kEventType_CookSurface ;
271- event.OvenEvent .Context = this ;
272- event.OvenEvent .Action = aAction;
273- event.OvenEvent .Actor = endpointId; // Store endpoint ID in Actor field
274- event.Handler = ActuatorMovementHandler;
271+ event.Type = AppEvent::kEventType_CookSurface ;
272+ event.OvenEvent .Context = this ;
273+ event.OvenEvent .Action = aAction;
274+ event.OvenEvent .Actor = endpointId; // Store endpoint ID in Actor field
275+ event.Handler = ActuatorMovementHandler;
275276 AppTask::GetAppTask ().PostEvent (&event);
276277 }
277278
@@ -286,58 +287,56 @@ bool OvenManager::InitiateCookSurfaceAction(int32_t aActor, Action_t aAction, ui
286287void OvenManager::ActuatorMovementHandler (AppEvent * aEvent)
287288{
288289 Action_t actionCompleted = INVALID_ACTION;
289- OvenManager * oven = static_cast <OvenManager *>(aEvent->OvenEvent .Context );
290+ OvenManager * oven = static_cast <OvenManager *>(aEvent->OvenEvent .Context );
290291
291292 switch (aEvent->Type )
292293 {
293- case AppEvent::kEventType_CookTop :
294+ case AppEvent::kEventType_CookTop : {
295+ // Handle CookTop state transitions
296+ if (oven->mCookTopState == kCookTopState_OffInitiated )
294297 {
295- // Handle CookTop state transitions
296- if (oven->mCookTopState == kCookTopState_OffInitiated )
297- {
298- oven->mCookTopState = kCookTopState_OffCompleted ;
299- actionCompleted = OFF_ACTION;
300- }
301- else if (oven->mCookTopState == kCookTopState_OnInitiated )
302- {
303- oven->mCookTopState = kCookTopState_OnCompleted ;
304- actionCompleted = ON_ACTION;
305- }
298+ oven->mCookTopState = kCookTopState_OffCompleted ;
299+ actionCompleted = OFF_ACTION;
306300 }
307- break ;
308- case AppEvent::kEventType_CookSurface :
301+ else if (oven->mCookTopState == kCookTopState_OnInitiated )
309302 {
310- // Handle CookSurface state transitions
311- chip::EndpointId endpointId = static_cast <chip::EndpointId>(aEvent->OvenEvent .Actor );
312- State_t * currentState = nullptr ;
313-
314- // Get the appropriate state pointer based on endpoint
315- if (endpointId == kCookSurfaceEndpoint1 )
316- {
317- currentState = &oven->mCookSurfaceState1 ;
318- }
319- else if (endpointId == kCookSurfaceEndpoint2 )
320- {
321- currentState = &oven->mCookSurfaceState2 ;
322- }
323- else
324- {
325- ChipLogError (AppServer, " Invalid CookSurface endpoint ID" );
326- return ; // Invalid endpoint
327- }
303+ oven->mCookTopState = kCookTopState_OnCompleted ;
304+ actionCompleted = ON_ACTION;
305+ }
306+ }
307+ break ;
308+ case AppEvent::kEventType_CookSurface : {
309+ // Handle CookSurface state transitions
310+ chip::EndpointId endpointId = static_cast <chip::EndpointId>(aEvent->OvenEvent .Actor );
311+ State_t * currentState = nullptr ;
312+
313+ // Get the appropriate state pointer based on endpoint
314+ if (endpointId == kCookSurfaceEndpoint1 )
315+ {
316+ currentState = &oven->mCookSurfaceState1 ;
317+ }
318+ else if (endpointId == kCookSurfaceEndpoint2 )
319+ {
320+ currentState = &oven->mCookSurfaceState2 ;
321+ }
322+ else
323+ {
324+ ChipLogError (AppServer, " Invalid CookSurface endpoint ID" );
325+ return ; // Invalid endpoint
326+ }
328327
329- if (*currentState == kCookSurfaceState_OffInitiated )
330- {
331- *currentState = kCookSurfaceState_OffCompleted ;
332- actionCompleted = OFF_ACTION;
333- }
334- else if (*currentState == kCookSurfaceState_OnInitiated )
335- {
336- *currentState = kCookSurfaceState_OnCompleted ;
337- actionCompleted = ON_ACTION;
338- }
328+ if (*currentState == kCookSurfaceState_OffInitiated )
329+ {
330+ *currentState = kCookSurfaceState_OffCompleted ;
331+ actionCompleted = OFF_ACTION;
339332 }
340- break ;
333+ else if (*currentState == kCookSurfaceState_OnInitiated )
334+ {
335+ *currentState = kCookSurfaceState_OnCompleted ;
336+ actionCompleted = ON_ACTION;
337+ }
338+ }
339+ break ;
341340 default :
342341 break ;
343342 }
@@ -362,9 +361,12 @@ struct BlockedTransition
362361
363362// Disallowed OvenMode Transitions.
364363static constexpr BlockedTransition kBlockedTransitions [] = {
365- { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeGrill ), to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing ) },
366- { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing ), to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean ) },
367- { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean ), to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeBake ) },
364+ { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeGrill ),
365+ to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing ) },
366+ { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeProofing ),
367+ to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean ) },
368+ { to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeClean ),
369+ to_underlying (TemperatureControlledCabinet::OvenModeDelegate::OvenModes::kModeBake ) },
368370};
369371
370372static bool IsTransitionBlocked (uint8_t fromMode, uint8_t toMode)
0 commit comments