16
16
* limitations under the License.
17
17
*/
18
18
#include < app-common/zap-generated/attributes/Accessors.h>
19
+ #include < lib/support/TypeTraits.h>
19
20
#include < rvc-modes.h>
20
21
#include < rvc-operational-state-delegate-impl.h>
21
22
@@ -41,12 +42,15 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands:
41
42
{
42
43
uint8_t currentMode = mInstance ->GetCurrentMode ();
43
44
44
- // Our business logic states that we can only switch into a running mode from the idle state.
45
- if (NewMode != RvcRunMode::ModeIdle && currentMode != RvcRunMode::ModeIdle)
45
+ if (!gRvcRunModeInstance ->HasFeature (static_cast <ModeBase::Feature>(RvcRunMode::Feature::kDirectModeChange )))
46
46
{
47
- response.status = to_underlying (ModeBase::StatusCode::kInvalidInMode );
48
- response.statusText .SetValue (chip::CharSpan::fromCharString (" Change to a running mode is only allowed from idle" ));
49
- return ;
47
+ // Our business logic states that we can only switch into a running mode from the idle state.
48
+ if (NewMode != RvcRunMode::ModeIdle && currentMode != RvcRunMode::ModeIdle)
49
+ {
50
+ response.status = to_underlying (ModeBase::StatusCode::kInvalidInMode );
51
+ response.statusText .SetValue (chip::CharSpan::fromCharString (" Change to a running mode is only allowed from idle" ));
52
+ return ;
53
+ }
50
54
}
51
55
52
56
auto rvcOpStateInstance = RvcOperationalState::GetRvcOperationalStateInstance ();
@@ -123,8 +127,8 @@ void emberAfRvcRunModeClusterInitCallback(chip::EndpointId endpointId)
123
127
VerifyOrDie (endpointId == 1 ); // this cluster is only enabled for endpoint 1.
124
128
VerifyOrDie (gRvcRunModeDelegate == nullptr && gRvcRunModeInstance == nullptr );
125
129
gRvcRunModeDelegate = new RvcRunMode::RvcRunModeDelegate;
126
- gRvcRunModeInstance =
127
- new ModeBase::Instance ( gRvcRunModeDelegate , 0x1 , RvcRunMode::Id, chip::to_underlying (RvcRunMode::Feature::kNoFeatures ));
130
+ gRvcRunModeInstance = new ModeBase::Instance ( gRvcRunModeDelegate , 0x1 , RvcRunMode::Id,
131
+ chip::to_underlying (RvcRunMode::Feature::kDirectModeChange ));
128
132
gRvcRunModeInstance ->Init ();
129
133
}
130
134
@@ -139,14 +143,17 @@ CHIP_ERROR RvcCleanModeDelegate::Init()
139
143
140
144
void RvcCleanModeDelegate::HandleChangeToMode (uint8_t NewMode, ModeBase::Commands::ChangeToModeResponse::Type & response)
141
145
{
142
- uint8_t rvcRunCurrentMode = gRvcRunModeInstance ->GetCurrentMode ();
143
-
144
- if (rvcRunCurrentMode != RvcRunMode::ModeIdle)
146
+ if (!gRvcCleanModeInstance ->HasFeature (static_cast <ModeBase::Feature>(RvcCleanMode::Feature::kDirectModeChange )))
145
147
{
146
- response.status = to_underlying (ModeBase::StatusCode::kInvalidInMode );
147
- response.statusText .SetValue (
148
- chip::CharSpan::fromCharString (" Cannot change the cleaning mode when the device is not in idle" ));
149
- return ;
148
+ uint8_t rvcRunCurrentMode = gRvcRunModeInstance ->GetCurrentMode ();
149
+
150
+ if (rvcRunCurrentMode != RvcRunMode::ModeIdle)
151
+ {
152
+ response.status = to_underlying (ModeBase::StatusCode::kInvalidInMode );
153
+ response.statusText .SetValue (
154
+ chip::CharSpan::fromCharString (" Cannot change the cleaning mode when the device is not in idle" ));
155
+ return ;
156
+ }
150
157
}
151
158
152
159
response.status = to_underlying (ModeBase::StatusCode::kSuccess );
@@ -213,7 +220,7 @@ void emberAfRvcCleanModeClusterInitCallback(chip::EndpointId endpointId)
213
220
VerifyOrDie (endpointId == 1 ); // this cluster is only enabled for endpoint 1.
214
221
VerifyOrDie (gRvcCleanModeDelegate == nullptr && gRvcCleanModeInstance == nullptr );
215
222
gRvcCleanModeDelegate = new RvcCleanMode::RvcCleanModeDelegate;
216
- gRvcCleanModeInstance =
217
- new ModeBase::Instance ( gRvcCleanModeDelegate , 0x1 , RvcCleanMode::Id, chip::to_underlying (RvcRunMode ::Feature::kNoFeatures ));
223
+ gRvcCleanModeInstance = new ModeBase::Instance ( gRvcCleanModeDelegate , 0x1 , RvcCleanMode::Id,
224
+ chip::to_underlying (RvcCleanMode ::Feature::kDirectModeChange ));
218
225
gRvcCleanModeInstance ->Init ();
219
226
}
0 commit comments