@@ -29,6 +29,11 @@ using ModeTagStructType = chip::app::Clusters::detail::Structs::ModeTagStruct::T
29
29
30
30
#ifdef MATTER_DM_PLUGIN_RVC_RUN_MODE_SERVER
31
31
#include < chef-rvc-mode-delegate.h>
32
+
33
+ #ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER
34
+ #include < chef-rvc-operational-state-delegate.h>
35
+ #endif // MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER
36
+
32
37
using namespace chip ::app::Clusters::RvcRunMode;
33
38
34
39
static std::unique_ptr<RvcRunModeDelegate> gRvcRunModeDelegate ;
@@ -51,7 +56,35 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands:
51
56
return ;
52
57
}
53
58
59
+ #ifdef MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER
60
+ OperationalState::GenericOperationalError err (to_underlying (OperationalState::ErrorStateEnum::kNoError ));
61
+ if (NewMode == RvcRunMode::ModeIdle)
62
+ {
63
+ if (currentMode != RvcRunMode::ModeIdle)
64
+ { // Stop existing cycle when going from cleaning/mapping to idle.
65
+ ChipLogProgress (DeviceLayer, " Stopping RVC cycle: %d" , currentMode);
66
+ gRvcOperationalStateDelegate ->HandleStopStateCallback (err);
67
+ }
68
+ }
69
+ else
70
+ {
71
+ if (currentMode == RvcRunMode::ModeIdle)
72
+ { // Start a new cycle when going from idle to clening/mapping.
73
+ ChipLogProgress (DeviceLayer, " Starting new RVC cycle: %d" , NewMode);
74
+ gRvcOperationalStateDelegate ->HandleStartStateCallback (err);
75
+ }
76
+ }
77
+ if (err.IsEqual (OperationalState::GenericOperationalError (to_underlying (OperationalState::ErrorStateEnum::kNoError ))))
78
+ {
79
+ response.status = to_underlying (ModeBase::StatusCode::kSuccess );
80
+ }
81
+ else
82
+ {
83
+ response.status = to_underlying (ModeBase::StatusCode::kGenericFailure );
84
+ }
85
+ #else
54
86
response.status = to_underlying (ModeBase::StatusCode::kSuccess );
87
+ #endif // MATTER_DM_PLUGIN_RVC_OPERATIONAL_STATE_SERVER
55
88
}
56
89
57
90
CHIP_ERROR RvcRunModeDelegate::GetModeLabelByIndex (uint8_t modeIndex, chip::MutableCharSpan & label)
@@ -296,3 +329,4 @@ void emberAfRvcCleanModeClusterInitCallback(chip::EndpointId endpointId)
296
329
gRvcCleanModeInstance ->Init ();
297
330
}
298
331
#endif // MATTER_DM_PLUGIN_RVC_CLEAN_MODE_SERVER
332
+
0 commit comments