Skip to content

Commit

Permalink
Update zap data type schema (#17645)
Browse files Browse the repository at this point in the history
* Clean up for the new data type schema rework

- Getting rid of StringHelper.js file from the chip repo into the zap repo and modifying the templates.json files accordingly
- Updating the zcl.json files to include the definition of ZCL data types
- Updating the xml files such that we do not have like named data types of the same type with a separate definition.
- Updating the xml files with the removal of cluster code references which are no longer defined
- JIRA: ZAPP-757

* rebasing chip repos master into my masster fork

* Changes for cleaner regen

- Making changes to ClusterHelper.js such that we return the correct enum and bitmap ItemTypes for enums and bitmaps based on size
- In ClusterHelper.js , made changes to the handleString call in enhancedItem because I ran into some unresolved promise issue. Rest of the changes are a result of formatting using restyle-diff script
- Some cleanup in ClusterTestGeneration.js
- Moved StringHelper.js from outside the chip repo into the zap repo. Will need to do this for all the files eventually. This lead to a changes in a couple of files in the requires
- Some changes to structure-member.zapt for displaying the type
- Changes to cluster-enums.zapt, enums.zapt since the enuma dn bitmap tables no longer have type. Just the name.
- Made changes to MatterIDL.zapt based on size
- Made changes o channel-cluster.xml and ha.xml to avoid renaming of enums with different definitions.
- The changes to the .h, cpp, .mm files is a result of the detection of enums, bitmaps correctly for attributes types and command args.
- Updating the pointer to the zap repo
- Changes made from some isString helper calls to if_is_string helper calls in zapt files because they were causing some application regens to pass successfully without generating

- JIRA: ZAPP-757

* Updating the zap repo pointer
JIRA: ZAPP-757

* Regening after rebase
JIRA: ZAPP-757

* Reverting the changes on StringHelper and putting it back in the matter repo.
JIRA: ZAPP-757

* Reverting the template changes for 2 apps and doing a regen
Updating the pointer to zap
JIRA: ZAPP-757

* Reverting the template changes for an app and doing a regen
JIRA: ZAPP-757

* Reverting the changes to the zapt template files
JIRA: ZAPP-757

* Reverting the changes to ClustersHelper.js and structure_member.zapt template
JIRA: ZAPP-757

* Update helper.js

Reverting the restyle diff changes

* Update helper.js

Removing unused require

* Running a restyle diff on ClusterHelper.js

* xml cleanup, Regen and zap repo update

- Updating the cluster codes in types.xml. These were removed for some reason due the those cluster codes not existing for some meta data files. However I am not seeing that now so adding them back.
- Doing a regen with the above change
- Updating the zap repo
- JIRA: ZAPP-757

* Cleaning up ClustersHelper.js
JIRa: ZAPP-757

* running a restyle-diff on the js file
JIRA: ZAPP-757

* cleanup
JIRA: ZAPP-757

* cleanup
JIRA: ZAPP-757

* Reverting the change in zll.xml on a cluster extension code which doesn't exist. This will be done on a spearate PR
JIRa: ZAPP-757

* Regening after rebasing
JIRA: ZAPP-757

* Renaming StatusEnums with cluster name prefix
JIRA: ZAPP-757

* Regening after rebase
JIRA: ZAPP-757

* minor clean up and defining Status in the types.xml because it is not determining the item referring to status type for ReadAttributeStatusRecord struct
JIRA: ZAPP-757

* Rebasing upstream/master and regeing
JIRA: ZAPP-757

* Returning the right c type when the data type is an enum or bitmap in src/app/zap-templates/templates/app/helper.js#zapTypeToClusterObjectType
Regening all the apps with the above change
JIRA: ZAPP-757

* Regen after rebase

* Cleaning up for enum and bitmap size of 3 and 6 because they do not have equivalent c data types
JIRA: ZAPP-757

* minor cleanup

* Cleaning up the decodable_value.zapt templates to remove .Raw() for bitmaps
JIRA: ZAPP-757

* Reverting the previous change
JIRA: ZAPP-757

* Rebasing and regening
JIRa: ZAPP-757

* Updating the zap repo and cleaning up a merge conflict I missed
JIRA: ZAPP-757

* Cleaning up the Accessors by making sure the right ZCL attribute types are referred too. The corresponding change for this was made in the determineType helper in zcl-util.js(zap repo)
JIRA: ZAPP-757

* Reverting the changes to helper.js such that baseline/atomic enums and bitmaps return uint and non-atomic/not-baseline enums and bitmaps return like they used to before
Regening with the changes in helper.js
JIRA: ZAPP-757

* Reverting the change in cluster-objects-struct.zapt which was not needed
Cleaning up the helper.js to return the bitmaps correctly for not-baseline/non-atomic bitmaps
Regening
JIRA: ZAPP-757

* Making changes to helper.js such that baseline/atomic enums and bitmaps return uint and non-atomic/not-baseline enums and bitmaps return like they used to before
Regening with the changes in helper.js
JIRA: ZAPP-757

* Cleaning up atomic enums and bitmaps for generation
JIRA: ZAPP-757

* - Cleaning up the atomic enums and bitmaps in the zapt templates
> - Also taking an exception for vendor_id which is an enum and not a number in the case of cpp implementation
> - Regening the sample apps
> - JIRA: ZAPP-757

* Cleanup the atomic enum generation for python
JIRa: ZAPP-757

* Cleaning up atomic enum generation
JIRA: ZAPP-757

* Cleaning up atomic enum generation
JIRA: ZAPP-757

* updating pigweed to the right commit. Changed by mistake during rebase
JIRa: ZAPP-757

* Regening after rebase
JIRa: ZAPP-757

* Reverting a change which may have happened by some formatting I do not know
JIRa: ZAPP-757

* Cleaning up templates with newer helpers
JIRa: ZAPP-757

* Minor cleanup
JIRA: ZAPP-757

* Cleaning up the templates
JIRA: ZAPP-757

* Moving the matter helpers from zap repo into helper.js for better visibility
Cleaning up regex
updating the zap repo
JIRA: ZAPP-757

* Cleaning up naming and description
JIRa: ZAPP-757

* Regening after rebase
JIRA: ZAPP-757

* Regening after rebase
JIRa: ZAPP-757

* Point efr32_sdk to where the main chip repo points too

* Cleaning up the ChipCallbackBridge generated files so that we do get unnecessary diff
JIRA: ZAPP-757

* Cleaning up the ChipTestCluster and ChipCallback generated files so that we do not get unnecessary diff
JIRA: ZAPP-757

* Cleaning up the Command generated file so that we do not get unnecessary diff
JIRA: ZAPP-757

* Cleaning up the Command generated file so that we do not get unnecessary diff
JIRA: ZAPP-757

* Minor cleanup
JIRa: ZAPP-757

* Regening after rebase
JIRA: ZAPP-757

* Updating the zap repo after rebasing zap
JIRA: ZAPP-757

* Cleanup by removing helpers which are not needed and adding comments as well as semicolons
JIRa: ZAPP-757

* Cleaning up based on the new data type schema
JIRa: ZAPP-757
  • Loading branch information
brdandu authored May 11, 2022
1 parent d2de7c1 commit f59dbe1
Show file tree
Hide file tree
Showing 38 changed files with 1,741 additions and 1,594 deletions.
302 changes: 151 additions & 151 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

Large diffs are not rendered by default.

166 changes: 83 additions & 83 deletions examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// It is for view/code review purposes only.

struct LabelStruct {
CHAR_STRING<16> label = 0;
CHAR_STRING<16> value = 1;
char_string<16> label = 0;
char_string<16> value = 1;
}

client cluster AccessControl = 31 {
Expand All @@ -30,7 +30,7 @@ client cluster AccessControl = 31 {
struct AccessControlEntry {
Privilege privilege = 1;
AuthMode authMode = 2;
nullable INT64U subjects[] = 3;
nullable int64u subjects[] = 3;
nullable Target targets[] = 4;
fabric_idx fabricIndex = 254;
}
Expand All @@ -42,7 +42,7 @@ client cluster AccessControl = 31 {
}

struct ExtensionEntry {
OCTET_STRING<128> data = 1;
octet_string<128> data = 1;
fabric_idx fabricIndex = 254;
}

Expand Down Expand Up @@ -95,7 +95,7 @@ server cluster AccessControl = 31 {
struct AccessControlEntry {
Privilege privilege = 1;
AuthMode authMode = 2;
nullable INT64U subjects[] = 3;
nullable int64u subjects[] = 3;
nullable Target targets[] = 4;
fabric_idx fabricIndex = 254;
}
Expand All @@ -107,7 +107,7 @@ server cluster AccessControl = 31 {
}

struct ExtensionEntry {
OCTET_STRING<128> data = 1;
octet_string<128> data = 1;
fabric_idx fabricIndex = 254;
}

Expand Down Expand Up @@ -216,8 +216,8 @@ server cluster Basic = 40 {

server cluster Descriptor = 29 {
struct DeviceType {
DEVTYPE_ID type = 0;
INT16U revision = 1;
devtype_id type = 0;
int16u revision = 1;
}

readonly attribute DeviceType deviceList[] = 0;
Expand Down Expand Up @@ -305,7 +305,7 @@ server cluster GeneralCommissioning = 48 {
}

struct BasicCommissioningInfo {
INT16U failSafeExpiryLengthSeconds = 0;
int16u failSafeExpiryLengthSeconds = 0;
}

attribute access(write: administer) int64u breadcrumb = 0;
Expand Down Expand Up @@ -398,13 +398,13 @@ server cluster GeneralDiagnostics = 51 {
}

struct NetworkInterfaceType {
CHAR_STRING<32> name = 0;
BOOLEAN isOperational = 1;
nullable BOOLEAN offPremiseServicesReachableIPv4 = 2;
nullable BOOLEAN offPremiseServicesReachableIPv6 = 3;
OCTET_STRING<8> hardwareAddress = 4;
OCTET_STRING IPv4Addresses[] = 5;
OCTET_STRING IPv6Addresses[] = 6;
char_string<32> name = 0;
boolean isOperational = 1;
nullable boolean offPremiseServicesReachableIPv4 = 2;
nullable boolean offPremiseServicesReachableIPv6 = 3;
octet_string<8> hardwareAddress = 4;
octet_string IPv4Addresses[] = 5;
octet_string IPv6Addresses[] = 6;
InterfaceType type = 7;
}

Expand Down Expand Up @@ -571,28 +571,28 @@ server cluster NetworkCommissioning = 49 {
}

struct NetworkInfo {
OCTET_STRING<32> networkID = 0;
BOOLEAN connected = 1;
octet_string<32> networkID = 0;
boolean connected = 1;
}

struct WiFiInterfaceScanResult {
WiFiSecurity security = 0;
OCTET_STRING<32> ssid = 1;
OCTET_STRING<6> bssid = 2;
INT16U channel = 3;
octet_string<32> ssid = 1;
octet_string<6> bssid = 2;
int16u channel = 3;
WiFiBand wiFiBand = 4;
INT8S rssi = 5;
int8s rssi = 5;
}

struct ThreadInterfaceScanResult {
INT16U panId = 0;
INT64U extendedPanId = 1;
CHAR_STRING<16> networkName = 2;
INT16U channel = 3;
INT8U version = 4;
OCTET_STRING<8> extendedAddress = 5;
INT8S rssi = 6;
INT8U lqi = 7;
int16u panId = 0;
int64u extendedPanId = 1;
char_string<16> networkName = 2;
int16u channel = 3;
int8u version = 4;
octet_string<8> extendedAddress = 5;
int8s rssi = 6;
int8u lqi = 7;
}

readonly attribute access(read: administer) int8u maxNetworks = 0;
Expand Down Expand Up @@ -666,17 +666,17 @@ server cluster NetworkCommissioning = 49 {
}

server cluster OnOff = 6 {
enum OnOffDelayedAllOffEffectVariant : enum8 {
enum OnOffDelayedAllOffEffectVariant : ENUM8 {
kFadeToOffIn0p8Seconds = 0;
kNoFade = 1;
k50PercentDimDownIn0p8SecondsThenFadeToOffIn12Seconds = 2;
}

enum OnOffDyingLightEffectVariant : enum8 {
enum OnOffDyingLightEffectVariant : ENUM8 {
k20PercenterDimUpIn0p5SecondsThenFadeToOffIn1Second = 0;
}

enum OnOffEffectIdentifier : enum8 {
enum OnOffEffectIdentifier : ENUM8 {
kDelayedAllOff = 0;
kDyingLight = 1;
}
Expand Down Expand Up @@ -718,17 +718,17 @@ server cluster OperationalCredentials = 62 {
}

struct NOCStruct {
OCTET_STRING noc = 1;
nullable OCTET_STRING icac = 2;
octet_string noc = 1;
nullable octet_string icac = 2;
fabric_idx fabricIndex = 254;
}

struct FabricDescriptor {
OCTET_STRING<65> rootPublicKey = 1;
VENDOR_ID vendorId = 2;
FABRIC_ID fabricId = 3;
NODE_ID nodeId = 4;
CHAR_STRING<32> label = 5;
octet_string<65> rootPublicKey = 1;
vendor_id vendorId = 2;
fabric_id fabricId = 3;
node_id nodeId = 4;
char_string<32> label = 5;
fabric_idx fabricIndex = 254;
}

Expand Down Expand Up @@ -814,11 +814,11 @@ server cluster OperationalCredentials = 62 {

server cluster SoftwareDiagnostics = 52 {
struct ThreadMetrics {
INT64U id = 0;
CHAR_STRING<8> name = 1;
INT32U stackFreeCurrent = 2;
INT32U stackFreeMinimum = 3;
INT32U stackSize = 4;
int64u id = 0;
char_string<8> name = 1;
int32u stackFreeCurrent = 2;
int32u stackFreeMinimum = 3;
int32u stackSize = 4;
}

info event SoftwareFault = 0 {
Expand Down Expand Up @@ -902,53 +902,53 @@ server cluster ThreadNetworkDiagnostics = 53 {
}

struct NeighborTable {
INT64U extAddress = 0;
INT32U age = 1;
INT16U rloc16 = 2;
INT32U linkFrameCounter = 3;
INT32U mleFrameCounter = 4;
INT8U lqi = 5;
INT8S averageRssi = 6;
INT8S lastRssi = 7;
INT8U frameErrorRate = 8;
INT8U messageErrorRate = 9;
BOOLEAN rxOnWhenIdle = 10;
BOOLEAN fullThreadDevice = 11;
BOOLEAN fullNetworkData = 12;
BOOLEAN isChild = 13;
int64u extAddress = 0;
int32u age = 1;
int16u rloc16 = 2;
int32u linkFrameCounter = 3;
int32u mleFrameCounter = 4;
int8u lqi = 5;
int8s averageRssi = 6;
int8s lastRssi = 7;
int8u frameErrorRate = 8;
int8u messageErrorRate = 9;
boolean rxOnWhenIdle = 10;
boolean fullThreadDevice = 11;
boolean fullNetworkData = 12;
boolean isChild = 13;
}

struct RouteTable {
INT64U extAddress = 0;
INT16U rloc16 = 1;
INT8U routerId = 2;
INT8U nextHop = 3;
INT8U pathCost = 4;
INT8U LQIIn = 5;
INT8U LQIOut = 6;
INT8U age = 7;
BOOLEAN allocated = 8;
BOOLEAN linkEstablished = 9;
int64u extAddress = 0;
int16u rloc16 = 1;
int8u routerId = 2;
int8u nextHop = 3;
int8u pathCost = 4;
int8u LQIIn = 5;
int8u LQIOut = 6;
int8u age = 7;
boolean allocated = 8;
boolean linkEstablished = 9;
}

struct SecurityPolicy {
INT16U rotationTime = 0;
BITMAP16 flags = 1;
int16u rotationTime = 0;
bitmap16 flags = 1;
}

struct OperationalDatasetComponents {
BOOLEAN activeTimestampPresent = 0;
BOOLEAN pendingTimestampPresent = 1;
BOOLEAN masterKeyPresent = 2;
BOOLEAN networkNamePresent = 3;
BOOLEAN extendedPanIdPresent = 4;
BOOLEAN meshLocalPrefixPresent = 5;
BOOLEAN delayPresent = 6;
BOOLEAN panIdPresent = 7;
BOOLEAN channelPresent = 8;
BOOLEAN pskcPresent = 9;
BOOLEAN securityPolicyPresent = 10;
BOOLEAN channelMaskPresent = 11;
boolean activeTimestampPresent = 0;
boolean pendingTimestampPresent = 1;
boolean masterKeyPresent = 2;
boolean networkNamePresent = 3;
boolean extendedPanIdPresent = 4;
boolean meshLocalPrefixPresent = 5;
boolean delayPresent = 6;
boolean panIdPresent = 7;
boolean channelPresent = 8;
boolean pskcPresent = 9;
boolean securityPolicyPresent = 10;
boolean channelMaskPresent = 11;
}

info event ConnectionStatus = 0 {
Expand Down
16 changes: 8 additions & 8 deletions examples/chip-tool/templates/tests/partials/command_value.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,33 @@
{{definedValue}};
{{else if (chip_tests_config_has definedValue)}}
m{{asUpperCamelCase definedValue}}.HasValue() ? m{{asUpperCamelCase definedValue}}.Value() :
{{~#if_chip_enum type~}}
{{~#if_is_strongly_typed_chip_enum type~}}
static_cast<{{zapTypeToEncodableClusterObjectType type ns=ns}}>({{chip_tests_config_get_default_value definedValue}});
{{else if (isCharString type)}}
chip::Span<const char>("{{chip_tests_config_get_default_value definedValue}}", {{utf8StringLength (chip_tests_config_get_default_value definedValue)}});
{{else if (isOctetString type)}}
{{!-- TODO Extract the length of the default value for ByteSpan--}}
{{else}}
{{#if_is_bitmap type}}
{{#if_is_strongly_typed_bitmap type}}
static_cast<{{zapTypeToEncodableClusterObjectType type ns=ns}}>({{asTypedLiteral (chip_tests_config_get_default_value definedValue) type}});
{{else}}
{{asTypedExpression (chip_tests_config_get_default_value definedValue) type}};
{{/if_is_bitmap}}
{{/if_chip_enum~}}
{{/if_is_strongly_typed_bitmap}}
{{/if_is_strongly_typed_chip_enum~}}
{{else~}}
{{~#if_chip_enum type~}}
{{~#if_is_strongly_typed_chip_enum type~}}
static_cast<{{zapTypeToEncodableClusterObjectType type ns=ns}}>({{definedValue}});
{{else if (isCharString type)}}
chip::Span<const char>("{{definedValue}}garbage: not in length on purpose", {{utf8StringLength definedValue}});
{{else if (isOctetString type)}}
chip::ByteSpan(chip::Uint8::from_const_char("{{octetStringEscapedForCLiteral definedValue}}garbage: not in length on purpose"), {{definedValue.length}});
{{else}}
{{#if_is_bitmap type}}
{{#if_is_strongly_typed_bitmap type}}
static_cast<{{zapTypeToEncodableClusterObjectType type ns=ns}}>({{asTypedLiteral definedValue type}});
{{else}}
{{asTypedExpression definedValue type}};
{{/if_is_bitmap}}
{{/if_chip_enum~}}
{{/if_is_strongly_typed_bitmap}}
{{/if_is_strongly_typed_chip_enum~}}
{{~/if~}}

{{/if_is_struct}}
Expand Down
Loading

0 comments on commit f59dbe1

Please sign in to comment.