Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MatterIDL codegen to not take into account enabled for client attributes #25737

Closed
wants to merge 10 commits into from

Conversation

andy31415
Copy link
Contributor

@andy31415 andy31415 commented Mar 17, 2023

We expect to generate accessors for all client side attributes, so for client side this switches
code generation loops to use zcl_attributes_server.

This also switches to workardouns for other settings because of different helper modes:

  • clusterRef for isGlobalAttributes
  • entryType for isArray
  • completely DROPS isReportable (since everything is reportable currently ...only added a TODO)

As a result, .matter files are now expected to have all attributes in client clusters, regardless of zap enabling/disabling on them.

After project-chip/zap#899 usage, we may be able to simplify these back...

Fixes #25684

@github-actions
Copy link

PR #25737: Size comparison from bbb8e93 to 568fd26

Full report (1 build for cc32xx)
platform target config section bbb8e93 568fd26 change % change
cc32xx lock CC3235SF_LAUNCHXL 0 0 0 0.0
(read only) 645489 645489 0 0.0
(read/write) 203848 203848 0 0.0
.ARM.attributes 44 44 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 197248 197248 0 0.0
.comment 194 194 0 0.0
.data 1480 1480 0 0.0
.debug_abbrev 930289 930289 0 0.0
.debug_aranges 87392 87392 0 0.0
.debug_frame 300284 300284 0 0.0
.debug_info 20246022 20246022 0 0.0
.debug_line 2661031 2661031 0 0.0
.debug_loc 2804874 2804874 0 0.0
.debug_ranges 283152 283152 0 0.0
.debug_str 3027037 3027037 0 0.0
.ramVecs 780 780 0 0.0
.resetVecs 64 64 0 0.0
.rodata 105993 105993 0 0.0
.shstrtab 232 232 0 0.0
.stab 204 204 0 0.0
.stabstr 441 441 0 0.0
.stack 2048 2048 0 0.0
.strtab 380331 380331 0 0.0
.symtab 257376 257376 0 0.0
.text 537376 537376 0 0.0

