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

Need clarification on the MatterPre/PostAttributeChangeCallbacks. #37205

Open
jadhavrohit924 opened this issue Jan 27, 2025 · 1 comment
Open

Comments

@jadhavrohit924
Copy link
Contributor

Image

Whenever there is a write request on the Matter attribute:

  1. The static/fixed constraints are checked in emAfWriteAttribute.
  2. MatterPreAttributeChangeCallback is called before updating an attribute.
  3. During the attribute update, dynamic constraints are checked in the server implementation of a cluster.
  4. After successfully passing the above steps, MatterPostAttributeChangeCallback is called.

If the application wants to update one of its drivers, when should that be done: in the Pre or Post AttributeChangeCallback?

  1. If the driver is updated in the PreAttributeChangeCallback and the server constraint check fails, then the Matter attribute will remain unchanged. However, the driver will have updated its state, leading to inconsistency.
  2. If the driver is updated in the PostAttributeChangeCallback and the application fails to update the driver, the Matter storage will be updated, but the driver will not. Again, this results in inconsistency.

How should such cases be handled? Should the PostAttributeChangeCallback have a return type and rollback mechanics in case the application returns an error in the PostAttributeChangeCallback?

@dhrishi
Copy link
Contributor

dhrishi commented Jan 27, 2025

From the PreAttributeChangeCallback documentation -

The value passed into this callback is the value to which the attribute is to be set by the framework.

This doesn't seem to be true in case where the dynamic constraint checks (that happen after the pre attribute change callback) fail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants