forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle nullable attributes in TLV-to-attr-store interactions and Acce…
…ssors (project-chip#11665) * Add a way to ask EmberAfAttributeMetadata whether the attribute is nullable. * Convert ZCL null values to/from TLV null when attributes are read/written. This implements the following semantics, for attributes we store in the attribute store (integers, booleans, strings, octet strings): Writes: * An attempt to write TLV null for non-nullable attributes leads to an error. * Writing TLV null to a nullable string or octet string sets its length to 0xFFFF or 0xFF depending on whether it's a long string or not. * Writing TLV null to a nullable integer or boolean uses the "NaU" or "NaS" ZCL representation to represent it. * Writing a TLV integer to an integer attribute makes a CanRepresentValue check and returns an error if it returns false. For now CanRepresentValue only disallows the NaU/NaS value for nullable attributes. Reads: * When reading a nullable integer or boolean, NaU/NaS is converted to TLV null. * When reading an integer or boolean all other cases go through a CanRepresentValue check (in case the value in the attr store is not actually valid) and return error if it returns false. * When reading a nullable string or octet string, length 0xFFFF/0xFF is converted to TLV null. * When reading a non-nullable string or octet string, length 0xFFFF/0xFF leads to an error. * Fix Accessors to handle nullable attributes. For setters, the new behavior is: * For non-string attributes when setting an integer or boolean value, do a CanRepresentValue check and fail if that fails. For string attributes, ensure that strings with 0xFF or 0xFFFF as length cannot be passed in in practice. * For nullable attributes add a SetNull method. * For nullable attributes add a Set() method taking a Nullable<T> and calling either SetNull or the setter that expects a non-null value. For getters, the new behavior is: * When reading a nullable integer or boolean, NaU/NaS is converted to a null value stored in the Nullable. * When reading a non-nullable integer or boolean, return error if CanRepresentValue returns false on the value from the attr store. * When reading a nullable string or octet string, length 0xFFFF/0xFF is converted to a null value stored in the Nullable. * When reading a non-nullable string or octet string, length 0xFFFF/0xFF leads to an error. The XML changes are for two problems the new asserts caught: we had strings that were short-typed, but had sizes that would not fit in a single byte length. * Add tests for nullable attributes. * Fix the Darwin tests by skipping the nullable read for now * Address review comments
- Loading branch information
1 parent
4bc6996
commit 86e0d9b
Showing
39 changed files
with
24,573 additions
and
3,433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.