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

dynamic endpoints: add automatic attr storage, instantiation from ZAP templates #28372

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Commits on Oct 25, 2024

  1. [attribute storage] add automatic attribute storage for dynamic endpo…

    …ints
    
    Dynamically defined endpoints can now have their own block of storage
    (to be provided by the caller of emberAfSetDynamicEndpoint()).
    
    If no storage is set for a dynamic endpoint, it behaves exactly as before,
    which is treating all attributes as "external", regardless of the respective
    bit in the attribute's metadata.
    
    With a storage provided, attributes behave the same way as static endpoint's
    do, that is, only those marked "external" need to be handled programmatically
    in the respective callbacks, other attributes' storage is automatic.
    plan44 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    044ecd9 View commit details
    Browse the repository at this point in the history
  2. [attribute storage] allow setting up dynamic endpoints from templates

    Instead of re-creating dynamic endpoint's cluster declarations
    using the DECLARE_DYNAMIC_xxx macros, the new
    `setupDynamicEndpointDeclaration()` function allows setting
    up a dynamic endpoint by using clusters defined in another
    endpoint as templates. Usually that is a disabled endpoint created
    in ZAP with all possibly dynamically used clusters assigned.
    
    In combination with dynamic endpoint attribute storage, this
    greatly simplifies implementing dynamic endpoints and allows
    configuring them using the ZAP tool to ensure specs conformance,
    much the same way as with statically defined endpoints.
    plan44 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    fc210b5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a7aec68 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    995f04b View commit details
    Browse the repository at this point in the history
  5. [attribute storage] template cluster specification now includes mask...

    ...to allow differentiating server and client sides of the same cluster type
    plan44 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    a2486e9 View commit details
    Browse the repository at this point in the history
  6. [attribute storage] dynamic attribute storage is now passed as Span...

    to allow checking that it has sufficient size
    plan44 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    de5bf7c View commit details
    Browse the repository at this point in the history
  7. [attribute storage] apply suggestion from PR review

    more readable attributeLocation calculation, remove unneeded ugly C cast
    plan44 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    42bd306 View commit details
    Browse the repository at this point in the history
  8. [attribute storage] BUILD.gn: apply suggestions from PR review

    - af-types needs platform/CHIPDeviceConfig.h for CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT
    - reflect this in BUILD.gn by adding the platform_config_header sourceset as dependency
    - remove unneeded comment lines in agreement with original author
    plan44 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    b868ea6 View commit details
    Browse the repository at this point in the history
  9. [attribute storage] apply help and review suggestions

    - check passed in endpointType is explicitly "empty" (zeroed out)
    - use CanCastTo instead of literally testing against 255
    - return appropriate errors
    - only return completely set-up or untouched endpointType
    - no const cast needed
    plan44 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    6478bb5 View commit details
    Browse the repository at this point in the history
  10. [attribute storage] revert attempt to use constexpr to skip compiling…

    … code
    
    Turns out that while this works well on current compilers, it does not with many embedded toolchains.
    
    - idea was that an if testing an always false constexpr bool should
      skip *compiling* its body.
    
    - we need that because that body refers to a struct field that is non-existing
      in the case when the if condition is constexpr false
    
    - note that we can't use a real >=C++17 constexpr if, because in the
      CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT>0 case, the condition cannot be a constexpr
    
    Bottom line: there seems no way around the uglier #ifdef around the `else if` clause.
    We can avoid an #ifdef in the middle of a condition expression.
    plan44 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    7560590 View commit details
    Browse the repository at this point in the history
  11. [attribute storage] avoid problems with summing up size in restricted…

    … int size result on some platforms
    
    - took the chance to add safe error exit on excessive cumulative cluster storage size.
    - using `typeof()` and `CanCastTo` throughout to make code independent of struct field sizes.
    plan44 committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    287b7d8 View commit details
    Browse the repository at this point in the history

Commits on Oct 28, 2024

  1. [attribute storage] apply comment clarification from PR review

    Co-authored-by: Andrei Litvin <[email protected]>
    plan44 and andy31415 authored Oct 28, 2024
    Configuration menu
    Copy the full SHA
    fd5b66c View commit details
    Browse the repository at this point in the history