Skip to content

Commit

Permalink
Add DirectModeChange feature to RVC Run Mode and RVC Clean Mode clust…
Browse files Browse the repository at this point in the history
…er XML and all-clusters-app implementation (#35258)

* Add DirectModeChange feature to RVC Run Mode and RVC Clean Mode cluster XML.

* Run update_cluster_revisions.py to update to the new RVC Run Mode cluster revision.

* Run update_cluster_revisions.py to update to the new RVC Clean Mode cluster revision.

* Regenerate generated code.
  • Loading branch information
bzbarsky-apple authored Aug 29, 2024
1 parent 9bbf5b9 commit 6c6b11f
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3235,7 +3235,7 @@ cluster LaundryWasherControls = 83 {

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster RvcRunMode = 84 {
revision 2;
revision 3;

enum ModeTag : enum16 {
kIdle = 16384;
Expand All @@ -3255,7 +3255,7 @@ cluster RvcRunMode = 84 {
}

bitmap Feature : bitmap32 {
kNoFeatures = 0x0;
kDirectModeChange = 0x10000;
}

struct ModeTagStruct {
Expand Down Expand Up @@ -3294,7 +3294,7 @@ cluster RvcRunMode = 84 {

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster RvcCleanMode = 85 {
revision 2;
revision 3;

enum ModeTag : enum16 {
kDeepClean = 16384;
Expand All @@ -3307,7 +3307,7 @@ cluster RvcCleanMode = 85 {
}

bitmap Feature : bitmap32 {
kNoFeatures = 0x0;
kDirectModeChange = 0x10000;
}

struct ModeTagStruct {
Expand Down Expand Up @@ -8489,7 +8489,7 @@ endpoint 1 {
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 3;

handle command ChangeToMode;
handle command ChangeToModeResponse;
Expand All @@ -8503,7 +8503,7 @@ endpoint 1 {
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 3;

handle command ChangeToMode;
handle command ChangeToModeResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9648,7 +9648,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -9804,7 +9804,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
39 changes: 23 additions & 16 deletions examples/all-clusters-app/all-clusters-common/src/rvc-modes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* limitations under the License.
*/
#include <app-common/zap-generated/attributes/Accessors.h>
#include <lib/support/TypeTraits.h>
#include <rvc-modes.h>
#include <rvc-operational-state-delegate-impl.h>

Expand All @@ -41,12 +42,15 @@ void RvcRunModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands:
{
uint8_t currentMode = mInstance->GetCurrentMode();

// Our business logic states that we can only switch into a running mode from the idle state.
if (NewMode != RvcRunMode::ModeIdle && currentMode != RvcRunMode::ModeIdle)
if (!gRvcRunModeInstance->HasFeature(static_cast<ModeBase::Feature>(RvcRunMode::Feature::kDirectModeChange)))
{
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(chip::CharSpan::fromCharString("Change to a running mode is only allowed from idle"));
return;
// Our business logic states that we can only switch into a running mode from the idle state.
if (NewMode != RvcRunMode::ModeIdle && currentMode != RvcRunMode::ModeIdle)
{
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(chip::CharSpan::fromCharString("Change to a running mode is only allowed from idle"));
return;
}
}

auto rvcOpStateInstance = RvcOperationalState::GetRvcOperationalStateInstance();
Expand Down Expand Up @@ -123,8 +127,8 @@ void emberAfRvcRunModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
VerifyOrDie(gRvcRunModeDelegate == nullptr && gRvcRunModeInstance == nullptr);
gRvcRunModeDelegate = new RvcRunMode::RvcRunModeDelegate;
gRvcRunModeInstance =
new ModeBase::Instance(gRvcRunModeDelegate, 0x1, RvcRunMode::Id, chip::to_underlying(RvcRunMode::Feature::kNoFeatures));
gRvcRunModeInstance = new ModeBase::Instance(gRvcRunModeDelegate, 0x1, RvcRunMode::Id,
chip::to_underlying(RvcRunMode::Feature::kDirectModeChange));
gRvcRunModeInstance->Init();
}

Expand All @@ -139,14 +143,17 @@ CHIP_ERROR RvcCleanModeDelegate::Init()

void RvcCleanModeDelegate::HandleChangeToMode(uint8_t NewMode, ModeBase::Commands::ChangeToModeResponse::Type & response)
{
uint8_t rvcRunCurrentMode = gRvcRunModeInstance->GetCurrentMode();

if (rvcRunCurrentMode != RvcRunMode::ModeIdle)
if (!gRvcCleanModeInstance->HasFeature(static_cast<ModeBase::Feature>(RvcCleanMode::Feature::kDirectModeChange)))
{
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(
chip::CharSpan::fromCharString("Cannot change the cleaning mode when the device is not in idle"));
return;
uint8_t rvcRunCurrentMode = gRvcRunModeInstance->GetCurrentMode();

if (rvcRunCurrentMode != RvcRunMode::ModeIdle)
{
response.status = to_underlying(ModeBase::StatusCode::kInvalidInMode);
response.statusText.SetValue(
chip::CharSpan::fromCharString("Cannot change the cleaning mode when the device is not in idle"));
return;
}
}

response.status = to_underlying(ModeBase::StatusCode::kSuccess);
Expand Down Expand Up @@ -213,7 +220,7 @@ void emberAfRvcCleanModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
VerifyOrDie(gRvcCleanModeDelegate == nullptr && gRvcCleanModeInstance == nullptr);
gRvcCleanModeDelegate = new RvcCleanMode::RvcCleanModeDelegate;
gRvcCleanModeInstance =
new ModeBase::Instance(gRvcCleanModeDelegate, 0x1, RvcCleanMode::Id, chip::to_underlying(RvcRunMode::Feature::kNoFeatures));
gRvcCleanModeInstance = new ModeBase::Instance(gRvcCleanModeDelegate, 0x1, RvcCleanMode::Id,
chip::to_underlying(RvcCleanMode::Feature::kDirectModeChange));
gRvcCleanModeInstance->Init();
}
8 changes: 4 additions & 4 deletions examples/chef/common/chef-rvc-mode-delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ void emberAfRvcRunModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(!gRvcRunModeDelegate && !gRvcRunModeInstance);

gRvcRunModeDelegate = std::make_unique<RvcRunModeDelegate>();
gRvcRunModeInstance = std::make_unique<ModeBase::Instance>(gRvcRunModeDelegate.get(), endpointId, RvcRunMode::Id,
chip::to_underlying(RvcRunMode::Feature::kNoFeatures));
gRvcRunModeInstance =
std::make_unique<ModeBase::Instance>(gRvcRunModeDelegate.get(), endpointId, RvcRunMode::Id, 0 /* No feature bits */);
gRvcRunModeInstance->Init();
}

Expand Down Expand Up @@ -290,8 +290,8 @@ void emberAfRvcCleanModeClusterInitCallback(chip::EndpointId endpointId)
VerifyOrDie(!gRvcCleanModeDelegate && !gRvcCleanModeInstance);

gRvcCleanModeDelegate = std::make_unique<RvcCleanModeDelegate>();
gRvcCleanModeInstance = std::make_unique<ModeBase::Instance>(gRvcCleanModeDelegate.get(), endpointId, RvcCleanMode::Id,
chip::to_underlying(RvcCleanMode::Feature::kNoFeatures));
gRvcCleanModeInstance =
std::make_unique<ModeBase::Instance>(gRvcCleanModeDelegate.get(), endpointId, RvcCleanMode::Id, 0 /* No feature bits */);
gRvcCleanModeInstance->Init();
}
#endif // MATTER_DM_PLUGIN_RVC_CLEAN_MODE_SERVER
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
}
],
"package": [
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"category": "matter",
"version": "chip-v1"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/zcl/zcl.json",
"type": "zcl-properties",
"category": "matter",
"version": 1,
"description": "Matter SDK ZCL data"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"category": "matter",
"version": "chip-v1"
}
],
"endpointTypes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ cluster GroupKeyManagement = 63 {

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster RvcRunMode = 84 {
revision 2;
revision 3;

enum ModeTag : enum16 {
kIdle = 16384;
Expand All @@ -1604,7 +1604,7 @@ cluster RvcRunMode = 84 {
}

bitmap Feature : bitmap32 {
kNoFeatures = 0x0;
kDirectModeChange = 0x10000;
}

struct ModeTagStruct {
Expand Down Expand Up @@ -1643,7 +1643,7 @@ cluster RvcRunMode = 84 {

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster RvcCleanMode = 85 {
revision 2;
revision 3;

enum ModeTag : enum16 {
kDeepClean = 16384;
Expand All @@ -1656,7 +1656,7 @@ cluster RvcCleanMode = 85 {
}

bitmap Feature : bitmap32 {
kNoFeatures = 0x0;
kDirectModeChange = 0x10000;
}

struct ModeTagStruct {
Expand Down Expand Up @@ -2010,7 +2010,7 @@ endpoint 1 {
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 3;

handle command ChangeToMode;
handle command ChangeToModeResponse;
Expand All @@ -2024,7 +2024,7 @@ endpoint 1 {
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 3;

handle command ChangeToMode;
handle command ChangeToModeResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2852,7 +2852,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -3008,7 +3008,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
12 changes: 6 additions & 6 deletions examples/rvc-app/rvc-common/rvc-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ cluster GroupKeyManagement = 63 {

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster RvcRunMode = 84 {
revision 2;
revision 3;

enum ModeTag : enum16 {
kIdle = 16384;
Expand All @@ -1268,7 +1268,7 @@ cluster RvcRunMode = 84 {
}

bitmap Feature : bitmap32 {
kNoFeatures = 0x0;
kDirectModeChange = 0x10000;
}

struct ModeTagStruct {
Expand Down Expand Up @@ -1307,7 +1307,7 @@ cluster RvcRunMode = 84 {

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster RvcCleanMode = 85 {
revision 2;
revision 3;

enum ModeTag : enum16 {
kDeepClean = 16384;
Expand All @@ -1320,7 +1320,7 @@ cluster RvcCleanMode = 85 {
}

bitmap Feature : bitmap32 {
kNoFeatures = 0x0;
kDirectModeChange = 0x10000;
}

struct ModeTagStruct {
Expand Down Expand Up @@ -1735,7 +1735,7 @@ endpoint 1 {
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 3;

handle command ChangeToMode;
handle command ChangeToModeResponse;
Expand All @@ -1749,7 +1749,7 @@ endpoint 1 {
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 3;

handle command ChangeToMode;
handle command ChangeToModeResponse;
Expand Down
4 changes: 2 additions & 2 deletions examples/rvc-app/rvc-common/rvc-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -2634,7 +2634,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
4 changes: 2 additions & 2 deletions scripts/tools/zap/tests/inputs/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -9648,7 +9648,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -9804,7 +9804,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,13 +977,13 @@
{ ZAP_EMPTY_DEFAULT(), 0x00000000, 0, ZAP_TYPE(ARRAY), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* SupportedModes */ \
{ ZAP_EMPTY_DEFAULT(), 0x00000001, 1, ZAP_TYPE(INT8U), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* CurrentMode */ \
{ ZAP_EMPTY_DEFAULT(), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* FeatureMap */ \
{ ZAP_SIMPLE_DEFAULT(2), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \
{ ZAP_SIMPLE_DEFAULT(3), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \
\
/* Endpoint: 1, Cluster: RVC Clean Mode (server) */ \
{ ZAP_EMPTY_DEFAULT(), 0x00000000, 0, ZAP_TYPE(ARRAY), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* SupportedModes */ \
{ ZAP_EMPTY_DEFAULT(), 0x00000001, 1, ZAP_TYPE(INT8U), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* CurrentMode */ \
{ ZAP_EMPTY_DEFAULT(), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* FeatureMap */ \
{ ZAP_SIMPLE_DEFAULT(2), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \
{ ZAP_SIMPLE_DEFAULT(3), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \
\
/* Endpoint: 1, Cluster: Temperature Control (server) */ \
{ ZAP_SIMPLE_DEFAULT(0), 0x00000004, 1, ZAP_TYPE(INT8U), 0 }, /* SelectedTemperatureLevel */ \
Expand Down
Loading

0 comments on commit 6c6b11f

Please sign in to comment.