Matter SDK Coverage Report
Current view: top level - app/util - af-types.h (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 100.0 % 3 3
Test Date: 2025-01-17 19:00:11 Functions: 75.0 % 4 3

            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 "att-storage.h"
      27              : #include <stdbool.h> // For bool
      28              : #include <stdint.h>  // For various uint*_t types
      29              : 
      30              : #include <app/util/basic-types.h>
      31              : #include <app/util/types_stub.h> // For various types.
      32              : 
      33              : #include <app/util/attribute-metadata.h> // EmberAfAttributeMetadata
      34              : 
      35              : #include <app/AttributePathParams.h>
      36              : #include <app/ConcreteAttributePath.h>
      37              : #include <app/data-model/Nullable.h>
      38              : #include <lib/core/DataModelTypes.h>
      39              : #include <lib/support/Variant.h>
      40              : #include <messaging/ExchangeContext.h>
      41              : 
      42              : #include <app-common/zap-generated/cluster-enums.h>
      43              : #include <app-common/zap-generated/cluster-objects.h>
      44              : #include <protocols/interaction_model/StatusCode.h>
      45              : 
      46              : /**
      47              :  * @brief Type for the cluster mask
      48              :  */
      49              : typedef uint8_t EmberAfClusterMask;
      50              : 
      51              : /**
      52              :  * @brief Generic function type, used for either of the cluster function.
      53              :  *
      54              :  * This type is used for the array of the cluster functions, and should
      55              :  * always be cast into one of the specific functions before being called.
      56              :  */
      57              : typedef void (*EmberAfGenericClusterFunction)(void);
      58              : 
      59              : /**
      60              :  * @brief A distinguished manufacturer code that is used to indicate the
      61              :  * absence of a manufacturer-specific cluster, command, or attribute.
      62              :  */
      63              : #define MATTER_DM_NULL_MANUFACTURER_CODE 0x0000
      64              : 
      65              : /**
      66              :  * @brief Struct describing cluster
      67              :  */
      68              : struct EmberAfCluster
      69              : {
      70              :     /**
      71              :      *  ID of cluster according to ZCL spec
      72              :      */
      73              :     chip::ClusterId clusterId;
      74              :     /**
      75              :      * Pointer to attribute metadata array for this cluster.
      76              :      */
      77              :     const EmberAfAttributeMetadata * attributes;
      78              :     /**
      79              :      * Total number of attributes
      80              :      */
      81              :     uint16_t attributeCount;
      82              :     /**
      83              :      * Total size of non-external, non-singleton attribute for this cluster.
      84              :      */
      85              :     uint16_t clusterSize;
      86              :     /**
      87              :      * Mask with additional functionality for cluster. See CLUSTER_MASK
      88              :      * macros.
      89              :      */
      90              :     EmberAfClusterMask mask;
      91              : 
      92              :     /**
      93              :      * An array into the cluster functions. The length of the array
      94              :      * is determined by the function bits in mask. This may be null
      95              :      * if this cluster has no functions.
      96              :      */
      97              :     const EmberAfGenericClusterFunction * functions;
      98              : 
      99              :     /**
     100              :      * A list of client generated commands. A client generated command
     101              :      * is a client to server command. Can be nullptr or terminated by 0xFFFF_FFFF.
     102              :      */
     103              :     const chip::CommandId * acceptedCommandList;
     104              : 
     105              :     /**
     106              :      * A list of server generated commands. A server generated command
     107              :      * is a response to client command request. Can be nullptr or terminated by 0xFFFF_FFFF.
     108              :      */
     109              :     const chip::CommandId * generatedCommandList;
     110              : 
     111              :     /**
     112              :      * Pointer to an array of event IDs of the events supported by the cluster instance.
     113              :      * Can be nullptr.
     114              :      */
     115              :     const chip::EventId * eventList;
     116              : 
     117              :     /**
     118              :      * Total number of events supported by the cluster instance (in eventList array).
     119              :      */
     120              :     uint16_t eventCount;
     121              : 
     122         2018 :     bool IsServer() const { return (mask & CLUSTER_MASK_SERVER) != 0; }
     123              : 
     124           99 :     bool IsClient() const { return (mask & CLUSTER_MASK_CLIENT) != 0; }
     125              : };
     126              : 
     127              : /**
     128              :  * @brief Struct that represents a logical device type consisting
     129              :  * of a DeviceID and its version.
     130              :  */
     131              : typedef struct
     132              : {
     133              :     chip::DeviceTypeId deviceId;
     134              :     uint8_t deviceVersion;
     135              : } EmberAfDeviceType;
     136              : 
     137              : /**
     138              :  * @brief Struct used to find an attribute in storage. Together the elements
     139              :  * in this search record constitute the "primary key" used to identify a unique
     140              :  * attribute value in attribute storage.
     141              :  */
     142              : typedef struct
     143              : {
     144              :     /**
     145              :      * Endpoint that the attribute is located on
     146              :      */
     147              :     chip::EndpointId endpoint;
     148              : 
     149              :     /**
     150              :      * Cluster that the attribute is located on.
     151              :      */
     152              :     chip::ClusterId clusterId;
     153              : 
     154              :     /**
     155              :      * The identifier for the attribute.
     156              :      */
     157              :     chip::AttributeId attributeId;
     158              : } EmberAfAttributeSearchRecord;
     159              : 
     160              : /**
     161              :  * This type is used to compare two ZCL attribute values. The size of this data
     162              :  * type depends on the platform.
     163              :  */
     164              : #ifdef HAL_HAS_INT64
     165              : typedef uint64_t EmberAfDifferenceType;
     166              : #else
     167              : typedef uint32_t EmberAfDifferenceType;
     168              : #endif
     169              : 
     170              : /**
     171              :  * @brief Endpoint type struct describes clusters that are on the endpoint.
     172              :  */
     173              : typedef struct
     174              : {
     175              :     /**
     176              :      * Pointer to the cluster structs, describing clusters on this
     177              :      * endpoint type.
     178              :      */
     179              :     const EmberAfCluster * cluster;
     180              :     /**
     181              :      * Number of clusters in this endpoint type.
     182              :      */
     183              :     uint8_t clusterCount;
     184              :     /**
     185              :      * Size of all non-external, non-singlet attribute in this endpoint type.
     186              :      */
     187              :     uint16_t endpointSize;
     188              : } EmberAfEndpointType;
     189              : 
     190              : enum class EmberAfEndpointOptions : uint8_t
     191              : {
     192              :     isEnabled         = 0x1,
     193              :     isFlatComposition = 0x2,
     194              :     isTreeComposition = 0x3,
     195              : };
     196              : 
     197              : /**
     198              :  * @brief Struct that maps actual endpoint type, onto a specific endpoint.
     199              :  */
     200              : struct EmberAfDefinedEndpoint
     201              : {
     202              :     /**
     203              :      * Actual zigbee endpoint number.
     204              :      */
     205              :     chip::EndpointId endpoint = chip::kInvalidEndpointId;
     206              : 
     207              :     /**
     208              :      * Span pointing to a list of supported device types
     209              :      */
     210              :     chip::Span<const EmberAfDeviceType> deviceTypeList;
     211              : 
     212              :     /**
     213              :      * Meta-data about the endpoint
     214              :      */
     215              :     chip::BitMask<EmberAfEndpointOptions> bitmask;
     216              :     /**
     217              :      * Endpoint type for this endpoint.
     218              :      */
     219              :     const EmberAfEndpointType * endpointType = nullptr;
     220              :     /**
     221              :      * Pointer to the DataVersion storage for the server clusters on this
     222              :      * endpoint
     223              :      */
     224              :     chip::DataVersion * dataVersions = nullptr;
     225              : 
     226              :     /**
     227              :      * Root endpoint id for composed device type.
     228              :      */
     229              :     chip::EndpointId parentEndpointId = chip::kInvalidEndpointId;
     230              : 
     231              :     /**
     232              :      * Span pointing to a list of tags. Lifetime has to outlive usage, and data is owned by callers.
     233              :      */
     234              :     chip::Span<const chip::app::Clusters::Descriptor::Structs::SemanticTagStruct::Type> tagList;
     235              : };
     236              : 
     237              : // Cluster specific types
     238              : 
     239              : /**
     240              :  * @brief Indicates the absence of a Scene table entry.
     241              :  */
     242              : #define MATTER_DM_SCENE_TABLE_NULL_INDEX 0xFF
     243              : /**
     244              :  * @brief Value used when setting or getting the endpoint in a Scene table
     245              :  * entry.  It indicates that the entry is not in use.
     246              :  */
     247              : #define MATTER_DM_SCENE_TABLE_UNUSED_ENDPOINT_ID 0x00
     248              : /**
     249              :  * @brief Maximum length of Scene names, not including the length byte.
     250              :  */
     251              : #define ZCL_SCENES_CLUSTER_MAXIMUM_NAME_LENGTH 16
     252              : /**
     253              :  * @brief The group identifier for the global scene.
     254              :  */
     255              : #define ZCL_SCENES_GLOBAL_SCENE_GROUP_ID 0x0000
     256              : /**
     257              :  * @brief The scene identifier for the global scene.
     258              :  */
     259              : #define ZCL_SCENES_GLOBAL_SCENE_SCENE_ID 0x00
     260              : 
     261              : /**
     262              :  * @brief Type for referring to the tick callback for cluster.
     263              :  *
     264              :  * Tick function will be called once for each tick for each endpoint in
     265              :  * the cluster. The rate of tick is determined by the metadata of the
     266              :  * cluster.
     267              :  */
     268              : typedef void (*EmberAfTickFunction)(chip::EndpointId endpoint);
     269              : 
     270              : /**
     271              :  * @brief Type for referring to the init callback for cluster.
     272              :  *
     273              :  * Init function is called when the application starts up, once for
     274              :  * each cluster/endpoint combination.
     275              :  */
     276              : typedef void (*EmberAfInitFunction)(chip::EndpointId endpoint);
     277              : 
     278              : /**
     279              :  * @brief Type for referring to the shutdown callback for cluster.
     280              :  *
     281              :  * Init function is called when the cluster is shut down, for example
     282              :  * when an endpoint is disabled
     283              :  */
     284              : typedef void (*EmberAfShutdownFunction)(chip::EndpointId endpoint);
     285              : 
     286              : /**
     287              :  * @brief Type for referring to the attribute changed callback function.
     288              :  *
     289              :  * This function is called just after an attribute changes.
     290              :  */
     291              : typedef void (*EmberAfClusterAttributeChangedCallback)(const chip::app::ConcreteAttributePath & attributePath);
     292              : 
     293              : /**
     294              :  * @brief Type for referring to the pre-attribute changed callback function.
     295              :  *
     296              :  * This function is called before an attribute changes.
     297              :  */
     298              : typedef chip::Protocols::InteractionModel::Status (*EmberAfClusterPreAttributeChangedCallback)(
     299              :     const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value);
     300              : 
     301              : #define MAX_INT32U_VALUE (0xFFFFFFFFUL)
     302              : #define MAX_INT16U_VALUE (0xFFFF)
     303              : 
     304              : /** @} END addtogroup */
     305              : 
     306              : namespace chip {
     307              : namespace app {
     308              : 
     309              : enum class MarkAttributeDirty
     310              : {
     311              :     kIfChanged,
     312              :     kNo,
     313              :     // kYes might need to be used if the attribute value was previously changed
     314              :     // without reporting, and now is being set in a situation where we know
     315              :     // reporting needs to be triggered (e.g. because QuieterReportingAttribute
     316              :     // indicated that).
     317              :     kYes,
     318              : };
     319              : 
     320              : /// Notification object of a specific path being changed
     321              : class AttributesChangedListener
     322              : {
     323              : public:
     324         2585 :     virtual ~AttributesChangedListener() = default;
     325              : 
     326              :     /// Called when the set of attributes identified by AttributePathParams (which may contain wildcards) is to be considered dirty.
     327              :     virtual void MarkDirty(const AttributePathParams & path) = 0;
     328              : };
     329              : 
     330              : } // namespace app
     331              : } // namespace chip
        

Generated by: LCOV version 2.0-1