-
Notifications
You must be signed in to change notification settings - Fork 82
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
Adding to zcl_attributes_server and enabled_attributes_for_cluster_and_side helpers to replace chip_server_cluster_attributes #899
Conversation
brdandu
commented
Jan 19, 2023
- chip_server_cluster_attributes is returning server attributes which are not actually enabled because the server side cluster is disabled.
- The reason chip_server_cluster_attributes is picking the server side attributes which are not enabled is because those are enabled in the .zap file(Which is the case for saving user selections and ease of use). However the helper is not actually checking if the cluster is enabled as well.
- all_user_cluster_attributes_irrespective_of_manufacturing_specification is solving this issue correctly and actually only showing attributes which are truly enabled.
- Github: ZAP#898
e6e8677
to
0c5a305
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused by what this is trying to address.
There are two ways to use chip_server_cluster_attributes
.
If includeAll is true, then it just returns all the attributes that are defined in the relevant cluster. Whether that cluster is enabled or not might affect whether chip_server_cluster_attributes
is reached at all.
If includeAll is false, then it returns all the attributes that are enabled in the relevant cluster. Again, whether that cluster is enabled or not affects whether it's reached, but in practice in this mode chip_server_cluster_attributes
should not be getting invoked for disabled clusters at all.
How is any of this related to the helpers being changed here?
I switched {{#chip_server_cluster_attributes}} in MatterIDL.zapt to {{#chip_server_cluster_attributes includeAll=false}} but that is not removing all the server attributes which should not be generated because the corresponding server cluster is disabled. |
The includeAll=false needs to be on the The real problem, it seems to me, is that But MatterIDL.zapt uses it inside |
I am looking at ChipCallbackTypes.zapt which uses {{#chip_client_clusters}} and {{#chip_server_cluster_attributes}}. I see Identify server cluster attributes generated in ChipCallbackTypes.h even though the Identify server cluster is disabled. I do not see includeAll=true here(Assuming includeAll is false by default like you mentioned). |
That one is a hack which explicitly relies on "we enable the server attributes, but then actually enable the client clusters". That is, it wants the observed behavior. It should really be using server clusters and includeAll=true, but the owners of that code have sort of abandoned it.... That is, this is codegen for the java "control everything" client. It should not depend on what server clusters are enabled (none of them, in practice) for controllers. |
To do further analysis here. Which of the following files are not hacks and not abandoned?
|
Files are not hacks. Specific things in a file might be hacks. The src/controller/java stuff is all more or less abandoned, at the moment, as far as I understand. Maybe new maintainers can be found for it; please check with the Google folks. The python, darwin and chip-tool bits are not abandoned, but they also have the behavior they want to have right now. So any PR that changes their output needs to be looked at very carefully to see what changed about the output and why. |
@andy31415 would you know anything about the java code. Is that still being used or can it be removed? |
I do not believe the java stuff was abandoned. Historically we had to move some of the files to be code generated by the python code generator because a single large file would crash the gcc NDK compiler with internal error. However converting handlebars to python jinja2 templates is a non-trivial effort, so we converted only what was crashing and not the rest. Which puts us in the awkward state of having 2 code generators even for java itself. |
A lot of controller/java/zap-generated are actually used by our builds currently:
Java files are also used below:
|
@brdandu To be clear, the Java stuff is used. It's just not particularly actively maintained and hasn't been in a while as far as I can tell. |
ok I will make some changes to the templates here and run them by you. |
2d8516b
to
013b170
Compare
52ee508
to
1bd167f
Compare
1bd167f
to
8b2ddae
Compare
f53ae4d
to
fd8af8c
Compare
Codecov Report
@@ Coverage Diff @@
## master #899 +/- ##
==========================================
+ Coverage 66.24% 66.48% +0.23%
==========================================
Files 155 156 +1
Lines 16708 16952 +244
Branches 3602 3681 +79
==========================================
+ Hits 11068 11270 +202
- Misses 5640 5682 +42
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
db03a4f
to
e7acecb
Compare
src-electron/generator/matter/app/zap-templates/templates/chip/helper.js
Outdated
Show resolved
Hide resolved
0e414d7
to
237bf3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reasonable step towards replacing stateful helpers with stateless helpers. Work in progress...
src-electron/generator/matter/app/zap-templates/templates/chip/helper.js
Outdated
Show resolved
Hide resolved
src-electron/generator/matter/app/zap-templates/templates/chip/helper.js
Outdated
Show resolved
Hide resolved
src-electron/generator/matter/app/zap-templates/templates/chip/helper.js
Outdated
Show resolved
Hide resolved
src-electron/generator/matter/controller/python/templates/helper.js
Outdated
Show resolved
Hide resolved
2bc8864
to
f01d94f
Compare
src-electron/generator/matter/controller/python/templates/helper.js
Outdated
Show resolved
Hide resolved
src-electron/generator/matter/controller/python/templates/helper.js
Outdated
Show resolved
Hide resolved
f01d94f
to
efed03c
Compare
efed03c
to
4f26132
Compare
…server helper to replace chip_server_cluster_attributes - chip_server_cluster_attributes is returning server attributes which are not actually enabled because the server side cluster is disabled. - The reason chip_server_cluster_attributes is picking the server side attributes which are not enabled is because those are enabled in the .zap file(Which is the case for saving user selections and ease of use). However the helper is not actually checking if the cluster is enabled as well. - enabled_attributes_for_cluster_and_side is solving this issue correctly and actually only showing attributes which are truly enabled. - Extending endpointTypeAttributeExtended such that there is a common place for an attribute map - Updating endpointTypeAttributeExtended with everything that attributeExportMapping had such that it can act as a common place for all other temporary maps that have been created across our code. Also sorting endpointTypeAttributeExtended for easier readability and avoiding duplicate keys - Updating zcl_attributes_server block helper such that it can behave like chip_server_cluster_attributes. - Updating attribute map such that it can be used more widely - Adding additional helpers to remove the stateful helpers - Adding removeKeys option for removing certain columns which are not needed in a block helper such as enabled_attributes_for_cluster_and_side and zcl_attributes_server - Adding if_unsupported_attribute_type and if_attribute_complex to check for unsupported and complex zcl data types - Deprecating old stateful helpers with new stateless helpers - Adding select data type using type name and cluster id to data_types, enums, bitmap, numbers and structs - Adding if_unsupported_attribute_callback helper and if_basic_attribute if helpers for java code generation - Deprecating java and python zcl type helpers with new zcl type helpers such that they do not need any stateful information coming from parent block helpers. For eg chipType and chipCallback.type - Adding tests for all the newly introduced helpers. - Updating Api documentation - Adding if_is_data_type_signed and as_zcl_data_type_size to determine sign and size of zcl data types - if_is_data_type_signed and as_zcl_data_type_size take type name and cluster id to return size and sign of the zcl data types - Github: ZAP#898
4f26132
to
8bff12d
Compare