Skip to content

Commit

Permalink
Mode base sdk implementation (#27504)
Browse files Browse the repository at this point in the history
* Added first draft of the ModeBase SDK implementation.

* Fixed build files and mode base source files from mode select references.

* Fixed final errors.

* Removed global accessor functions in place instance attributes.

* Renamed internal members to mX. Replaced the use the zap Feature map with and internally managed variable.

* Added Command Types and DecodableTypes to the SDK implementation to bypass the limitations of the the current zap generation.

* Added ModeBase attributes to the list of attributeAccessInterfaceAttributes to ensure that not RAM memory is allocated for these attibutes.

* Merged the mode base delegate into the mode base instance due to attribute accessability following management of attributes by the mode base instance.

* Added documentation and readme for the ModeBase alias.

* Added the dishwasher mode cluster to the all-clusters-app example.

* Added the laundry washer mode cluster to the all-clusters-app example.

* Added the refrigerator and temperature controlled cabinet mode cluster to the all-clusters-app example.

* Renamed the mode base alias all-clusters-app examples to the correct naming.

* Implemented interaction between the ModeBase and OnOff servers. Added ModeBase attribute type infos. Updated documentation.

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* Fixed copy paste issues in the mode base cluster objects.

* Moved the ModeBaseAliasesInstanceMap into the ModeBase namespace and added a getter for it.

* Moved OnOff server common behavior in a top-level anonymous namespace method.

* Apply suggestions from code review

Accepted readme suggestions.

Co-authored-by: Tennessee Carmel-Veilleux <[email protected]>

* Renamed the readme

* Added doc to ModeBase instance init. Removed the use of using in made-base-server.h

* Added validity checking when updating attributes.

* Made ModeBase functions that are required to be implemented by the user pure virtural.

* Renamed constants according to the convention.

* Made persistant attributes persistant. Experimented with helper accessor functions for persistent attributes.

* Fixed code after merge

* Regenerats all-clusters-app.matter after merge

* Restyled by clang-format

* Restyled by prettier-markdown

* Simplified IsSupportedMode to make it more readable.

* Removed the use of using from header files.

* Removed the use of using from mode-base-server.h.

* Enabled UpdateModeBaseCurrentModeToOnMode only when the ModeBase plugin is enabled.

* Restyled by clang-format

* In the OnOff server, include mode-base only when the ModeBase plugin is enabled.

* Fixed AliasedCluster's type

* Changed to calling of Update sttribute functions when loading persistent attributes on init.

* Moved the ChangeToModeResponse command from the accepted commands to the generated commands list.

* Renamed isAliasedCluster to isDerivedCluster.

* Refactored the supported modes encoding to make the Read switch statement more readable.

* Fixed typos in the ModeBase readme.

Co-authored-by: Boris Zbarsky <[email protected]>

* Simplified the encoding function and some comments.

* Fixed var naming and GetModeLabelByIndex return.

* Fixed incorrect version number in some ModeBase derived clusters.

* Made mode base derived cluster code more readble with using

* Removed unneccissary namespace paths.

* Removed unneccissary size checking.

* Refactored GetModeTagsByIndex to make it more readable.

* Added new StatusCode.

* Used chip::CharSpan::fromCharString to avoid setting the length.

* Added missing function nampspace.

* Made the mode-base-cluster-objects.h more readable by removing unneccessery namespace specifications.

* Made the mode-base-cluster-objects.h more readable by simplifying the DecodableArgType definition.

* Removed redundant processing in the Read function.

* Added cluster constants to make the code more readabel.

* Changed attribute write errors.

* Added attribute getters and setters documentaton.

* Added FeatureMap to the list of attributeAccessInterfaceAttributes.

* Used std::set instead of std::map to hold the ModeBase Instances.

* Removed the BuildModeOptionStruct helper function to avoid giving incorroct expectations to the SDK consumers.

* Changed the Delegate's API to remove the need for the GetNumberOfModes method.

* Changed checks for essetion setup in the ModeBase init to VerifyOrDie.

* Moved the setting of the CurrentMode based on the StartUpMode, OnMode and OnOff cluster values to the ModeBase init function. Added some TODOs from the reviews.

* Added documentation about the required lifetime of the ModeBase Instance object.

* Refoctored ModeBase to separate out the Delegate functionality into a separate class.

* Added generated code after merge

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* Added ModeBase to the spellcheck. Allowed the use of set in mode-base-server.h

* Removed the ModeBase constraint that the cluster ID given should be of an actual ModeBase derived cluster.

* Changed the ModeBase derived cluster's instatiation in the all-clusters-app to make it easier to include for all platforms.

* Defined EMBER_AF_PLUGIN_MODE_BASE for the linux all-clustres-app to enable OfOff cluster related code.

* Restyled by whitespace

* Restyled by clang-format

* Restyled by prettier-markdown

* Fixed the lock app gni argument chip_project_config_include_dirs as it was pointing to the all-clusters-app's include dir.

* Fixed ModeBase derived clusters version numbers in zap.

* Apply suggestions from code review

Co-authored-by: Boris Zbarsky <[email protected]>

* Updated the Mode Base readme afther review.

* Removed ModeBase from the .github/.wordlist.txt

Co-authored-by: Boris Zbarsky <[email protected]>

* Unregister the AttributeAccessOverride when deconstructing a Mode Base instance.

* Added // nogncheck to the Mode Base includes in the OnOff server code.

* Updated Mode Base function documentatio.

* Added read case for the Feature Map.

* Restyled by clang-format

* Restyled by prettier-markdown

* used the feature map's enum instead of a literal number in the Mode Bease examples.

* Restyled by clang-format

* Fixed return bug in the Mode Base RVC examples.

* Update .github/workflows/build.yaml

Co-authored-by: Boris Zbarsky <[email protected]>

* Fixed attribute get issue in the Mode Base RVC example.

Co-authored-by: Petru Lauric <[email protected]>

* Checkedout out-of-sync third-party repos to match what is on master.

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Tennessee Carmel-Veilleux <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
Co-authored-by: Petru Lauric <[email protected]>
  • Loading branch information
5 people authored and pull[bot] committed Sep 28, 2023
1 parent 2d1acdf commit 1156035
Show file tree
Hide file tree
Showing 36 changed files with 3,774 additions and 864 deletions.
309 changes: 309 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2489,6 +2489,204 @@ server cluster ModeSelect = 80 {
command ChangeToMode(ChangeToModeRequest): DefaultSuccess = 0;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
server cluster LaundryWasherMode = 81 {
enum ModeTag : ENUM16 {
kNormal = 16384;
kDelicate = 16385;
kHeavy = 16386;
kWhites = 16387;
}

bitmap Feature : BITMAP32 {
kOnOff = 0x1;
}

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

readonly attribute ModeOptionStruct supportedModes[] = 0;
readonly attribute int8u currentMode = 1;
attribute nullable int8u startUpMode = 2;
attribute nullable int8u onMode = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct ChangeToModeRequest {
INT8U newMode = 0;
}

response struct ChangeToModeResponse = 1 {
ENUM8 status = 0;
optional CHAR_STRING statusText = 1;
}

command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
server cluster RefrigeratorAndTemperatureControlledCabinetMode = 82 {
enum ModeTag : ENUM16 {
kRapidCool = 16384;
kRapidFreeze = 16385;
}

bitmap Feature : BITMAP32 {
kOnOff = 0x1;
}

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

readonly attribute ModeOptionStruct supportedModes[] = 0;
readonly attribute int8u currentMode = 1;
attribute nullable int8u startUpMode = 2;
attribute nullable int8u onMode = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct ChangeToModeRequest {
INT8U newMode = 0;
}

response struct ChangeToModeResponse = 1 {
ENUM8 status = 0;
optional CHAR_STRING statusText = 1;
}

command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
server cluster RvcRunMode = 84 {
enum ModeTag : ENUM16 {
kIdle = 16384;
kCleaning = 16385;
}

enum StatusCode : ENUM8 {
kStuck = 65;
kDustBinMissing = 66;
kDustBinFull = 67;
kWaterTankEmpty = 68;
kWaterTankMissing = 69;
kWaterTankLidOpen = 70;
kMopCleaningPadMissing = 71;
kBatteryLow = 72;
}

bitmap Feature : BITMAP32 {
kOnOff = 0x1;
}

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

readonly attribute ModeOptionStruct supportedModes[] = 0;
readonly attribute int8u currentMode = 1;
attribute nullable int8u startUpMode = 2;
attribute nullable int8u onMode = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct ChangeToModeRequest {
INT8U newMode = 0;
}

response struct ChangeToModeResponse = 1 {
ENUM8 status = 0;
optional CHAR_STRING statusText = 1;
}

command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
server cluster RvcCleanMode = 85 {
enum ModeTag : ENUM16 {
kDeepClean = 16384;
kVacuum = 16385;
kMop = 16386;
}

enum StatusCode : ENUM8 {
kCleaningInProgress = 64;
}

bitmap Feature : BITMAP32 {
kOnOff = 0x1;
}

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

readonly attribute ModeOptionStruct supportedModes[] = 0;
readonly attribute int8u currentMode = 1;
attribute nullable int8u startUpMode = 2;
attribute nullable int8u onMode = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct ChangeToModeRequest {
INT8U newMode = 0;
}

response struct ChangeToModeResponse = 1 {
ENUM8 status = 0;
optional CHAR_STRING statusText = 1;
}

command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
}

/** Attributes and commands for configuring the temperature control, and reporting temperature. */
server cluster TemperatureControl = 86 {
bitmap Feature : BITMAP32 {
Expand Down Expand Up @@ -2538,6 +2736,52 @@ server cluster RefrigeratorAlarm = 87 {
readonly attribute int16u clusterRevision = 65533;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
server cluster DishwasherMode = 89 {
enum ModeTag : ENUM16 {
kNormal = 16384;
kHeavy = 16385;
kLight = 16386;
}

bitmap Feature : BITMAP32 {
kOnOff = 0x1;
}

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

readonly attribute ModeOptionStruct supportedModes[] = 0;
readonly attribute int8u currentMode = 1;
attribute nullable int8u startUpMode = 2;
attribute nullable int8u onMode = 3;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

request struct ChangeToModeRequest {
INT8U newMode = 0;
}

response struct ChangeToModeResponse = 1 {
ENUM8 status = 0;
optional CHAR_STRING statusText = 1;
}

command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
}

/** Attributes for reporting air quality classification */
server cluster AirQuality = 91 {
enum AirQualityEnum : ENUM8 {
Expand Down Expand Up @@ -6243,6 +6487,58 @@ endpoint 1 {
ram attribute manufacturerExtension default = 255;
}

server cluster LaundryWasherMode {
callback attribute supportedModes;
callback attribute currentMode;
callback attribute startUpMode;
callback attribute onMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
}

server cluster RefrigeratorAndTemperatureControlledCabinetMode {
callback attribute supportedModes;
callback attribute currentMode;
callback attribute startUpMode;
callback attribute onMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
}

server cluster RvcRunMode {
callback attribute supportedModes;
callback attribute currentMode;
callback attribute startUpMode;
callback attribute onMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
}

server cluster RvcCleanMode {
callback attribute supportedModes;
callback attribute currentMode;
callback attribute startUpMode;
callback attribute onMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
}

server cluster TemperatureControl {
ram attribute selectedTemperatureLevel default = 0;
callback attribute supportedTemperatureLevels;
Expand All @@ -6267,6 +6563,19 @@ endpoint 1 {
ram attribute clusterRevision default = 1;
}

server cluster DishwasherMode {
callback attribute supportedModes;
callback attribute currentMode;
callback attribute startUpMode;
callback attribute onMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
}

server cluster AirQuality {
ram attribute airQuality default = 0;
callback attribute generatedCommandList;
Expand Down
Loading

0 comments on commit 1156035

Please sign in to comment.