Matter SDK Coverage Report
Current view: top level - app/util - af-types.h (source / functions) Coverage Total Hit
Test: SHA:f84fe08d06f240e801b5d923f8a938a9938ca110 Lines: 100.0 % 2 2
Test Date: 2025-02-22 08:08:07 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  *
       3              :  *    Copyright (c) 2020 Project CHIP Authors
       4              :  *
       5              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       6              :  *    you may not use this file except in compliance with the License.
       7              :  *    You may obtain a copy of the License at
       8              :  *
       9              :  *        http://www.apache.org/licenses/LICENSE-2.0
      10              :  *
      11              :  *    Unless required by applicable law or agreed to in writing, software
      12              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      13              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14              :  *    See the License for the specific language governing permissions and
      15              :  *    limitations under the License.
      16              :  */
      17              : 
      18              : #pragma once
      19              : 
      20              : /** @addtogroup aftypes Zigbee Application Framework Types Reference
      21              :  * This documentation describes the types used by the Zigbee
      22              :  * Application Framework.
      23              :  * @{
      24              :  */
      25              : 
      26              : #include <stdbool.h> // For bool
      27              : #include <stdint.h>  // For various uint*_t types
      28              : 
      29              : #include <app/util/AttributesChangedListener.h>
      30              : #include <app/util/MarkAttributeDirty.h>
      31              : #include <app/util/basic-types.h>
      32              : #include <app/util/types_stub.h> // For various types.
      33              : 
      34              : #include <app/util/attribute-metadata.h> // EmberAfAttributeMetadata
      35              : 
      36              : #include <app/AttributePathParams.h>
      37              : #include <app/ConcreteAttributePath.h>
      38              : #include <app/data-model-provider/MetadataTypes.h>
      39              : #include <app/data-model/Nullable.h>
      40              : #include <lib/core/DataModelTypes.h>
      41              : #include <lib/support/Variant.h>
      42              : #include <messaging/ExchangeContext.h>
      43              : 
      44              : #include <app-common/zap-generated/cluster-enums.h>
      45              : #include <app-common/zap-generated/cluster-objects.h>
      46              : #include <protocols/interaction_model/StatusCode.h>
      47              : 
      48              : /**
      49              :  * @brief Generic function type, used for either of the cluster function.
      50              :  *
      51              :  * This type is used for the array of the cluster functions, and should
      52              :  * always be cast into one of the specific functions before being called.
      53              :  */
      54              : typedef void (*EmberAfGenericClusterFunction)(void);
      55              : 
      56              : /**
      57              :  * @brief A distinguished manufacturer code that is used to indicate the
      58              :  * absence of a manufacturer-specific cluster, command, or attribute.
      59              :  */
      60              : #define MATTER_DM_NULL_MANUFACTURER_CODE 0x0000
      61              : 
      62              : // The following define names are relevant to the ZAP_CLUSTER_MASK macro.
      63              : #define MATTER_CLUSTER_FLAG_INIT_FUNCTION 0x01
      64              : #define MATTER_CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION 0x02
      65              : // Bit 2 (0x04)  and Bit3 (0x08) are free.
      66              : #define MATTER_CLUSTER_FLAG_SHUTDOWN_FUNCTION 0x10
      67              : #define MATTER_CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION 0x20
      68              : #define MATTER_CLUSTER_FLAG_SERVER 0x40
      69              : #define MATTER_CLUSTER_FLAG_CLIENT 0x80
      70              : 
      71              : /**
      72              :  * @brief Type for the cluster mask
      73              :  *  Value of the mask represents a single, or aggregated, MATTER_CLUSTER_FLAG_X
      74              :  */
      75              : typedef uint8_t EmberAfClusterMask;
      76              : 
      77              : /**
      78              :  * @brief Struct describing cluster
      79              :  */
      80              : struct EmberAfCluster
      81              : {
      82              :     /**
      83              :      *  ID of cluster according to ZCL spec
      84              :      */
      85              :     chip::ClusterId clusterId;
      86              :     /**
      87              :      * Pointer to attribute metadata array for this cluster.
      88              :      */
      89              :     const EmberAfAttributeMetadata * attributes;
      90              :     /**
      91              :      * Total number of attributes
      92              :      */
      93              :     uint16_t attributeCount;
      94              :     /**
      95              :      * Total size of non-external, non-singleton attribute for this cluster.
      96              :      */
      97              :     uint16_t clusterSize;
      98              :     /**
      99              :      * Mask with additional functionality for cluster. See CLUSTER_MASK
     100              :      * macros.
     101              :      */
     102              :     EmberAfClusterMask mask;
     103              : 
     104              :     /**
     105              :      * An array into the cluster functions. The length of the array
     106              :      * is determined by the function bits in mask. This may be null
     107              :      * if this cluster has no functions.
     108              :      */
     109              :     const EmberAfGenericClusterFunction * functions;
     110              : 
     111              :     /**
     112              :      * A list of client generated commands. A client generated command
     113              :      * is a client to server command. Can be nullptr or terminated by 0xFFFF_FFFF.
     114              :      */
     115              :     const chip::CommandId * acceptedCommandList;
     116              : 
     117              :     /**
     118              :      * A list of server generated commands. A server generated command
     119              :      * is a response to client command request. Can be nullptr or terminated by 0xFFFF_FFFF.
     120              :      */
     121              :     const chip::CommandId * generatedCommandList;
     122              : 
     123              :     /**
     124              :      * Pointer to an array of event IDs of the events supported by the cluster instance.
     125              :      * Can be nullptr.
     126              :      */
     127              :     const chip::EventId * eventList;
     128              : 
     129              :     /**
     130              :      * Total number of events supported by the cluster instance (in eventList array).
     131              :      */
     132              :     uint16_t eventCount;
     133              : 
     134        12833 :     bool IsServer() const { return (mask & MATTER_CLUSTER_FLAG_SERVER) != 0; }
     135              : 
     136            8 :     bool IsClient() const { return (mask & MATTER_CLUSTER_FLAG_CLIENT) != 0; }
     137              : };
     138              : 
     139              : using EmberAfDeviceType = chip::app::DataModel::DeviceTypeEntry;
     140              : 
     141              : /**
     142              :  * @brief Struct used to find an attribute in storage. Together the elements
     143              :  * in this search record constitute the "primary key" used to identify a unique
     144              :  * attribute value in attribute storage.
     145              :  */
     146              : typedef struct
     147              : {
     148              :     /**
     149              :      * Endpoint that the attribute is located on
     150              :      */
     151              :     chip::EndpointId endpoint;
     152              : 
     153              :     /**
     154              :      * Cluster that the attribute is located on.
     155              :      */
     156              :     chip::ClusterId clusterId;
     157              : 
     158              :     /**
     159              :      * The identifier for the attribute.
     160              :      */
     161              :     chip::AttributeId attributeId;
     162              : } EmberAfAttributeSearchRecord;
     163              : 
     164              : /**
     165              :  * This type is used to compare two ZCL attribute values. The size of this data
     166              :  * type depends on the platform.
     167              :  */
     168              : #ifdef HAL_HAS_INT64
     169              : typedef uint64_t EmberAfDifferenceType;
     170              : #else
     171              : typedef uint32_t EmberAfDifferenceType;
     172              : #endif
     173              : 
     174              : /**
     175              :  * @brief Endpoint type struct describes clusters that are on the endpoint.
     176              :  */
     177              : typedef struct
     178              : {
     179              :     /**
     180              :      * Pointer to the cluster structs, describing clusters on this
     181              :      * endpoint type.
     182              :      */
     183              :     const EmberAfCluster * cluster;
     184              :     /**
     185              :      * Number of clusters in this endpoint type.
     186              :      */
     187              :     uint8_t clusterCount;
     188              :     /**
     189              :      * Size of all non-external, non-singlet attribute in this endpoint type.
     190              :      */
     191              :     uint16_t endpointSize;
     192              : } EmberAfEndpointType;
     193              : 
     194              : enum class EmberAfEndpointOptions : uint8_t
     195              : {
     196              :     isEnabled         = 0x1,
     197              :     isFlatComposition = 0x2,
     198              :     isTreeComposition = 0x3,
     199              : };
     200              : 
     201              : /**
     202              :  * @brief Struct that maps actual endpoint type, onto a specific endpoint.
     203              :  */
     204              : struct EmberAfDefinedEndpoint
     205              : {
     206              :     /**
     207              :      * Actual zigbee endpoint number.
     208              :      */
     209              :     chip::EndpointId endpoint = chip::kInvalidEndpointId;
     210              : 
     211              :     /**
     212              :      * Span pointing to a list of supported device types
     213              :      */
     214              :     chip::Span<const EmberAfDeviceType> deviceTypeList;
     215              : 
     216              :     /**
     217              :      * Meta-data about the endpoint
     218              :      */
     219              :     chip::BitMask<EmberAfEndpointOptions> bitmask;
     220              :     /**
     221              :      * Endpoint type for this endpoint.
     222              :      */
     223              :     const EmberAfEndpointType * endpointType = nullptr;
     224              :     /**
     225              :      * Pointer to the DataVersion storage for the server clusters on this
     226              :      * endpoint
     227              :      */
     228              :     chip::DataVersion * dataVersions = nullptr;
     229              : 
     230              :     /**
     231              :      * Root endpoint id for composed device type.
     232              :      */
     233              :     chip::EndpointId parentEndpointId = chip::kInvalidEndpointId;
     234              : 
     235              :     /**
     236              :      * Span pointing to a list of tags. Lifetime has to outlive usage, and data is owned by callers.
     237              :      */
     238              :     chip::Span<const chip::app::Clusters::Descriptor::Structs::SemanticTagStruct::Type> tagList;
     239              : };
     240              : 
     241              : /**
     242              :  * @brief Type for referring to the tick callback for cluster.
     243              :  *
     244              :  * Tick function will be called once for each tick for each endpoint in
     245              :  * the cluster. The rate of tick is determined by the metadata of the
     246              :  * cluster.
     247              :  */
     248              : typedef void (*EmberAfTickFunction)(chip::EndpointId endpoint);
     249              : 
     250              : /**
     251              :  * @brief Type for referring to the init callback for cluster.
     252              :  *
     253              :  * Init function is called when the application starts up, once for
     254              :  * each cluster/endpoint combination.
     255              :  */
     256              : typedef void (*EmberAfInitFunction)(chip::EndpointId endpoint);
     257              : 
     258              : /**
     259              :  * @brief Type for referring to the shutdown callback for cluster.
     260              :  *
     261              :  * Init function is called when the cluster is shut down, for example
     262              :  * when an endpoint is disabled
     263              :  */
     264              : typedef void (*EmberAfShutdownFunction)(chip::EndpointId endpoint);
     265              : 
     266              : /**
     267              :  * @brief Type for referring to the attribute changed callback function.
     268              :  *
     269              :  * This function is called just after an attribute changes.
     270              :  */
     271              : typedef void (*EmberAfClusterAttributeChangedCallback)(const chip::app::ConcreteAttributePath & attributePath);
     272              : 
     273              : /**
     274              :  * @brief Type for referring to the pre-attribute changed callback function.
     275              :  *
     276              :  * This function is called before an attribute changes.
     277              :  */
     278              : typedef chip::Protocols::InteractionModel::Status (*EmberAfClusterPreAttributeChangedCallback)(
     279              :     const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value);
     280              : 
     281              : #define MAX_INT32U_VALUE (0xFFFFFFFFUL)
     282              : #define MAX_INT16U_VALUE (0xFFFF)
     283              : 
     284              : /** @} END addtogroup */
        

Generated by: LCOV version 2.0-1