{{~/if~}}
{{#if (is_client side)}}
{{#zcl_attributes_server}}
{{~#if clusterRef}}{{!Using `ClusterRef` to detect global attributes~}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works but if needed I am wondering if global attributes belong to a certain range. In that case you can also use if_compare if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a numeric range seems even more hard-coded. Ideally I would have the helper, however isGlobalAttribute does not work.

{{~/chip_access_elements~}}
{{~#if isNullable~}}
nullable {{!marker to place a space even with whitespace removal~}}
{{~/if~}} {{#if entryType}}{{entryType}}{{else}}{{type}}{{/if}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use {{#if isArray}} if under zcl_attributes_server block helper

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did not work for me. isArray was always false (notice that isArray was already used in this method)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work with today's ZAP release.

readonly {{!marker to place a space even with whitespace removal~}}
{{~/unless~}}
{{~!TODO: write only attributes should also be supported~}}
{{~!TODO: non-reportable (nosubscribe) attributes should also be supported ~}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supported using isReportable and isReportableAttribute under zcl_attributes_server

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isReportable does not mean the same thing as Matter's nosubscribe. Most importantly, isReportable is a ZAP setting, while nosubscribe needs to be an XML thing attached to the attribute independent of config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isReportable stopped working when I was using zcl_attributes_server. It was only working for the chip_* version.

src/app/zap-templates/templates/app/MatterIDL.zapt Outdated Show resolved Hide resolved
{{/zcl_attributes_server~}}
{{else}}
{{#chip_server_cluster_attributes}}
{{~#unless isGlobalAttribute~}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to switch to chip_server_cluster_attributes here?
Are you looking for if_basic_attribute by any chance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chip_server_cluster_attributes was used before already before. I only switched the client-side currently. This piece of code is unchanged from what was before (except I moved the attribute generation into a common file to re-use it)

Comment on lines +1678 to +1679
readonly attribute int16u primary1X = 17;
readonly attribute int16u primary1Y = 18;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The light switch app most definitely does not do this.

What is this part of the .matter file used for in the light switch app, if anything? What is the goal of listing this at all, if it's just going to be a list of everything in the cluster? Why not just have a list of clusters at that point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the client-side cluster version.
It looks to me like the zap file says that the light app has the client-side cluster enabled for light switch. I am not sure why it does that ... but it does.

We do have an oddity in codegen here: our client side always only uses src/controller/data_model/controller-clusters.matter however our codegen client and server side.

I believe ideally we should separate client and server IDLs, however that is likely a different change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Light switches are required by spec to support certain client clusters: On/Off, and depending on the switch Level Control, etc.

our client side always only uses src/controller/data_model/controller-clusters.matter

Some of our clients use that. Not all. Light-switch does not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I think we need to clearly decide what "client side" means in .matter files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client-side in matter files represents what client side shows up as zap (i.e. side == client).
It was meant to be a representation of what zap contains as configuration.

The issue seems to also be that our usage of "side == client" under zap is unusual ... we seem to care about cluster enabling but not about underlying attributes/commands enabling (is this true?). I am not familiar enough with zap logic to understand this. Logic-wise it seems to me like client-side should be able to use whatever it wants where as server side has granular opinionated control about what it wants to support (i.e. we cannot just codegen everything)

Copy link
Contributor

@bzbarsky-apple bzbarsky-apple Mar 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue seems to also be that our usage of "side == client" under zap is unusual

Our usage in some specific clients.

We seem to care about cluster enabling but not about underlying attributes/commands enabling

That is the current state of things. Ideally, we would move to not caring about any of the ZAP state in those clients at all, since they are meant to be "everything" clients and should ideally just generate based on the XML. Ideally they would not reference a .zap or .matter file at all.

I am pretty sure Darwin could make that switch now; I can't speak for the other clients. We would need to think a bit about whether chip-tool should expose some of the clusters that are currently disabled in the client ZAP config (like the proxy bits)....

Logic-wise it seems to me like client-side should be able to use whatever it wants

For some of our APIs there are strongly typed callback types, etc, and those get codegenned.

I think it would be worth looking at something like light-switch-app to see what, if anything, is actually codegenned there based on the client config. If the answer is "nothing", so the only things using the client config are the "everything" clients, that would be useful information.

src/app/zap-templates/templates/app/MatterIDL.zapt Outdated Show resolved Hide resolved
@github-actions
Copy link

PR #25737: Size comparison from bbb8e93 to 790b79a

Increases (1 build for cc32xx)
platform target config section bbb8e93 790b79a change % change
cc32xx lock CC3235SF_LAUNCHXL .debug_info 20246022 2024602 2 0.0
Full report (1 build for cc32xx)
platform target config section bbb8e93 790b79a change % change
cc32xx lock CC3235SF_LAUNCHXL 0 0 0 0.0
(read only) 645489 645489 0 0.0
(read/write) 203848 203848 0 0.0
.ARM.attributes 44 44 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 197248 197248 0 0.0
.comment 194 194 0 0.0
.data 1480 1480 0 0.0
.debug_abbrev 930289 930289 0 0.0
.debug_aranges 87392 87392 0 0.0
.debug_frame 300284 300284 0 0.0
.debug_info 20246022 2024602 2 0.0
.debug_line 2661031 2661031 0 0.0
.debug_loc 2804874 2804874 0 0.0
.debug_ranges 283152 283152 0 0.0
.debug_str 3027037 3027037 0 0.0
.ramVecs 780 780 0 0.0
.resetVecs 64 64 0 0.0
.rodata 105993 105993 0 0.0
.shstrtab 232 232 0 0.0
.stab 204 204 0 0.0
.stabstr 441 441 0 0.0
.stack 2048 2048 0 0.0
.strtab 380331 380331 0 0.0
.symtab 257376 257376 0 0.0
.text 537376 537376 0 0.0

@andy31415
Copy link
Contributor Author

Closing as #25693 will fix this and makes sure java zap-codegen is in sync with matter IDL codegen.

@andy31415 andy31415 closed this Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [controller] Missing support for TemperatureSetpointHold on client-side.
4 participants