Initial commit: ESP32-C6 Zigbee sensor switch project

This commit is contained in:
2025-11-01 11:57:33 +11:00
commit a8fc24fdf5
1792 changed files with 279851 additions and 0 deletions

View File

@@ -0,0 +1,369 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Alarms cluster definitions
*/
#ifndef ZB_ZCL_ALARMS_H
#define ZB_ZCL_ALARMS_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_ALARMS
* @{
*/
/* Cluster ZB_ZCL_CLUSTER_ID_ALARMS */
/*! @name Alarms cluster attributes
@{
*/
/*! @brief Alarms cluster attribute identifiers
@see ZCL spec, subclause 3.11.2.2
*/
enum zb_zcl_alarms_attr_e
{
/*! @brief AlarmCount attribute */
ZB_ZCL_ATTR_ALARMS_ALARM_COUNT_ID = 0x0000
};
/*! @} */ /* Alarms cluster attributes */
/** @brief Default value for Alarms cluster revision global attribute */
#define ZB_ZCL_ALARMS_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/*!
@brief Declare attribute list for Alarms cluster (only cluster revision attribute)
@param attr_list - attribute list name
*/
#define ZB_ZCL_DECLARE_ALARMS_ATTR_LIST(attr_list) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_ALARMS) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @name Alarms cluster commands
@{
*/
/*! @brief Alarms cluster command identifiers
@see ZCL spec, subclause 3.11.2.4
*/
enum zb_zcl_alarms_cmd_e
{
ZB_ZCL_CMD_ALARMS_RESET_ALARM_ID = 0x00, /**< "Reset alarm" command. */
ZB_ZCL_CMD_ALARMS_RESET_ALL_ALARMS_ID = 0x01, /**< "Reset all alarms" command. */
ZB_ZCL_CMD_ALARMS_GET_ALARM_ID = 0x02, /**< "Get alarms" command. */
ZB_ZCL_CMD_ALARMS_RESET_ALARM_LOG_ID = 0x03 /**< "Reset alarm log" command. */
};
/*! @brief Structured representation of Reset alarm command payload */
typedef ZB_PACKED_PRE struct zb_zcl_alarms_reset_alarm_req_s
{
/** Alarm Code field */
zb_uint8_t alarm_code;
/** Cluster ID field */
zb_uint16_t cluster_id;
} ZB_PACKED_STRUCT zb_zcl_alarms_reset_alarm_req_t;
/** @brief Reset alarm payload length macro */
#define ZB_ZCL_ALARMS_RESET_ALARM_REQ_PAYLOAD_LEN \
sizeof(zb_zcl_alarms_reset_alarm_req_t)
/*! @brief Send Reset alarm command
@param buffer to put data to
@param addr - address of the device to send command to
@param dst_addr_mode - addressing mode
@param dst_ep destination endpoint
@param ep - current endpoint
@param prof_id - profile identifier
@param dis_default_resp - "Disable default response" flag
@param cb - callback to call to report send status
@param alarm_code - Alarm Code field
@param cluster_id - Cluster ID field
*/
#define ZB_ZCL_ALARMS_SEND_RESET_ALARM_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, cb, alarm_code, cluster_id) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ALARMS_RESET_ALARM_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (alarm_code)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (cluster_id)); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ALARMS, cb); \
}
/** @brief Parses Reset alarm command and fills in data request
structure. If request contains invalid data, status will set to ZB_FALSE.
@param data_buf - pointer to zb_buf_t buffer containing command request data
@param reset_alarm_req - variable to save command request
@param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
@note data_buf buffer should contain command request payload without ZCL header.
*/
#define ZB_ZCL_ALARMS_GET_RESET_ALARM_REQ(data_buf, reset_alarm_req, status) \
{ \
zb_zcl_alarms_reset_alarm_req_t *reset_alarm_req_ptr; \
(reset_alarm_req_ptr) = zb_buf_len(data_buf) >= \
ZB_ZCL_ALARMS_RESET_ALARM_REQ_PAYLOAD_LEN ? \
(zb_zcl_alarms_reset_alarm_req_t*)zb_buf_begin(data_buf) : NULL; \
if (reset_alarm_req_ptr != NULL) \
{ \
reset_alarm_req.alarm_code = reset_alarm_req_ptr->alarm_code; \
ZB_HTOLE16(&(reset_alarm_req).cluster_id, &(reset_alarm_req_ptr->cluster_id)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
else \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
}
/*! @brief Send Reset all alarms command
@param buffer to put data to
@param addr - address of the device to send command to
@param dst_addr_mode - addressing mode
@param dst_ep destination endpoint
@param ep - current endpoint
@param prof_id - profile identifier
@param dis_default_resp - "Disable default response" flag
@param cb - callback to call to report send status
*/
#define ZB_ZCL_ALARMS_SEND_RESET_ALL_ALARMS_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ALARMS_RESET_ALL_ALARMS_ID); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ALARMS, cb); \
}
/*! @brief Send Get alarm command
@param buffer to put data to
@param addr - address of the device to send command to
@param dst_addr_mode - addressing mode
@param dst_ep destination endpoint
@param ep - current endpoint
@param prof_id - profile identifier
@param dis_default_resp - "Disable default response" flag
@param cb - callback to call to report send status
*/
#define ZB_ZCL_ALARMS_SEND_GET_ALARM_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ALARMS_GET_ALARM_ID); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ALARMS, cb); \
}
/*! @brief Send Reset alarm log command
@param buffer to put data to
@param addr - address of the device to send command to
@param dst_addr_mode - addressing mode
@param dst_ep destination endpoint
@param ep - current endpoint
@param prof_id - profile identifier
@param dis_default_resp - "Disable default response" flag
@param cb - callback to call to report send status
*/
#define ZB_ZCL_ALARMS_SEND_RESET_ALARM_LOG_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ALARMS_RESET_ALARM_LOG_ID); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ALARMS, cb); \
}
/********************************** Responses *******************/
/** @brief Alarms cluster response command identifiers
@see ZCL spec, subclause 3.6.2.3
*/
enum zb_zcl_alarms_cmd_resp_e
{
ZB_ZCL_CMD_ALARMS_ALARM_ID = 0x00, /**< Alarm command identifier. */
ZB_ZCL_CMD_ALARMS_GET_ALARM_RES_ID = 0x01 /**< Get alarm response command identifier. */
};
/** @cond internals_doc */
/* Alarms cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_ALARMS_SERVER_ROLE_GENERATED_CMD_LIST ZB_ZCL_CMD_ALARMS_ALARM_ID
#define ZB_ZCL_CLUSTER_ID_ALARMS_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_ALARMS_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_ALARMS_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_ALARMS_RESET_ALARM_ID, \
ZB_ZCL_CMD_ALARMS_RESET_ALL_ALARMS_ID
#define ZB_ZCL_CLUSTER_ID_ALARMS_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_ALARMS_CLIENT_ROLE_GENERATED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
/*! @brief Structured representation of Alarm command payload */
typedef zb_zcl_alarms_reset_alarm_req_t zb_zcl_alarms_alarm_res_t;
typedef ZB_PACKED_PRE struct zb_zcl_alarm_get_alarm_hdr_res_s
{
zb_uint8_t status; /**< Status field */
} ZB_PACKED_STRUCT zb_zcl_alarm_get_alarm_hdr_res_t;
/** @brief Get alarm response command structure */
typedef ZB_PACKED_PRE struct zb_zcl_alarm_get_alarm_res_s
{
zb_uint8_t status; /**< Status field */
zb_uint8_t alarm_code; /**< Alarm code field */
zb_uint16_t cluster_id; /**< Cluster ID field */
zb_uint32_t timestamp; /**< TimeStamp field */
} ZB_PACKED_STRUCT zb_zcl_alarm_get_alarm_res_t;
/** @internal Get alarm response size */
#define ZB_ZCL_ALARM_GET_ALARM_RES_SIZE \
sizeof(zb_zcl_alarm_get_alarm_res_t)
/** @internal Get alarm response header size */
#define ZB_ZCL_ALARM_GET_ALARM_HDR_RES_SIZE \
sizeof(zb_zcl_alarm_get_alarm_hdr_res_t)
/*! @brief Send Alarm command (to client)
@param buffer to put data to
@param addr - address of the device to send command to
@param dst_addr_mode - addressing mode
@param dst_ep destination endpoint
@param ep - current endpoint
@param prof_id - profile identifier
@param cb - callback to call to report send status
@param alarm_code - Alarm Code
@param cluster_id - Cluster Id
*/
#define ZB_ZCL_ALARMS_SEND_ALARM_RES( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, cb, alarm_code, cluster_id) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ALARMS_ALARM_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (alarm_code)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (cluster_id)); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ALARMS, cb); \
}
/** @brief Parses Reset alarm command and fills in data request
structure. If request contains invalid data, status will set to ZB_FALSE.
@param data_ptr - pointer to a variable of type @ref zb_zcl_alarms_alarm_res_t.
@param buffer containing the packet (by pointer).
@param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_ALARMS_GET_ALARM_RES(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_alarms_alarm_res_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_alarms_alarm_res_t *src_ptr = \
(zb_zcl_alarms_alarm_res_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(data_ptr)->alarm_code = src_ptr->alarm_code; \
ZB_HTOLE16(&((data_ptr)->cluster_id), &(src_ptr->cluster_id)); \
} \
}
/** @brief Parses Get alarm response command and returns response data
structure or status = ZB_FALSE if request contains invalid data.
@param data_buf - pointer to zb_buf_t buffer containing command response data
@param get_alarm_res - command response record
@param status - variable to put parse status to (see @ref zb_zcl_parse_status_t)
@note data_buf buffer should contain response command payload without ZCL header
*/
#define ZB_ZCL_ALARMS_GET_GET_ALARM_RES(data_buf, get_alarm_res, status) \
{ \
zb_zcl_alarm_get_alarm_res_t *get_alarm_res_ptr; \
if (zb_buf_len(data_buf) >= ZB_ZCL_ALARM_GET_ALARM_HDR_RES_SIZE) \
{ \
(get_alarm_res_ptr) = zb_buf_begin(data_buf); \
get_alarm_res.status = get_alarm_res_ptr->status; \
if (zb_buf_len(data_buf) >= ZB_ZCL_ALARM_GET_ALARM_RES_SIZE) \
{ \
get_alarm_res.alarms_code = get_alarm_res_ptr->alarm_code; \
ZB_HTOLE16(&(get_alarm_res).cluster_id, &(get_alarm_res_ptr->cluster_id)); \
ZB_HTOLE32(&(get_alarm_res).timestamp, &(get_alarm_res_ptr->timestamp)); \
} \
status = ZB_TRUE; \
} \
else \
{ \
status = ZB_FALSE; \
} \
}
/*! @} */ /* Alarms cluster commands */
/*! @internal @name Alarms cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
/*! @internal Number of attributes mandatory for reporting in Alarms cluster */
#define ZB_ZCL_ALARMS_REPORT_ATTR_COUNT 0
/*! @} */ /* Alarms cluster internals */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_alarms_init_server(void);
void zb_zcl_alarms_init_client(void);
#define ZB_ZCL_CLUSTER_ID_ALARMS_SERVER_ROLE_INIT zb_zcl_alarms_init_server
#define ZB_ZCL_CLUSTER_ID_ALARMS_CLIENT_ROLE_INIT zb_zcl_alarms_init_client
#endif /* ZB_ZCL_ALARMS_H */

View File

@@ -0,0 +1,817 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Analog Input cluster definitions
*/
#ifndef ZB_ZCL_ANALOG_INPUT_H
#define ZB_ZCL_ANALOG_INPUT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_ANALOG_INPUT
* @{
* @details
* The Analog Input cluster provides an interface for reading the value of an
* analog measurement and accessing various characteristics of that measurement.
* No cluster specific commands are received or generated.
*/
/* Cluster ZB_ZCL_CLUSTER_ID_ANALOG_INPUT */
/** @defgroup ZB_ZCL_ANALOG_INPUT_ATTRS_GROUP Analog Input cluster attributes
* @{
*/
/** @brief Analog Input cluster attribute identifiers
* @see ZCL spec, Analog Input (Basic) Cluster 3.14.2.4.1
*/
enum zb_zcl_analog_input_attr_e
{
/** @brief Description attribute, ZCL spec 3.14.11.4 */
ZB_ZCL_ATTR_ANALOG_INPUT_DESCRIPTION_ID = 0x001c,
/** @brief MaxPresentValue attribute, ZCL spec 3.14.11.5 */
ZB_ZCL_ATTR_ANALOG_INPUT_MAX_PRESENT_VALUE_ID = 0x0041,
/** @brief MinPresentValue attribute, ZCL spec 3.14.11.8 */
ZB_ZCL_ATTR_ANALOG_INPUT_MIN_PRESENT_VALUE_ID = 0x0045,
/** @brief OutOfService attribute, ZCL spec 3.14.11.1 */
ZB_ZCL_ATTR_ANALOG_INPUT_OUT_OF_SERVICE_ID = 0x0051,
/** @brief PresentValue attribute, ZCL spec 3.14.11.2 */
ZB_ZCL_ATTR_ANALOG_INPUT_PRESENT_VALUE_ID = 0x0055,
/** @brief Reliability attribute, ZCL spec 3.14.11.9 */
ZB_ZCL_ATTR_ANALOG_INPUT_RELIABILITY_ID = 0x0067,
/** @brief Resolution attribute, ZCL spec 3.14.11.11 */
ZB_ZCL_ATTR_ANALOG_INPUT_RESOLUTION_ID = 0x006a,
/** @brief StatusFlags attribute, ZCL spec 3.14.11.3 */
ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID = 0x006f,
/** @brief EngineeringUnits attribute, ZCL spec 3.14.11.10 */
ZB_ZCL_ATTR_ANALOG_INPUT_ENGINEERING_UNITS_ID = 0x0075,
/** @brief ApplicationType attribute, ZCL spec 3.14.11.19 */
ZB_ZCL_ATTR_ANALOG_INPUT_APPLICATION_TYPE_ID = 0x0100,
};
/**
* @brief StatusFlags attribute values.
* @see ZCL spec 3.14.11.3 for details.
*/
enum zb_zcl_analog_input_status_flags_value_e
{
ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_NORMAL = 0x00, /**< Normal (default) state. */
ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_IN_ALARM = 0x01, /**< In alarm bit. */
ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_FAULT = 0x02, /**< Fault bit. */
ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_OVERRIDDEN = 0x04, /**< Overridden bit. */
ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_OUT_OF_SERVICE = 0x08, /**< Out of service bit. */
};
/** @brief Reliability attribute values.
* @see ZCL spec 3.14.11.9 for details.
*/
enum zb_zcl_analog_input_reliability_value_e
{
ZB_ZCL_ANALOG_INPUT_RELIABILITY_NO_FAULT_DETECTED = 0x00,
ZB_ZCL_ANALOG_INPUT_RELIABILITY_NO_SENSOR = 0x01,
ZB_ZCL_ANALOG_INPUT_RELIABILITY_OVER_RANGE = 0x02,
ZB_ZCL_ANALOG_INPUT_RELIABILITY_UNDER_RANGE = 0x03,
ZB_ZCL_ANALOG_INPUT_RELIABILITY_OPEN_LOOP = 0x04,
ZB_ZCL_ANALOG_INPUT_RELIABILITY_SHORTED_LOOP = 0x05,
ZB_ZCL_ANALOG_INPUT_RELIABILITY_NO_OUTPUT = 0x06,
ZB_ZCL_ANALOG_INPUT_RELIABILITY_UNRELIABLE_OTHER = 0x07,
ZB_ZCL_ANALOG_INPUT_RELIABILITY_PROCESS_ERROR = 0x08,
/* 0x09 is for multistate clusters only */
ZB_ZCL_ANALOG_INPUT_RELIABILITY_CONFIGURATION_ERROR = 0x0a,
};
/** @defgroup ZB_ZCL_ANALOG_INPUT_APPLICATION_TYPES Analog Input cluster application types
* @{
* @details
* The ApplicationType attribute indicates the specific application usage
* for the cluster. ApplicationType is subdivided into Group, Type and
* an Index number, as follows:
*
* Group = Bits 24 to 31
* An indication of the cluster this attribute is part of. Analog Input
* clusters have Group = 0x00.
*
* Type = Bits 16 to 23
* The physical quantity that the PresentValue attribute of the cluster
* represents.
*
* Index = Bits 0 to 15
* The specific application usage of the cluster.
*/
#define ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(_type, _id) (((_type & 0xff) << 16) | (_id & 0xffff))
/** @brief Type values for Analog Input cluster applications
* @see ZCL spec 3.14.11.19.1
*/
enum zb_zcl_ai_application_types_e
{
ZB_ZCL_AI_APP_TYPE_TEMPERATURE,
ZB_ZCL_AI_APP_TYPE_HUMIDITY,
ZB_ZCL_AI_APP_TYPE_PRESSURE,
ZB_ZCL_AI_APP_TYPE_FLOW,
ZB_ZCL_AI_APP_TYPE_PERCENTAGE,
ZB_ZCL_AI_APP_TYPE_PPM,
ZB_ZCL_AI_APP_TYPE_RPM,
ZB_ZCL_AI_APP_TYPE_CURRENT_IN_AMPS,
ZB_ZCL_AI_APP_TYPE_FREQUENCY,
ZB_ZCL_AI_APP_TYPE_POWER_IN_WATTS,
ZB_ZCL_AI_APP_TYPE_POWER_IN_KILOWATTS,
ZB_ZCL_AI_APP_TYPE_ENERGY,
ZB_ZCL_AI_APP_TYPE_COUNT_UNITLESS,
ZB_ZCL_AI_APP_TYPE_ENTHALPY,
ZB_ZCL_AI_APP_TYPE_TIME,
/* Types 0x0f to 0xfe are reserved */
ZB_ZCL_AI_APP_TYPE_OTHER = 0xff
};
/** @defgroup ZB_ZCL_AI_TEMPERATURE_APP_TYPE Analog Input cluster representing temperature
* @{
*/
/** @brief Values for 'Temperature in degrees Celsius' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.1
*/
enum zb_zcl_ai_temperature_in_degrees_celsius_e
{
ZB_ZCL_AI_TEMPERATURE_2_PIPE_ENTERING = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_TEMPERATURE, 0x0000),
ZB_ZCL_AI_TEMPERATURE_2_PIPE_LEAVING,
ZB_ZCL_AI_TEMPERATURE_BOILER_ENTERING,
ZB_ZCL_AI_TEMPERATURE_BOILER_LEAVING,
ZB_ZCL_AI_TEMPERATURE_CHILLER_CHILLED_WATER_ENTERING,
ZB_ZCL_AI_TEMPERATURE_CHILLER_CHILLED_WATER_LEAVING,
ZB_ZCL_AI_TEMPERATURE_CHILLER_CONDENSER_WATER_ENTERING,
ZB_ZCL_AI_TEMPERATURE_CHILLER_CONDENSER_WATER_LEAVING,
ZB_ZCL_AI_TEMPERATURE_COLD_DECK,
ZB_ZCL_AI_TEMPERATURE_COOLING_COIL_DISCHARGE,
ZB_ZCL_AI_TEMPERATURE_COOLING_ENTERING_WATER,
ZB_ZCL_AI_TEMPERATURE_COOLING_LEAVING_WATER,
ZB_ZCL_AI_TEMPERATURE_CONDENSER_WATER_RETURN,
ZB_ZCL_AI_TEMPERATURE_CONDENSER_WATER_SUPPLY,
ZB_ZCL_AI_TEMPERATURE_DECOUPLE_LOOP_0, /* Note: Decouple Loop is duplicated in spec */
ZB_ZCL_AI_TEMPERATURE_BUILDING_LOAD,
ZB_ZCL_AI_TEMPERATURE_DECOUPLE_LOOP_1,
ZB_ZCL_AI_TEMPERATURE_DEW_POINT,
ZB_ZCL_AI_TEMPERATURE_DISCHARGE_AIR,
ZB_ZCL_AI_TEMPERATURE_DISCHARGE,
ZB_ZCL_AI_TEMPERATURE_EXHAUST_AIR_AFTER_HEAT_RECOVERY,
ZB_ZCL_AI_TEMPERATURE_EXHAUST_AIR,
ZB_ZCL_AI_TEMPERATURE_GLYCOL,
ZB_ZCL_AI_TEMPERATURE_HEAT_RECOVERY_AIR,
ZB_ZCL_AI_TEMPERATURE_HOT_DECK,
ZB_ZCL_AI_TEMPERATURE_HEAT_EXCHANGER_BYPASS,
ZB_ZCL_AI_TEMPERATURE_HEAT_EXCHANGER_ENTERING,
ZB_ZCL_AI_TEMPERATURE_HEAT_EXCHANGER_LEAVING,
ZB_ZCL_AI_TEMPERATURE_MECHANICAL_ROOM,
ZB_ZCL_AI_TEMPERATURE_MIXED_AIR_0, /* Note: Mixed Air is duplicated in spec */
ZB_ZCL_AI_TEMPERATURE_MIXED_AIR_1,
ZB_ZCL_AI_TEMPERATURE_OUTDOOR_AIR_DEWPOINT,
ZB_ZCL_AI_TEMPERATURE_OUTDOOR_AIR,
ZB_ZCL_AI_TEMPERATURE_PREHEAT_AIR,
ZB_ZCL_AI_TEMPERATURE_PREHEAT_ENTERING_WATER,
ZB_ZCL_AI_TEMPERATURE_PREHEAT_LEAVING_WATER,
ZB_ZCL_AI_TEMPERATURE_PRIMARY_CHILLED_WATER_RETURN,
ZB_ZCL_AI_TEMPERATURE_PRIMARY_CHILLED_WATER_SUPPLY,
ZB_ZCL_AI_TEMPERATURE_PRIMARY_HOT_WATER_RETURN,
ZB_ZCL_AI_TEMPERATURE_PRIMARY_HOT_WATER_SUPPLY,
ZB_ZCL_AI_TEMPERATURE_REHEAT_COIL_DISCHARGE,
ZB_ZCL_AI_TEMPERATURE_REHEAT_ENTERING_WATER,
ZB_ZCL_AI_TEMPERATURE_REHEAT_LEAVING_WATER,
ZB_ZCL_AI_TEMPERATURE_RETURN_AIR,
ZB_ZCL_AI_TEMPERATURE_SECONDARY_CHILLED_WATER_RETURN,
ZB_ZCL_AI_TEMPERATURE_SECONDARY_CHILLED_WATER_SUPPLY,
ZB_ZCL_AI_TEMPERATURE_SECONDARY_HW_RETURN,
ZB_ZCL_AI_TEMPERATURE_SECONDARY_HW_SUPPLY,
ZB_ZCL_AI_TEMPERATURE_SIDELOOP_RESET,
ZB_ZCL_AI_TEMPERATURE_SIDELOOP_SETPOINT,
ZB_ZCL_AI_TEMPERATURE_SIDELOOP,
ZB_ZCL_AI_TEMPERATURE_SOURCE,
ZB_ZCL_AI_TEMPERATURE_SUPPLY_AIR,
ZB_ZCL_AI_TEMPERATURE_SUPPLY_LOW_LIMIT,
ZB_ZCL_AI_TEMPERATURE_TOWER_BASIN,
ZB_ZCL_AI_TEMPERATURE_TWO_PIPE_LEAVING_WATER,
ZB_ZCL_AI_TEMPERATURE_RESERVED,
ZB_ZCL_AI_TEMPERATURE_ZONE_DEWPOINT,
ZB_ZCL_AI_TEMPERATURE_ZONE_SENSOR_SETPOINT,
ZB_ZCL_AI_TEMPERATURE_ZONE_SENSOR_SETPOINT_OFFSET,
ZB_ZCL_AI_TEMPERATURE_ZONE,
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_TEMPERATURE_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_TEMPERATURE, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_TEMPERATURE_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_HUMIDITY_APP_TYPE Analog Input cluster representing humidity
* @{
*/
/** @brief Values for 'Relative Humidity in %' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.2
*/
enum zb_zcl_ai_relative_humidity_in_percent_e
{
ZB_ZCL_AI_HUMIDITY_DISCHARGE = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_HUMIDITY, 0x0000),
ZB_ZCL_AI_HUMIDITY_EXHAUST,
ZB_ZCL_AI_HUMIDITY_HOT_DECK,
ZB_ZCL_AI_HUMIDITY_MIXED_AIR,
ZB_ZCL_AI_HUMIDITY_OUTDOOR_AIR,
ZB_ZCL_AI_HUMIDITY_RETURN,
ZB_ZCL_AI_HUMIDITY_SIDELOOP,
ZB_ZCL_AI_HUMIDITY_SPACE,
ZB_ZCL_AI_HUMIDITY_ZONE,
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_HUMIDITY_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_HUMIDITY, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_HUMIDITY_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_PRESSURE_APP_TYPE Analog Input cluster representing pressure
* @{
*/
/** @brief Values for 'Pressure in Pascal' type of Analog Input cluster
* @see 3.14.11.19.1.3
*/
enum zb_zcl_ai_pressure_in_pascal_e
{
ZB_ZCL_AI_PRESSURE_BOILER_PUMP_DIFFERENTIAL = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_PRESSURE, 0x0000),
ZB_ZCL_AI_PRESSURE_BUILDING_STATIC,
ZB_ZCL_AI_PRESSURE_COLD_DECK_DIFFERENTIAL_SENSOR,
ZB_ZCL_AI_PRESSURE_CHILLED_WATER_BUILDING_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_COLD_DECK_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_COLD_DECK_STATIC,
ZB_ZCL_AI_PRESSURE_CONDENSER_WATER_PUMP_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_DISCHARGE_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_DISCHARGE_STATIC_1,
ZB_ZCL_AI_PRESSURE_DISCHARGE_STATIC_2,
ZB_ZCL_AI_PRESSURE_EXHAUST_AIR_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_EXHAUST_AIR_STATIC,
ZB_ZCL_AI_PRESSURE_EXHAUST_DIFFERENTIAL_0, /* Note: Exhaust Differential is duplicated in spec */
ZB_ZCL_AI_PRESSURE_EXHAUST_DIFFERENTIAL_1,
ZB_ZCL_AI_PRESSURE_HOT_DECK_DIFFERENTIAL_0, /* Note: Hot Deck Differential is duplicated in spec */
ZB_ZCL_AI_PRESSURE_HOT_DECK_DIFFERENTIAL_1,
ZB_ZCL_AI_PRESSURE_HOT_DECK_STATIC,
ZB_ZCL_AI_PRESSURE_HOT_WATER_BLDG_DIFF,
ZB_ZCL_AI_PRESSURE_HEAT_EXCHANGER_STEAM,
ZB_ZCL_AI_PRESSURE_MIN_OUTDOOR_AIR_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_OUTDOOR_AIR_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_PRIMARY_CHILLED_WATER_PUMP_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_PRIMATY_HOT_WATER_PUMP_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_RELIEF_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_RETURN_AIR_STATIC,
ZB_ZCL_AI_PRESSURE_RETURN_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_SECONDARY_CHILLED_WATER_PUMP_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_SECONDARY_HOT_WATER_PUMP_DIFFERENTIAL,
ZB_ZCL_AI_PRESSURE_SIDELOOP,
ZB_ZCL_AI_PRESSURE_STEAM,
ZB_ZCL_AI_PRESSURE_SUPPLY_DIFFERENTIAL_SENSOR,
/* 0x0200 to 0xffffe are Vendor defined */
ZB_ZCL_AI_PRESSURE_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_PRESSURE, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_PRESSURE_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_FLOW_APP_TYPE Analog Input cluster representing flow
* @{
*/
/** @brief Values for 'Flow in Liters per Second' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.4
*/
enum zb_zcl_ai_flow_in_liters_per_second_e
{
ZB_ZCL_AI_FLOW_CHILLED_WATER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_FLOW, 0x0000),
ZB_ZCL_AI_FLOW_CHILLER_CHILLED_WATER,
ZB_ZCL_AI_FLOW_CHILLER_CONDENSER_WATER,
ZB_ZCL_AI_FLOW_COLD_DECK,
ZB_ZCL_AI_FLOW_DECOUPLE_LOOP,
ZB_ZCL_AI_FLOW_DISCHARGE,
ZB_ZCL_AI_FLOW_EXHAUST_FAN,
ZB_ZCL_AI_FLOW_EXHAUST,
ZB_ZCL_AI_FLOW_FAN,
ZB_ZCL_AI_FLOW_HOT_DECK,
ZB_ZCL_AI_FLOW_HOT_WATER,
ZB_ZCL_AI_FLOW_MIN_OUTDOOR_AIR_FAN,
ZB_ZCL_AI_FLOW_MIN_OUTDOOR_AIR,
ZB_ZCL_AI_FLOW_OUTDOOR_AIR,
ZB_ZCL_AI_FLOW_PRIMARY_CHILLED_WATER,
ZB_ZCL_AI_FLOW_RELIEF_FAN,
ZB_ZCL_AI_FLOW_RELIEF,
ZB_ZCL_AI_FLOW_RETURN_FAN,
ZB_ZCL_AI_FLOW_RETURN,
ZB_ZCL_AI_FLOW_SECONDARY_CHILLED_WATER_FLOW,
ZB_ZCL_AI_FLOW_SUPPLY_FAN,
ZB_ZCL_AI_FLOW_TOWER_FAN,
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_FLOW_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_FLOW, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_FLOW_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_PERCENTAGE_APP_TYPE Analog Input cluster representing percentage
* @{
*/
/** @brief Values for 'Percentage %' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.5
*/
enum zb_zcl_ai_percentage_e
{
ZB_ZCL_AI_PERCENTAGE_CHILLER_FULL_LOAD_AMPERAGE = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_PERCENTAGE, 0x0000),
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_PERCENTAGE_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_PERCENTAGE, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_PERCENTAGE_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_PPM_APP_TYPE Analog Input cluster representing parts per million
* @{
*/
/** @brief Values for 'Parts per Million PPM' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.6
*/
enum zb_zcl_ai_ppm_e
{
ZB_ZCL_AI_PPM_RETURN_CARBON_DIOXIDE = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_PPM, 0x0000),
ZB_ZCL_AI_PPM_ZONE_CARBON_DIOXIDE,
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_PPM_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_PPM, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_PPM_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_RPM_APP_TYPE Analog Input cluster representing rotational speed
* @{
*/
/** @brief Values for 'Rotational Speed in RPM' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.7
*/
enum zb_zcl_ai_rpm_e
{
ZB_ZCL_AI_RPM_EXHAUS_FAN_REMOTE = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_RPM, 0x0000),
ZB_ZCL_AI_RPM_HEAT_RECOVERY_WHEEL_REMOTE,
ZB_ZCL_AI_RPM_MIN_OUTDOOR_AIR_FAN_REMOTE,
ZB_ZCL_AI_RPM_RELIEF_FAN_REMOTE,
ZB_ZCL_AI_RPM_RETURN_FAN_REMOTE,
ZB_ZCL_AI_RPM_SUPPLY_FAN_REMOTE,
ZB_ZCL_AI_RPM_VARIABLE_SPEED_DRIVE_MOTOR,
ZB_ZCL_AI_RPM_VARIABLE_SPEED_DRIVE_SETPOINT,
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_RPM_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_RPM, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_RPM_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_CURRENT_APP_TYPE Analog Input cluster representing current
* @{
*/
/** @brief Values for 'Current in Amps' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.8
*/
enum zb_zcl_ai_current_e
{
ZB_ZCL_AI_CURRENT_CHILLER_AMPS = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_CURRENT_IN_AMPS, 0x0000),
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_CURRENT_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_CURRENT_IN_AMPS, 0xffff),
};
/** @} */ /* end of ZB_ZCL_AI_CURRENT_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_FREQUENCY_APP_TYPE Analog Input cluster representing frequency
* @{
*/
/** @brief Values for 'Frequency in Hz' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.9
*/
enum zb_zcl_ai_frequency_e
{
ZB_ZCL_AI_FREQUENCY_VARIABLE_SPEED_DRIVE_OUTPUT = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_FREQUENCY, 0x0000),
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_FREQUENCY_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_FREQUENCY, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_FREQUENCY_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_POWER_IN_WATTS_APP_TYPE Analog Input cluster representing power in Watts
* @{
*/
/** @brief Values for 'Power in Watts' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.10
*/
enum zb_zcl_ai_power_in_watts_e
{
ZB_ZCL_AI_POWER_IN_WATTS_CONSUMPTION = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_POWER_IN_WATTS, 0x0000),
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_POWER_IN_WATTS_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_POWER_IN_WATTS, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_POWER_IN_WATTS_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_POWER_IN_KILOWATTS_APP_TYPE Analog Input cluster representing power in kiloWatts
* @{
*/
/** @brief Values for 'Power in kW' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.11
*/
enum zb_zcl_ai_power_in_kilowatts_e
{
ZB_ZCL_AI_POWER_IN_KILOWATTS_ABSOLUTE = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_POWER_IN_KILOWATTS, 0x0000),
ZB_ZCL_AI_POWER_IN_KILOWATTS_CONSUMPTION,
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_POWER_IN_KILOWATTS_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_POWER_IN_KILOWATTS, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_POWER_IN_KILOWATTS_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_ENERGY_APP_TYPE Analog Input cluster representing energy
* @{
*/
/** @brief Values for 'Energy in kWH' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.12
*/
enum zb_zcl_ai_energy_kwh_e
{
ZB_ZCL_AI_ENERGY_KWH_VARIABLE_SPEED_DRIVE = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_ENERGY, 0x0000),
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_ENERGY_KWH_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_ENERGY, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_ENERGY_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_COUNT_UNITLESS_APP_TYPE Analog Input cluster representing unitless count
* @{
*/
/** @brief Values for 'Count - Unitless' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.13
*/
enum zb_zcl_ai_count_unitless_e
{
ZB_ZCL_AI_COUNT_UNITLESS_COUNT = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_COUNT_UNITLESS, 0x0000),
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_COUNT_UNITLESS_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_COUNT_UNITLESS, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_COUNT_UNITLESS_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_ENTHALPY_APP_TYPE Analog Input cluster representing enthalpy
* @{
*/
/** @brief Values for 'Enthalpy in KJoules per Kg' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.14
*/
enum zb_zcl_ai_enthaply_e
{
ZB_ZCL_AI_ENTHALPY_OUTDOOR_AIR = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_ENTHALPY, 0x0000),
ZB_ZCL_AI_ENTHALPY_RETURN_AIR,
ZB_ZCL_AI_ENTHALPY_SPACE,
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_ENTHALPY_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_ENTHALPY, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_ENTHALPY_APP_TYPE group */
/** @defgroup ZB_ZCL_AI_TIME_APP_TYPE Analog Input cluster representing time
* @{
*/
/** @brief Values for 'Time in Seconds' type of Analog Input cluster
* @see ZCL spec 3.14.11.19.1.15
*/
enum zb_zcl_ai_time_e
{
ZB_ZCL_AI_TIME_RELATIVE = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_TIME, 0x0000),
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AI_TIME_OTHER = ZB_ZCL_AI_SET_APP_TYPE_WITH_ID(ZB_ZCL_AI_APP_TYPE_TIME, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AI_TIME_APP_TYPE group */
/** @} */ /* end of ZB_ZCL_ANALOG_INPUT_APPLICATION_TYPES */
/** @brief Default value for Analog Input cluster revision global attribute */
#define ZB_ZCL_ANALOG_INPUT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for Description attribute */
#define ZB_ZCL_ANALOG_INPUT_DESCRIPTION_DEFAULT_VALUE {0}
/** @brief Default value for OutOfService attribute */
#define ZB_ZCL_ANALOG_INPUT_OUT_OF_SERVICE_DEFAULT_VALUE ZB_FALSE
/** @brief Default value for Reliability attribute */
#define ZB_ZCL_ANALOG_INPUT_RELIABILITY_DEFAULT_VALUE ZB_ZCL_ANALOG_INPUT_RELIABILITY_NO_FAULT_DETECTED
/** @brief Default value for StatusFlags attribute */
#define ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_DEFAULT_VALUE ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_NORMAL
/** @brief StatusFlags attribute minimum value */
#define ZB_ZCL_ANALOG_INPUT_STATUS_FLAGS_MIN_VALUE 0
/** @brief StatusFlags attribute maximum value */
#define ZB_ZCL_ANALOG_INPUT_STATUS_FLAGS_MAX_VALUE 0x0f
/** @cond internals_doc */
/** @name Analog Input cluster internals
* Internal structures for Analog Input cluster
* @{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_DESCRIPTION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_DESCRIPTION_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_MAX_PRESENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_MAX_PRESENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_MIN_PRESENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_MIN_PRESENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_OUT_OF_SERVICE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_OUT_OF_SERVICE_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_PRESENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_PRESENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_RELIABILITY_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_RELIABILITY_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_RESOLUTION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_RESOLUTION_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_ENGINEERING_UNITS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_ENGINEERING_UNITS_ID, \
ZB_ZCL_ATTR_TYPE_16BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_INPUT_APPLICATION_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_INPUT_APPLICATION_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** Number of attributes mandatory for reporting in Analog Input cluster */
#define ZB_ZCL_ANALOG_INPUT_REPORT_ATTR_COUNT 2
/** @} */
/** @endcond */ /* Analog Input cluster internals */
/** @brief Declare attribute list for Analog Input cluster
* @param attr_list - attribute list name
* @param description - pointer to variable storing Description attribute value
* @param max_present_value - pointer to variable storing MaxPresentValue attribute value
* @param min_present_value - pointer to variable storing MinPresentValue attribute value
* @param out_of_service - pointer to variable storing OutOfService attribute value
* @param present_value - pointer to variable storing PresentValue attribute value
* @param reliability - pointer to variable storing Reliability attribute value
* @param resolution - pointer to variable storing Resolution attribute value
* @param status_flags - pointer to variable storing StatusFlags attribute value
* @param engineering_units - pointer to variable storing EngineeringUnits attribute value
* @param app_type - pointer to variable storing ApplicationType attribute value
*/
#define ZB_ZCL_DECLARE_ANALOG_INPUT_ATTRIB_LIST( \
attr_list, \
description, \
max_present_value, \
min_present_value, \
out_of_service, \
present_value, \
reliability, \
resolution, \
status_flags, \
engineering_units, \
app_type) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_ANALOG_INPUT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_DESCRIPTION_ID, (description)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_MAX_PRESENT_VALUE_ID, (max_present_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_MIN_PRESENT_VALUE_ID, (min_present_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_OUT_OF_SERVICE_ID, (out_of_service)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_PRESENT_VALUE_ID, (present_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_RELIABILITY_ID, (reliability)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_RESOLUTION_ID, (resolution)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID, (status_flags)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_ENGINEERING_UNITS_ID, (engineering_units)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_INPUT_APPLICATION_TYPE_ID, (app_type)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @} */ /* end of ZB_ZCL_ANALOG_INPUT_ATTRS_GROUP group */
/** @defgroup ZB_ZCL_ANALOG_INPUT_ATTR_API Analog Input cluster attribute value manipulation API
* @{
*/
/** @brief Set normal operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_ANALOG_INPUT_SET_NORMAL_MODE(ep) \
{ \
zb_uint8_t val; \
\
val = ZB_FALSE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_INPUT_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
val = ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_NORMAL; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
}
/** @brief Set Out of service operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_ANALOG_INPUT_SET_OUT_OF_SERVICE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
val = ZB_TRUE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_INPUT_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_OUT_OF_SERVICE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @brief Set overridden operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_ANALOG_INPUT_SET_OVERRIDDEN_MODE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_OVERRIDDEN;\
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @brief Set fault status flag
* @param ep - endpoint number
*/
#define ZB_ZCL_ANALOG_INPUT_SET_FAULT_STATUS(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_ANALOG_INPUT_STATUS_FLAG_FAULT; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_INPUT_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @} */ /* end of ZB_ZCL_ANALOG_INPUT_ATTR_API group */
/** @} */ /* ZCL Analog Input cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_analog_input_init_server(void);
void zb_zcl_analog_input_init_client(void);
#define ZB_ZCL_CLUSTER_ID_ANALOG_INPUT_SERVER_ROLE_INIT zb_zcl_analog_input_init_server
#define ZB_ZCL_CLUSTER_ID_ANALOG_INPUT_CLIENT_ROLE_INIT zb_zcl_analog_input_init_client
#endif /* ZB_ZCL_ANALOG_INPUT_H */

View File

@@ -0,0 +1,565 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Analog Value cluster definitions */
#ifndef ZB_ZCL_ANALOG_VALUE_H
#define ZB_ZCL_ANALOG_VALUE_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_ANALOG_VALUE
* @{
* @details
* The Analog Value (Basic) cluster provides an interface for setting
* an analog value, typically used as a control system parameter, and
* accessing various characteristics of that value.
*/
/* ZB_ZCL_CLUSTER_ID_ANALOG_VALUE = 0x000e defined in zb_zcl_common.h ZCL spec 3.14.4 */
/** @name Analog Value cluster attributes
* @{
*/
/** @brief Analog Value cluster attribute identifiers
* @see ZCL spec, Analog Value (Basic) Cluster 3.14.4.4.2
*/
enum zb_zcl_analog_value_attr_e
{
/** @brief Description attribute, ZCL spec 3.14.11.4 */
ZB_ZCL_ATTR_ANALOG_VALUE_DESCRIPTION_ID = 0x001c,
/** @brief OutOfService attribute, ZCL spec 3.14.11.1 */
ZB_ZCL_ATTR_ANALOG_VALUE_OUT_OF_SERVICE_ID = 0x0051,
/** @brief PresentValue attribute, ZCL spec 3.14.11.2 */
ZB_ZCL_ATTR_ANALOG_VALUE_PRESENT_VALUE_ID = 0x0055,
// TODO: Support PriorityArray attribute
// @brief PriorityArray attribute, ZCL spec 3.14.11.6
//ZB_ZCL_ATTR_ANALOG_VALUE_PRIORITY_ARRAY_ID = 0x0057,
/** @brief Reliability attribute, ZCL spec 3.14.11.9 */
ZB_ZCL_ATTR_ANALOG_VALUE_RELIABILITY_ID = 0x0067,
/** @brief RelinquishDefault attribute, ZCL spec 3.14.11.7 */
ZB_ZCL_ATTR_ANALOG_VALUE_RELINQUISH_DEFAULT_ID = 0x0068,
/** @brief StatusFlags attribute, ZCL spec 3.14.11.3 */
ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID = 0x006f,
/** @brief EngineeringUnits attribute, ZCL spec 3.14.11.10 */
ZB_ZCL_ATTR_ANALOG_VALUE_ENGINEERING_UNITS_ID = 0x0075,
/** @brief ApplicationType attribute, ZCL spec 3.14.11.19 */
ZB_ZCL_ATTR_ANALOG_VALUE_APPLICATION_TYPE_ID = 0x0100,
};
/**
* @brief StatusFlags attribute values.
* @see ZCL spec 3.14.11.3 for details.
*/
enum zb_zcl_analog_value_status_flags_value_e
{
ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_NORMAL = 0x00, /**< Normal (default) state. */
ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_IN_ALARM = 0x01, /**< In alarm bit. */
ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_FAULT = 0x02, /**< Fault bit. */
ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_OVERRIDDEN = 0x04, /**< Overridden bit. */
ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_OUT_OF_SERVICE = 0x08, /**< Out of service bit. */
};
/** @brief Reliability attribute values.
* @see ZCL spec 3.14.11.9 for details.
*/
enum zb_zcl_analog_value_reliability_value_e
{
ZB_ZCL_ANALOG_VALUE_RELIABILITY_NO_FAULT_DETECTED = 0x00, /**< No fault detected */
ZB_ZCL_ANALOG_VALUE_RELIABILITY_NO_SENSOR = 0x01, /**< No sensor */
ZB_ZCL_ANALOG_VALUE_RELIABILITY_OVER_RANGE = 0x02, /**< Over range */
ZB_ZCL_ANALOG_VALUE_RELIABILITY_UNDER_RANGE = 0x03, /**< Under range */
ZB_ZCL_ANALOG_VALUE_RELIABILITY_OPEN_LOOP = 0x04, /**< Open loop */
ZB_ZCL_ANALOG_VALUE_RELIABILITY_SHORTED_LOOP = 0x05, /**< Shorted loop */
ZB_ZCL_ANALOG_VALUE_RELIABILITY_NO_OUTPUT = 0x06, /**< No output */
ZB_ZCL_ANALOG_VALUE_RELIABILITY_UNRELIABLE_OTHER = 0x07, /**< Unreliable other */
ZB_ZCL_ANALOG_VALUE_RELIABILITY_PROCESS_ERROR = 0x08, /**< Process error */
/* 0x09 is for multistate clusters only */
ZB_ZCL_ANALOG_VALUE_RELIABILITY_CONFIGURATION_ERROR = 0x0a, /**< Configuration error */
};
/** @name Analog Value cluster application types
* @{
* @details
* The ApplicationType attribute indicates the specific application usage
* for the cluster. ApplicationType is subdivided into Group, Type and
* an Index number, as follows:
*
* - Group = Bits 24 to 31
* An indication of the cluster this attribute is part of. Analog Value
* clusters have Group = 0x02.
*
* - Type = Bits 16 to 23
* The physical quantity that the PresentValue attribute of the cluster
* represents.
*
* - Index = Bits 0 to 15
* The specific application usage of the cluster.
*/
#define ZB_ZCL_AV_GROUP_ID 0x02
#define ZB_ZCL_AV_SET_APP_TYPE_WITH_ID(_type, _id) ((ZB_ZCL_AV_GROUP_ID << 24) | ((_type & 0xff) << 16) | (_id & 0xffff))
/** @defgroup ZB_ZCL_ANALOG_VALUE_APP_TYPES Analog Value cluster application types */
/** @{ */
/** @brief Type values for Analog Value cluster applications
* @see ZCL spec 3.14.11.19.3
*/
enum zb_zcl_av_application_types_e
{
ZB_ZCL_AV_APP_TYPE_TEMPERATURE = 0x00, /**< Temperature */
ZB_ZCL_AV_APP_TYPE_AREA = 0x01, /**< Area */
ZB_ZCL_AV_APP_TYPE_MULTIPLIER = 0x02, /**< Multiplier */
ZB_ZCL_AV_APP_TYPE_FLOW = 0x03, /**< Flow */
ZB_ZCL_AV_APP_TYPE_OTHER = 0xff, /**< Other */
};
/** @name Analog Value cluster representing temperature
* @{
*/
/** @brief Values for 'Temperature in degrees Celsius' type of Analog Value cluster
* @see ZCL spec 3.14.11.19.3.1
*/
enum zb_zcl_av_temperature_in_degrees_celsius_e
{
ZB_ZCL_AV_TEMPERATURE_SETPOINT_OFFSET_0 /**< Setpoint Offset */
= ZB_ZCL_AV_SET_APP_TYPE_WITH_ID(ZB_ZCL_AV_APP_TYPE_TEMPERATURE, 0x0000),
ZB_ZCL_AV_TEMPERATURE_TEMP_DEADBAND, /**< Temp deadband */
ZB_ZCL_AV_TEMPERATURE_OCCUPIED_HEATING_SETPOINT, /**< Occupied heating setpoint */
ZB_ZCL_AV_TEMPERATURE_UNOCCUPIED_HEATING_SETPOINT, /**< Unoccupied heating setpoint */
ZB_ZCL_AV_TEMPERATURE_OCCUPIED_COOLING_SETPOINT, /**< Occupied cooling setpoint */
ZB_ZCL_AV_TEMPERATURE_UNOCCUPIED_COOLING_SETPOINT, /**< Unoccupied cooling setpoint */
ZB_ZCL_AV_TEMPERATURE_STANDBY_HEAT_SETPOINT, /**< Standby heat setpoint */
ZB_ZCL_AV_TEMPERATURE_STANDBY_COOLING_SETPOINT, /**< Standby cooling setpoint */
ZB_ZCL_AV_TEMPERATURE_EFFECTIVE_OCCUPIED_HEATING_SETPOINT, /**< Effective occupied heating setpoint */
ZB_ZCL_AV_TEMPERATURE_EFFECTIVE_UNOCCUPIED_HEATING_SETPOINT, /**< Effective unoccupied heating setpoint */
ZB_ZCL_AV_TEMPERATURE_EFFECTIVE_OCCUPIED_COOLING_SETPOINT, /**< Effective occupied cooling setpoint */
ZB_ZCL_AV_TEMPERATURE_EFFECTIVE_UNOCCUPIED_COOLING_SETPOINT, /**< Effective unoccupied cooling setpoint */
ZB_ZCL_AV_TEMPERATURE_EFFECTIVE_STANDBY_HEAT_SETPOINT, /**< Effective standby heat setpoint */
ZB_ZCL_AV_TEMPERATURE_EFFECTIVE_STANDBY_COOLING_SETPOINT, /**< Effective standby cooling setpoint */
ZB_ZCL_AV_TEMPERATURE_SETPOINT_OFFSET_2, /**< Setpoint offset 2 */
ZB_ZCL_AV_TEMPERATURE_SETPOINT_SHIFT, /**< Setpoint shift */
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AV_TEMPERATURE_OTHER /**< Other*/
= ZB_ZCL_AV_SET_APP_TYPE_WITH_ID(ZB_ZCL_AV_APP_TYPE_TEMPERATURE, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AV_TEMPERATURE_APP_TYPE group */
/** @name Analog Value cluster representing Area
* @{
*/
/** @brief Values for 'Area in Square Metres' type of Analog Value cluster
* @see 3.14.11.19.3.2
*/
enum zb_zcl_av_area_in_squares_meters
{
ZB_ZCL_AV_AREA_DUCT_AREA /**< Duct Area */
= ZB_ZCL_AV_SET_APP_TYPE_WITH_ID(ZB_ZCL_AV_APP_TYPE_AREA, 0x0000),
/* 0x0200 to 0xffffe are Vendor defined */
ZB_ZCL_AV_AREA_OTHER /**< Other */
= ZB_ZCL_AV_SET_APP_TYPE_WITH_ID(ZB_ZCL_AV_APP_TYPE_AREA, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AV_AREA_APP_TYPE group */
/** @brief Values for 'Multiplier - Number' type of Analog Value cluster
* @see 3.14.11.19.3.3
*/
enum zb_zcl_av_multiplier_number_e
{
ZB_ZCL_AV_MULTIPLIER_DUCT_MULTIPLIER /**< Duct Area */
= ZB_ZCL_AV_SET_APP_TYPE_WITH_ID(ZB_ZCL_AV_APP_TYPE_MULTIPLIER, 0x0000),
/* 0x0200 to 0xffffe are Vendor defined */
ZB_ZCL_AV_MULTIPLIER_OTHER /**< Other */
= ZB_ZCL_AV_SET_APP_TYPE_WITH_ID(ZB_ZCL_AV_APP_TYPE_MULTIPLIER, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AV_AREA_APP_TYPE group */
/** @name Analog Value cluster representing flow
* @{
*/
/** @brief Values for 'Flow in Litres per Second' type of Analog Value cluster
* @see ZCL spec 3.14.11.19.3.4
*/
enum zb_zcl_av_flow_in_liters_per_second_e
{
ZB_ZCL_AV_FLOW_MINIMUM_AIR_FLOW /**< Minimum Air Flow */
= ZB_ZCL_AV_SET_APP_TYPE_WITH_ID(ZB_ZCL_AV_APP_TYPE_FLOW, 0x0000),
ZB_ZCL_AV_FLOW_MAXIMUM_AIR_FLOW, /**< Maximum Air Flow */
ZB_ZCL_AV_FLOW_HEATING_MINIMUM_AIR_FLOW, /**< Heating Minimum Air Flow */
ZB_ZCL_AV_FLOW_HEATING_MAXIMUM_AIR_FLOW, /**< Heating Maximum Air Flow */
ZB_ZCL_AV_FLOW_STANDBY_MINIMUM_AIR_FLOW, /**< Standby Minimum Air Flow */
ZB_ZCL_AV_FLOW_STANDBY_MAXIMUM_AIR_FLOW, /**< Standby Maximum Air Flow */
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_AV_FLOW_OTHER /**< Other */
= ZB_ZCL_AV_SET_APP_TYPE_WITH_ID(ZB_ZCL_AV_APP_TYPE_FLOW, 0xffff)
};
/** @} */ /* end of ZB_ZCL_AV_FLOW_APP_TYPE group */
/** @} */ /* end of ZB_ZCL_ANALOG_VALUE_APPLICATION_TYPES */
/** @brief Default value for Analog Value cluster revision global attribute */
#define ZB_ZCL_ANALOG_VALUE_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for Description attribute */
#define ZB_ZCL_ANALOG_VALUE_DESCRIPTION_DEFAULT_VALUE {0}
/** @brief Default value for OutOfService attribute */
#define ZB_ZCL_ANALOG_VALUE_OUT_OF_SERVICE_DEFAULT_VALUE ZB_FALSE
/** @brief Default value for Reliability attribute */
#define ZB_ZCL_ANALOG_VALUE_RELIABILITY_DEFAULT_VALUE ZB_ZCL_ANALOG_VALUE_RELIABILITY_NO_FAULT_DETECTED
/** @brief Default value for StatusFlags attribute */
#define ZB_ZCL_ANALOG_VALUE_STATUS_FLAGS_DEFAULT_VALUE ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_NORMAL
/** @brief StatusFlags attribute minimum value */
#define ZB_ZCL_ANALOG_VALUE_STATUS_FLAGS_MIN_VALUE 0
/** @brief StatusFlags attribute maximum value */
#define ZB_ZCL_ANALOG_VALUE_STATUS_FLAGS_MAX_VALUE 0x0f
/** @cond internals_doc */
/** @name Analog Value cluster internals
* Internal structures for Analog Value cluster
* @{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_VALUE_DESCRIPTION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_VALUE_DESCRIPTION_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_VALUE_OUT_OF_SERVICE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_VALUE_OUT_OF_SERVICE_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_VALUE_PRESENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_VALUE_PRESENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_VALUE_RELIABILITY_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_VALUE_RELIABILITY_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_VALUE_RELINQUISH_DEFAULT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_VALUE_RELINQUISH_DEFAULT_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_VALUE_ENGINEERING_UNITS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_VALUE_ENGINEERING_UNITS_ID, \
ZB_ZCL_ATTR_TYPE_16BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ANALOG_VALUE_APPLICATION_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ANALOG_VALUE_APPLICATION_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** Number of attributes mandatory for reporting in Analog Value cluster */
#define ZB_ZCL_ANALOG_VALUE_REPORT_ATTR_COUNT 0
/** @} */
/** @endcond */ /* Analog Value cluster internals */
/** @brief Declare attribute list for Analog Value cluster
* @param attr_list - attribute list name
* @param description - pointer to variable storing Description attribute value
* @param out_of_service - pointer to variable storing OutOfService attribute value
* @param present_value - pointer to variable storing PresentValue attribute value
* @param reliability - pointer to variable storing Reliability attribute value
* @param relinquish_default - pointer to variable storing RelinquishDefault attribute value
* @param status_flags - pointer to variable storing StatusFlags attribute value
* @param engineering_units - pointer to variable storing EngineeringUnits attribute value
* @param app_type - pointer to variable storing ApplicationType attribute value
*/
#define ZB_ZCL_DECLARE_ANALOG_VALUE_ATTRIB_LIST( \
attr_list, \
description, \
out_of_service, \
present_value, \
reliability, \
relinquish_default, \
status_flags, \
engineering_units, \
app_type) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_ANALOG_VALUE) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_VALUE_DESCRIPTION_ID, (description)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_VALUE_OUT_OF_SERVICE_ID, (out_of_service)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_VALUE_PRESENT_VALUE_ID, (present_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_VALUE_RELIABILITY_ID, (reliability)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_VALUE_RELINQUISH_DEFAULT_ID, (relinquish_default)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID, (status_flags)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_VALUE_ENGINEERING_UNITS_ID, (engineering_units)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ANALOG_VALUE_APPLICATION_TYPE_ID, (app_type)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! Maximum length of Description string field */
#define ZB_ZCL_ANALOG_VALUE_DESCRIPTION_MAX_LEN 16
/**
* @brief Analog Value cluster attributes
*/
typedef struct zb_zcl_analog_value_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_ANALOG_VALUE_DESCRIPTION_ID
* @see ZB_ZCL_ATTR_ANALOG_VALUE_DESCRIPTION_ID
*/
zb_char_t description[ZB_ZCL_ANALOG_VALUE_DESCRIPTION_MAX_LEN + 1];
/** @copydoc ZB_ZCL_ATTR_ANALOG_VALUE_OUT_OF_SERVICE_ID
* @see ZB_ZCL_ATTR_ANALOG_VALUE_OUT_OF_SERVICE_ID
*/
zb_bool_t out_of_service;
/** @copydoc ZB_ZCL_ATTR_ANALOG_VALUE_PRESENT_VALUE_ID
* @see ZB_ZCL_ATTR_ANALOG_VALUE_PRESENT_VALUE_ID
*/
zb_single_t present_value;
/** @copydoc ZB_ZCL_ATTR_ANALOG_VALUE_RELIABILITY_ID
* @see ZB_ZCL_ATTR_ANALOG_VALUE_RELIABILITY_ID
*/
zb_uint8_t reliability;
/** @copydoc ZB_ZCL_ATTR_ANALOG_VALUE_RELINQUISH_DEFAULT_ID
* @see ZB_ZCL_ATTR_ANALOG_VALUE_RELINQUISH_DEFAULT_ID
*/
zb_single_t relinquish_default;
/** @copydoc ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID
* @see ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID
*/
zb_uint8_t status_flags;
/** @copydoc ZB_ZCL_ATTR_ANALOG_VALUE_ENGINEERING_UNITS_ID
* @see ZB_ZCL_ATTR_ANALOG_VALUE_ENGINEERING_UNITS_ID
*/
zb_uint16_t engineering_units;
/** @copydoc ZB_ZCL_ATTR_ANALOG_VALUE_APPLICATION_TYPE_ID
* @see ZB_ZCL_ATTR_ANALOG_VALUE_APPLICATION_TYPE_ID
*/
zb_uint32_t application_type;
} zb_zcl_analog_value_attrs_t;
/** @brief Declare attribute list for Analog Value cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of @ref zb_zcl_analog_value_attrs_t type
* (containing Analog Value cluster attributes)
*/
#define ZB_ZCL_DECLARE_ANALOG_VALUE_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_ANALOG_VALUE_ATTRIB_LIST(attr_list, \
&attrs.description, \
&attrs.out_of_service, \
&attrs.present_value, \
&attrs.reliability, \
&attrs.relinquish_default, \
&attrs.status_flags, \
&attrs.engineering_units, \
&attrs.application_type)
/** @} */ /* end of ZB_ZCL_ANALOG_VALUE_ATTRS_GROUP group */
/** @name Analog Value cluster attribute value manipulation API
* @{
*/
/** @brief Set normal operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_ANALOG_VALUE_SET_NORMAL_MODE(ep) \
{ \
zb_uint8_t val; \
\
val = ZB_FALSE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_VALUE_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
val = ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_NORMAL; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
}
/** @brief Set Out of service operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_ANALOG_VALUE_SET_OUT_OF_SERVICE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
val = ZB_TRUE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_VALUE_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_OUT_OF_SERVICE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @brief Set overridden operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_ANALOG_VALUE_SET_OVERRIDDEN_MODE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_OVERRIDDEN;\
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @brief Set fault status flag
* @param ep - endpoint number
*/
#define ZB_ZCL_ANALOG_VALUE_SET_FAULT_STATUS(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_ANALOG_VALUE_STATUS_FLAG_FAULT; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_ANALOG_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_ANALOG_VALUE_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @} */ /* end of ZB_ZCL_ANALOG_VALUE_ATTR_API group */
/** @} */ /* ZCL Analog Value cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_analog_value_init_server(void);
void zb_zcl_analog_value_init_client(void);
#define ZB_ZCL_CLUSTER_ID_ANALOG_VALUE_SERVER_ROLE_INIT zb_zcl_analog_value_init_server
#define ZB_ZCL_CLUSTER_ID_ANALOG_VALUE_CLIENT_ROLE_INIT zb_zcl_analog_value_init_client
#endif /* ZB_ZCL_ANALOG_VALUE_H */ /**< H */

View File

@@ -0,0 +1,595 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: ZCL Basic Cluster definitions
*/
#ifndef ZB_ZCL_BASIC_H
#define ZB_ZCL_BASIC_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_BASIC
* @{
* @details
* According to ZCL spec, clause 3.2, Basic cluster contains attributes only. These attributes
* could be queried with @ref ZB_ZCL_COMMANDS "general ZCL commands".
*/
/** @name Basic cluster attributes
* @{
*/
/** @brief Basic cluster information attribute set identifiers
@see ZCL spec, subclauses 3.2.2.2.1 to 3.2.2.2.9
*/
enum zb_zcl_basic_info_attr_e
{
/** ZCL version attribute */
ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID = 0x0000,
/** Application version attribute */
ZB_ZCL_ATTR_BASIC_APPLICATION_VERSION_ID = 0x0001,
/** Stack version attribute */
ZB_ZCL_ATTR_BASIC_STACK_VERSION_ID = 0x0002,
/** Hardware version attribute */
ZB_ZCL_ATTR_BASIC_HW_VERSION_ID = 0x0003,
/** Manufacturer name attribute */
ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID = 0x0004,
/** Model identifier attribute */
ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID = 0x0005,
/** Date code attribute */
ZB_ZCL_ATTR_BASIC_DATE_CODE_ID = 0x0006,
/** Power source attribute */
ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID = 0x0007,
/** The GenericDeviceClass attribute defines the field of application of the
* GenericDeviceType attribute. */
ZB_ZCL_ATTR_BASIC_GENERIC_DEVICE_CLASS_ID = 0x0008,
/** The GenericDeviceType attribute allows an application to show an icon on
* a rich user interface (e.g. smartphone app). */
ZB_ZCL_ATTR_BASIC_GENERIC_DEVICE_TYPE_ID = 0x0009,
/** The ProductCode attribute allows an application to specify a code for
* the product. */
ZB_ZCL_ATTR_BASIC_PRODUCT_CODE_ID = 0x000a,
/** The ProductURL attribute specifies a link to a web page containing specific
* product information. */
ZB_ZCL_ATTR_BASIC_PRODUCT_URL_ID = 0x000b,
/** Vendor specific human readable (displayable) string representing the versions
* of one of more program images supported on the device. */
ZB_ZCL_ATTR_BASIC_MANUFACTURER_VERSION_DETAILS_ID = 0x000c,
/** Vendor specific human readable (displayable) serial number. */
ZB_ZCL_ATTR_BASIC_SERIAL_NUMBER_ID = 0x000d,
/** Vendor specific human readable (displayable) product label. */
ZB_ZCL_ATTR_BASIC_PRODUCT_LABEL_ID = 0x000e,
/** Manufacturer-specific reference to the version of the software. */
ZB_ZCL_ATTR_BASIC_SW_BUILD_ID = 0x4000,
};
/** @brief Basic cluster settings attribute set identifiers
@see ZCL spec, subclauses 3.2.2.2.10 to 3.2.2.2.15
*/
enum zb_zcl_basic_settings_attr_e
{
/*! Location description attribute */
ZB_ZCL_ATTR_BASIC_LOCATION_DESCRIPTION_ID = 0x0010,
/*! Physical environment attribute */
ZB_ZCL_ATTR_BASIC_PHYSICAL_ENVIRONMENT_ID = 0x0011,
/*! Device enabled attribute */
ZB_ZCL_ATTR_BASIC_DEVICE_ENABLED_ID = 0x0012,
/*! Alarm mask attribute */
ZB_ZCL_ATTR_BASIC_ALARM_MASK_ID = 0x0013,
/*! Disable local config attribute */
ZB_ZCL_ATTR_BASIC_DISABLE_LOCAL_CONFIG_ID = 0x0014
};
/**
* @brief Permitted values for "Power source" attribute.
* @see ZCL spec, subclauses 3.2.2.2.9.
*/
enum zb_zcl_basic_power_source_e
{
ZB_ZCL_BASIC_POWER_SOURCE_UNKNOWN = 0x00, /**< Power source unknown. */
ZB_ZCL_BASIC_POWER_SOURCE_MAINS_SINGLE_PHASE = 0x01, /**< Single-phase mains. */
ZB_ZCL_BASIC_POWER_SOURCE_MAINS_THREE_PHASE = 0x02, /**< 3-phase mains. */
ZB_ZCL_BASIC_POWER_SOURCE_BATTERY = 0x03, /**< Battery source. */
ZB_ZCL_BASIC_POWER_SOURCE_DC_SOURCE = 0x04, /**< DC source. */
ZB_ZCL_BASIC_POWER_SOURCE_EMERGENCY_MAINS_CONST = 0x05, /**< Emergency mains constantly
powered. */
ZB_ZCL_BASIC_POWER_SOURCE_EMERGENCY_MAINS_TRANSF = 0x06 /**< Emergency mains and transfer
switch. */
};
/** @brief Basic permitted values for "Physical environment" attribute.
@note most of values are profile-specific.
@see ZCL spec, subclause 3.2.2.2.12
*/
enum zb_zcl_basic_physical_env_e
{
/*! Environment unspecified */
ZB_ZCL_BASIC_ENV_UNSPECIFIED = 0,
/*! Environment unknown */
ZB_ZCL_BASIC_ENV_UNKNOWN = 0xff
};
/** @brief Permitted bits for "Alarm mask" attribute
@see ZCL spec, subclause 3.2.2.2.14
*/
enum zb_zcl_basic_alarm_mask_e
{
/*! General hardware fault */
ZB_ZCL_BASIC_ALARM_MASK_HW_FAULT = 0,
/*! General software fault */
ZB_ZCL_BASIC_ALARM_MASK_SW_FAULT = 1
};
/** @brief Value structure for "Disable local config" attribute
@see ZCL spec, subclause 3.2.2.2.15
*/
typedef struct zb_zcl_basic_disable_local_conf_s
{
/*! Reset to factory defaults disabled */
zb_bitfield_t reset_disabled : 1;
/*! Device configuration enabled */
zb_bitfield_t config_enabled : 1;
/*! Reserved bits */
zb_bitfield_t reserved : 6;
} zb_zcl_basic_disable_local_conf_t;
/** @brief Default value for Basic cluster revision global attribute */
#define ZB_ZCL_BASIC_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0003u)
/** @brief Default value for ZCL version attribute */
#define ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE ((zb_uint8_t)ZB_ZCL_VERSION)
/** @brief Default value for Application version attribute */
#define ZB_ZCL_BASIC_APPLICATION_VERSION_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for Stack version attribute */
#define ZB_ZCL_BASIC_STACK_VERSION_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for Hardware version attribute */
#define ZB_ZCL_BASIC_HW_VERSION_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for Manufacturer name attribute */
#define ZB_ZCL_BASIC_MANUFACTURER_NAME_DEFAULT_VALUE {0}
/** @brief Default value for Model identifier attribute */
#define ZB_ZCL_BASIC_MODEL_IDENTIFIER_DEFAULT_VALUE {0}
/** @brief Default value for Date code attribute */
#define ZB_ZCL_BASIC_DATE_CODE_DEFAULT_VALUE {0}
/** @brief Default value for Power source attribute */
#define ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE (ZB_ZCL_BASIC_POWER_SOURCE_UNKNOWN)
/** @brief Default value for GenericDeviceClass attribute */
#define ZB_ZCL_BASIC_GENERIC_DEVICE_CLASS_DEFAULT_VALUE ((zb_uint8_t)0xFF)
/** @brief Default value for GenericDeviceType attribute */
#define ZB_ZCL_BASIC_GENERIC_DEVICE_TYPE_DEFAULT_VALUE ((zb_uint8_t)0xFF)
/** @brief Default value for ProductCode attribute */
#define ZB_ZCL_BASIC_PRODUCT_CODE_DEFAULT_VALUE {0}
/** @brief Default value for ProductURL attribute */
#define ZB_ZCL_BASIC_PRODUCT_URL_DEFAULT_VALUE {0}
/** @brief Default value for ManufacturerVersionDetails attribute */
#define ZB_ZCL_BASIC_MANUFACTURER_VERSION_DETAILS_DEFAULT_VALUE {0}
/** @brief Default value for SerialNumber attribute */
#define ZB_ZCL_BASIC_SERIAL_NUMBER_DEFAULT_VALUE {0}
/** @brief Default value for ProductLabel attribute */
#define ZB_ZCL_BASIC_PRODUCT_LABEL_DEFAULT_VALUE {0}
/** @brief Default value for location description attribute */
#define ZB_ZCL_BASIC_LOCATION_DESCRIPTION_DEFAULT_VALUE {0}
/** @brief Default value for Physical environment attribute */
#define ZB_ZCL_BASIC_PHYSICAL_ENVIRONMENT_DEFAULT_VALUE (ZB_ZCL_BASIC_ENV_UNSPECIFIED)
/** @brief Default value for Device enabled attribute */
#define ZB_ZCL_BASIC_DEVICE_ENABLED_DEFAULT_VALUE ((zb_uint8_t)0x01)
/** @brief Default value for Alarm mask attribute */
#define ZB_ZCL_BASIC_ALARM_MASK_DEFAULT_VALUE (ZB_ZCL_BASIC_ALARM_MASK_HW_FAULT)
/** @brief Default value for Disable local config attribute */
#define ZB_ZCL_BASIC_DISABLE_LOCAL_CONFIG_DEFAULT_VALUE ((zb_zcl_basic_disable_local_conf_t){0,0,0})
/**
* @brief Default value for SWBuildId attribute.
* @note Default value supposes that attribute will be stored as Pascal-style string (i. e.
* length-byte, then content).
*/
#define ZB_ZCL_BASIC_SW_BUILD_ID_DEFAULT_VALUE {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
/** @cond internals_doc */
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_APPLICATION_VERSION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_APPLICATION_VERSION_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_STACK_VERSION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_STACK_VERSION_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_HW_VERSION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_HW_VERSION_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_DATE_CODE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_DATE_CODE_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_LOCATION_DESCRIPTION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_LOCATION_DESCRIPTION_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_PHYSICAL_ENVIRONMENT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_PHYSICAL_ENVIRONMENT_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_DEVICE_ENABLED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_DEVICE_ENABLED_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BASIC_SW_BUILD_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BASIC_SW_BUILD_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#if defined ZB_ZCL_SUPPORT_CLUSTER_SCENES
/*! Scenes field set length for Basic cluster */
#define ZB_ZCL_CLUSTER_ID_BASIC_SCENE_FIELD_SETS_LENGTH 0
#endif /* defined ZB_ZCL_SUPPORT_CLUSTER_SCENES */
/** @endcond */ /* internals_doc */
/** @brief Declare attribute list for Basic cluster
@param attr_list - attribute list name
@param zcl_version - pointer to variable to store zcl version attribute value
@param power_source - pointer to variable to store power source attribute value
@snippet lighting/dimmable_light_tl/light_device_zr.c BASIC_CLUSTER_DECLARE
*/
#define ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST(attr_list, zcl_version, power_source) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_BASIC) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, (zcl_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID, (power_source)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @brief Declare attribute list for Basic cluster
@param attr_list - attribute list name
@param zcl_version - pointer to variable to store zcl version attribute value
@param power_source - pointer to variable to store power source attribute value
@param device_enabled - pointer to variable to store device enabled attribute value
*/
#define ZB_ZCL_DECLARE_BASIC_WITH_DEVICE_ENABLED_ATTRIB_LIST(attr_list, zcl_version, power_source, device_enabled) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST(attr_list) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, (zcl_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID, (power_source)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_DEVICE_ENABLED_ID, (device_enabled)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/**
* @brief Declare attribute list for Basic cluster (extended attribute set).
* @param attr_list [IN] - attribute list name.
* @param zcl_version [IN] - pointer to variable storing ZCL version attribute value.
* @param app_version [IN] - pointer to the variable storing application version.
* @param stack_version [IN] - pointer to the variable storing stack version.
* @param hardware_version [IN] - pointer to the variable storing hardware version.
* @param manufacturer_name [IN] - pointer to the variable storing manufacturer name.
* @param model_id [IN] - pointer to the variable storing model identifier.
* @param date_code [IN] - pointer to the variable storing date code.
* @param power_source [IN] - pointer to variable storing power source attribute value.
* @param location_id [IN] - pointer to variable storing location description attribute value.
* @param ph_env [IN] - pointer to variable storing physical environment attribute value.
* @param sw_build_id [IN] - pointer to the variable storing software version reference.
*/
#define ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST_EXT( \
attr_list, \
zcl_version, \
app_version, \
stack_version, \
hardware_version, \
manufacturer_name, \
model_id, \
date_code, \
power_source, \
location_id, \
ph_env, \
sw_build_id) \
zb_bool_t device_enable_##attr_list = ZB_TRUE; \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_BASIC) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, (zcl_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_APPLICATION_VERSION_ID, (app_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_STACK_VERSION_ID, (stack_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_HW_VERSION_ID, (hardware_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, (manufacturer_name))\
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, (model_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_DATE_CODE_ID, (date_code)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID, (power_source)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_SW_BUILD_ID, (sw_build_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_DEVICE_ENABLED_ID, \
&(device_enable_##attr_list)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_LOCATION_DESCRIPTION_ID, (location_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_PHYSICAL_ENVIRONMENT_ID, (ph_env)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/**
* @brief Declare attribute list for Basic cluster (extended attribute set).
* @param attr_list [IN] - attribute list name.
* @param zcl_version [IN] - pointer to variable storing ZCL version attribute value.
* @param app_version [IN] - pointer to the variable storing application version.
* @param stack_version [IN] - pointer to the variable storing stack version.
* @param hardware_version [IN] - pointer to the variable storing hardware version.
* @param manufacturer_name [IN] - pointer to the variable storing manufacturer name.
* @param model_id [IN] - pointer to the variable storing model identifier.
* @param date_code [IN] - pointer to the variable storing date code.
* @param power_source [IN] - pointer to variable storing power source attribute value.
* @param location_id [IN] - pointer to variable storing location description attribute value.
* @param ph_env [IN] - pointer to variable storing physical environment attribute value.
* @param sw_build_id [IN] - pointer to the variable storing software version reference.
* @param device_enabled - pointer to the variable storing device enabled reference.
*/
#define ZB_ZCL_DECLARE_BASIC_WITH_DEVICE_ENABLED_ATTRIB_LIST_EXT( \
attr_list, \
zcl_version, \
app_version, \
stack_version, \
hardware_version, \
manufacturer_name, \
model_id, \
date_code, \
power_source, \
location_id, \
ph_env, \
sw_build_id, \
device_enabled) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST(attr_list) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, (zcl_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_APPLICATION_VERSION_ID, (app_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_STACK_VERSION_ID, (stack_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_HW_VERSION_ID, (hardware_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, (manufacturer_name))\
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, (model_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_DATE_CODE_ID, (date_code)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID, (power_source)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_SW_BUILD_ID, (sw_build_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_DEVICE_ENABLED_ID, (device_enabled)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_LOCATION_DESCRIPTION_ID, (location_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BASIC_PHYSICAL_ENVIRONMENT_ID, (ph_env)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! Maximum length of ManufacturerName string field */
#define ZB_ZCL_CLUSTER_ID_BASIC_MANUFACTURER_NAME_MAX_LEN 32
/*! Maximum length of ModelIdentifier string field */
#define ZB_ZCL_CLUSTER_ID_BASIC_MODEL_IDENTIFIER_MAX_LEN 32
/**
* @brief Basic cluster attributes
*/
typedef struct zb_zcl_basic_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID
* @see ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID
*/
zb_uint8_t zcl_version;
/** @copydoc ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID
* @see ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID
*/
zb_uint8_t power_source;
} zb_zcl_basic_attrs_t;
/** @brief Declare attribute list for Basic cluster cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of @ref zb_zcl_basic_attrs_t type (containing Basic cluster attributes)
*/
#define ZB_ZCL_DECLARE_BASIC_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST(attr_list, &attrs.zcl_version, &attrs.power_source)
/** @} */ /* Basic cluster attributes */
/*! @name Alarms cluster commands
@{
*/
/*! @brief Basic cluster command identifiers
@see ZCL spec, subclause 3.2.2.3
*/
enum zb_zcl_basic_cmd_e
{
ZB_ZCL_CMD_BASIC_RESET_ID = 0x00, /**< "Reset to Factory Defaults" command. */
};
/** @cond internals_doc */
/* Basic cluster commands lists : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_BASIC_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CMD_BASIC_RESET_ID
#define ZB_ZCL_CLUSTER_ID_BASIC_CLIENT_ROLE_GENERATED_CMD_LIST ZB_ZCL_CLUSTER_ID_BASIC_SERVER_ROLE_RECEIVED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
////////////////////////////////////////
/*! @brief Send Reset to Factory Defaults command
@param buffer to put data to
@param addr - address of the device to send command to
@param dst_addr_mode - addressing mode
@param dst_ep destination endpoint
@param ep - current endpoint
@param prof_id - profile identifier
@param dis_default_resp - "Disable default response" flag
@param cb - callback to call to report send status
*/
#define ZB_ZCL_BASIC_SEND_RESET_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_BASIC_RESET_ID); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_BASIC, cb); \
}
/** Call device callback in user application to reset application settings to defaults.
* @param[in] buffer - pointer to buffer for callback
* @param[in] ep - current endpoint
* @param[out] result - callback status
*/
#define ZB_ZCL_RESET_TO_FACTORY_DEFAULTS_USER_APP(buffer, ep, result) \
{ \
TRACE_MSG(TRACE_ZCL1, "ZB_ZCL_RESET_TO_FACTORY_DEFAULTS_USER_APP", (FMT__0)); \
if (ZCL_CTX().device_cb) \
{ \
zb_zcl_device_callback_param_t *user_app_data = \
ZB_BUF_GET_PARAM(buffer, zb_zcl_device_callback_param_t); \
user_app_data->device_cb_id = ZB_ZCL_BASIC_RESET_CB_ID; \
user_app_data->endpoint = (ep); \
user_app_data->status = RET_OK; \
(ZCL_CTX().device_cb)(param); \
result = user_app_data->status; \
} \
}
/*! @brief Check Device Enabled attribute value and should the stack process command or not.
@see ZCL spec, subclause 3.2.2.2.18 DeviceEnabled Attribute
@param ep_id Endpoint ID
@param cmd_id Command ID
@param cluster_id Cluster ID
@param is_common_command Is command common or cluster specific
@return ZB_TRUE if command should be processed or sent, ZB_FALSE otherwise
*/
zb_bool_t zb_zcl_check_is_device_enabled(zb_uint8_t ep_id, zb_uint8_t cmd_id, zb_uint16_t cluster_id, zb_bool_t is_common_command);
/** @} */ /* Basic cluster commands */
/*! @} */ /* ZCL Basic cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_basic_init_server(void);
void zb_zcl_basic_init_client(void);
#define ZB_ZCL_CLUSTER_ID_BASIC_SERVER_ROLE_INIT zb_zcl_basic_init_server
#define ZB_ZCL_CLUSTER_ID_BASIC_CLIENT_ROLE_INIT zb_zcl_basic_init_client
#endif /* ZB_ZCL_BASIC_H */

View File

@@ -0,0 +1,292 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Binary Input cluster
*/
#ifndef ZB_ZCL_BINARY_INPUT_H
#define ZB_ZCL_BINARY_INPUT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_BINARY_INPUT
* @{
* @details
* According to ZCL spec, subclause 3.14.4, Binary Input (Basic) cluster has no cluster-specific
* commands. Cluster attributes could be queried with
* @ref ZB_ZCL_COMMANDS "general ZCL commands".
*
*
*/
/* ZB_ZCL_CLUSTER_ID_BINARY_INPUT = 0x000f defined in zb_zcl_common.h ZCL spec 3.14.4 */
/*! @name Binary Input cluster attributes
@{
*/
/** @brief Binary Input cluster attribute identifiers. */
enum zb_zcl_binary_input_attr_e
{
/** This attribute, of type Character string, MAY be used to hold a human readable
* description of the ACTIVE state of a binary PresentValue. */
ZB_ZCL_ATTR_BINARY_INPUT_ACTIVE_TEXT_ID = 0x0004,
/** The Description attribute, of type Character string, MAY be used to hold a
* description of the usage of the input, output or value, as appropriate
* to the cluster. */
ZB_ZCL_ATTR_BINARY_INPUT_DESCRIPTION_ID = 0x001C,
/** This attribute, of type Character string, MAY be used to hold a human readable
* description of the INACTIVE state of a binary PresentValue. */
ZB_ZCL_ATTR_BINARY_INPUT_INACTIVE_TEXT_ID = 0x002E,
/** @brief OutOfService attribute */
ZB_ZCL_ATTR_BINARY_INPUT_OUT_OF_SERVICE_ID = 0x0051,
/** This attribute, of type enumeration, indicates the relationship between
* the physical state of the input (or output as appropriate for the cluster)
* and the logical state represented by a binary PresentValue attribute,
* when OutOfService is FALSE. */
ZB_ZCL_ATTR_BINARY_INPUT_POLARITY_ID = 0x0054,
/** @brief PresentValue attribute */
ZB_ZCL_ATTR_BINARY_INPUT_PRESENT_VALUE_ID = 0x0055,
// adding GP specific attributes
ZB_ZCL_ATTR_GP_ATTR_BINARY_INPUT_BATTERY_VALUE_ID = 0x0056,
ZB_ZCL_ATTR_GP_ATTR_BINARY_INPUT_TEMPERATURE_VALUE_ID = 0x0057,
ZB_ZCL_ATTR_GP_ATTR_BINARY_INPUT_TAMPER_VALUE_ID = 0x0058,
// end GP specific attributes
/** The Reliability attribute, of type 8-bit enumeration, provides an indication
* of whether the PresentValue or the operation of the physical input,
* output or value in question (as appropriate for the cluster) is reliable
* as far as can be determined and, if not, why not. */
ZB_ZCL_ATTR_BINARY_INPUT_RELIABILITY_ID = 0x0067,
/** @brief StatusFlag attribute */
ZB_ZCL_ATTR_BINARY_INPUT_STATUS_FLAG_ID = 0x006F,
/** The ApplicationType attribute is an unsigned 32-bit integer that indicates
* the specific application usage for this cluster. */
ZB_ZCL_ATTR_BINARY_INPUT_APPLICATION_TYPE_ID = 0x0100,
};
/**
* @brief StatusFlag attribute values.
* @see ZCL spec 3.14.10.3.
*/
enum zb_zcl_binary_input_status_flag_value_e
{
ZB_ZCL_BINARY_INPUT_STATUS_FLAG_NORMAL = 0x00, /**< Normal (default) state. */
ZB_ZCL_BINARY_INPUT_STATUS_FLAG_IN_ALARM = 0x01, /**< In alarm bit. */
ZB_ZCL_BINARY_INPUT_STATUS_FLAG_FAULT = 0x02, /**< Fault bit. */
ZB_ZCL_BINARY_INPUT_STATUS_FLAG_OVERRIDEN = 0x04, /**< Overridden bit. */
ZB_ZCL_BINARY_INPUT_STATUS_FLAG_OUT_OF_SERVICE = 0x08, /**< Out of service bit. */
};
/** @brief Default value for Binary Input cluster revision global attribute */
#define ZB_ZCL_BINARY_INPUT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for ActiveText attribute */
#define ZB_ZCL_BINARY_INPUT_ACTIVE_TEXT_DEFAULT_VALUE {0}
/** @brief Default value for Description attribute */
#define ZB_ZCL_BINARY_INPUT_DESCRIPTION_DEFAULT_VALUE {0}
/** @brief Default value for InactiveText attribute */
#define ZB_ZCL_BINARY_INPUT_INACTIVE_TEXT_DEFAULT_VALUE {0}
/*! @brief OutOfService attribute default value */
#define ZB_ZCL_BINARY_INPUT_OUT_OF_SERVICE_DEFAULT_VALUE ZB_FALSE
/** @brief Default value for Polarity attribute */
#define ZB_ZCL_BINARY_INPUT_POLARITY_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for Reliability attribute */
#define ZB_ZCL_BINARY_INPUT_RELIABILITY_DEFAULT_VALUE ((zb_uint8_t)0x00)
/*! @brief StatusFlag attribute default value */
#define ZB_ZCL_BINARY_INPUT_STATUS_FLAG_DEFAULT_VALUE ZB_ZCL_BINARY_INPUT_STATUS_FLAG_NORMAL
/*! @brief StatusFlag attribute minimum value */
#define ZB_ZCL_BINARY_INPUT_STATUS_FLAG_MIN_VALUE 0
/*! @brief StatusFlag attribute maximum value */
#define ZB_ZCL_BINARY_INPUT_STATUS_FLAG_MAX_VALUE 0x0F
/** @brief Declare attribute list for Binary Input cluster
@param attr_list - attribute list name
@param out_of_service - pointer to variable to store OutOfService attribute value
@param present_value - pointer to variable to store PresentValue attribute value
@param status_flag - pointer to variable to store StatusFlag attribute value
*/
#define ZB_ZCL_DECLARE_BINARY_INPUT_ATTRIB_LIST( \
attr_list, out_of_service, present_value, status_flag) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_BINARY_INPUT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BINARY_INPUT_OUT_OF_SERVICE_ID, (out_of_service)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BINARY_INPUT_PRESENT_VALUE_ID, (present_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_BINARY_INPUT_STATUS_FLAG_ID, (status_flag)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Binary Input cluster attributes */
/*! @name Binary input attribute value manipulation API
@{
*/
/** @brief Set normal operating mode
@param ep - endpoint number
*/
#define ZB_ZCL_BINARY_INPUT_SET_NORMAL_MODE(ep) \
{ \
zb_uint8_t val; \
\
val = ZB_FALSE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_BINARY_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_BINARY_INPUT_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
val = ZB_ZCL_BINARY_INPUT_STATUS_FLAG_NORMAL; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_BINARY_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_BINARY_INPUT_STATUS_FLAG_ID, \
&val, ZB_FALSE); \
}
/** @brief Set Out of service operating mode
@param ep - endpoint number
*/
#define ZB_ZCL_BINARY_INPUT_SET_OUT_OF_SERVICE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
val = ZB_TRUE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_BINARY_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_BINARY_INPUT_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_BINARY_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_BINARY_INPUT_STATUS_FLAG_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_BINARY_INPUT_STATUS_FLAG_OUT_OF_SERVICE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_BINARY_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_BINARY_INPUT_STATUS_FLAG_ID, \
&val, ZB_FALSE); \
} \
}
/** @brief Set overridden operating mode
@param ep - endpoint number
*/
#define ZB_ZCL_BINARY_INPUT_SET_OVERRIDEN_MODE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_BINARY_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_BINARY_INPUT_STATUS_FLAG_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_BINARY_INPUT_STATUS_FLAG_OVERRIDEN; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_BINARY_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_BINARY_INPUT_STATUS_FLAG_ID, \
&val, ZB_FALSE); \
} \
}
/*! @} */ /* Binary input cluster commands */
/** @cond internals_doc */
/** @name Binary Input cluster internals
Internal structures for Binary Input cluster
@{
*/
/* Optionally, access to this attribute may be changed to READ_WRITE */
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BINARY_INPUT_OUT_OF_SERVICE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BINARY_INPUT_OUT_OF_SERVICE_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/* Optionally, access to this attribute may be changed to READ_WRITE */
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BINARY_INPUT_PRESENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BINARY_INPUT_PRESENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_BINARY_INPUT_STATUS_FLAG_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_BINARY_INPUT_STATUS_FLAG_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! Number of attributes mandatory for reporting in Binary Input cluster */
#define ZB_ZCL_BINARY_INPUT_REPORT_ATTR_COUNT 2
/*! @}
* @endcond */ /* Binary Input cluster internals */
/*! @} */ /* ZCL Binary Input cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_binary_input_init_server(void);
void zb_zcl_binary_input_init_client(void);
#define ZB_ZCL_CLUSTER_ID_BINARY_INPUT_SERVER_ROLE_INIT zb_zcl_binary_input_init_server
#define ZB_ZCL_CLUSTER_ID_BINARY_INPUT_CLIENT_ROLE_INIT zb_zcl_binary_input_init_client
#endif /* ZB_ZCL_BINARY_INPUT_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,227 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Carbon Dioxide Measurement cluster definitions */
#ifndef ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_H
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_CONCENTRATION_MEASUREMENT
* @{
* @details
* The server cluster provides an interface to concentration measurement
* functionality. The measurement is reportable and may be configured for
* reporting. Concentration measurements include, but are not limited to,
* levels in gases, such as CO, CO2, and ethylene, or in fluids and
* solids, such as dissolved oxygen, chemi8721 cals & pesticides.
*
* Carbon Dioxide (CO2)
*/
/* Cluster ZB_ZCL_CLUSTER_ID_CARBON_DIOXIDE_MEASUREMENT */
/** @name Carbon Dioxide Measurement cluster attributes
* @{
*/
/** @brief Carbon Dioxide Measurement cluster attribute identifiers
* @see ZCL spec, Carbon Dioxide Measurement Cluster 4.14.1.4
*/
enum zb_zcl_carbon_dioxide_measurement_attr_e
{
/** @brief MeasuredValue attribute, ZCL spec 4.13.2.1.1 */
ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_ID = 0x0000,
/** @brief MinMeasuredValue attribute, ZCL spec 4.13.2.1.2 */
ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MIN_MEASURED_VALUE_ID = 0x0001,
/** @brief MaxMeasuredValue attribute, ZCL spec 4.13.2.1.3 */
ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MAX_MEASURED_VALUE_ID = 0x0002,
/** @brief Tolerance attribute, ZCL spec 4.13.2.1.4 */
ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_TOLERANCE_ID = 0x0003,
};
/** @brief MeasuredValue attribute unknown */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_UNKNOWN (.0/.0)
/** @brief MinMeasuredValue attribute undefined */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_MIN_MEASURED_VALUE_UNDEFINED (.0/.0)
/** @brief MaxMeasuredValue attribute undefined */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_MAX_MEASURED_VALUE_UNDEFINED (.0/.0)
/** @brief MinMeasuredValue attribute minimum value */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_MIN_MEASURED_VALUE_MIN_VALUE 0.0
/** @brief MaxMeasuredValue attribute maximum value */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_MAX_MEASURED_VALUE_MAX_VALUE 1.0
/** @brief Default value for Carbon Dioxide Measurement cluster revision global attribute */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for MeasuredValue attribute */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_DEFAULT_VALUE (.0/.0)
/** @brief Default value for MinMeasuredValue attribute */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_MIN_MEASURED_VALUE_DEFAULT_VALUE (.0/.0)
/** @brief Default value for MaxMeasuredValue attribute */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_MAX_MEASURED_VALUE_DEFAULT_VALUE (.0/.0)
/** @cond internals_doc */
/** @name Carbon Dioxide Measurement cluster internals
* Internal structures for Carbon Dioxide Measurement cluster
* @{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MIN_MEASURED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MIN_MEASURED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MAX_MEASURED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MAX_MEASURED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_TOLERANCE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_TOLERANCE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** Number of attributes mandatory for reporting in Carbon Dioxide Measurement cluster */
#define ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_REPORT_ATTR_COUNT 1
/** @} */
/** @endcond */ /* Carbon Dioxide Measurement cluster internals */
/** @brief Declare attribute list for Carbon Dioxide Measurement cluster
* @param attr_list - attribute list name
* @param measured_value - pointer to variable storing MeasuredValue attribute value
* @param min_measured_value - pointer to variable storing MinMeasuredValue attribute value
* @param max_measured_value - pointer to variable storing MaxMeasuredValue attribute value
* @param tolerance - pointer to variable storing Tolerance attribute value
*/
#define ZB_ZCL_DECLARE_CARBON_DIOXIDE_MEASUREMENT_ATTRIB_LIST( \
attr_list, \
measured_value, \
min_measured_value, \
max_measured_value, \
tolerance) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_ID, (measured_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MIN_MEASURED_VALUE_ID, (min_measured_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MAX_MEASURED_VALUE_ID, (max_measured_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_TOLERANCE_ID, (tolerance)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/**
* @brief Carbon Dioxide Measurement cluster attributes
*/
typedef struct zb_zcl_carbon_dioxide_measurement_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_ID
* @see ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MEASURED_VALUE_ID
*/
zb_single_t measured_value;
/** @copydoc ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MIN_MEASURED_VALUE_ID
* @see ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MIN_MEASURED_VALUE_ID
*/
zb_single_t min_measured_value;
/** @copydoc ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MAX_MEASURED_VALUE_ID
* @see ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_MAX_MEASURED_VALUE_ID
*/
zb_single_t max_measured_value;
/** @copydoc ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_TOLERANCE_ID
* @see ZB_ZCL_ATTR_CARBON_DIOXIDE_MEASUREMENT_TOLERANCE_ID
*/
zb_single_t tolerance;
} zb_zcl_carbon_dioxide_measurement_attrs_t;
/** @brief Declare attribute list for Carbon Dioxide Measurement cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of @ref zb_zcl_carbon_dioxide_measurement_attrs_t type
* (containing Carbon Dioxide Measurement cluster attributes)
*/
#define ZB_ZCL_DECLARE_CARBON_DIOXIDE_MEASUREMENT_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_CARBON_DIOXIDE_MEASUREMENT_ATTRIB_LIST(attr_list, \
&attrs.measured_value, \
&attrs.min_measured_value, \
&attrs.max_measured_value, \
&attrs.tolerance)
/** @} */ /* end of ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_ATTRS_GROUP group */
/** @} */ /* ZCL Carbon Dioxide Measurement cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_carbon_dioxide_measurement_init_server(void);
void zb_zcl_carbon_dioxide_measurement_init_client(void);
#define ZB_ZCL_CLUSTER_ID_CARBON_DIOXIDE_MEASUREMENT_SERVER_ROLE_INIT zb_zcl_carbon_dioxide_measurement_init_server
#define ZB_ZCL_CLUSTER_ID_CARBON_DIOXIDE_MEASUREMENT_CLIENT_ROLE_INIT zb_zcl_carbon_dioxide_measurement_init_client
#endif /* ZB_ZCL_CARBON_DIOXIDE_MEASUREMENT_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,116 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Configuration for Zigbee cluster library
*/
#ifndef ZB_ZCL_CONFIG_H
#define ZB_ZCL_CONFIG_H 1
/** @cond DOXYGEN_ZCL_SECTION */
/************ ZCL specific configuration ******************/
/**
ZCL: transactions table size
*/
#define ZCL_TRAN_TABLE_SIZE 16U
/* DA: range check error */
/* #define ZB_DISABLE_TEMP_MEASUREMENT_TOLERANCE_ID */
/* #define ZB_ZCL_OTA_INCREMENTAL_QUERY_INTERVAL */
/* Enable CVC feature */
#define ZB_ZCL_ENABLE_CVC
/* Disable Poll Control Check-Ins during OTA upgrade (to reduce the load) */
#define xZB_ZCL_NO_CHECKINS_DURING_OTA
/*********************** Cluster to command configuration **********************/
/* General commands default processing */
#define ZB_ZCL_ENABLE_DEFAULT_REPORT_ATTR_PROCESSING
/* Control per-cluster default command processing */
#if defined (ZB_ZCL_SUPPORT_CLUSTER_GROUPS)
#define ZB_ZCL_ENABLE_DEFAULT_GROUPS_PROCESSING
#endif /* ZB_ZCL_SUPPORT_CLUSTER_GROUPS */
#if defined (ZB_ZCL_SUPPORT_CLUSTER_GROUPS_CLIENT)
#define ZB_ZCL_ENABLE_DEFAULT_GROUPS_PROCESSING_CLIENT
#endif /* ZB_ZCL_SUPPORT_CLUSTER_GROUPS_CLIENT */
/* Control per-cluster default scene extension processing */
#if defined ZB_ZCL_SUPPORT_CLUSTER_SCENES
#if defined ZB_ZCL_SUPPORT_CLUSTER_THERMOSTAT
#define ZB_ZCL_SUPPORT_THERMOSTAT_SCENE_EXTENSIONS
#endif /* defined ZB_ZCL_SUPPORT_CLUSTER_THERMOSTAT */
#endif /* defined ZB_ZCL_SUPPORT_CLUSTER_SCENES */
#if defined ZB_ZCL_SUPPORT_CLUSTER_POLL_CONTROL
#define ZB_HA_ENABLE_POLL_CONTROL_SERVER
#endif /* defined ZB_ZCL_SUPPORT_CLUSTER_POLL_CONTROL */
/* TODO: Divide Server and Client processing and turn on server part only when it is really needed -
* OTA cluster is rather big in terms of ROM size! */
#if defined ZB_ZCL_SUPPORT_CLUSTER_OTA_UPGRADE
#define ZB_ZCL_ENABLE_DEFAULT_OTA_UPGRADE_PROCESSING
#define ZB_HA_ENABLE_OTA_UPGRADE_SERVER 1
#define ZB_HA_ENABLE_OTA_UPGRADE_CLIENT 1
#endif /* defined ZB_ZCL_SUPPORT_CLUSTER_OTA_UPGRADE */
#if defined ZB_ZCL_SUPPORT_CLUSTER_TUNNEL
#define ZB_ZCL_ENABLE_DEFAULT_TUNNEL_PROCESSING
#endif /* defined ZB_ENABLE_TUNNEL_CLUSTER */
#if defined ZB_ZCL_SUPPORT_CLUSTER_IR_BLASTER
#define ZB_ZCL_ENABLE_DEFAULT_IR_BLASTER_PROCESSING
#endif /* defined ZB_ENABLE_IR_BLASTER_CLUSTER */
#if defined ZB_ZCL_SUPPORT_CLUSTER_DIAGNOSTICS
#define ZB_MAC_DIAGNOSTICS
#define ZDO_DIAGNOSTICS
#endif /* ZB_ZCL_SUPPORT_CLUSTER_DIAGNOSTICS */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
#endif /* ZB_ZCL_CONFIG_H */

View File

@@ -0,0 +1,495 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Poll Control cluster definitions
*/
#ifndef ZB_ZCL_CONTROL4_NETWORKING_H
#define ZB_ZCL_CONTROL4_NETWORKING_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_CONTROL4
* @{
* @details
* @warning Using this cluster makes an application not conforming to the Zigbee PRO specification
*
* This cluster provides an application level interface between Zigbee devices and a Control4
* Controller.
*
* This is implemented using Control4 specific profile ZB_AF_CONTROL4_PROFILE_ID.
*
* Control4 Network cluster also uses Many-To-One routing requests.
*
*/
/** @name Control4 Network cluster attributes
* @{
*/
enum zb_zcl_control4_networking_attr_e
{
ZB_ZCL_ATTR_CONTROL4_NETWORKING_DEVICE_TYPE_ID = 0x0000,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_ANNOUNCE_WINDOW_ID = 0x0001,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_MTORR_PERIOD_ID = 0x0002,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_FIRMWARE_VERSION_ID = 0x0004,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_REFLASH_VERSION_ID = 0x0005,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_BOOT_COUNT_ID = 0x0006,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_PRODUCT_STRING_ID = 0x0007,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_NODE_ID_ID = 0x0008,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_LONG_ID_ID = 0x0009,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_COST_ID = 0x000a,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_MESH_CHANNEL_ID = 0x000c,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_AVG_RSSI_ID = 0x0013,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_AVG_LQI_ID = 0x0014,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_BATTERY_LEVEL_ID = 0x0015,
ZB_ZCL_ATTR_CONTROL4_NETWORKING_RADIO_4_BARS_ID = 0x0016
};
enum zb_zcl_control4_networking_device_type_e
{
/*! "Non-sleepy end device" value */
ZB_ZCL_CONTROL4_NETWORKING_DEVICE_TYPE_END_DEVICE = 0x03,
/*! "Sleepy end device" value */
ZB_ZCL_CONTROL4_NETWORKING_DEVICE_TYPE_SLEEPY_END_DEVICE = 0x04
};
/** @brief Default value for Control4 networking cluster revision global attribute */
#define ZB_ZCL_CONTROL4_NETWORKING_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
#define ZB_ZCL_CONTROL4_NETWORKING_REFLASH_VERSION_VENDOR_SPECIFIC 0xff
#define ZB_ZCL_CONTROL4_NETWORKING_BOOT_COUNT_DEF_VALUE 0
#define ZB_ZCL_CONTROL4_NETWORKING_ANNOUNCE_WINDOW_MIN_VALUE ((zb_uint16_t)0x000f)
#define ZB_ZCL_CONTROL4_NETWORKING_ANNOUNCE_WINDOW_DEF_VALUE ((zb_uint16_t)0x012c)
#define ZB_ZCL_CONTROL4_NETWORKING_MTORR_PERIOD_MIN_VALUE ((zb_uint16_t)0x000f)
#define ZB_ZCL_CONTROL4_NETWORKING_MTORR_PERIOD_DEF_VALUE ((zb_uint16_t)0x012c)
#define ZB_ZCL_CONTROL4_NETWORKING_ACCESS_POINT_NODE_ID_DEF_VALUE ((zb_uint16_t)0xffff)
#define ZB_ZCL_CONTROL4_NETWORKING_ACCESS_POINT_LONG_ID_DEF_VALUE {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
#define ZB_ZCL_CONTROL4_NETWORKING_ACCESS_POINT_COST_DEF_VALUE 0xff
#define ZB_ZCL_CONTROL4_NETWORKING_MESH_CHANNEL_MIN_VALUE 0x0b
#define ZB_ZCL_CONTROL4_NETWORKING_MESH_CHANNEL_MAX_VALUE 0x19
#define ZB_ZCL_CONTROL4_NETWORKING_AVG_RSSI_MIN_VALUE -128
#define ZB_ZCL_CONTROL4_NETWORKING_AVG_RSSI_MAX_VALUE 0
#define ZB_ZCL_CONTROL4_NETWORKING_BATTERY_LEVEL_MIN_VALUE 0
#define ZB_ZCL_CONTROL4_NETWORKING_BATTERY_LEVEL_MAX_VALUE 100
#define ZB_ZCL_CONTROL4_NETWORKING_RADIO_4_BARS_MAX_VALUE 4
/* Number of searching ZAP attempts */
#define ZB_ZCL_CONTROL4_NETWORK_SEARCHING_ZAP_ATTEMPTS 2
/** @brief Declare attribute list for C4 Network cluster
@param attr_list - attribute list name
@param device_type - pointer to variable to store Device Type attribute value
@param firmware_version - pointer to variable to store Firmware Version attribute value
@param reflash_version - pointer to variable to store Reflash Version attribute value
@param boot_count - pointer to variable to store Boot Count attribute value
@param product_string - pointer to variable to store Product String attribute value
@param access_point_node_ID - pointer to variable to store Access Point Node ID attribute value
@param access_point_long_ID - pointer to variable to store Access Point Long ID attribute value
@param access_point_cost - pointer to variable to store Access Point Cost ID attribute value
@param mesh_channel - pointer to variable to store Mesh Channel attribute value
*/
#define ZB_ZCL_DECLARE_CONTROL4_NETWORKING_ATTRIB_LIST_SRV(attr_list, device_type, firmware_version, \
reflash_version, boot_count, product_string, access_point_node_ID, access_point_long_ID, \
access_point_cost, mesh_channel) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_CONTROL4_NETWORKING) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_DEVICE_TYPE_ID, (device_type)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_FIRMWARE_VERSION_ID, (firmware_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_REFLASH_VERSION_ID, (reflash_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_BOOT_COUNT_ID, (boot_count)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_PRODUCT_STRING_ID, (product_string)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_NODE_ID_ID, (access_point_node_ID)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_LONG_ID_ID, (access_point_long_ID)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_COST_ID, (access_point_cost)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_MESH_CHANNEL_ID, (mesh_channel)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @brief Declare extended attribute list for C4 Network cluster
@param attr_list - attribute list name
@param device_type - pointer to variable to store Device Type attribute value
@param firmware_version - pointer to variable to store Firmware Version attribute value
@param announce_window - pointer to variable to store Announce Window attribute value
@param MTORR_period - pointer to variable to store MTORR Period attribute value
@param reflash_version - pointer to variable to store Reflash Version attribute value
@param boot_count - pointer to variable to store Boot Count attribute value
@param product_string - pointer to variable to store Product String attribute value
@param access_point_node_ID - pointer to variable to store Access Point Node ID attribute value
@param access_point_long_ID - pointer to variable to store Access Point Long ID attribute value
@param access_point_cost - pointer to variable to store Access Point Cost ID attribute value
@param mesh_channel - pointer to variable to store Mesh Channel attribute value
@param avg_RSSI - pointer to variable to store Avg RSSI attribute value
@param avg_LQI - pointer to variable to store Avg LQI attribute value
@param battery_level - pointer to variable to store Battery Level attribute value
@param radio_4_bars - pointer to variable to store Radio 4-Bar attribute value
*/
#define ZB_ZCL_DECLARE_CONTROL4_NETWORKING_ATTRIB_LIST_SRV_EXT(attr_list, device_type, firmware_version, \
announce_window, MTORR_period, \
reflash_version, boot_count, product_string, access_point_node_ID, access_point_long_ID, \
access_point_cost, mesh_channel, \
avg_RSSI, avg_LQI, battery_level, radio_4_bars) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_CONTROL4_NETWORKING) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_DEVICE_TYPE_ID, (device_type)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_ANNOUNCE_WINDOW_ID, (announce_window)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_MTORR_PERIOD_ID, (MTORR_period)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_FIRMWARE_VERSION_ID, (firmware_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_REFLASH_VERSION_ID, (reflash_version)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_BOOT_COUNT_ID, (boot_count)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_PRODUCT_STRING_ID, (product_string)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_NODE_ID_ID, (access_point_node_ID)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_LONG_ID_ID, (access_point_long_ID)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_COST_ID, (access_point_cost)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_MESH_CHANNEL_ID, (mesh_channel)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_AVG_RSSI_ID, (avg_RSSI)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_AVG_LQI_ID, (avg_LQI)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_BATTERY_LEVEL_ID, (battery_level)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CONTROL4_NETWORKING_RADIO_4_BARS_ID, (radio_4_bars)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @} */ /*Control4 Network cluster attributes */
/** @name Control4 Network cluster commands
* @{
*/
enum zb_zcl_control4_networking_cmd_e
{
ZB_ZCL_CMD_CONTROL4_NETWORKING_IMMEDIATE_ANNOUNCE_ID = 0x00 /**< "Immediate announce command" command. */
};
#define ZB_ZCL_CLUSTER_ID_CONTROL4_NETWORKING_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_CONTROL4_NETWORKING_IMMEDIATE_ANNOUNCE_ID \
#define ZB_ZCL_CLUSTER_ID_CONTROL4_NETWORKING_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_CONTROL4_NETWORKING_CLIENT_ROLE_GENERATED_CMD_LIST
/** @cond internals_doc */
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_DEVICE_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_DEVICE_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_ANNOUNCE_WINDOW_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_ANNOUNCE_WINDOW_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_MTORR_PERIOD_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_MTORR_PERIOD_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_FIRMWARE_VERSION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_FIRMWARE_VERSION_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_REFLASH_VERSION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_REFLASH_VERSION_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_BOOT_COUNT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_BOOT_COUNT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_PRODUCT_STRING_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_PRODUCT_STRING_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_NODE_ID_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_NODE_ID_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_LONG_ID_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_LONG_ID_ID, \
ZB_ZCL_ATTR_TYPE_IEEE_ADDR, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_COST_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_ACCESS_POINT_COST_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_MESH_CHANNEL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_MESH_CHANNEL_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_AVG_RSSI_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_AVG_RSSI_ID, \
ZB_ZCL_ATTR_TYPE_S8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_AVG_LQI_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_AVG_LQI_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_BATTERY_LEVEL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_BATTERY_LEVEL_ID, \
ZB_ZCL_ATTR_TYPE_S8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CONTROL4_NETWORKING_RADIO_4_BARS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_CONTROL4_NETWORKING_RADIO_4_BARS_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @endcond */ /*internals_doc*/
/**
* Control4 Network Cluster Endpoint.
*
* @attention This endpoint number is reserved for internal usage in the stack (for Control4 feature).
*/
#define ZB_CONTROL4_NETWORK_ENDPOINT 0xc4
#define ZB_ZCL_CONTROL4_NETWORK_DECLARE_CLUSTER_LIST( \
cluster_list_name, \
c4_network_attr_list) \
zb_zcl_cluster_desc_t cluster_list_name[] = \
{ \
ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_CONTROL4_NETWORKING, \
ZB_ZCL_ARRAY_SIZE(c4_network_attr_list, zb_zcl_attr_t), \
(c4_network_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \
), \
ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_CONTROL4_NETWORKING, \
0, \
NULL, \
ZB_ZCL_CLUSTER_CLIENT_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \
) \
}
/*!
@brief Declare simple descriptor for C4 Network Cluster endpoint
@param ep_name - endpoint variable name
*/
#define ZB_ZCL_CONTROL4_NETWORK_DECLARE_SIMPLE_DESC(ep_name) \
/* ZB_DECLARE_SIMPLE_DESC(1, 1); it is already defined */ \
ZB_AF_SIMPLE_DESC_TYPE(1, 1) simple_desc_##ep_name = \
{ \
ZB_CONTROL4_NETWORK_ENDPOINT, \
ZB_AF_CONTROL4_PROFILE_ID, \
0, 1, 0, 1, 1, \
{ \
ZB_ZCL_CLUSTER_ID_CONTROL4_NETWORKING, \
ZB_ZCL_CLUSTER_ID_CONTROL4_NETWORKING \
} \
}
/*!
@brief Declare endpoint for C4 Network Cluster
@param ep_name - endpoint variable name
@param cluster_list - endpoint cluster list
*/
#define ZB_ZCL_CONTROL4_NETWORK_DECLARE_EP(ep_name, cluster_list) \
ZB_ZCL_CONTROL4_NETWORK_DECLARE_SIMPLE_DESC(ep_name); \
ZB_AF_DECLARE_ENDPOINT_DESC(ep_name, \
ZB_CONTROL4_NETWORK_ENDPOINT, ZB_AF_CONTROL4_PROFILE_ID, \
0, \
NULL, \
ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), \
cluster_list, \
(zb_af_simple_desc_1_1_t*)&simple_desc_##ep_name, \
0, NULL, 0, NULL)
/**
Control4 Network Cluster states
*/
typedef enum zb_zcl_control4_network_state_e
{
ZB_ZCL_CONTROL4_NETWORK_STATE_IDLE,
ZB_ZCL_CONTROL4_NETWORK_STATE_SEARCHING_ZAP,
ZB_ZCL_CONTROL4_NETWORK_STATE_RUNNING,
ZB_ZCL_CONTROL4_NETWORK_STATE_STOPPED,
} zb_zcl_control4_network_state_t;
/**
Control4 Zigbee Access Point (ZAP) discovery events
*/
typedef enum zb_zcl_control4_zap_discover_event_e
{
/** Information from ZAP (NODE ID and/or LONG_NODE_ID) received and is different from the
* current and default value. Bindings and/or reporting in the user application may require to be updated
*/
ZB_ZCL_CONTROL4_NETWORK_ZAP_UPDATED,
/** ZAP discovered failed after retrying ZB_ZCL_CONTROL4_NETWORK_SEARCHING_ZAP_ATTEMPTS times.
* User application may retry restart the Control4 network cluster or leave the network.
*/
ZB_ZCL_CONTROL4_NETWORK_ZAP_DISCOVER_FAILED,
} zb_zcl_control4_zap_discover_event_t;
/** Control4 ZAP discover user app notification payload */
typedef struct zb_zcl_control4_zap_info_notify_s
{
/** Event for user application to handle*/
zb_zcl_control4_zap_discover_event_t event;
} zb_zcl_control4_zap_info_notify_t;
/**
Start Control4 Network Cluster
*/
zb_ret_t zb_zcl_control4_network_cluster_start(void);
/**
Stop Control4 Network Cluster
*/
void zb_zcl_control4_network_cluster_stop(void);
/**
Get Control4 Network Cluster state
*/
zb_zcl_control4_network_state_t zb_zcl_control4_network_cluster_get_state(void);
/**
Handle Read Attribute Response from Control4 Network Cluster
*/
void zb_zcl_control4_network_cluster_read_attr_resp_handler(zb_bufid_t param);
/** @} */ /*Control4 Network cluster commands */
/*! @} */ /* ZCL Control4 Network cluster */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
/**
Control4 Network Cluster Initialization
*/
void zb_zcl_control4_networking_init_server(void);
void zb_zcl_control4_networking_init_client(void);
#define ZB_ZCL_CLUSTER_ID_CONTROL4_NETWORKING_SERVER_ROLE_INIT zb_zcl_control4_networking_init_server
#define ZB_ZCL_CLUSTER_ID_CONTROL4_NETWORKING_CLIENT_ROLE_INIT zb_zcl_control4_networking_init_client
#endif /* ZB_ZCL_CONTROL4_NETWORKING_H */

View File

@@ -0,0 +1,519 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Time cluster definitions
*/
#ifndef ZB_ZCL_CUSTOM_ATTR_H
#define ZB_ZCL_CUSTOM_ATTR_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond (DOXYGEN_HA_SECTION && internals_doc) */
/** @addtogroup zcl_api
* @{
*/
#define ZB_ZCL_CLUSTER_ID_CUSTOM 0x1A0A
#define ZB_CUSTOM_DEVICE_ID 0x29A
#define ZB_CUSTOM_DEVICE_VERSION 6
/*! @name Custom Attributes cluster attributes
@{
*/
/*! @brief Custom Attributes attribute identifiers
*/
enum zb_zcl_custom_cluster_attr_e
{
ZB_ZCL_CUSTOM_CLUSTER_ATTR_U8_ID = 0x0001,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_S16_ID = 0x0002,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_24BIT_ID = 0x0003,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_32BITMAP_ID = 0x0004,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_IEEE_ID = 0x0005,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_ID = 0x0006,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_UTC_TIME_ID = 0x0007,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_OCTET_STRING_ID = 0x0008,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_BOOL_ID = 0x0009,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_128_BIT_KEY_ID = 0x000a,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_U16_ID = 0x000b,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_U32_ID = 0x000c,
ZB_ZCL_CUSTOM_CLUSTER_ATTR_LONG_OCTET_STRING_ID = 0x000d
};
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_U8_DEFAULT_VALUE 0
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_S16_DEFAULT_VALUE 0
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_24BIT_DEFAULT_VALUE { 0 }
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_32BITMAP_DEFAULT_VALUE 0
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_IEEE_DEFAULT_VALUE { 0 }
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_DEFAULT_VALUE { 0 }
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_UTC_TIME_DEFAULT_VALUE 0
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_BYTE_ARRAY_DEFAULT_VALUE { 0 }
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_BOOL_DEFAULT_VALUE ZB_FALSE
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_128_BIT_KEY_DEFAULT_VALUE { 0 }
/** @brief Default value for Custom cluster revision global attribute */
#define ZB_ZCL_CUSTOM_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/*! @brief Max size of char string attribute (with length byte) */
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_MAX_SIZE 11
/*! @brief Max size of byte array attribute (with length bytes) */
#define ZB_ZCL_CUSTOM_CLUSTER_ATTR_BYTE_ARRAY_MAX_SIZE 66
/*! @} */ /* Custom Attributes cluster attributes */
/*! @name Custom Attributes commands
@{
*/
/*! @brief Custom cluster commands identifiers */
enum zb_zcl_custom_cluster_cmd_e
{
ZB_ZCL_CUSTOM_CLUSTER_CMD1_ID = 0x21,
ZB_ZCL_CUSTOM_CLUSTER_CMD2_ID = 0x22,
ZB_ZCL_CUSTOM_CLUSTER_CMD3_ID = 0x23
};
/*! @brief Custom cluster responses identifiers */
enum zb_zcl_custom_cluster_resp_e
{
ZB_ZCL_CUSTOM_CLUSTER_CMD1_RESP_ID = 0xF1,
ZB_ZCL_CUSTOM_CLUSTER_CMD2_RESP_ID = 0xF2
};
/******** Custom cluster command 1 ********/
enum zb_zcl_custom_cluster_cmd1_mode_e
{
ZB_ZCL_CUSTOM_CLUSTER_CMD1_MODE1 = 0x01,
ZB_ZCL_CUSTOM_CLUSTER_CMD1_MODE2 = 0x02
};
typedef ZB_PACKED_PRE struct zb_zcl_custom_cluster_cmd1_req_s
{
zb_uint8_t mode;
zb_uint8_t value;
}
ZB_PACKED_STRUCT zb_zcl_custom_cluster_cmd1_req_t;
#define ZB_ZCL_CUSTOM_CLUSTER_GET_CMD1_REQ(buf, req, parse_status) \
{ \
zb_zcl_custom_cluster_cmd1_req_t *req_ptr = \
zb_buf_len(buf) >= sizeof(zb_zcl_custom_cluster_cmd1_req_t) ? \
(zb_zcl_custom_cluster_cmd1_req_t*)zb_buf_begin(buf) : NULL; \
parse_status = ZB_ZCL_PARSE_STATUS_FAILURE; \
if (req_ptr) \
{ \
ZB_MEMCPY(&(req), req_ptr, sizeof(zb_zcl_custom_cluster_cmd1_req_t)); \
parse_status = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
}
/*! @brief Send Custom cluster command 1
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param mode - mode value (@see zb_zcl_custom_cluster_cmd1_mode_t)
@param value - some value
*/
#define ZB_ZCL_CUSTOM_CLUSTER_SEND_CMD1_REQ( \
buffer, dst_addr, dst_addr_mode, dst_ep, \
src_ep, def_resp, cb, mode, value) \
{ \
zb_uint8_t *ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ( \
ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CUSTOM_CLUSTER_CMD1_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (mode)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (value)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(buffer), (dst_addr), (dst_addr_mode), (dst_ep), (src_ep), \
ZB_AF_HA_PROFILE_ID, ZB_ZCL_CLUSTER_ID_CUSTOM, (cb)); \
}
/******** Custom cluster Response to command 1 ********/
typedef ZB_PACKED_PRE struct zb_zcl_custom_cluster_cmd1_resp_s
{
zb_uint8_t status;
}
ZB_PACKED_STRUCT zb_zcl_custom_cluster_cmd1_resp_t;
#define ZB_ZCL_CUSTOM_CLUSTER_GET_CMD1_RESP(buf, resp, parse_status) \
{ \
zb_zcl_custom_cluster_cmd1_resp_t *resp_ptr = \
zb_buf_len(buf) >= sizeof(zb_zcl_custom_cluster_cmd1_resp_t) ? \
(zb_zcl_custom_cluster_cmd1_resp_t*)zb_buf_begin(buf) : NULL; \
parse_status = ZB_ZCL_PARSE_STATUS_FAILURE; \
if (resp_ptr) \
{ \
ZB_MEMCPY(&(resp), resp_ptr, sizeof(zb_zcl_custom_cluster_cmd1_resp_t)); \
parse_status = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
}
/*! @brief Send Custom cluster response to command 1
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param status - status value
*/
#define ZB_ZCL_CUSTOM_CLUSTER_SEND_CMD1_RESP( \
buffer, seq, dst_addr, dst_addr_mode, \
dst_ep, src_ep, cb, status) \
{ \
zb_uint8_t *cmd_ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(cmd_ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER( \
cmd_ptr, (seq), ZB_ZCL_CUSTOM_CLUSTER_CMD1_RESP_ID); \
ZB_ZCL_PACKET_PUT_DATA8(cmd_ptr, (status)); \
ZB_ZCL_FINISH_PACKET((buffer), cmd_ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(buffer), (dst_addr), (dst_addr_mode), (dst_ep), (src_ep), \
ZB_AF_HA_PROFILE_ID, ZB_ZCL_CLUSTER_ID_CUSTOM, (cb)); \
}
/******** Custom cluster command 2 ********/
enum zb_zcl_custom_cluster_cmd2_param_e
{
ZB_ZCL_CUSTOM_CLUSTER_CMD2_PARAM1 = 0x01,
ZB_ZCL_CUSTOM_CLUSTER_CMD2_PARAM2 = 0x02,
ZB_ZCL_CUSTOM_CLUSTER_CMD2_PARAM3 = 0x03,
ZB_ZCL_CUSTOM_CLUSTER_CMD2_PARAM4 = 0x04
};
typedef ZB_PACKED_PRE struct zb_zcl_custom_cluster_cmd2_req_s
{
zb_uint8_t param;
zb_uint16_t value;
}
ZB_PACKED_STRUCT zb_zcl_custom_cluster_cmd2_req_t;
#define ZB_ZCL_CUSTOM_CLUSTER_GET_CMD2_REQ(buf, req, parse_status) \
{ \
zb_zcl_custom_cluster_cmd2_req_t *req_ptr = \
zb_buf_len(buf) >= sizeof(zb_zcl_custom_cluster_cmd2_req_t) ? \
(zb_zcl_custom_cluster_cmd2_req_t*)zb_buf_begin(buf) : NULL; \
parse_status = ZB_ZCL_PARSE_STATUS_FAILURE; \
if (req_ptr) \
{ \
ZB_MEMCPY(&(req), req_ptr, sizeof(zb_zcl_custom_cluster_cmd2_req_t)); \
if (req_ptr->value < 0xFFFF) \
{ \
parse_status = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
} \
}
/*! @brief Send Custom cluster command 2
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param param - some parameter
@param value - some value
*/
#define ZB_ZCL_CUSTOM_CLUSTER_SEND_CMD2_REQ( \
buffer, dst_addr, dst_addr_mode, dst_ep, \
src_ep, def_resp, cb, param, value) \
{ \
zb_uint8_t *ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ( \
ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CUSTOM_CLUSTER_CMD2_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (param)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (value)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(buffer), (dst_addr), (dst_addr_mode), (dst_ep), (src_ep), \
ZB_AF_HA_PROFILE_ID, ZB_ZCL_CLUSTER_ID_CUSTOM, (cb)); \
}
/******** Custom cluster Response to command 2 ********/
typedef ZB_PACKED_PRE struct zb_zcl_custom_cluster_cmd2_resp_s
{
zb_uint8_t status;
}
ZB_PACKED_STRUCT zb_zcl_custom_cluster_cmd2_resp_t;
#define ZB_ZCL_CUSTOM_CLUSTER_GET_CMD2_RESP(buf, resp, status) \
{ \
zb_zcl_custom_cluster_cmd2_resp_t *resp_ptr = \
zb_buf_len(buf) >= sizeof(zb_zcl_custom_cluster_cmd2_resp_t) ? \
(zb_zcl_custom_cluster_cmd2_resp_t*)zb_buf_begin(buf) : NULL; \
status = ZB_ZCL_PARSE_STATUS_FAILURE; \
if (resp_ptr) \
{ \
ZB_MEMCPY(&(resp), resp_ptr, sizeof(zb_zcl_custom_cluster_cmd2_resp_t)); \
status = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
}
/*! @brief Send Custom cluster response to command 2
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param status - status value
*/
#define ZB_ZCL_CUSTOM_CLUSTER_SEND_CMD2_RESP( \
buffer, seq, dst_addr, dst_addr_mode, \
dst_ep, src_ep, cb, status) \
{ \
zb_uint8_t *cmd_ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(cmd_ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER( \
cmd_ptr, seq, ZB_ZCL_CUSTOM_CLUSTER_CMD2_RESP_ID); \
ZB_ZCL_PACKET_PUT_DATA8(cmd_ptr, (status)); \
ZB_ZCL_FINISH_PACKET((buffer), cmd_ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(buffer), (dst_addr), (dst_addr_mode), (dst_ep), (src_ep), \
ZB_AF_HA_PROFILE_ID, ZB_ZCL_CLUSTER_ID_CUSTOM, (cb)); \
}
/******** Custom cluster command 3 ********/
typedef ZB_PACKED_PRE struct zb_zcl_custom_cluster_cmd3_req_s
{
zb_char_t zcl_str[ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_MAX_SIZE];
}
ZB_PACKED_STRUCT zb_zcl_custom_cluster_cmd3_req_t;
#define ZB_ZCL_CUSTOM_CLUSTER_GET_CMD3_REQ(buf, req, parse_status) \
{ \
zb_uint8_t zcl_str_len = *((zb_uint8_t*)zb_buf_begin(buf)); \
parse_status = ZB_ZCL_PARSE_STATUS_FAILURE; \
if (((zb_uint_t)(zcl_str_len + 1)) == zb_buf_len(buf)) \
{ \
ZB_MEMCPY(&(req), zb_buf_begin(buf), zcl_str_len + 1); \
parse_status = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
}
/*! @brief Send Custom cluster command 3
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param zcl_str_ptr - pointer to ZCL string
*/
#define ZB_ZCL_CUSTOM_CLUSTER_SEND_CMD3_REQ( \
buffer, dst_addr, dst_addr_mode, dst_ep, \
src_ep, def_resp, cb, zcl_str_ptr) \
{ \
zb_uint8_t *ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ( \
ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CUSTOM_CLUSTER_CMD3_ID); \
ZB_ZCL_PACKET_PUT_STRING(ptr, (zcl_str_ptr)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(buffer), (dst_addr), (dst_addr_mode), (dst_ep), (src_ep), \
ZB_AF_HA_PROFILE_ID, ZB_ZCL_CLUSTER_ID_CUSTOM, (cb)); \
}
/*! @} */ /* Custom Attributes commands */
/*! @internal @name Custom Attributes internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_U8_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_U8_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_S16_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_S16_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_WRITE_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_24BIT_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_24BIT_ID, \
ZB_ZCL_ATTR_TYPE_24BIT, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_32BITMAP_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_32BITMAP_ID, \
ZB_ZCL_ATTR_TYPE_32BITMAP, \
ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_IEEE_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_IEEE_ID, \
ZB_ZCL_ATTR_TYPE_IEEE_ADDR, \
ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL | ZB_ZCL_ATTR_ACCESS_WRITE_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_INTERNAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_UTC_TIME_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_UTC_TIME_ID, \
ZB_ZCL_ATTR_TYPE_UTC_TIME, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_OCTET_STRING_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_OCTET_STRING_ID, \
ZB_ZCL_ATTR_TYPE_OCTET_STRING, \
ZB_ZCL_ATTR_ACCESS_WRITE_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_BOOL_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_BOOL_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE | ZB_ZCL_ATTR_ACCESS_SCENE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_128_BIT_KEY_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_128_BIT_KEY_ID, \
ZB_ZCL_ATTR_TYPE_128_BIT_KEY, \
ZB_ZCL_ATTR_MANUF_SPEC, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_CUSTOM_CLUSTER_ATTR_LONG_OCTET_STRING_ID(data_ptr) \
{ \
ZB_ZCL_CUSTOM_CLUSTER_ATTR_LONG_OCTET_STRING_ID, \
ZB_ZCL_ATTR_TYPE_LONG_OCTET_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @internal @brief Declare attribute list for Custom Attributes cluster
*/
#define ZB_ZCL_DECLARE_CUSTOM_ATTR_CLUSTER_ATTRIB_LIST( \
attr_list, u8_attr, s16_attr, _24bit_attr, _32bitmap_attr, ieee_attr, \
char_string_attr, utc_time_attr, octet_string_attr, bool_attr, _128_bit_key_attr, long_octet_string_attr) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_CUSTOM) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_U8_ID, (u8_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_S16_ID, (s16_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_24BIT_ID, (_24bit_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_32BITMAP_ID, (_32bitmap_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_IEEE_ID, (ieee_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_ID, (char_string_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_UTC_TIME_ID, (utc_time_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_OCTET_STRING_ID, (octet_string_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_BOOL_ID, (bool_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_128_BIT_KEY_ID, (_128_bit_key_attr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_CUSTOM_CLUSTER_ATTR_LONG_OCTET_STRING_ID, (long_octet_string_attr)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @internal Number of attributes mandatory for reporting in Custom Attributes cluster */
#define ZB_ZCL_CUSTOM_ATTR_REPORT_ATTR_COUNT 8
/*! @} */ /* Custom Attributes cluster internals */
/*! @} */ /* ZCL Custom Attributes cluster definitions */
/** @endcond */ /* (DOXYGEN_ZCL_SECTION && internals_doc) */
void zb_zcl_custom_attr_init_server(void);
void zb_zcl_custom_attr_init_client(void);
#define ZB_ZCL_CLUSTER_ID_CUSTOM_SERVER_ROLE_INIT zb_zcl_custom_attr_init_server
#define ZB_ZCL_CLUSTER_ID_CUSTOM_CLIENT_ROLE_INIT zb_zcl_custom_attr_init_client
#endif /* ZB_ZCL_CUSTOM_ATTR_H */

View File

@@ -0,0 +1,206 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: ZCL Continuous Value Change feature commands declarations
*/
#ifndef ZCL_CVC_COMMANDS_H
#define ZCL_CVC_COMMANDS_H 1
#if defined ZB_CVC_FEATURE_SUPPORT
/** @cond DOXYGEN_ZCL_SECTION */
/* Documentation - doc/HA/continuous_value_change-detailed_design.doc */
/* Internal variables,
see 1.7.4 */
/** @brief CVC Transition Time As Fast As Able */
#define ZB_ZCL_CVC_TRANSITION_TIME_AS_FAST_AS_ABLE 0xffff
/** @brief CVC Transition Time minimal */
#define ZB_ZCL_CVC_TRANSITION_TIME_MINIMAL 0x0001
/** @brief CVC Transition Time error */
#define ZB_ZCL_CVC_TRANSITION_TIME_ERROR 20
/** @brief CVC Transition Time Unit (in msec) */
#define ZB_ZCL_CVC_TRANSITION_TIME_UNIT_MS 100
/** @brief CVC Transition Time Unit (in beacon intervals) */
#define ZB_ZCL_CVC_TRANSITION_TIME_UNIT_BE ZB_TIME_ONE_SECOND / 10
/** @brief CVC Invalid Remaining Time */
#define ZB_ZCL_CVC_INVALID_REMAINING_TIME 0xffff
/** @brief CVC Invalid Alarm Id */
#define ZB_ZCL_CVC_INVALID_ALARM_ID (zb_uint8_t)-1
/** @brief CVC Transition Timer Quant (in msec) */
#define ZB_ZCL_CVC_TRANSITION_TIMER_QUANT_MS 100
/** @brief CVC Transition Timer Quant */
#define ZB_ZCL_CVC_TRANSITION_TIMER_QUANT_BE \
ZB_MILLISECONDS_TO_SYS_TIMER_INTERVAL(ZB_ZCL_CVC_TRANSITION_TIMER_QUANT_MS)
/** @brief CVC Transition Time Unit */
#define ZB_ZCL_CVC_TRANSITION_TIME_UNIT_IN_QUANTS \
(ZB_ZCL_CVC_TRANSITION_TIME_UNIT_MS / ZB_ZCL_CVC_TRANSITION_TIMER_QUANT_MS)
#define ZB_ZCL_UNDEFINED_CVC_SLOT 0xff
#define ZB_ZCL_MAX_CVC_SLOTS_BY_EP (ZB_ZCL_UNDEFINED_CVC_SLOT / ZB_ZCL_MAX_EP_NUMBER)
/** @brief Value set function that will be used for setting value on device */
typedef zb_ret_t (ZB_CODE * zb_zcl_cvc_value_set_func_t)(zb_uint8_t endpoint, zb_uint16_t* new_value, zb_uint16_t remaining_time);
/** @internal Structure of Input variables
*/
typedef struct zb_zcl_cvc_input_variables_s
{
/** @brief Current Value */
zb_uint16_t current_value16;
/** @brief End Value */
zb_uint16_t end_value16;
/** @brief Min Value */
zb_uint16_t min_value16;
/** @brief Max Value */
zb_uint16_t max_value16;
/** @brief Overlapping flag */
zb_uint8_t overlap;
/** @brief Transition Time */
zb_uint16_t transition_time;
/** @brief Value set function */
zb_zcl_cvc_value_set_func_t value_set_func;
/** @brief Buffer id for after_processing_cb */
zb_uint8_t buf_id;
/** @brief After Processing callback */
zb_callback_t after_processing_cb;
} zb_zcl_cvc_input_variables_t;
/** @internal Structure of Continuous Value Change variables
*/
typedef struct zb_zcl_cvc_variables_s
{
/** @brief Input variables */
zb_zcl_cvc_input_variables_t input_var;
/** @brief Time to next scheduled operation (delta time) */
zb_uint16_t delta_time;
/** @brief Transition Time in Transition Timer Quants*/
zb_uint32_t transition_time_quant;
/** @brief Delta value for one step */
zb_int16_t delta_value16;
/** @brief Number of remaining steps for transition */
zb_uint16_t steps_number;
/** @brief Step number for extra increment delta value */
zb_uint16_t extra_inc_value_step;
/** @brief Step number for extra increment delta time */
zb_uint16_t extra_inc_time_step;
/** @brief End time of transition */
zb_time_t end_time;
/** @brief Available time error */
zb_uint16_t time_err;
} zb_zcl_cvc_variables_t;
/** @internal Structure of Alarm variables
*/
typedef struct zb_zcl_cvc_alarm_variables_s
{
/** @brief Endpoint id */
zb_uint8_t endpoint_id;
/** @brief Cluster id */
zb_uint16_t cluster_id;
/** @brief Attribute id */
zb_uint16_t attribute_id;
/** @brief Alarm buffer id */
zb_uint8_t alarm_buf_id;
/** @brief Is Used flag */
zb_bool_t is_used;
} ZB_PACKED_STRUCT
zb_zcl_cvc_alarm_variables_t;
/*!
@brief Calculate transition values and put it into buffer.
@param input_var - pointer to zb_zcl_cvc_input_variables_s containing input data
@return buffer ID with zb_zcl_cvc_variables_s
*/
zb_uint8_t zb_zcl_cvc_calculate_transition_values(zb_zcl_cvc_input_variables_t* input_var);
/*!
@brief Initialize and start transition.
@param endpoint_id - ep id
@param cluster_id - cluster id
@param attribute_id - attribute id (from cluster)
@param alarm_buf_id - buffer_id with zb_zcl_cvc_variables_s
@return alarm ID
*/
zb_uint8_t zb_zcl_cvc_start_alarm(zb_uint8_t endpoint_id,
zb_uint16_t cluster_id,
zb_uint16_t attribute_id,
zb_uint8_t alarm_buf_id);
/*!
@brief Initialize and start transition.
@param alarm_id - alarm id
@return old transition's buffer (input_var.buf_id)
*/
zb_uint8_t zb_zcl_cvc_stop_transition(zb_uint8_t alarm_id);
/*!
@brief Check transition running.
@param endpoint_id - ep id
@param cluster_id - cluster id
@param attribute_id - attribute id (from cluster)
@return alarm ID (ZB_ZCL_CVC_INVALID_ALARM_ID if it is not running)
*/
zb_uint8_t zb_zcl_cvc_check_transition_running(
zb_uint8_t endpoint_id,
zb_uint16_t cluster_id,
zb_uint16_t attribute_id);
/*! @brief Initialize alarm list (stored in device context). */
void zb_zcl_init_cvc_alarm_info(void);
/*!
@brief Get remaining time of transition.
@param alarm_id - alarm id
@return remaining time
*/
zb_uint16_t zb_zcl_cvc_get_remaining_time(zb_uint8_t alarm_id);
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
#endif /* ZB_CVC_FEATURE_SUPPORT */
#endif /* ZCL_LEVEL_CVC_COMMANDS_H */

View File

@@ -0,0 +1,758 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Daily Schedule cluster definitions
*/
#ifndef ZB_ZCL_DAILY_SCHEDULE_H_
#define ZB_ZCL_DAILY_SCHEDULE_H_
/******************************************************************************/
/******************************************************************************/
#include "zboss_api_core.h"
#include "zboss_api_aps.h"
#include "zb_zcl_common.h"
/** @cond (DOXYGEN_ZCL_SECTION && DOXYGEN_DAILY_SCHEDULE_CLUSTER) */
/** @addtogroup ZB_ZCL_DAILY_SCHEDULE
* @{
* @details
* The Daily Schedule cluster allows information that can be scheduled for an entire day
* to be transferred within the premises. The information is distributed by an ESI
* or similar server device.
*/
/* Cluster ZB_ZCL_CLUSTER_ID_DAILY_SCHEDULE */
/** @defgroup ZB_ZCL_DAILY_SCHEDULE_ATTRS Daily Schedule cluster attributes
* @{
*/
/** The attributes defined in this cluster are arranged into sets of related attributes;
* each set can contain up to 256 attributes. Attribute identifiers are encoded
* such that the most significant Octet specifies the attribute set and the least
* significant Octet specifies the attribute within the set.
* @see Zigbee-17-05035-004 Table D-3
*/
typedef enum zb_zcl_daily_schedule_srv_attr_sets_e
{
ZB_ZCL_DAILY_SCHEDULE_AUXILIARY_SWITCH_LABEL_SET = 0x00, /**< Auxiliary Switch Label
Attribute Set */
ZB_ZCL_DAILY_SCHEDULE_SCHEDULE_ATTRIBUTES_SET = 0x01, /**< Schedule Attribute Set */
/* 0x02-0xFF reserved */
} zb_zcl_daily_schedule_srv_attr_sets_t;
/** @see Zigbee-17-05035-004 Table D-4 Auxiliary Switch Label Attribute Set */
typedef enum zb_zcl_daily_schedule_srv_auxiliary_switch_attr_set_e
{
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_AUX_SWITCH_1_LABEL = 0x0000, /**< The @e AuxSwitchNLabel attributes provide
a method for assigning a label to
* an Auxiliary Switch.
*/
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_AUX_SWITCH_2_LABEL,
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_AUX_SWITCH_3_LABEL,
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_AUX_SWITCH_4_LABEL,
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_AUX_SWITCH_5_LABEL,
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_AUX_SWITCH_6_LABEL,
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_AUX_SWITCH_7_LABEL,
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_AUX_SWITCH_8_LABEL
} zb_zcl_daily_schedule_srv_auxiliary_switch_attr_set_t;
/** @see Zigbee-17-05035-004 Table D-5 Schedule Attribute Set */
typedef enum zb_zcl_daily_schedule_srv_schedule_attr_set_e
{
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_CURR_AUX_LOAD_SWITCH_STATE = 0x0100, /**< The @e
CurrentAuxiliaryLoadSwitchState
attribute */
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_CURR_DELIVERED_TIER = 0x0101, /**< The @e CurrentDeliveredTier
attribute */
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_CURR_TIER_LABEL = 0x0102, /**< The @e CurrentTierLabel attribute*/
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_LINKY_PEAK_PERIOD_STATUS = 0x0103, /**< The @e LinkyPeakPeriodStatus
attribute */
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_PEAK_START_TIME = 0x0104, /**< The @e PeakStartTime attribute */
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_PEAK_END_TIME = 0x0105, /**< The @e PeakEndTime attribute */
/* (O) */
ZB_ZCL_ATTR_DAILY_SCHEDULE_CURR_TARIFF_LABEL = 0x0106, /**< The @e CurrentTariffLabel attribute */
} zb_zcl_daily_schedule_srv_schedule_attr_set_t;
/** The @e LinkyPeakPeriodStatus attribute subfields */
typedef ZB_PACKED_PRE struct zb_zcl_daily_schedule_attr_linky_peak_period_status_s
{
zb_bitfield_t on_peak:2;
zb_bitfield_t peak_period_prior_notice:2;
zb_bitfield_t next_day_color:2;
zb_bitfield_t current_day_color:2;
} zb_zcl_daily_schedule_attr_linky_peak_period_status_t;
/** @brief Default value for Daily Schedule cluster revision global attribute (not defined anywhere) */
#define ZB_ZCL_DAILY_SCHEDULE_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/*!
@brief Declare attribute list for Daily Schedule cluster (only cluster revision attribute)
@param attr_list - attribute list name
*/
#define ZB_ZCL_DECLARE_DAILY_SCHEDULE_ATTR_LIST(attr_list) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_DAILY_SCHEDULE) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/* Constants for Current Day Color and Next Day Color subfields */
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_COLOR_UNUSED 0b00
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_COLOR_LOW_BLUE 0b01
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_COLOR_MEDIUM_WHITE 0b10
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_COLOR_HIGH_RED 0b11
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_PRIOR_NOTICE_NONE 0b00
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_PRIOR_NOTICE_PP1 0b01
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_PRIOR_NOTICE_PP2 0b10
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_PRIOR_NOTICE_PP3 0b11
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_ON_PEAK_NONE 0b00
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_ON_PEAK_PERIOD_1 0b01
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_ON_PEAK_PERIOD_2 0b10
#define ZB_ZCL_ATTR_LINKY_PEAK_PERIOD_STATUS_ON_PEAK_PERIOD_3 0b11
/** @} */ /* ZB_ZCL_DAILY_SCHEDULE_ATTRS */
/** @defgroup ZB_ZCL_DAILY_SCHEDULE_COMMANDS Daily Schedule cluster commands
* @{
*/
/** Daily Schedule cluster client command identifiers.
* @see Zigbee-17-05035-004 Table D-14 Commands Received by the Daily Schedule Cluster Server
*/
typedef enum zb_zcl_daily_schedule_cli_cmd_e
{
/* (O) */
ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_SCHEDULE = 0x00, /**< This command initiates
PublishSchedule command(s) for
specified Schedule updates. */
/* (O) */
ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_DAY_PROFILE = 0x01, /**< This command initiates one or more
PublishDayProfile commands for the
referenced Schedule. */
/* (O) */
ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_SCHEDULE_CANCELLATION = 0x05, /**< This command initiates
the return of the last
CancelSchedule command held
on the associated server. */
} zb_zcl_daily_schedule_cli_cmd_t;
/** @see Zigbee-17-05035-004 Table D-3 Daily Schedule Cluster Attribute Sets */
typedef enum zb_zcl_daily_schedule_srv_cmd_e
{
/* (O) */
ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_SCHEDULE = 0x00, /**< The PublishSchedule command is
published in response to a GetSchedule
command or if new schedule information
is available. */
/* (O) */
ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_DAY_PROFILE = 0x01, /**< The PublishDayProfile command is
published in response to
a GetDayProfile command. */
/* (O) */
ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_CANCEL_SCHEDULE = 0x05, /**< The CancelSchedule command indicates
that all data associated with
a particular schedule instance
should be discarded. */
/* (O) */
ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_CANCEL_ALL_SCHEDULES = 0x06, /**< The CancelAllSchedules command indicates
that all data associated with
all schedules should be discarded. */
} zb_zcl_daily_schedule_srv_cmd_t;
/* Daily schedule cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_DAILY_SCHEDULE_SERVER_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_SCHEDULE, \
ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_DAY_PROFILE, \
ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_CANCEL_SCHEDULE, \
ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_CANCEL_ALL_SCHEDULES
#define ZB_ZCL_CLUSTER_ID_DAILY_SCHEDULE_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_DAILY_SCHEDULE_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_DAILY_SCHEDULE_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_SCHEDULE, \
ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_DAY_PROFILE, \
ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_SCHEDULE_CANCELLATION
#define ZB_ZCL_CLUSTER_ID_DAILY_SCHEDULE_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_DAILY_SCHEDULE_CLIENT_ROLE_GENERATED_CMD_LIST
/** Schedule type enumeration.
* @see Zigbee-17-05035-004 Table D-12 Schedule Type Enumeration
*/
typedef enum zb_zcl_daily_schedule_type_e
{
ZB_ZCL_DAILY_SCHEDULE_TYPE_LINKY_SCHEDULE = 0x00, /**< Linky Schedule */
/* reserved 0x01 - 0xFF */
} zb_zcl_daily_schedule_type_t;
/** Check if schedule type is valid
* @param _t - @ref zb_zcl_daily_schedule_get_schedule_payload_t::schedule_type field
* @see @ref zb_zcl_daily_schedule_get_schedule_payload_t
*/
#define ZB_ZCL_DAILY_SCHEDULE_TYPE_IS_VALID(_t) \
(_t <= ZB_ZCL_DAILY_SCHEDULE_TYPE_LINKY_SCHEDULE)
/** @ref ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_SCHEDULE "GetSchedule" command payload
* @see Zigbee-17-05035-004, D.9.2.4.1.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_daily_schedule_get_schedule_payload_s
{
/** An unsigned 32-bit field containing a unique identifier for the commodity provider.
* This field allows differentiation in deregulated markets where multiple commodity
* providers may be available.
*/
zb_uint32_t provider_id;
/** UTC Timestamp indicating the earliest start time of schedules to be
* returned by the corresponding PublishSchedule command.
*/
zb_uint32_t earliest_start_time;
/** A 32-bit integer representing the minimum Issuer Event ID of schedules
* to be returned by the corresponding PublishSchedule command
*/
zb_uint32_t min_issuer_event_id;
/** An 8-bit integer which represents the maximum number of PublishSchedule commands
* that the client is willing to receive in response to this command.
*/
zb_uint8_t number_of_schedules;
/** An 8-bit enumeration identifying the type of the requested schedule.
* @see zb_zcl_daily_schedule_type_t
*/
zb_uint8_t schedule_type;
} ZB_PACKED_STRUCT zb_zcl_daily_schedule_get_schedule_payload_t;
/** Macro for initialization @ref ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_SCHEDULE "GetSchedule" command payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_GET_SCHEDULE_PL_INIT \
(zb_zcl_daily_schedule_get_schedule_payload_t) {0}
/** Macro for initialization @ref ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_DAY_PROFILE "GetDayProfile" command payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_GET_DAY_PROFILE_PL_INIT \
(zb_zcl_daily_schedule_get_day_profile_payload_t) {0}
/** Check if @ref ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_SCHEDULE "GetSchedule" command payload size is valid
* @param size - size of received data payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_GET_SCHEDULE_PL_SIZE_IS_VALID(size) \
((size >= sizeof(zb_zcl_daily_schedule_get_schedule_payload_t) ? ZB_TRUE : ZB_FALSE))
/** Check if @ref ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_DAY_PROFILE "GetDayProfile" command payload size is valid
* @param size - size of received data payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_GET_DAY_PROFILE_PL_SIZE_IS_VALID(size) \
((size >= sizeof(zb_zcl_daily_schedule_get_day_profile_payload_t) ? ZB_TRUE : ZB_FALSE))
/** This enumeration presents possible values of Schedule Time Reference field
* @see Zigbee-17-05035-004, Table D-13 Schedule Time Reference Enumeration
*/
typedef enum zb_zcl_daily_schedule_time_reference_e
{
ZB_ZCL_DAILY_SCHEDULE_TIME_REFERENCE_UTC_TIME = 0x00, /**< UTC time */
ZB_ZCL_DAILY_SCHEDULE_TIME_REFERENCE_STANDARD_TIME, /**< Standard time */
ZB_ZCL_DAILY_SCHEDULE_TIME_REFERENCE_LOCAL_TIME /**< Local time */
/* 0x03 - 0xFF is reserved */
} zb_zcl_daily_schedule_time_reference_t;
/** @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_SCHEDULE "PublishSchedule" command
* @see Zigbee-17-05035-004, subclause D.9.2.3.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_daily_schedule_publish_schedule_payload_s
{
/** An unsigned 32-bit field containing a unique identifier for the commodity
* provider.
*/
zb_uint32_t provider_id; /* (M) */
/** Unique identifier generated by the commodity provider. When new information
* is provided that replaces older information for the same time period, this
* field allows devices to determine which information is newer.
*/
zb_uint32_t issuer_event_id; /* (M) */
/** Unique identifier generated by the commodity Supplier to identify a particular schedule.
*/
zb_uint32_t schedule_id; /* (M) */
/** Unique identifier generated by the commodity supplier.
*/
zb_uint16_t day_id; /* (M) */
/** A UTC Time field to denote the time at which the published schedule becomes
* valid. A start date/time of 0x00000000 shall indicate that the command
* should be executed immediately.
*/
zb_uint32_t start_time; /* (M) */
/** An 8-bit enumeration identifying the type of schedule published in this
* command.
* @see zb_zcl_daily_schedule_type_t
*/
zb_uint8_t schedule_type; /* (M) */
/** This field indicates how the Start Times contained in the schedule are to be interpreted.
* @see zb_zcl_daily_schedule_time_reference_t
*/
zb_uint8_t schedule_time_reference; /* (M) */
/** The ScheduleName provides a method for utilities to assign a name to a schedule.
*/
zb_uint8_t schedule_name[1 + 12]; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_daily_schedule_publish_schedule_payload_t;
/** Macro for initialization @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_SCHEDULE "PublishSchedule" command payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_PUBLISH_SCHEDULE_PL_INIT \
(zb_zcl_daily_schedule_publish_schedule_payload_t) {0}
/** Macro for initialization @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_DAY_PROFILE "PublishDayProfile" command payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_PUBLISH_DAY_PROFILE_PL_INIT \
(zb_zcl_daily_schedule_publish_day_profile_payload_t) {0}
/** Macro for initialization @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_CANCEL_SCHEDULE "CancelSchedule" command payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_CANCEL_SCHEDULE_PL_INIT \
(zb_zcl_daily_schedule_cancel_schedule_payload_t) {0}
/** Compute expected size of received @ref zb_zcl_daily_schedule_publish_schedule_payload_t
* data payload
* @param pl - pointer to @ref zb_zcl_daily_schedule_publish_schedule_payload_t payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_PUBLISH_SCHEDULE_PL_EXPECTED_SIZE(pl) \
(sizeof(zb_zcl_daily_schedule_publish_schedule_payload_t)-sizeof((pl)->schedule_name)+1+ZB_ZCL_GET_STRING_LENGTH((pl)->schedule_name))
/** Check if @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_SCHEDULE "PublishSchedule" command payload size is valid
* @param pl - pointer to @ref zb_zcl_daily_schedule_publish_schedule_payload_t payload (pointer
* to buffer beginning that contains @ref zb_zcl_daily_schedule_publish_schedule_payload_t data payload)
* @param size - size of received data payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_PUBLISH_SCHEDULE_PL_SIZE_IS_VALID(pl, size) \
((size >= ZB_ZCL_DAILY_SCHEDULE_PUBLISH_SCHEDULE_PL_EXPECTED_SIZE((zb_zcl_daily_schedule_publish_schedule_payload_t *)pl)) ? ZB_TRUE : ZB_FALSE)
/** Check if @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_DAY_PROFILE "PublishDayProfile" command payload size is valid
* @param size - size of received data payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_PUBLISH_DAY_PROFILE_PL_SIZE_IS_VALID(size) \
((size >= (sizeof(zb_zcl_daily_schedule_publish_day_profile_payload_t)-sizeof(void *)-sizeof(zb_uint8_t)) ? ZB_TRUE : ZB_FALSE))
/** Check if @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_CANCEL_SCHEDULE "CancelSchedule" command payload size is valid
* @param size - size of received data payload
*/
#define ZB_ZCL_DAILY_SCHEDULE_CANCEL_SCHEDULE_PL_SIZE_IS_VALID(size) \
((size >= sizeof(zb_zcl_daily_schedule_cancel_schedule_payload_t) ? ZB_TRUE : ZB_FALSE))
/** Linky Schedules Command Sub-Payload structure
* See Zigbee-17-05035-004, D.9.2.3.2.3.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_daily_schedule_linky_schedule_entry_s
{
/** The Start Time is represented in minutes from midnight.
*/
zb_uint16_t start_time; /* (M) */
/** This is the current price tier that is valid until
* the start time of the next Schedule Entry.
*/
zb_uint8_t price_tier; /* (M) */
/** The required status of the auxiliary switches is indicated by the state of the bits.
* Bit0 correspond to Auxiliary Switch 1 and bit7 corresponds to Auxiliary Switch 8.
*/
zb_uint8_t auxiliary_load_switch_state; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_daily_schedule_linky_schedule_entry_t;
/** The format of schedule entry is dependent on schedule type.
*/
typedef ZB_PACKED_PRE union zb_zcl_daily_schedule_entry_u
{
zb_zcl_daily_schedule_linky_schedule_entry_t linky_schedule_entry;
} ZB_PACKED_STRUCT zb_zcl_daily_schedule_entry_t;
/** @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_DAY_PROFILE "PublishDayProfile" command payload.
* @see Zigbee-17-05035-004, subclause D.9.2.3.2
*/
typedef ZB_PACKED_PRE struct zb_zcl_daily_schedule_publish_day_profile_payload_s
{
/** An unsigned 32-bit field containing a unique identifier for the commodity
* provider.
*/
zb_uint32_t provider_id; /* (M) */
/** Unique identifier generated by the commodity provider. When new information
* is provided that replaces older information for the same time period, this
* field allows devices to determine which information is newer.
*/
zb_uint32_t issuer_event_id; /* (M) */
/** Unique identifier generated by the commodity supplier. The Day ID is used as a reference to assign a Day Profile to a Daily Schedule
*/
zb_uint16_t day_id; /* (M) */
/** Unique identifier generated by the commodity Supplier to identify a particular schedule.
*/
zb_uint32_t schedule_id; /* (M) */
/** An 8-bit integer representing the total number of ScheduleEntries in this Day Profile.
*/
zb_uint8_t total_number_of_schedule_entries; /* (M) */
/** The CommandIndex is used to count the payload fragments in the case where the entire payload
* does not fit into one message. The CommandIndex starts at 0 and is incremented for each fragment
* belonging to the same command
*/
zb_uint8_t command_index; /* (M) */
/** In the case where the entire payload does not fit into one message, the
* Total Number of Commands field indicates the total number of sub-commands
* in the message.
*/
zb_uint8_t total_number_of_commands; /* (M) */
/** An 8-bit enumeration identifying the type of schedule published in this
* command.
* @see zb_zcl_daily_schedule_type_t
*/
zb_uint8_t schedule_type; /* (M) */
/**
* day_schedule_entries pointer is considered as a beginning of array (of day schedule entries),
* number_of_entries_in_this_command - as a number of entries. Please also take into account
* overall ZCL payload size.
* @see zb_zcl_daily_schedule_entry_t
*/
zb_zcl_daily_schedule_entry_t *day_schedule_entries; /* (M) */
/** An 8-bit integer representing the number of Day Schedule entries in
* this command
*/
zb_uint8_t number_of_entries_in_this_command; /* (ZBOSS) */
} ZB_PACKED_STRUCT zb_zcl_daily_schedule_publish_day_profile_payload_t;
/** @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_CANCEL_SCHEDULE "CancelSchedule" command payload.
* @see Zigbee-17-05035-004, D.9.2.3.3
*/
typedef ZB_PACKED_PRE struct zb_zcl_daily_schedule_cancel_schedule_payload_s
{
/** An unsigned 32-bit field containing a unique identifier for the commodity
* provider.
*/
zb_uint32_t provider_id; /* (M) */
/** Unique identifier generated by the commodity Supplier to identify a particular schedule.
*/
zb_uint32_t schedule_id; /* (M) */
/** An 8-bit enumeration identifying the type of schedule published in this
* command.
* @see zb_zcl_daily_schedule_type_t
*/
zb_uint8_t schedule_type; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_daily_schedule_cancel_schedule_payload_t;
/** @ref ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_DAY_PROFILE "GetDayProfile" command payload
* @see Zigbee-17-05035-004, D.9.2.4.2
*/
typedef ZB_PACKED_PRE struct zb_zcl_daily_schedule_get_day_profile_payload_s
{
/** An unsigned 32-bit field containing a unique identifier for the commodity
* provider.
*/
zb_uint32_t provider_id; /* (M) */
/**
* ScheduleID of the schedule to which the requested Day Profile belongs.
*/
zb_uint16_t day_id;
} ZB_PACKED_STRUCT zb_zcl_daily_schedule_get_day_profile_payload_t;
/** Function for sending @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_SCHEDULE "PublishSchedule" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param pl - Packet payload (ref to @ref zb_zcl_daily_schedule_publish_schedule_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives
* APS ack.
*/
void zb_zcl_daily_schedule_send_cmd_publish_schedule(zb_uint8_t param, const zb_addr_u *dst_addr,
zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep, zb_uint8_t src_ep,
const zb_zcl_daily_schedule_publish_schedule_payload_t *pl,
zb_callback_t cb);
/** Function for send @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_PUBLISH_DAY_PROFILE "PublishDayProfile" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param pl - Packet payload (ref to @ref zb_zcl_daily_schedule_publish_day_profile_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives
* APS ack.
*/
void zb_zcl_daily_schedule_send_cmd_publish_day_profile(zb_uint8_t param,
const zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep, zb_uint8_t src_ep,
const zb_zcl_daily_schedule_publish_day_profile_payload_t *pl,
zb_callback_t cb
);
/** Function for sending @ref ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_SCHEDULE "GetSchedule" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param pl - Packet payload (ref to @ref zb_zcl_daily_schedule_get_schedule_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives
* APS ack.
*/
void zb_zcl_daily_schedule_send_cmd_get_schedule(zb_uint8_t param,
const zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep, zb_uint8_t src_ep,
const zb_zcl_daily_schedule_get_schedule_payload_t *pl,
zb_callback_t cb
);
/** Function for sending @ref ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_DAY_PROFILE "GetDayProfile" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param pl - Packet payload (ref to @ref zb_zcl_daily_schedule_get_day_profile_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives
* APS ack.
*/
void zb_zcl_daily_schedule_send_cmd_get_day_profile(zb_uint8_t param,
const zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep, zb_uint8_t src_ep,
const zb_zcl_daily_schedule_get_day_profile_payload_t *pl,
zb_callback_t cb
);
/** Function for send @ref ZB_ZCL_DAILY_SCHEDULE_CLI_CMD_GET_SCHEDULE_CANCELLATION
* "GetScheduleCancellation" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param cb - Callback which should be called when the ZCL stack receives
* APS ack.
*/
void zb_zcl_daily_schedule_send_cmd_get_schedule_cancellation(zb_uint8_t param,
const zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep, zb_uint8_t src_ep,
zb_callback_t cb
);
/** Function for send @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_CANCEL_SCHEDULE "CancelSchedule" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param pl - Packet payload (ref to @ref zb_zcl_daily_schedule_cancel_schedule_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives
* APS ack.
*/
void zb_zcl_daily_schedule_send_cmd_cancel_schedule(zb_uint8_t param,
const zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep, zb_uint8_t src_ep,
const zb_zcl_daily_schedule_cancel_schedule_payload_t *pl,
zb_callback_t cb
);
/** Function for send @ref ZB_ZCL_DAILY_SCHEDULE_SRV_CMD_CANCEL_ALL_SCHEDULES "CancelAllSchedules" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param cb - Callback which should be called when the ZCL stack receives
* APS ack.
*/
void zb_zcl_daily_schedule_send_cmd_cancel_all_schedules(zb_uint8_t param,
const zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep, zb_uint8_t src_ep,
zb_callback_t cb
);
/** Macro for calling @ref zb_zcl_daily_schedule_send_cmd_publish_schedule function
*/
#define ZB_ZCL_DAILY_SCHEDULE_SEND_CMD_PUBLISH_SCHEDULE(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload) \
zb_zcl_daily_schedule_send_cmd_publish_schedule(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** Macro for calling @ref zb_zcl_daily_schedule_send_cmd_publish_day_profile function
*/
#define ZB_ZCL_DAILY_SCHEDULE_SEND_CMD_PUBLISH_DAY_PROFILE(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload) \
zb_zcl_daily_schedule_send_cmd_publish_day_profile(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_zcl_daily_schedule_send_cmd_cancel_schedule function
*/
#define ZB_ZCL_DAILY_SCHEDULE_SEND_CMD_CANCEL_SCHEDULE(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload) \
zb_zcl_daily_schedule_send_cmd_cancel_schedule(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_zcl_daily_schedule_send_cmd_cancel_all_schedules function
*/
#define ZB_ZCL_DAILY_SCHEDULE_SEND_CMD_CANCEL_ALL_SCHEDULES(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep) \
zb_zcl_daily_schedule_send_cmd_cancel_all_schedules(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, NULL)
/** Macro for call @ref zb_zcl_daily_schedule_send_cmd_get_schedule function
*/
#define ZB_ZCL_DAILY_SCHEDULE_SEND_CMD_GET_SCHEDULE(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload) \
zb_zcl_daily_schedule_send_cmd_get_schedule(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_zcl_daily_schedule_send_cmd_get_day_profile function
*/
#define ZB_ZCL_DAILY_SCHEDULE_SEND_CMD_GET_DAY_PROFILE(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload) \
zb_zcl_daily_schedule_send_cmd_get_day_profile(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_zcl_daily_schedule_send_cmd_get_schedule_cancellation function
*/
#define ZB_ZCL_DAILY_SCHEDULE_SEND_CMD_GET_SCHEDULE_CANCELLATION(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep) \
zb_zcl_daily_schedule_send_cmd_get_schedule_cancellation(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, NULL)
/** @} */ /* ZB_ZCL_DAILY_SCHEDULE_COMMANDS */
/** @brief Default value for CurrentAuxiliaryLoadSwitchState attribute */
#define ZB_ZCL_DAILY_SCHEDULE_CURRENT_AUXILLARY_LOAD_SWITCH_STATE_DEFAULT_VALUE 0x00
/** @brief Default value for LinkyPeakPeriodStatus attribute */
#define ZB_ZCL_DAILY_SCHEDULE_LINKY_PEAK_PERIOD_STATUS_DEFAULT_VALUE 0x00
/** @brief Default value for PeakStartTime attribute */
#define ZB_ZCL_DAILY_SCHEDULE_PEAK_START_TIME_DEFAULT_VALUE ((zb_uint32_t)0xFFFFFFFF)
/** @brief Default value for PeakEndTime attribute */
#define ZB_ZCL_DAILY_SCHEDULE_PEAK_END_TIME_DEFAULT_VALUE ((zb_uint32_t)0xFFFFFFFF)
/** @brief Default value for CurrentTariffLabel attribute */
#define ZB_ZCL_DAILY_SCHEDULE_CURRENT_TARIFF_LABEL_DEFAULT_VALUE {0}
/** @} */ /* ZCL Daily Schedule cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
/******************************************************************************/
/* Server */
/******************************************************************************/
/* Client */
/******************************************************************************/
/* Common */
/******************************************************************************/
void zb_zcl_daily_schedule_init_server();
void zb_zcl_daily_schedule_init_client();
#define ZB_ZCL_CLUSTER_ID_DAILY_SCHEDULE_SERVER_ROLE_INIT zb_zcl_daily_schedule_init_server
#define ZB_ZCL_CLUSTER_ID_DAILY_SCHEDULE_CLIENT_ROLE_INIT zb_zcl_daily_schedule_init_client
/******************************************************************************/
#endif /* ZB_ZCL_DAILY_SCHEDULE_H_ */

View File

@@ -0,0 +1,209 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Dehumidification Control cluster definitions
*/
#ifndef ZB_ZCL_DEHUMIDIFICATION_CONTROL_H
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_DEHUMIDIFICATION
* @{
*/
/* Cluster ZB_ZCL_CLUSTER_ID_DEHUMIDIFICATION_CONTROL */
/*! @name Dehumidification Control cluster attributes
@{
*/
/*! @brief Dehumidification Control cluster attribute identifiers
@see ZCL spec, subclause 6.4.2.2
*/
enum zb_zcl_dehumidification_control_attr_e
{
/** The RelativeHumidity attribute is an 8-bit value that represents the current
* relative humidity (in %) measured by a local or remote sensor. */
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_RELATIVE_HUMIDITY_ID = 0x0000,
/** @brief Dehumidification Cooling attribute */
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_COOLING_ID = 0x0001,
/** @brief RHDehumidification Setpoint attribute */
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_RHDEHUMIDIFICATION_SETPOINT_ID = 0x0010,
/** The RelativeHumidityMode attribute is an 8-bit value that specifies how
* the RelativeHumidity value is being updated. */
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_RELATIVE_HUMIDITY_MODE_ID = 0x0011,
/** The DehumidificationLockout attribute is an 8-bit value that specifies
* whether dehumidification is allowed or not. */
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_LOCKOUT_ID = 0x0012,
/** @brief Dehumidification Hysteresis attribute */
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_HYSTERESIS_ID = 0x0013,
/** @brief Dehumidification Max Cool attribute */
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_MAX_COOL_ID = 0x0014,
/** The RelativeHumidityDisplay attribute is an 8-bit value that specifies
* whether the RelativeHumidity value is displayed to the user or not. */
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_RELATIVE_HUMIDITY_DISPLAY_ID = 0x0015,
};
/** @brief Default value for Dehumidification Control cluster revision global attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Min value for RHDehumidification Setpoint attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_RHDEHUMIDIFICATION_SETPOINT_MIN_VALUE 0x1e
/** @brief Max value for RHDehumidification Setpoint attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_RHDEHUMIDIFICATION_SETPOINT_MAX_VALUE 0x64
/** @brief Default value for RHDehumidification Setpoint attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_RHDEHUMIDIFICATION_SETPOINT_DEFAULT_VALUE 0x32
/** @brief Default value for RelativeHumidityMode attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_RELATIVE_HUMIDITY_MODE_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for DehumidificationLockout attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_LOCKOUT_DEFAULT_VALUE ((zb_uint8_t)0x01)
/** @brief Min value for Dehumidification Hysteresis attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_HYSTERESIS_MIN_VALUE 0x02
/** @brief Max value for Dehumidification Hysteresis attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_HYSTERESIS_MAX_VALUE 0x14
/** @brief Default value for Dehumidification Hysteresis attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_HYSTERESIS_DEFAULT_VALUE 0x02
/** @brief Min value for Dehumidification Max Cool attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_MAX_COOL_MIN_VALUE 0x14
/** @brief Max value for Dehumidification Max Cool attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_MAX_COOL_MAX_VALUE 0x64
/** @brief Default value for Dehumidification Max Cool attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_MAX_COOL_DEFAULT_VALUE 0x14
/** @brief Default value for RelativeHumidityDisplay attribute */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_RELATIVE_HUMIDITY_DISPLAY_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Declare attribute list for Dehumidification Control cluster
@param attr_list - attribute list name
@param dehumid_cooling - pointer to variable to store Dehumidification Cooling attribute value
@param dehumid_setpoint - pointer to variable to store Dehumidification Setpoint attribute value
@param dehumid_hysteresis - pointer to variable to store Dehumidification Hysteresis attribute value
@param dehumid_max_cool - pointer to variable to store Dehumidification Max Cool attribute value
*/
#define ZB_ZCL_DECLARE_DEHUMIDIFICATION_CONTROL_ATTRIB_LIST(attr_list, dehumid_cooling, dehumid_setpoint, \
dehumid_hysteresis, dehumid_max_cool) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_DEHUMIDIFICATION_CONTROL) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_COOLING_ID, (dehumid_cooling)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_RHDEHUMIDIFICATION_SETPOINT_ID, (dehumid_setpoint)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_HYSTERESIS_ID, (dehumid_hysteresis)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_MAX_COOL_ID, (dehumid_max_cool)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Dehumidification Control cluster attributes */
/*! @name Dehumidification Control cluster commands
@{
*/
/*! @} */ /* Dehumidification Control cluster commands */
/** @cond internals_doc */
/*! @internal @name Dehumidification Control cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_COOLING_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_COOLING_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_RHDEHUMIDIFICATION_SETPOINT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_RHDEHUMIDIFICATION_SETPOINT_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_HYSTERESIS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_HYSTERESIS_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_MAX_COOL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEHUMIDIFICATION_CONTROL_DEHUMIDIFICATION_MAX_COOL_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in Dehumidification Control cluster */
#define ZB_ZCL_DEHUMIDIFICATION_CONTROL_REPORT_ATTR_COUNT 1
/*! @} */ /* Dehumidification Control cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/*! @} */ /* ZCL HA Dehumidification Control cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_dehumidification_control_init_server(void);
void zb_zcl_dehumidification_control_init_client(void);
#define ZB_ZCL_CLUSTER_ID_DEHUMID_CONTROL_SERVER_ROLE_INIT zb_zcl_dehumidification_control_init_server
#define ZB_ZCL_CLUSTER_ID_DEHUMID_CONTROL_CLIENT_ROLE_INIT zb_zcl_dehumidification_control_init_client
#endif /* ZB_ZCL_DEHUMID_CONTROL_H */

View File

@@ -0,0 +1,371 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Device Temperature Configuration cluster definitions */
#ifndef ZB_ZCL_DEVICE_TEMP_CONFIG_H
#define ZB_ZCL_DEVICE_TEMP_CONFIG_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_DEVICE_TEMP_CONFIG
* @{
* @details
* Attributes for determining information about a devices internal
* temperature, and for configuring under/over temperature alarms for
* temperatures that are outside the devices operating range.
*/
/* Cluster ZB_ZCL_CLUSTER_ID_DEVICE_TEMP_CONFIG */
/** @name Device Temperature Configuration cluster attributes
* @{
*/
/** @brief Device Temperature Configuration cluster attribute identifiers
* @see ZCL spec, Device Temperature Configuration Cluster 3.4.1.4
*/
enum zb_zcl_device_temp_config_attr_e
{
/** @brief CurrentTemp attribute, ZCL spec 3.4.2.2.1 */
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_CURRENT_TEMP_ID = 0x0000,
/** @brief MinTempExperienced attribute, ZCL spec 3.4.2.2.1 */
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MIN_TEMP_EXPERIENCED_ID = 0x0001,
/** @brief MaxTempExperienced attribute, ZCL spec 3.4.2.2.1 */
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MAX_TEMP_EXPERIENCED_ID = 0x0002,
/** @brief OverTempTotalDwell attribute, ZCL spec 3.4.2.2.1 */
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_OVER_TEMP_TOTAL_DWELL_ID = 0x0003,
/** @brief DeviceTempAlarmMask attribute, ZCL spec 3.4.2.2.2 */
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_DEVICE_TEMP_ALARM_MASK_ID = 0x0010,
/** @brief LowTempThreshold attribute, ZCL spec 3.4.2.2.2 */
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_THRESHOLD_ID = 0x0011,
/** @brief HighTempThreshold attribute, ZCL spec 3.4.2.2.2 */
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_THRESHOLD_ID = 0x0012,
/** @brief LowTempDwellTripPoint attribute, ZCL spec 3.4.2.2.2 */
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_DWELL_TRIP_POINT_ID = 0x0013,
/** @brief HighTempDwellTripPoint attribute, ZCL spec 3.4.2.2.2 */
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_DWELL_TRIP_POINT_ID = 0x0014,
};
/** @brief Default value for Device Temperature Configuration cluster revision global attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Minimum value for CurrentTemp attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_CURRENT_TEMP_MIN_VALUE (-200)
/** @brief Maximum value for CurrentTemp attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_CURRENT_TEMP_MAX_VALUE (+200)
/** @brief Minimum value for MinTempExperienced attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_MIN_TEMP_EXPERIENCED_MIN_VALUE (-200)
/** @brief Maximum value for MinTempExperienced attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_MIN_TEMP_EXPERIENCED_MAX_VALUE (+200)
/** @brief Minimum value for MaxTempExperienced attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_MAX_TEMP_EXPERIENCED_MIN_VALUE (-200)
/** @brief Maximum value for MaxTempExperienced attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_MAX_TEMP_EXPERIENCED_MAX_VALUE (+200)
/** @brief Minimum value for OverTotalDwell attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_OVER_TEMP_TOTAL_DWELL_MIN_VALUE (0x0000)
/** @brief Maximum value for OverTotalDwell attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_OVER_TEMP_TOTAL_DWELL_MAX_VALUE (0xffff)
/** @brief Minimum value for DeviceTempAlarmMask attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_DEVICE_TEMP_ALARM_MASK_MIN_VALUE (0b00000000)
/** @brief Maximum value for DeviceTempAlarmMask attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_DEVICE_TEMP_ALARM_MASK_MAX_VALUE (0b00000011)
/** @brief Minimum value for LowTempThreshold attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_LOW_TEMP_THRESHOLD_MIN_VALUE (-200)
/** @brief Maximum value for LowTempThreshold attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_LOW_TEMP_THRESHOLD_MAX_VALUE (+200)
/** @brief Minimum value for HighTempThreshold attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_HIGH_TEMP_THRESHOLD_MIN_VALUE (-200)
/** @brief Maximum value for HighTempThreshold attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_HIGH_TEMP_THRESHOLD_MAX_VALUE (+200)
/** @brief Minimum value for LowTempTripPoint attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_LOW_TEMP_DWELL_TRIP_POINT_MIN_VALUE (0x000000)
/** @brief Maximum value for LowTempTripPoint attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_LOW_TEMP_DWELL_TRIP_POINT_MAX_VALUE (0xffffff)
/** @brief Minimum value for HighTempTripPoint attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_HIGH_TEMP_DWELL_TRIP_POINT_MIN_VALUE (0x000000)
/** @brief Maximum value for HighTempTripPoint attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_HIGH_TEMP_DWELL_TRIP_POINT_MAX_VALUE (0xffffff)
/** @brief Default value for CurrentTemp attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_CURRENT_TEMP_DEFAULT_VALUE ZB_ZCL_NON_VALUE_INT16
/** @brief Default value for MinTempExperienced attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_MIN_TEMP_EXPERIENCED_DEFAULT_VALUE ZB_ZCL_NON_VALUE_INT16
/** @brief Default value for MaxTempExperienced attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_MAX_TEMP_EXPERIENCED_DEFAULT_VALUE ZB_ZCL_NON_VALUE_INT16
/** @brief Default value for OverTempTotalDwell attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_OVER_TEMP_TOTAL_DWELL_DEFAULT_VALUE 0
/** @brief Default value for DeviceTempAlarmMask attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_DEVICE_TEMP_ALARM_MASK_DEFAULT_VALUE 0
/** @brief Default value for LowTempThreshold attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_LOW_TEMP_THRESHOLD_DEFAULT_VALUE ZB_ZCL_NON_VALUE_INT16
/** @brief Default value for HighTempThreshold attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_HIGH_TEMP_THRESHOLD_DEFAULT_VALUE ZB_ZCL_NON_VALUE_INT16
/** @brief Default value for LowTempDwellTripPoint attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_LOW_TEMP_DWELL_TRIP_POINT_DEFAULT_VALUE ZB_ZCL_NON_VALUE_UINT24
/** @brief Default value for HighTempDwellTripPoint attribute */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_HIGH_TEMP_DWELL_TRIP_POINT_DEFAULT_VALUE ZB_ZCL_NON_VALUE_UINT24
/** @cond internals_doc */
/** @name Device Temperature Configuration cluster internals
* Internal structures for Device Temperature Configuration cluster
* @{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_CURRENT_TEMP_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_CURRENT_TEMP_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MIN_TEMP_EXPERIENCED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MIN_TEMP_EXPERIENCED_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MAX_TEMP_EXPERIENCED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MAX_TEMP_EXPERIENCED_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_OVER_TEMP_TOTAL_DWELL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_OVER_TEMP_TOTAL_DWELL_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_DEVICE_TEMP_ALARM_MASK_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_DEVICE_TEMP_ALARM_MASK_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_THRESHOLD_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_THRESHOLD_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_THRESHOLD_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_THRESHOLD_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_DWELL_TRIP_POINT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_DWELL_TRIP_POINT_ID, \
ZB_ZCL_ATTR_TYPE_U24, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_DWELL_TRIP_POINT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_DWELL_TRIP_POINT_ID, \
ZB_ZCL_ATTR_TYPE_U24, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** Number of attributes mandatory for reporting in Device Temperature Configuration cluster */
#define ZB_ZCL_DEVICE_TEMP_CONFIG_REPORT_ATTR_COUNT 0
/** @} */
/** @endcond */ /* Device Temperature Configuration cluster internals */
/** @brief Declare attribute list for Device Temperature Configuration cluster
* @param attr_list - attribute list name
* @param current_temp - pointer to variable storing CurrentTemp attribute value
* @param min_temp_experienced - pointer to variable storing MinTempExperienced attribute value
* @param max_temp_experienced - pointer to variable storing MaxTempExperienced attribute value
* @param over_temp_total_dwell - pointer to variable storing OverTempTotalDwell attribute value
* @param device_temp_alarm_mask - pointer to variable storing DeviceTempAlarmMask attribute value
* @param low_temp_threshold - pointer to variable storing LowTempThreshold attribute value
* @param high_temp_threshold - pointer to variable storing HighTempThreshold attribute value
* @param low_temp_dwell_trip_point - pointer to variable storing LowTempDwellTripPoint attribute value
* @param high_temp_dwell_trip_point - pointer to variable storing HighTempDwellTripPoint attribute value
*/
#define ZB_ZCL_DECLARE_DEVICE_TEMP_CONFIG_ATTRIB_LIST(attr_list, \
current_temp, \
min_temp_experienced, \
max_temp_experienced, \
over_temp_total_dwell, \
device_temp_alarm_mask, \
low_temp_threshold, \
high_temp_threshold, \
low_temp_dwell_trip_point, \
high_temp_dwell_trip_point) \
\
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_DEVICE_TEMP_CONFIG) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_CURRENT_TEMP_ID, (current_temp)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MIN_TEMP_EXPERIENCED_ID, (min_temp_experienced)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MAX_TEMP_EXPERIENCED_ID, (max_temp_experienced)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_OVER_TEMP_TOTAL_DWELL_ID, (over_temp_total_dwell)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_DEVICE_TEMP_ALARM_MASK_ID, (device_temp_alarm_mask)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_THRESHOLD_ID, (low_temp_threshold)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_THRESHOLD_ID, (high_temp_threshold)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_DWELL_TRIP_POINT_ID, (low_temp_dwell_trip_point)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_DWELL_TRIP_POINT_ID, (high_temp_dwell_trip_point)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/**
* @brief Device Temperature Configuration cluster attributes
*/
typedef struct zb_zcl_device_temp_config_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_CURRENT_TEMP_ID
* @see ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_CURRENT_TEMP_ID
*/
zb_int16_t current_temp;
/** @copydoc ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MIN_TEMP_EXPERIENCED_ID
* @see ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MIN_TEMP_EXPERIENCED_ID
*/
zb_int16_t min_temp_experienced;
/** @copydoc ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MAX_TEMP_EXPERIENCED_ID
* @see ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_MAX_TEMP_EXPERIENCED_ID
*/
zb_int16_t max_temp_experienced;
/** @copydoc ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_OVER_TEMP_TOTAL_DWELL_ID
* @see ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_OVER_TEMP_TOTAL_DWELL_ID
*/
zb_uint16_t over_temp_total_dwell;
/** @copydoc ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_DEVICE_TEMP_ALARM_MASK_ID
* @see ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_DEVICE_TEMP_ALARM_MASK_ID
*/
zb_uint8_t device_temp_alarm_mask;
/** @copydoc ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_THRESHOLD_ID
* @see ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_THRESHOLD_ID
*/
zb_int16_t low_temp_threshold;
/** @copydoc ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_THRESHOLD_ID
* @see ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_THRESHOLD_ID
*/
zb_int16_t high_temp_threshold;
/** @copydoc ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_DWELL_TRIP_POINT_ID
* @see ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_LOW_TEMP_DWELL_TRIP_POINT_ID
*/
zb_uint24_t low_temp_dwell_trip_point;
/** @copydoc ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_DWELL_TRIP_POINT_ID
* @see ZB_ZCL_ATTR_DEVICE_TEMP_CONFIG_HIGH_TEMP_DWELL_TRIP_POINT_ID
*/
zb_uint24_t high_temp_dwell_trip_point;
} zb_zcl_device_temp_config_attrs_t;
/** @brief Declare attribute list for Device Temperature Configuration cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of @ref zb_zcl_device_temp_config_attrs_t type
* (containing Device Temperature Configuration cluster attributes)
*/
#define ZB_ZCL_DECLARE_DEVICE_TEMP_CONFIG_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_DEVICE_TEMP_CONFIG_ATTRIB_LIST(attr_list, \
&attrs.current_temp, \
&attrs.min_temp_experienced, \
&attrs.max_temp_experienced, \
&attrs.over_temp_total_dwell, \
&attrs.device_temp_alarm_mask, \
&attrs.low_temp_threshold, \
&attrs.high_temp_threshold, \
&attrs.low_temp_dwell_trip_point, \
&attrs.high_temp_dwell_trip_point)
/** @} */ /* end of ZB_ZCL_DEVICE_TEMP_CONFIG_ATTRS_GROUP group */
/** @} */ /* ZCL Device Temperature Configuration cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_device_temp_config_init_server(void);
void zb_zcl_device_temp_config_init_client(void);
#define ZB_ZCL_CLUSTER_ID_DEVICE_TEMP_CONFIG_SERVER_ROLE_INIT zb_zcl_device_temp_config_init_server
#define ZB_ZCL_CLUSTER_ID_DEVICE_TEMP_CONFIG_CLIENT_ROLE_INIT zb_zcl_device_temp_config_init_client
#endif /* ZB_ZCL_DEVICE_TEMP_CONFIG_H */

View File

@@ -0,0 +1,696 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Diagnostics cluster definitions
*/
#ifndef ZB_ZCL_DIAGNOSTICS_H
#define ZB_ZCL_DIAGNOSTICS_H 1
#if defined(ZB_ZCL_SUPPORT_CLUSTER_DIAGNOSTICS) || defined(DOXYGEN)
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_DIAGNOSTICS
* @{
* @details
* ZCL Diagnostics cluster definitions
*/
/* Cluster ZB_ZCL_CLUSTER_ID_DIAGNOSTICS */
/*! @name Diagnostics cluster attributes
@{
*/
typedef ZB_PACKED_PRE struct zb_zcl_diagnostics_ctx_s
{
zb_mac_diagnostic_info_t mac_data;
zdo_diagnostics_info_t zdo_data;
zb_callback_t sync_data_cb;
zb_uint8_t cb_param;
}
ZB_PACKED_STRUCT zb_zcl_diagnostics_ctx_t;
extern zb_zcl_diagnostics_ctx_t diagnostics_ctx_zcl;
/*! @brief Diagnostics cluster attribute identifiers
@see HA spec, Diagnostics Cluster 9.3.2.2.2
*/
enum zb_zcl_diagnostics_attr_e
{
/** @brief number_of_resets, Zigbee Diagnostic Cluster spec 1.2.2.1.1 */
ZB_ZCL_ATTR_DIAGNOSTICS_NUMBER_OF_RESETS_ID = 0x0000,
/** This attribute keeps track of the number of writes to persistent memory.
* HA spec 9.2.2.2.1.2 */
ZB_ZCL_ATTR_DIAGNOSTICS_PERSISTENT_MEMORY_WRITES_ID = 0x0001,
/** @brief MacRxBcast, HA spec 9.2.2.2.2.1 */
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_RX_BCAST_ID = 0x0100,
/** @brief MacTxBcast, HA spec 9.2.2.2.2.2 */
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_BCAST_ID = 0x0101,
/** MacRxUcast Attribute A counter that is incremented each time the MAC
* layer receives a unicast. */
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_RX_UCAST_ID = 0x0102,
/** @brief MacTxUcast, HA spec 9.2.2.2.2.4 */
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_ID = 0x0103,
/** MacTxUcastRetry Attribute A counter that is incremented each time
* the MAC layer retries a unicast. */
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_RETRY_ID = 0x0104,
/** MacTxUcastFail Attribute A counter that is incremented each time
* the MAC layer fails to send a unicast. */
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_FAIL_ID = 0x0105,
/** APSRxBcast Attribute A counter that is incremented each time
* the APS layer receives a broadcast. */
ZB_ZCL_ATTR_DIAGNOSTICS_APS_RX_BCAST_ID = 0x0106,
/** @brief aps_tx_bcast, HA spec 9.3.2.2.2 (??) */
ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_BCAST_ID = 0x0107,
/** APSRxUcast Attribute A counter that is incremented each time
* the APS layer receives a unicast. */
ZB_ZCL_ATTR_DIAGNOSTICS_APS_RX_UCAST_ID = 0x0108,
/** @brief aps_tx_ucast_success, HA spec 9.3.2.2.2 (??) */
ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_SUCCESS_ID = 0x0109,
/** APSTxUcastRetry Attribute A counter that is incremented each time
* the APS layer retries the sending of a unicast. */
ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_RETRY_ID = 0x010A,
/** @brief aps_tx_ucast_fail, HA spec 9.3.2.2.2 (??) */
ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_FAIL_ID = 0x010b,
/** RouteDiscInitiated Attribute A counter that is incremented each time
* a route request is initiated . */
ZB_ZCL_ATTR_DIAGNOSTICS_ROUTE_DISC_INITIATED_ID = 0x010C,
/** NeighborAdded Attribute A counter that is incremented each time
* an entry is added to the neighbor table. */
ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_ADDED_ID = 0x010D,
/** NeighborRemoved Attribute A counter that is incremented each time
* an entry is removed from the neighbor table. */
ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_REMOVED_ID = 0x010E,
/** A counter that is incremented each time a neighbor table entry becomes stale
* because the neighbor has not been heard from. */
ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_STALE_ID = 0x010F,
/** @brief join_indication, HA spec 1.2.2.2.17 */
ZB_ZCL_ATTR_DIAGNOSTICS_JOIN_INDICATION_ID = 0x0110,
/** A counter that is incremented each time an entry is removed from the child table. */
ZB_ZCL_ATTR_DIAGNOSTICS_CHILD_MOVED_ID = 0x0111,
/** A counter that is incremented each time a message is dropped at the network
* layer because the APS frame counter was not higher than the last message seen
* from that source. */
ZB_ZCL_ATTR_DIAGNOSTICS_NWKFC_FAILURE_ID = 0x0112,
/** A counter that is incremented each time a message is dropped at the APS layer
* because the APS frame counter was not higher than the last message seen from
* that source. */
ZB_ZCL_ATTR_DIAGNOSTICS_APSFC_FAILURE_ID = 0x0113,
/** A counter that is incremented each time a message is dropped at the APS layer
* because it had APS encryption but the key associated with the sender has
* not been authenticated, and thus the key is not authorized for use
* in APS data messages. */
ZB_ZCL_ATTR_DIAGNOSTICS_APS_UNAUTHORIZED_KEY_ID = 0x0114,
/** A counter that is incremented each time a NWK encrypted message was received
* but dropped because decryption failed. */
ZB_ZCL_ATTR_DIAGNOSTICS_NWK_DECRYPT_FAILURES_ID = 0x0115,
/** A counter that is incremented each time an APS encrypted message was received
* but dropped because decryption failed. */
ZB_ZCL_ATTR_DIAGNOSTICS_APS_DECRYPT_FAILURES_ID = 0x0116,
/** A counter that is incremented each time the stack failed to allocate a packet
* buffers. This doesn't necessarily mean that the packet buffer count was 0 at
* the time, but that the number requested was greater than the number free. */
ZB_ZCL_ATTR_DIAGNOSTICS_PACKET_BUFFER_ALLOCATE_FAILURES_ID = 0x0117,
/** A counter that is incremented each time a unicast packet is relayed. */
ZB_ZCL_ATTR_DIAGNOSTICS_RELAYED_UCAST_ID = 0x0118,
/** A counter that is incremented each time a packet is dropped because the PHY to
* MAC queue was exhausted */
ZB_ZCL_ATTR_DIAGNOSTICS_PHYTOMACQUEUELIMITREACHED_ID = 0x0119,
/** A counter that is incremented each time a packet was dropped due to a packet
* validation error. This could be due to length or other formatting problems
* in the packet. */
ZB_ZCL_ATTR_DIAGNOSTICS_PACKET_VALIDATEDROPCOUNT_ID = 0x011A,
/** A counter that is equal to the average number of MAC retries needed to send
* an APS message, HA spec 9.2.2.2.2.27 */
ZB_ZCL_ATTR_DIAGNOSTICS_AVERAGE_MAC_RETRY_PER_APS_ID = 0x011b,
/** This is the Link Quality Indicator for the last message received. There is no
* current agreed upon standard for calculating the LQI. For some implementations
* LQI is related directly to RSSI for others it is a function of the number of
* errors received over a fixed number of bytes in a given message. The one thing
* that has been agreed is that the Link Quality Indicator is a value between 0
* and 255 where 0 indicates the worst possible link and 255 indicates the best
* possible link. Note that for a device reading the Last Message LQI the returned
* value SHALL be the LQI for the read attribute message used to read the attribute
* itself. */
ZB_ZCL_ATTR_DIAGNOSTICS_LAST_LQI_ID = 0x011c,
/** This is the receive signal strength indication for the last message received.
* As with Last Message LQI, a device reading the Last Message RSSI, the returned
* value SHALL be the RSSI of the read attribute message used to read the attribute
* itself. */
ZB_ZCL_ATTR_DIAGNOSTICS_LAST_RSSI_ID = 0x011d,
/*! @brief A counter that is incremented on the NWK layer
* each time tries number of a packet resending are gone.
*
* @note It's a non-standard counter that depends on ZB_ENABLE_NWK_RETRANSMIT and
* will be zero always when the macro isn't set. */
ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_NWK_RETRY_OVERFLOW_ID = 0xff00,
/** A non-standard counter that is incremented each time an the PHY layer was unable
* to transmit due to a failed CCA */
ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_PHY_CCA_FAILURES_ID = 0xff01,
/** A non-standard counter of the number of times the NWK broadcast was dropped
* because the broadcast table was full. */
ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_BCAST_TABLE_FULL_ID = 0xff02
};
/** @brief Default value for Diagnostics cluster revision global attribute */
#define ZB_ZCL_DIAGNOSTICS_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0003u)
/** @brief Default value for number_of_resets attribute */
#define ZB_ZCL_DIAGNOSTICS_NUMBER_OF_RESETS_DEFAULT_VALUE ((zb_uint16_t)0x00000000)
/** @brief Default value for PersistentMemoryWrites attribute */
#define ZB_ZCL_DIAGNOSTICS_PERSISTENT_MEMORY_WRITES_DEFAULT_VALUE ((zb_uint16_t)0x00000000)
/** @brief Default value for MacRxBcast attribute */
#define ZB_ZCL_DIAGNOSTICS_MAC_RX_BCAST_DEFAULT_VALUE ((zb_uint32_t)0)
/** @brief Default value for MacTxBcast attribute */
#define ZB_ZCL_DIAGNOSTICS_MAC_TX_BCAST_DEFAULT_VALUE ((zb_uint32_t)0)
/** @brief Default value for MacRxUcast attribute */
#define ZB_ZCL_DIAGNOSTICS_MAC_RX_UCAST_DEFAULT_VALUE ((zb_uint32_t)0)
/** @brief Default value for MacTxUcast attribute */
#define ZB_ZCL_DIAGNOSTICS_MAC_TX_UCAST_DEFAULT_VALUE ((zb_uint32_t)0)
/** @brief Default value for MacTxUcastRetry attribute */
#define ZB_ZCL_DIAGNOSTICS_MAC_TX_UCAST_RETRY_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for MacTxUcastFail attribute */
#define ZB_ZCL_DIAGNOSTICS_MAC_TX_UCAST_FAIL_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for APSRxBcast attribute */
#define ZB_ZCL_DIAGNOSTICS_APS_RX_BCAST_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for aps_tx_bcast attribute */
#define ZB_ZCL_DIAGNOSTICS_APS_TX_BCAST_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for APSRxUcast attribute */
#define ZB_ZCL_DIAGNOSTICS_APS_RX_UCAST_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for aps_tx_ucast_success attribute */
#define ZB_ZCL_DIAGNOSTICS_APS_TX_UCAST_SUCCESS_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for APSTxUcastRetry attribute */
#define ZB_ZCL_DIAGNOSTICS_APS_TX_UCAST_RETRY_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for aps_tx_ucast_fail attribute */
#define ZB_ZCL_DIAGNOSTICS_APS_TX_UCAST_FAIL_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for RouteDiscInitiated attribute */
#define ZB_ZCL_DIAGNOSTICS_ROUTE_DISC_INITIATED_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for NeighborAdded attribute */
#define ZB_ZCL_DIAGNOSTICS_NEIGHBOR_ADDED_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for NeighborRemoved attribute */
#define ZB_ZCL_DIAGNOSTICS_NEIGHBOR_REMOVED_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for NeighborStale attribute */
#define ZB_ZCL_DIAGNOSTICS_NEIGHBOR_STALE_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for join_indication attribute */
#define ZB_ZCL_DIAGNOSTICS_JOIN_INDICATION_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for ChildMoved attribute */
#define ZB_ZCL_DIAGNOSTICS_CHILD_MOVED_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for nwk_fc_failure attribute */
#define ZB_ZCL_DIAGNOSTICS_NWKFC_FAILURE_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for aps_fc_failure attribute */
#define ZB_ZCL_DIAGNOSTICS_APSFC_FAILURE_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for APSUnauthorizedKey attribute */
#define ZB_ZCL_DIAGNOSTICS_APS_UNAUTHORIZED_KEY_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for NWKDecryptFailures attribute */
#define ZB_ZCL_DIAGNOSTICS_NWK_DECRYPT_FAILURES_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for APSDecryptFailures attribute */
#define ZB_ZCL_DIAGNOSTICS_APS_DECRYPT_FAILURES_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for packet_buffer_allocate_failures attribute */
#define ZB_ZCL_DIAGNOSTICS_PACKET_BUFFER_ALLOCATE_FAILURES_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for RelayedUcast attribute */
#define ZB_ZCL_DIAGNOSTICS_RELAYED_UCAST_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for PhytoMACqueuelimitreached attribute */
#define ZB_ZCL_DIAGNOSTICS_PHYTO_MA_CQUEUELIMITREACHED_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for PacketValidatedropcount attribute */
#define ZB_ZCL_DIAGNOSTICS_PACKET_VALIDATEDROPCOUNT_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for AverageMACRetryPerAPS attribute */
#define ZB_ZCL_DIAGNOSTICS_AVERAGE_MAC_RETRY_PER_APS_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for LastLQI attribute */
#define ZB_ZCL_DIAGNOSTICS_LAST_LQI_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for LastRSSI attribute */
#define ZB_ZCL_DIAGNOSTICS_LAST_RSSI_DEFAULT_VALUE ((zb_int8_t)0)
#define ZB_ZCL_DIAGNOSTICS_CUSTOM_ATTR_NWK_RETRY_OVERFLOW_DEFAULT_VALUE ((zb_uint16_t)0)
#define ZB_ZCL_DIAGNOSTICS_CUSTOM_ATTR_PHY_CCA_FAILURES_DEFAULT_VALUE ((zb_uint16_t)0)
#define ZB_ZCL_DIAGNOSTICS_CUSTOM_ATTR_BCAST_TABLE_FULL_DEFAULT_VALUE ((zb_uint16_t)0)
/** @cond internals_doc */
/*! @internal @name Diagnostics cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_NUMBER_OF_RESETS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_NUMBER_OF_RESETS_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_PACKET_BUFFER_ALLOCATE_FAILURES_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_PACKET_BUFFER_ALLOCATE_FAILURES_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_JOIN_INDICATION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_JOIN_INDICATION_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_MAC_RX_BCAST_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_RX_BCAST_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_BCAST_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_BCAST_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_MAC_RX_UCAST_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_RX_BCAST_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_RETRY_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_RETRY_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_FAIL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_FAIL_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_BCAST_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_BCAST_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_SUCCESS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_SUCCESS_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_RETRY_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_RETRY_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_FAIL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_FAIL_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_ROUTE_DISC_INITIATED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_ROUTE_DISC_INITIATED_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_AVERAGE_MAC_RETRY_PER_APS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_AVERAGE_MAC_RETRY_PER_APS_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_LAST_LQI_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_LAST_LQI_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_LAST_RSSI_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_LAST_RSSI_ID, \
ZB_ZCL_ATTR_TYPE_S8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_CHILD_MOVED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_CHILD_MOVED_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_NWKFC_FAILURE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_NWKFC_FAILURE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_APSFC_FAILURE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_APSFC_FAILURE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_APS_UNAUTHORIZED_KEY_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_APS_UNAUTHORIZED_KEY_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_NWK_DECRYPT_FAILURES_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_NWK_DECRYPT_FAILURES_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_APS_DECRYPT_FAILURES_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_APS_DECRYPT_FAILURES_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_PHYTOMACQUEUELIMITREACHED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_PHYTOMACQUEUELIMITREACHED_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_PACKET_VALIDATEDROPCOUNT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_PACKET_VALIDATEDROPCOUNT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_ADDED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_ADDED_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_REMOVED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_REMOVED_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_STALE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_STALE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_NWK_RETRY_OVERFLOW_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_NWK_RETRY_OVERFLOW_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_PHY_CCA_FAILURES_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_PHY_CCA_FAILURES_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_BCAST_TABLE_FULL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_BCAST_TABLE_FULL_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @brief Declare attribute list for Diagnostics cluster - server side
@param attr_list - attribute list name
*/
#define ZB_ZCL_DECLARE_DIAGNOSTICS_ATTRIB_LIST(attr_list) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_DIAGNOSTICS) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_MAC_RX_BCAST_ID, &diagnostics_ctx_zcl.mac_data.mac_rx_bcast) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_BCAST_ID, &diagnostics_ctx_zcl.mac_data.mac_tx_bcast) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_MAC_RX_UCAST_ID, &diagnostics_ctx_zcl.mac_data.mac_rx_ucast) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_ID, &diagnostics_ctx_zcl.mac_data.mac_tx_ucast_total_zcl) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_RETRY_ID, &diagnostics_ctx_zcl.mac_data.mac_tx_ucast_retries_zcl) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_MAC_TX_UCAST_FAIL_ID, &diagnostics_ctx_zcl.mac_data.mac_tx_ucast_failures_zcl) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_LAST_LQI_ID, &diagnostics_ctx_zcl.mac_data.last_msg_lqi) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_LAST_RSSI_ID, &diagnostics_ctx_zcl.mac_data.last_msg_rssi) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_PHYTOMACQUEUELIMITREACHED_ID, &diagnostics_ctx_zcl.mac_data.phy_to_mac_que_lim_reached) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_PACKET_VALIDATEDROPCOUNT_ID, &diagnostics_ctx_zcl.mac_data.mac_validate_drop_cnt) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_PHY_CCA_FAILURES_ID, &diagnostics_ctx_zcl.mac_data.phy_cca_fail_count) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_NUMBER_OF_RESETS_ID, &diagnostics_ctx_zcl.zdo_data.number_of_resets) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_BCAST_ID, &diagnostics_ctx_zcl.zdo_data.aps_tx_bcast) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_SUCCESS_ID, &diagnostics_ctx_zcl.zdo_data.aps_tx_ucast_success) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_RETRY_ID, &diagnostics_ctx_zcl.zdo_data.aps_tx_ucast_retry) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_APS_TX_UCAST_FAIL_ID, &diagnostics_ctx_zcl.zdo_data.aps_tx_ucast_fail) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_ROUTE_DISC_INITIATED_ID, &diagnostics_ctx_zcl.zdo_data.route_disc_initiated) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_ADDED_ID, &diagnostics_ctx_zcl.zdo_data.nwk_neighbor_added) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_REMOVED_ID, &diagnostics_ctx_zcl.zdo_data.nwk_neighbor_removed) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_NEIGHBOR_STALE_ID, &diagnostics_ctx_zcl.zdo_data.nwk_neighbor_stale) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_JOIN_INDICATION_ID, &diagnostics_ctx_zcl.zdo_data.join_indication) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_AVERAGE_MAC_RETRY_PER_APS_ID, &diagnostics_ctx_zcl.zdo_data.average_mac_retry_per_aps_message_sent) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_PACKET_BUFFER_ALLOCATE_FAILURES_ID, &diagnostics_ctx_zcl.zdo_data.packet_buffer_allocate_failures) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_CHILD_MOVED_ID, &diagnostics_ctx_zcl.zdo_data.childs_removed) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_NWKFC_FAILURE_ID, &diagnostics_ctx_zcl.zdo_data.nwk_fc_failure) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_APSFC_FAILURE_ID, &diagnostics_ctx_zcl.zdo_data.aps_fc_failure) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_APS_UNAUTHORIZED_KEY_ID, &diagnostics_ctx_zcl.zdo_data.aps_unauthorized_key) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_NWK_DECRYPT_FAILURES_ID, &diagnostics_ctx_zcl.zdo_data.nwk_decrypt_failure) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_APS_DECRYPT_FAILURES_ID, &diagnostics_ctx_zcl.zdo_data.aps_decrypt_failure) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_NWK_RETRY_OVERFLOW_ID, &diagnostics_ctx_zcl.zdo_data.nwk_retry_overflow) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DIAGNOSTICS_CUSTOM_ATTR_BCAST_TABLE_FULL_ID, &diagnostics_ctx_zcl.zdo_data.nwk_bcast_table_full) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Diagnostics cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/* ACHTUNG! ATTENTION!
* If you need to add a counter, do the following steps:
* 1) add a macro to declare an attribute like it's done above:
* ZB_SET_ATTR_DESCR_WITH_*attr_id*(data_ptr)
* 2) declare the attribute in the attributes list:
* ZB_ZCL_DECLARE_DIAGNOSTICS_ATTRIB_LIST
* 3) implement your counter at:
* 3.1) ZDO
* - zb_zdo_globals.h -> zdo_diagnostics_info_t
* - zdo_diagnostics.h -> zdo_diagnostics_counter_id_t
* - zdo_diagnostics.c -> zdo_diagnostics_inc()
* - increment your counter in code using the ZDO_DIAGNOSTICS_INC() macro;
* OR
* 3.2) MAC
* - zb_mac.h -> zb_mac_diagnostic_info_t
* - mac_zcl_diagnostic.c -> implement a function to increment the counter;
* - mac_internal.h -> add macros to use the incrementing function;
* - increment your counter in code using the macro;
* 4) add copying the counter value to
* zcl_diagnostics_commands.c -> zb_zcl_diagnostics_get_attr_value_by_id()
*
* Important note:
* We have asynchronous reading the Diagnostics attributes:
* in the zb_zcl_read_attr_handler() we call zdo_diagnostics_get_stats()
* that will copy all counters to the same buffer from the first byte.
* What the problem? We have the following buffer structure:
* a) buffer begin (from zero byte! not from zb_buf_begin()) - will contain all counters;
* b) buffer middle (from zb_buf_begin()) - contains one or more zb_zcl_read_attr_req_t;
* c) buffer end (can be get with ZB_BUF_GET_PARAM()) - contains zb_zcl_parsed_hdr_t.
* As you see, we can place all counters only from buffer begin (a).
* It's possible to get a situation when we don't have enough space,
* and you will catch assert in the zdo_diagnostics_get_mac_stats_cb() function.
* In this case it's necessary to move data from buffer middle to the right a bit.
*/
/*! @} */ /* Diagnostics cluster attributes */
/*! @} */ /* ZCL Diagnostics cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_diagnostics_init_server(void);
void zb_zcl_diagnostics_init_client(void);
/**
* @brief Synchronize MAC and ZDO counters with ZCL attributes.
*
* Call this function each time when you want to get an attribute value
* and process statistic using @zb_zcl_get_attr_desc_a
*
* When synchronization will be finished, users callback
* with a specified parameter will be called.
*
* @param cb_param - a parameter of users callback
* @param cb - users callback
*/
zb_ret_t zb_zcl_diagnostics_sync_counters(zb_uint8_t cb_param, zb_callback_t cb);
#define ZB_ZCL_CLUSTER_ID_DIAGNOSTICS_SERVER_ROLE_INIT zb_zcl_diagnostics_init_server
#define ZB_ZCL_CLUSTER_ID_DIAGNOSTICS_CLIENT_ROLE_INIT zb_zcl_diagnostics_init_client
#else /* defined(ZB_ZCL_SUPPORT_CLUSTER_DIAGNOSTICS) */
#define ZB_ZCL_CLUSTER_ID_DIAGNOSTICS_SERVER_ROLE_INIT
#define ZB_ZCL_CLUSTER_ID_DIAGNOSTICS_CLIENT_ROLE_INIT
#endif /* defined(ZB_ZCL_SUPPORT_CLUSTER_DIAGNOSTICS) */
#endif /* ZB_ZCL_DIAGNOSTICS_H */

View File

@@ -0,0 +1,799 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: DOOR_LOCK cluster definitions
*/
#ifndef ZB_ZCL_DOOR_LOCK_H
#define ZB_ZCL_DOOR_LOCK_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_DOOR_LOCK
* @{
* @details
* Door Lock cluster defined in ZCL spec, clause 7.3.
*
* The cluster contains 2 command sets:
* @li Lock Door request and response;
* @li Unlock Door request and response.
*
* Both requests have no payload and could be scheduled for sending with corresponding macros.
* Both responses have simple payload, and their sending and parsing with corresponding macros
* is almost trivial.
*
* @par Examples:
*
* Send Door Lock command:
* @snippet HA_samples/door_lock/sample_zed.c send_door_lock_req
*
* Send Door Unlock command:
* @snippet HA_samples/door_lock/sample_zed.c send_door_lock_unlock_req
*
*/
/*! @name Door Lock cluster attributes
@{
*/
/*! @brief Door Lock cluster attribute identifiers
@see ZCL spec, subclause 7.3.2.2
*/
enum zb_zcl_door_lock_attr_e
{
/** @brief LockState attribute */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_ID = 0x0000,
/** @brief LockType attribute */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_ID = 0x0001,
/** @brief ActuatorEnabled attribute */
ZB_ZCL_ATTR_DOOR_LOCK_ACTUATOR_ENABLED_ID = 0x0002,
/** @brief DoorState attribute */
ZB_ZCL_ATTR_DOOR_LOCK_DOOR_STATE_ID = 0x0003,
/** @brief DoorOpenEvents attribute */
ZB_ZCL_ATTR_DOOR_LOCK_NUM_OF_DOOR_OPEN_EVENTS_ID = 0x0004,
/** @brief DoorClosedEvents attribute */
ZB_ZCL_ATTR_DOOR_LOCK_NUM_OF_DOOR_CLOSED_EVENTS_ID = 0x0005,
/** @brief OpenPeriod attribute */
ZB_ZCL_ATTR_DOOR_LOCK_OPEN_PERIOD_ID = 0x0006,
/** The number of available log records. */
ZB_ZCL_ATTR_DOOR_LOCK_NUMBER_OF_LOG_RECORDS_SUPPORTED_ID = 0x0010,
/** @brief NumberOfTotalUsersSupported attribute */
ZB_ZCL_ATTR_DOOR_LOCK_NUM_TOTAL_USERS_ID = 0x0011,
/** @brief NumberOfPINUsersSupported attribute */
ZB_ZCL_ATTR_DOOR_LOCK_NUM_PIN_USERS_ID = 0x0012,
/** The number of RFID users supported. */
ZB_ZCL_ATTR_DOOR_LOCK_NUMBER_OF_RFID_USERS_SUPPORTED_ID = 0x0013,
/** @brief NumberOfWeekDaySchedulesSupportedPerUser attribute */
ZB_ZCL_ATTR_DOOR_LOCK_NUM_WEEK_DAY_SCHEDULE_PER_USER_ID = 0x0014,
/** @brief NumberOfYearDaySchedulesSupportedPerUser attribute */
ZB_ZCL_ATTR_DOOR_LOCK_NUM_YEAR_DAY_SCHEDULE_PER_USER_ID = 0x0015,
/** @brief NumberOfHolidaySchedulesSupported attribute */
ZB_ZCL_ATTR_DOOR_LOCK_NUM_HOLIDAY_SCHEDULE_ID = 0x0016,
/** @brief Max PIN code length attribute */
ZB_ZCL_ATTR_DOOR_LOCK_MAX_PIN_LEN_ID = 0x0017,
/** @brief Min PIN code length attribute */
ZB_ZCL_ATTR_DOOR_LOCK_MIN_PIN_LEN_ID = 0x0018,
/** An 8-bit value indicates the maximum length in bytes of a RFID Code
* on this device. */
ZB_ZCL_ATTR_DOOR_LOCK_MAX_RFID_CODE_LENGTH_ID = 0x0019,
/** An 8-bit value indicates the minimum length in bytes of a RFID Code
* on this device. */
ZB_ZCL_ATTR_DOOR_LOCK_MIN_RFID_CODE_LENGTH_ID = 0x001A,
/** Enable/disable event logging. */
ZB_ZCL_ATTR_DOOR_LOCK_ENABLE_LOGGING_ID = 0x0020,
/** Modifies the language for the on-screen or audible user interface using
* three bytes from ISO-639-1. */
ZB_ZCL_ATTR_DOOR_LOCK_LANGUAGE_ID = 0x0021,
/** The settings for the LED support three different modes. */
ZB_ZCL_ATTR_DOOR_LOCK_LED_SETTINGS_ID = 0x0022,
/** The number of seconds to wait after unlocking a lock before it automatically
* locks again. */
ZB_ZCL_ATTR_DOOR_LOCK_AUTO_RELOCK_TIME_ID = 0x0023,
/** The sound volume on a door lock has three possible settings: silent, low
* and high volumes. */
ZB_ZCL_ATTR_DOOR_LOCK_SOUND_VOLUME_ID = 0x0024,
/** @brief OperatingMode attribute */
ZB_ZCL_ATTR_DOOR_LOCK_OPERATING_MODE_ID = 0x0025,
/** @brief SupportedOperatingModes attribute */
ZB_ZCL_ATTR_DOOR_LOCK_OPERATION_MODES_SUPPORTED_ID = 0x0026,
/** This attribute represents the default configurations as they are physically
* set on the device (example: hardware dip switch setting, etc) and represents
* the default setting for some of the attributes within this Operational Setting
* Attribute Set (for example: LED, Auto Lock, Sound Volume, and Operating Mode
* attributes). */
ZB_ZCL_ATTR_DOOR_LOCK_DEFAULT_CONFIGURATION_REGISTER_ID = 0x0027,
/** @brief EnableLocalProgramming attribute */
ZB_ZCL_ATTR_DOOR_LOCK_ENABLE_LOCAL_PROGRAMMING_ID = 0x0028,
/** Enable/disable the ability to lock the door lock with a single touch on
* the door lock. */
ZB_ZCL_ATTR_DOOR_LOCK_ENABLE_ONE_TOUCH_LOCKING_ID = 0x0029,
/** Enable/disable an inside LED that allows the user to see at a glance
* if the door is locked. */
ZB_ZCL_ATTR_DOOR_LOCK_ENABLE_INSIDE_STATUS_LED_ID = 0x002A,
/** Enable/disable a button inside the door that is used to put the lock
* into privacy mode. */
ZB_ZCL_ATTR_DOOR_LOCK_ENABLE_PRIVACY_MODE_BUTTON_ID = 0x002B,
/** The number of incorrect codes or RFID presentment attempts a user
* is allowed to enter before the door will enter a lockout state. */
ZB_ZCL_ATTR_DOOR_LOCK_WRONG_CODE_ENTRY_LIMIT_ID = 0x0030,
/** The number of seconds that the lock shuts down following wrong code entry. */
ZB_ZCL_ATTR_DOOR_LOCK_USER_CODE_TEMPORARY_DISABLE_TIME_ID = 0x0031,
/** Boolean set to True if it is ok for the door lock server to send PINs
* over the air. */
ZB_ZCL_ATTR_DOOR_LOCK_SEND_PIN_OVER_THE_AIR_ID = 0x0032,
/** @brief Require PIN for RF operation attribute */
ZB_ZCL_ATTR_DOOR_LOCK_REQUIRE_PIN_RF_ID = 0x0033,
/** The Security Level attribute allows the door lock manufacturer to indicate
* what level of security the door lock requires. */
ZB_ZCL_ATTR_DOOR_LOCK_SECURITY_LEVEL_ID = 0x0034,
/** The alarm mask is used to turn on/off alarms for particular functions */
ZB_ZCL_ATTR_DOOR_LOCK_ALARM_MASK_ID = 0x0040,
/** Event mask used to turn on and off the transmission of keypad operation events. */
ZB_ZCL_ATTR_DOOR_LOCK_KEYPAD_OPERATION_EVENT_MASK_ID = 0x0041,
/** Event mask used to turn on and off the transmission of RF operation events. */
ZB_ZCL_ATTR_DOOR_LOCK_RF_OPERATION_EVENT_MASK_ID = 0x0042,
/** Event mask used to turn on and off manual operation events. */
ZB_ZCL_ATTR_DOOR_LOCK_MANUAL_OPERATION_EVENT_MASK_ID = 0x0043,
/** Event mask used to turn on and off RFID operation events. */
ZB_ZCL_ATTR_DOOR_LOCK_RFID_OPERATION_EVENT_MASK_ID = 0x0044,
/** Event mask used to turn on and off keypad programming events. */
ZB_ZCL_ATTR_DOOR_LOCK_KEYPAD_PROGRAMMING_EVENT_MASK_ID = 0x0045,
/** Event mask used to turn on and off RF programming events. */
ZB_ZCL_ATTR_DOOR_LOCK_RF_PROGRAMMING_EVENT_MASK_ID = 0x0046,
/** Event mask used to turn on and off RFID programming events. */
ZB_ZCL_ATTR_DOOR_LOCK_RFID_PROGRAMMING_EVENT_MASK_ID = 0x0047,
};
/** @brief Values for LockState attribute
* @see ZCL spec, subclause 7.3.2.2.1
*/
enum zb_zcl_door_lock_lock_state_e
{
/*! "Not fully locked" value */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_NOT_FULLY_LOCKED = 0x00,
/*! "Locked" value */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_LOCKED = 0x01,
/*! "Unlocked" value */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_UNLOCKED = 0x02,
/*! "Not Defined" value */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_UNDEFINED = 0xff
};
/** @brief Default value for Door Lock cluster revision global attribute */
#define ZB_ZCL_DOOR_LOCK_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0003u)
/** @brief Default value for Lock State attribute. */
#define ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_DEFAULT_VALUE ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_UNDEFINED
/** @brief Values for LockType attribute
* @see ZCL spec, subclause 7.3.2.2.2
*/
enum zb_zcl_door_lock_lock_type_e
{
/*! "Deadbolt" value */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_DEADBOLT = 0x00,
/*! "Magnetic" value */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_MAGNETIC = 0x01,
/*! "Other" value */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_OTHER = 0x02,
/*! "Not Defined" value */
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_UNDEFINED = 0xff
};
/** @brief Default value for Lock Type attribute. */
#define ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_DEFAULT_VALUE ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_UNDEFINED
/** @brief Values for ActuatorEnabled attribute
* @see ZCL spec, subclause 7.3.2.2.3
*/
enum zb_zcl_door_lock_actuator_enabled_e
{
/*! "Disabled" value */
ZB_ZCL_ATTR_DOOR_LOCK_ACTUATOR_ENABLED_DISABLED = 0x0b0,
/*! "Enabled" value */
ZB_ZCL_ATTR_DOOR_LOCK_ACTUATOR_ENABLED_ENABLED = 0x0b1
};
/** @brief Default value for Actuator Enabled attribute. */
#define ZB_ZCL_ATTR_DOOR_LOCK_ACTUATOR_ENABLED_DEFAULT_VALUE \
ZB_ZCL_ATTR_DOOR_LOCK_ACTUATOR_ENABLED_ENABLED
/** @brief Values for DoorState attribute
* @see ZCL spec, subclause 7.3.2.2.4
*/
enum zb_zcl_door_lock_door_state_e
{
/*! "Open" value */
ZB_ZCL_ATTR_DOOR_LOCK_DOOR_STATE_OPEN = 0x00,
/*! "Closed" value */
ZB_ZCL_ATTR_DOOR_LOCK_DOOR_STATE_CLOSED = 0x01,
/*! "Error (jammed)" value */
ZB_ZCL_ATTR_DOOR_LOCK_DOOR_STATE_ERROR_JAMMED = 0x02,
/*! "Error (forced open)" value */
ZB_ZCL_ATTR_DOOR_LOCK_DOOR_STATE_ERROR_FORCED_OPEN = 0x03,
/*! "Error (unspecified)" value */
ZB_ZCL_ATTR_DOOR_LOCK_DOOR_STATE_ERROR_UNSPECIFIED = 0x04
};
/** @brief Declare attribute list for Door Lock cluster
@param attr_list - attribute list name
@param lock_state
@param lock_type
@param actuator_enabled
*/
#define ZB_ZCL_DECLARE_DOOR_LOCK_ATTRIB_LIST(attr_list, \
lock_state, \
lock_type, \
actuator_enabled) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_DOOR_LOCK) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_ID, (lock_state)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_ID, (lock_type)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_ACTUATOR_ENABLED_ID, (actuator_enabled)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Door Lock cluster attributes */
/*! @name Door Lock cluster commands
@{
*/
/*! @brief Door Lock cluster commands
@see ZCL spec, subclause 7.3.2.3 Commands Received
*/
enum zb_zcl_door_lock_cmd_e
{
/** This command causes the lock device to lock the door. */
ZB_ZCL_CMD_DOOR_LOCK_LOCK_DOOR = 0x00,
/** This command causes the lock device to unlock the door. */
ZB_ZCL_CMD_DOOR_LOCK_UNLOCK_DOOR = 0x01,
/** Request the status of the lock. */
ZB_ZCL_CMD_DOOR_LOCK_TOGGLE = 0x02,
/** This command causes the lock device to unlock the door with a timeout parameter. */
ZB_ZCL_CMD_DOOR_LOCK_UNLOCK_WITH_TIMEOUT = 0x03,
/** Request a log record. */
ZB_ZCL_CMD_DOOR_LOCK_GET_LOG_RECORD = 0x04,
/** Set a PIN into the lock. */
ZB_ZCL_CMD_DOOR_LOCK_SET_PIN_CODE = 0x05,
/** Retrieve a PIN Code. */
ZB_ZCL_CMD_DOOR_LOCK_GET_PIN_CODE = 0x06,
/** Delete a PIN. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_PIN_CODE = 0x07,
/** Clear out all PINs on the lock. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_ALL_PIN_CODES = 0x08,
/** Set the status of a user ID. */
ZB_ZCL_CMD_DOOR_LOCK_SET_USER_STATUS = 0x09,
/** Get the status of a user. */
ZB_ZCL_CMD_DOOR_LOCK_GET_USER_STATUS = 0x0A,
/** Set a weekly repeating schedule for a specified user. */
ZB_ZCL_CMD_DOOR_LOCK_SET_WEEKDAY_SCHEDULE = 0x0B,
/** Retrieve the specific weekly schedule for the specific user. */
ZB_ZCL_CMD_DOOR_LOCK_GET_WEEKDAY_SCHEDULE = 0x0C,
/** Clear the specific weekly schedule for the specific user. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_WEEKDAY_SCHEDULE = 0x0D,
/** Set a time-specific schedule ID for a specified user. */
ZB_ZCL_CMD_DOOR_LOCK_SET_YEAR_DAY_SCHEDULE = 0x0E,
/** Retrieve the specific year day schedule for the specific user. */
ZB_ZCL_CMD_DOOR_LOCK_GET_YEAR_DAY_SCHEDULE = 0x0F,
/** Clears the specific year day schedule for the specific user. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_YEAR_DAY_SCHEDULE = 0x10,
/** Set the holiday Schedule by specifying local start time and local end time
* with respect to any Lock Operating Mode. */
ZB_ZCL_CMD_DOOR_LOCK_SET_HOLIDAY_SCHEDULE = 0x11,
/** Get the holiday Schedule by specifying Holiday ID. */
ZB_ZCL_CMD_DOOR_LOCK_GET_HOLIDAY_SCHEDULE = 0x12,
/** Clear the holiday Schedule by specifying Holiday ID. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_HOLIDAY_SCHEDULE = 0x13,
/** Set the type byte for a specified user. */
ZB_ZCL_CMD_DOOR_LOCK_SET_USER_TYPE = 0x14,
/** Retrieve the type byte for a specific user. */
ZB_ZCL_CMD_DOOR_LOCK_GET_USER_TYPE = 0x15,
/** Set an ID for RFID access into the lock. */
ZB_ZCL_CMD_DOOR_LOCK_SET_RFID_CODE = 0x16,
/** Retrieve an ID. */
ZB_ZCL_CMD_DOOR_LOCK_GET_RFID_CODE = 0x17,
/** Delete an ID. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_RFID_CODE = 0x18,
/** Clear out all RFIDs on the lock. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_ALL_RFID_CODES = 0x19,
};
/*! @brief Door Lock cluster commands response
@see ZCL spec, subclause 7.3.2.4 Commands Generated
*/
enum zb_zcl_door_lock_cmd_resp_e
{
/** This command is sent in response to a Lock command with one status byte payload. */
ZB_ZCL_CMD_DOOR_LOCK_LOCK_DOOR_RES = 0x00,
/** This command is sent in response to a Unlock command with one status byte payload. */
ZB_ZCL_CMD_DOOR_LOCK_UNLOCK_DOOR_RES = 0x01,
/** This command is sent in response to a Toggle command with one status byte payload. */
ZB_ZCL_CMD_DOOR_LOCK_TOGGLE_RESPONSE = 0x02,
/** This command is sent in response to an Unlock with Timeout command
* with one status byte payload. */
ZB_ZCL_CMD_DOOR_LOCK_UNLOCK_WITH_TIMEOUT_RESPONSE = 0x03,
/** Returns the specified log record. */
ZB_ZCL_CMD_DOOR_LOCK_GET_LOG_RECORD_RESPONSE = 0x04,
/** Returns status of the PIN set command. */
ZB_ZCL_CMD_DOOR_LOCK_SET_PIN_CODE_RESPONSE = 0x05,
/** Returns the PIN for the specified user ID. */
ZB_ZCL_CMD_DOOR_LOCK_GET_PIN_CODE_RESPONSE = 0x06,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_PIN_CODE_RESPONSE = 0x07,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_ALL_PIN_CODES_RESPONSE = 0x08,
/** Returns the pass or fail value for the setting of the user status. */
ZB_ZCL_CMD_DOOR_LOCK_SET_USER_STATUS_RESPONSE = 0x09,
/** Returns the user status for the specified user ID. */
ZB_ZCL_CMD_DOOR_LOCK_GET_USER_STATUS_RESPONSE = 0x0A,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_SET_WEEKDAY_SCHEDULE_RESPONSE = 0x0B,
/** Returns the weekly repeating schedule data for the specified schedule ID. */
ZB_ZCL_CMD_DOOR_LOCK_GET_WEEKDAY_SCHEDULE_RESPONSE = 0x0C,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_WEEKDAY_SCHEDULE_RESPONSE = 0x0D,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_SET_YEAR_DAY_SCHEDULE_RESPONSE = 0x0E,
/** Returns the weekly repeating schedule data for the specified schedule ID. */
ZB_ZCL_CMD_DOOR_LOCK_GET_YEAR_DAY_SCHEDULE_RESPONSE = 0x0F,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_YEAR_DAY_SCHEDULE_RESPONSE = 0x10,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_SET_HOLIDAY_SCHEDULE_RESPONSE = 0x11,
/** Returns the Holiday Schedule Entry for the specified Holiday ID. */
ZB_ZCL_CMD_DOOR_LOCK_GET_HOLIDAY_SCHEDULE_RESPONSE = 0x12,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_HOLIDAY_SCHEDULE_RESPONSE = 0x13,
/** Returns the pass or fail value for the setting of the user type. */
ZB_ZCL_CMD_DOOR_LOCK_SET_USER_TYPE_RESPONSE = 0x14,
/** Returns the user type for the specified user ID. */
ZB_ZCL_CMD_DOOR_LOCK_GET_USER_TYPE_RESPONSE = 0x15,
/** Returns status of the Set RFID Code command. */
ZB_ZCL_CMD_DOOR_LOCK_SET_RFID_CODE_RESPONSE = 0x16,
/** Returns the RFID code for the specified user ID. */
ZB_ZCL_CMD_DOOR_LOCK_GET_RFID_CODE_RESPONSE = 0x17,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_RFID_CODE_RESPONSE = 0x18,
/** Returns pass/fail of the command. */
ZB_ZCL_CMD_DOOR_LOCK_CLEAR_ALL_RFID_CODES_RESPONSE = 0x19,
/** The door lock server sends out operation event notification when the
* event is triggered by the various event sources. */
ZB_ZCL_CMD_DOOR_LOCK_OPERATION_EVENT_NOTIFICATION_ID = 0x20,
/** The door lock server sends out a programming event notification
* whenever a programming event takes place on the door lock. */
ZB_ZCL_CMD_DOOR_LOCK_PROGRAMMING_EVENT_NOTIFICATION = 0x21,
};
enum zb_zcl_door_lock_operation_event_source_e
{
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_SOURCE_KEYPAD = 0x00,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_SOURCE_RF = 0x01,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_SOURCE_MANUAL = 0x02,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_SOURCE_RFID = 0x03,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_SOURCE_INDETERMINATE = 0xFF,
};
/** @cond internals_doc */
/* Door lock cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_DOOR_LOCK_SERVER_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_DOOR_LOCK_LOCK_DOOR_RES, \
ZB_ZCL_CMD_DOOR_LOCK_UNLOCK_DOOR_RES
#define ZB_ZCL_CLUSTER_ID_DOOR_LOCK_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_DOOR_LOCK_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_DOOR_LOCK_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_DOOR_LOCK_LOCK_DOOR, \
ZB_ZCL_CMD_DOOR_LOCK_UNLOCK_DOOR
#define ZB_ZCL_CLUSTER_ID_DOOR_LOCK_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_DOOR_LOCK_CLIENT_ROLE_GENERATED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
/** @brief Default value for NumberOfLogRecordsSupported attribute */
#define ZB_ZCL_DOOR_LOCK_NUMBER_OF_LOG_RECORDS_SUPPORTED_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for NumTotalUsers attribute */
#define ZB_ZCL_DOOR_LOCK_NUM_TOTAL_USERS_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for NumPINUsers attribute */
#define ZB_ZCL_DOOR_LOCK_NUM_PIN_USERS_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for NumberOfRFIDUsersSupported attribute */
#define ZB_ZCL_DOOR_LOCK_NUMBER_OF_RFID_USERS_SUPPORTED_DEFAULT_VALUE ((zb_uint16_t)0)
/** @brief Default value for NumWeekDaySchedulePerUser attribute */
#define ZB_ZCL_DOOR_LOCK_NUM_WEEK_DAY_SCHEDULE_PER_USER_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for NumYearDaySchedulePerUser attribute */
#define ZB_ZCL_DOOR_LOCK_NUM_YEAR_DAY_SCHEDULE_PER_USER_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for NumHolidaySchedule attribute */
#define ZB_ZCL_DOOR_LOCK_NUM_HOLIDAY_SCHEDULE_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for MaxPINLen attribute */
#define ZB_ZCL_DOOR_LOCK_MAX_PIN_LEN_DEFAULT_VALUE ((zb_uint8_t)0x08)
/** @brief Default value for MinPINLen attribute */
#define ZB_ZCL_DOOR_LOCK_MIN_PIN_LEN_DEFAULT_VALUE ((zb_uint8_t)0x04)
/** @brief Default value for MaxRFIDCodeLength attribute */
#define ZB_ZCL_DOOR_LOCK_MAX_RFID_CODE_LENGTH_DEFAULT_VALUE ((zb_uint8_t)0x14)
/** @brief Default value for MinRFIDCodeLength attribute */
#define ZB_ZCL_DOOR_LOCK_MIN_RFID_CODE_LENGTH_DEFAULT_VALUE ((zb_uint8_t)0x08)
/** @brief Default value for EnableLogging attribute */
#define ZB_ZCL_DOOR_LOCK_ENABLE_LOGGING_DEFAULT_VALUE ((zb_bool_t)0)
/** @brief Default value for Language attribute */
#define ZB_ZCL_DOOR_LOCK_LANGUAGE_DEFAULT_VALUE {0}
/** @brief Default value for LEDSettings attribute */
#define ZB_ZCL_DOOR_LOCK_LED_SETTINGS_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for AutoRelockTime attribute */
#define ZB_ZCL_DOOR_LOCK_AUTO_RELOCK_TIME_DEFAULT_VALUE ((zb_uint32_t)0)
/** @brief Default value for SoundVolume attribute */
#define ZB_ZCL_DOOR_LOCK_SOUND_VOLUME_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for OperatingMode attribute */
#define ZB_ZCL_DOOR_LOCK_OPERATING_MODE_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for OperationModesSupported attribute */
#define ZB_ZCL_DOOR_LOCK_OPERATION_MODES_SUPPORTED_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for DefaultConfigurationRegister attribute */
#define ZB_ZCL_DOOR_LOCK_DEFAULT_CONFIGURATION_REGISTER_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for EnableLocalProgramming attribute */
#define ZB_ZCL_DOOR_LOCK_ENABLE_LOCAL_PROGRAMMING_DEFAULT_VALUE ((zb_bool_t)0x01)
/** @brief Default value for EnableOneTouchLocking attribute */
#define ZB_ZCL_DOOR_LOCK_ENABLE_ONE_TOUCH_LOCKING_DEFAULT_VALUE ((zb_bool_t)0)
/** @brief Default value for EnableInsideStatusLED attribute */
#define ZB_ZCL_DOOR_LOCK_ENABLE_INSIDE_STATUS_LED_DEFAULT_VALUE ((zb_bool_t)0)
/** @brief Default value for EnablePrivacyModeButton attribute */
#define ZB_ZCL_DOOR_LOCK_ENABLE_PRIVACY_MODE_BUTTON_DEFAULT_VALUE ((zb_bool_t)0)
/** @brief Default value for WrongCodeEntryLimit attribute */
#define ZB_ZCL_DOOR_LOCK_WRONG_CODE_ENTRY_LIMIT_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for UserCodeTemporaryDisableTime attribute */
#define ZB_ZCL_DOOR_LOCK_USER_CODE_TEMPORARY_DISABLE_TIME_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for SendPINOverTheAir attribute */
#define ZB_ZCL_DOOR_LOCK_SEND_PIN_OVER_THE_AIR_DEFAULT_VALUE ((zb_bool_t)0)
/** @brief Default value for RequirePIN_RF_ID attribute */
#define ZB_ZCL_DOOR_LOCK_REQUIRE_PIN_RF_ID_DEFAULT_VALUE ((zb_bool_t)0)
/** @brief Default value for SecurityLevel attribute */
#define ZB_ZCL_DOOR_LOCK_SECURITY_LEVEL_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for AlarmMask attribute */
#define ZB_ZCL_DOOR_LOCK_ALARM_MASK_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for KeypadOperationEventMask attribute */
#define ZB_ZCL_DOOR_LOCK_KEYPAD_OPERATION_EVENT_MASK_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RFOperationEventMask attribute */
#define ZB_ZCL_DOOR_LOCK_RF_OPERATION_EVENT_MASK_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for ManualOperationEventMask attribute */
#define ZB_ZCL_DOOR_LOCK_MANUAL_OPERATION_EVENT_MASK_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RFIDOperationEventMask attribute */
#define ZB_ZCL_DOOR_LOCK_RFID_OPERATION_EVENT_MASK_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for KeypadProgrammingEventMask attribute */
#define ZB_ZCL_DOOR_LOCK_KEYPAD_PROGRAMMING_EVENT_MASK_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RFProgrammingEventMask attribute */
#define ZB_ZCL_DOOR_LOCK_RF_PROGRAMMING_EVENT_MASK_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RFIDProgrammingEventMask attribute */
#define ZB_ZCL_DOOR_LOCK_RFID_PROGRAMMING_EVENT_MASK_DEFAULT_VALUE ((zb_uint16_t)0x0000)
enum zb_zcl_door_lock_operation_event_code_e
{
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_CODE_UNKNOWN = 0x00,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_CODE_LOCK = 0x01,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_CODE_UNLOCK = 0x02,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_CODE_KEY_LOCK = 0x08,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_CODE_KEY_UNLOCK = 0x09,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_CODE_MANUAL_LOCK = 0x0D,
ZB_ZCL_DOOR_LOCK_OPERATION_EVENT_CODE_MANUAL_UNLOCK = 0x0E,
};
enum zb_zcl_door_lock_keypad_operation_event_mask_e
{
ZB_ZCL_DOOR_LOCK_KEYPAD_OPERATION_EVENT_MASK_UNKNOWN = (1l << 0),
ZB_ZCL_DOOR_LOCK_KEYPAD_OPERATION_EVENT_MASK_LOCK = (1l << 1),
ZB_ZCL_DOOR_LOCK_KEYPAD_OPERATION_EVENT_MASK_UNLOCK = (1l << 2),
};
enum zb_zcl_door_lock_rf_operation_event_mask_e
{
ZB_ZCL_DOOR_LOCK_RF_OPERATION_EVENT_MASK_UNKNOWN = (1l << 0),
ZB_ZCL_DOOR_LOCK_RF_OPERATION_EVENT_MASK_LOCK = (1l << 1),
ZB_ZCL_DOOR_LOCK_RF_OPERATION_EVENT_MASK_UNLOCK = (1l << 2),
};
enum zb_zcl_door_lock_manual_operation_event_mask_e
{
ZB_ZCL_DOOR_LOCK_MANUAL_OPERATION_EVENT_MASK_UNKNOWN = (1l << 0),
ZB_ZCL_DOOR_LOCK_MANUAL_OPERATION_EVENT_MASK_THUMBTURN_LOCK = (1l << 1),
ZB_ZCL_DOOR_LOCK_MANUAL_OPERATION_EVENT_MASK_THUMBTURN_UNLOCK = (1l << 2),
ZB_ZCL_DOOR_LOCK_MANUAL_OPERATION_EVENT_MASK_KEY_LOCK = (1l << 4),
ZB_ZCL_DOOR_LOCK_MANUAL_OPERATION_EVENT_MASK_KEY_UNLOCK = (1l << 5),
ZB_ZCL_DOOR_LOCK_MANUAL_OPERATION_EVENT_MASK_MANUAL_LOCK = (1l << 9),
ZB_ZCL_DOOR_LOCK_MANUAL_OPERATION_EVENT_MASK_MANUAL_UNLOCK = (1l << 10),
};
/*! @brief General macro for sending a "Door Lock" cluster command
@param buffer to put command payload and headers to
@param dst_addr address to send to
@param dst_addr_mode destination address mode
@param dst_ep destination endpoint
@param ep source endpoint
@param dis_default_resp "Disable default response" flag
@param cb command send status callback
*/
#define ZB_ZCL_DOOR_LOCK_SEND_LOCK_DOOR_REQ(buffer, \
dst_addr, \
dst_addr_mode, \
dst_ep, \
ep, \
dis_default_resp, \
cb) \
ZB_ZCL_SEND_CMD( buffer, \
dst_addr, \
dst_addr_mode, \
dst_ep, \
ep, \
ZB_AF_HA_PROFILE_ID, \
dis_default_resp, \
ZB_ZCL_CLUSTER_ID_DOOR_LOCK, \
ZB_ZCL_CMD_DOOR_LOCK_LOCK_DOOR, \
cb)
/*! @brief General macro for sending a "Door Unlock" cluster command
@param buffer to put command payload and headers to
@param dst_addr address to send to
@param dst_addr_mode destination address mode
@param dst_ep destination endpoint
@param ep source endpoint
@param dis_default_resp "Disable default response" flag
@param cb command send status callback
*/
#define ZB_ZCL_DOOR_LOCK_SEND_UNLOCK_DOOR_REQ(buffer, \
dst_addr, \
dst_addr_mode, \
dst_ep, \
ep, \
dis_default_resp, \
cb) \
ZB_ZCL_SEND_CMD(buffer, \
dst_addr, \
dst_addr_mode, \
dst_ep, \
ep, \
ZB_AF_HA_PROFILE_ID, \
dis_default_resp, \
ZB_ZCL_CLUSTER_ID_DOOR_LOCK, \
ZB_ZCL_CMD_DOOR_LOCK_UNLOCK_DOOR, cb)
/*! @brief Door Lock command send response macro
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param seq_num - sequence number
@param status - result of command execute
@param aps_secured - APS security mode
*/
#define ZB_ZCL_DOOR_LOCK_SEND_LOCK_DOOR_RES(buffer, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
seq_num, \
status, \
aps_secured) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, seq_num, ZB_ZCL_CMD_DOOR_LOCK_LOCK_DOOR_RES); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, status); \
ZB_ZCL_FINISH_N_SEND_PACKET_NEW(buffer, \
ptr, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
ZB_ZCL_CLUSTER_ID_DOOR_LOCK, \
NULL, \
aps_secured, \
ZB_FALSE, \
0); \
}
/*! @brief Door Unlock command send response macro
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param seq_num - sequence number
@param status - result of command execute
@param aps_secured - APS security mode
*/
#define ZB_ZCL_DOOR_LOCK_SEND_UNLOCK_DOOR_RES(buffer, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
seq_num, \
status, \
aps_secured) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, seq_num, ZB_ZCL_CMD_DOOR_LOCK_UNLOCK_DOOR_RES); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, status); \
ZB_ZCL_FINISH_N_SEND_PACKET_NEW(buffer, \
ptr, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
ZB_ZCL_CLUSTER_ID_DOOR_LOCK, \
NULL, \
aps_secured, \
ZB_FALSE, \
0); \
}
/*! Door lock commands response payload structure */
typedef ZB_PACKED_PRE struct zb_zcl_door_lock_read_lock_door_res_payload_s
{
zb_uint8_t status; /*!< Command execution status */
} ZB_PACKED_STRUCT zb_zcl_door_lock_read_lock_door_res_payload_t;
/*! @brief Door Lock response structured reading
@param buffer - ID of the message buffer (of type zb_bufid_t) containing payload
@return pointer to @ref zb_zcl_door_lock_read_lock_door_res_payload_s structure
@attention returned pointer will point to the same data in the buffer thus being valid until
buffer data will be overwritten.
*/
#define ZB_ZCL_DOOR_LOCK_READ_LOCK_DOOR_RES(buffer) \
( (zb_buf_len((buffer)) < sizeof(zb_zcl_door_lock_read_lock_door_res_payload_t)) \
? NULL \
: (zb_zcl_door_lock_read_lock_door_res_payload_t*)zb_buf_begin((buffer)))
/*! Door unlock commands response payload structure */
typedef ZB_PACKED_PRE struct zb_zcl_door_lock_read_unlock_door_res_payload_s
{
zb_uint8_t status; /*!< Command execution status */
} ZB_PACKED_STRUCT zb_zcl_door_lock_read_unlock_door_res_payload_t;
/*! @brief Door unLock response structured reading
@param buffer - ID of the message buffer (of type zb_buf_t)
containing payload
@return pointer to @ref zb_zcl_door_lock_read_unlock_door_res_payload_s structure
@attention returned pointer will point to the same data in the buffer thus
being valid until buffer data will be overwritten.
*/
#define ZB_ZCL_DOOR_LOCK_READ_UNLOCK_DOOR_RES(buffer) \
( (zb_buf_len((buffer)) < sizeof(zb_zcl_door_lock_read_unlock_door_res_payload_t)) \
? NULL \
: (zb_zcl_door_lock_read_unlock_door_res_payload_t*)zb_buf_begin((buffer)))
/*! @} */ /* Door Lock cluster commands */
/*! @cond internals_doc
@internal @name Door Lock cluster internals
Internal structures for Door Lock cluster
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING | ZB_ZCL_ATTR_ACCESS_SCENE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DOOR_LOCK_ACTUATOR_ENABLED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DOOR_LOCK_ACTUATOR_ENABLED_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DOOR_LOCK_RF_OPERATION_EVENT_MASK_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_DOOR_LOCK_RF_OPERATION_EVENT_MASK_ID, \
ZB_ZCL_ATTR_TYPE_16BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal @brief Number of attributes mandatory for reporting in Door Lock cluster */
#define ZB_ZCL_DOOR_LOCK_REPORT_ATTR_COUNT 1
/*! @}
@endcond */ /* Door Lock cluster internals */
/*! @} */ /* ZCL Door Lock cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_door_lock_init_server(void);
void zb_zcl_door_lock_init_client(void);
#define ZB_ZCL_CLUSTER_ID_DOOR_LOCK_SERVER_ROLE_INIT zb_zcl_door_lock_init_server
#define ZB_ZCL_CLUSTER_ID_DOOR_LOCK_CLIENT_ROLE_INIT zb_zcl_door_lock_init_client
#endif /* ZB_ZCL_DOOR_LOCK_H */

View File

@@ -0,0 +1,753 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Demand Response and Load Control cluster definitions
*/
#ifndef ZB_ZCL_DRLC_H_
#define ZB_ZCL_DRLC_H_
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_DRLC
* @{
* @details This cluster provides an interface to the functionality of Smart
* Energy Demand Response and Load Control.
*/
/* Cluster ZB_ZCL_CLUSTER_ID_DRLC */
/** @defgroup ZB_ZCL_DRLC_ATTRS_AND_ENUMS DRLC attributes and enumerations
* @{
* @details
* This section describes DRLC client attributes and common cluster enumerations.
*/
/** @brief Default value for DRLC cluster revision global attribute */
#define ZB_ZCL_DRLC_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief Maximal value for implemented DRLC cluster revision global attribute */
#define ZB_ZCL_DRLC_CLUSTER_REVISION_MAX ZB_ZCL_DRLC_CLUSTER_REVISION_DEFAULT
/** DRLC Client attributes. @see SE spec, subclause D.2.3.2 */
typedef enum zb_zcl_drlc_cli_attr_e
{
ZB_ZCL_ATTR_DRLC_UTILITY_ENROLLMENT_GROUP = 0x0000, /**< UtilityEnrollmentGroup attribute.
* Provides for utilities to assign devices to groups.
*/
ZB_ZCL_ATTR_DRLC_START_RANDOMIZATION_MINUTES = 0x0001, /**< StartRandomizationMinutes attribute.
* Represents the maximum number of minutes to be used
* when randomizing the start of an event.
*/
ZB_ZCL_ATTR_DRLC_DURATION_RANDOMIZATION_MINUTES = 0x0002, /**< DurationRandomizationMinutes attribute.
* Represents the maximum number of minutes to be used
* when randomizing the duration of an event.
*/
ZB_ZCL_ATTR_DRLC_DEVICE_CLASS_VALUE = 0x0003, /**< DeviceClassValue attribute.
* Identifies which bits the device will match in the
* Device Class fields.
*/
} zb_zcl_drlc_cli_attr_t;
/** Criticality Level value applied by the device.
* @see SE spec, Table D-3
*/
typedef enum zb_zcl_drlc_criticality_levels_e
{
ZB_ZCL_DRLC_CRITICALITY_LEVEL_0 = 0x00, /**< Reserved */
ZB_ZCL_DRLC_CRITICALITY_LEVEL_1, /**< Green */
ZB_ZCL_DRLC_CRITICALITY_LEVEL_2, /**< Level 1 */
ZB_ZCL_DRLC_CRITICALITY_LEVEL_3, /**< Level 2 */
ZB_ZCL_DRLC_CRITICALITY_LEVEL_4, /**< Level 3 */
ZB_ZCL_DRLC_CRITICALITY_LEVEL_5, /**< Level 4 */
ZB_ZCL_DRLC_CRITICALITY_LEVEL_6, /**< Level 5 */
ZB_ZCL_DRLC_CRITICALITY_LEVEL_7, /**< Emergency */
ZB_ZCL_DRLC_CRITICALITY_LEVEL_8, /**< Planned Outage */
ZB_ZCL_DRLC_CRITICALITY_LEVEL_9 /**< Service Disconnect */
} zb_zcl_drlc_criticality_levels_t;
/** DRLC device classes enumeration.
* @see SE spec, Table D-2.
*/
typedef enum zb_zcl_drlc_device_class_e
{
ZB_ZCL_DRLC_DEVICE_CLASS_HVAC = 1 << 0, /**< HVAC Compressor or Furnace */
ZB_ZCL_DRLC_DEVICE_CLASS_STRIP_HEATER = 1 << 1, /**< Strip Heaters/Baseboard Heaters */
ZB_ZCL_DRLC_DEVICE_CLASS_WATER_HEATER = 1 << 2, /**< Water Heater */
ZB_ZCL_DRLC_DEVICE_CLASS_POOL_PUMP = 1 << 3, /**< Pool Pump/Spa/Jacuzzi */
ZB_ZCL_DRLC_DEVICE_CLASS_SMART_APPLIANCE = 1 << 4, /**< Smart Appliances */
ZB_ZCL_DRLC_DEVICE_CLASS_IRRIGATION_PUMP = 1 << 5, /**< Irrigation Pump */
ZB_ZCL_DRLC_DEVICE_CLASS_MCI_LOADS = 1 << 6, /**< Managed Commercial & Industrial (C&I) loads */
ZB_ZCL_DRLC_DEVICE_CLASS_SIMPLE_LOADS = 1 << 7, /**< Simple misc. (Residential On/Off) loads */
ZB_ZCL_DRLC_DEVICE_CLASS_EXTERIOR_LIGHTNING = 1 << 8, /**< Exterior Lighting */
ZB_ZCL_DRLC_DEVICE_CLASS_INTERIOR_LIGHTNING = 1 << 9, /**< Interior Lighting */
ZB_ZCL_DRLC_DEVICE_CLASS_ELECTRIC_VEHICLE = 1 << 10, /**< Electric Vehicle */
ZB_ZCL_DRLC_DEVICE_CLASS_GENERATION_SYSTEMS = 1 << 11 /**< Generation Systems */
} zb_zcl_drlc_device_class_t;
/** DRLC Event Status enum
* @see SE spec, Table D-9
*/
typedef enum zb_zcl_drlc_event_status_e
{
ZB_ZCL_DRLC_EVENT_RESERVED_00 = 0x00, /**< Reserved for future use. */
ZB_ZCL_DRLC_EVENT_LCE_RECEIVED, /**< Load Control Event command received */
ZB_ZCL_DRLC_EVENT_EVENT_STARTED, /**< Event started */
ZB_ZCL_DRLC_EVENT_EVENT_COMPLETED, /**< Event completed */
ZB_ZCL_DRLC_EVENT_OPT_OUT, /**< User has chosen to “Opt-Out”, user will not participate in this event */
ZB_ZCL_DRLC_EVENT_OPT_IN, /**< User has chosen to “Opt-In”, user will participate in this event */
ZB_ZCL_DRLC_EVENT_EVENT_CANCELLED, /**< The event has been cancelled */
ZB_ZCL_DRLC_EVENT_EVENT_SUPERSEDED, /**< The event has been superseded */
ZB_ZCL_DRLC_EVENT_EVENT_PARTIALLY_OPT_OUT, /**< Event partially completed with User “Opt-Out”. */
ZB_ZCL_DRLC_EVENT_EVENT_PARTIALLY_OPT_IN, /**< Event partially completed due to User “Opt-In”. */
ZB_ZCL_DRLC_EVENT_EVENT_COMPLETED_NO_USER, /**< Event completed, no User participation (Previous “Opt-Out”). */
ZB_ZCL_DRLC_EVENT_RESERVED_0B, /**< Reserved for future use. */
ZB_ZCL_DRLC_EVENT_RESERVED_F7 = 0xF7, /**< Reserved for future use. */
ZB_ZCL_DRLC_EVENT_REJECTED_INVALID_CANCEL_CMD, /**< Rejected - Invalid Cancel Command (Default) */
ZB_ZCL_DRLC_EVENT_REJECTED_INVALID_EFFECTIVE_TIME, /**< Rejected - Invalid Cancel Command (Invalid Effective Time) */
ZB_ZCL_DRLC_EVENT_RESERVED_FA, /**< Reserved */
ZB_ZCL_DRLC_EVENT_REJECTED_EXPIRED, /**< Rejected - Event was received after it had expired@n (Current Time > Start Time + Duration) */
ZB_ZCL_DRLC_EVENT_RESERVED_FC, /**< Reserved for future use. */
ZB_ZCL_DRLC_EVENT_REJECTED_UNDEFINED_EVENT, /**< Rejected - Invalid Cancel Command (Undefined Event) */
ZB_ZCL_DRLC_EVENT_REJECTED, /**< Load Control Event command Rejected */
ZB_ZCL_DRLC_EVENT_RESERVED_FF /**< Reserved for future use. */
} zb_zcl_drlc_event_status_t;
/** DRLC signature type enum */
typedef enum zb_zcl_drlc_signature_type_e
{
ZB_ZCL_DRLC_LCE_NO_SIGNATURE = 0x00, /**< No Signature */
ZB_ZCL_DRLC_LCE_SIGNATURE_ECDSA, /**< ECDSA */
ZB_ZCL_DRLC_LCE_SIGNATURE_RESERVED /**< Reserved */
} zb_zcl_drlc_signature_type_t;
/** @} */ /* ZB_ZCL_DRLC_ATTRS_AND_ENUMS */
/** @defgroup ZB_ZCL_DRLC_COMMANDS_STRUCTURES_AND_DEFINITIONS DRLC commands
* @{
* @details
* This section describes all commands structures and data payloads.
*/
/** Commands are generated by DRLC Server.
* @see SE spec, Table D-1
*/
typedef enum zb_zcl_drlc_srv_cmd_e
{
ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT = 0x00, /**< LoadControlEvent is generated when the ESI wants to control one or more
* load control devices usually as the result of an energy curtailment
* command from the Smart Energy Network.
* @see zb_zcl_drlc_lce_payload_s
*/
ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT = 0x01, /**< CancelLoadControlEvent is generated when the ESI wants to cancel
* previously scheduled control of one or more load control devices, usually
* as the result of an energy curtailment command from the Smart Energy
* Network
* @see zb_zcl_drlc_cancel_lce_payload_s
*/
ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS = 0x02, /**< CancellAllLoadControlEvents is generated when the ESI wants to cancel all
* events for control device(s)
*/
} zb_zcl_drlc_srv_cmd_t;
/** Commands are generated by DRLC Client.
* @see SE spec, Table D-8
*/
typedef enum zb_zcl_drlc_cli_cmd_e
{
ZB_ZCL_DRLC_CLI_CMD_REPORT_EVENT_STATUS = 0x00, /**< ReportEventStatus is generated when the client device detects a change of
* state for an active LoadControl event.
* @see zb_zcl_drlc_report_event_status_payload_s
*/
ZB_ZCL_DRLC_CLI_CMD_GET_SCHEDULED_EVENTS = 0x01, /**< GetScheduledEvents is generated when the client device wishes to verify
* the available LoadControl events.
* @see zb_zcl_drlc_get_scheduled_events_payload_s
*/
} zb_zcl_drlc_cli_cmd_t;
/** @cond internals_doc */
/* DRLC cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_DRLC_SERVER_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT, \
ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT, \
ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS
#define ZB_ZCL_CLUSTER_ID_DRLC_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_DRLC_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_DRLC_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_DRLC_CLI_CMD_REPORT_EVENT_STATUS, \
ZB_ZCL_DRLC_CLI_CMD_GET_SCHEDULED_EVENTS
#define ZB_ZCL_CLUSTER_ID_DRLC_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_DRLC_CLIENT_ROLE_GENERATED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
/* Payload description */
/** @ref ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT "LoadControlEvent" command payload.
* @see SE spec, Figure D-2
*/
typedef ZB_PACKED_PRE struct zb_zcl_drlc_lce_payload_s {
/** Unique identifier generated by the Energy provider.
* The value of this field allows matching of Event reports
* with a specific Demand Response and Load Control event.
*/
zb_uint32_t issuer_event_id; /* (M) */
/** Bit encoded field representing the Device Class to apply the
* current Load Control Event. Each bit, if set individually or
* in combination, indicates the class device(s) needing to
* participate in the event.
*/
zb_uint16_t device_class; /* (M) */
/** This field can be used in conjunction with the Device Class bits
* for providing a mechanism to direct Load Control Events
* to groups of Devices.
*/
zb_uint8_t utility_enrollment_group; /* (M) */
/** UTC Timestamp representing when the event is scheduled to start.
* A start time of 0x00000000 is a special time denoting “now.”
*/
zb_uint32_t start_time; /* (M) */
/** Duration of this event in number of minutes.
* Maximum value is 1440 (one day).
*/
zb_uint16_t duration_in_minutes; /* (M) */
/** This field defines the level of criticality of event. The
* action for an event can be solely based on this value,
* or combination with other Load Control Event fields.
*/
zb_uint8_t criticality_level; /* (M) */
/** Requested offset to apply to the normal cooling setpoint
* at the time of the start of the event in + 0.1 Celsius.
*/
zb_uint8_t cooling_temperature_offset; /* (O) - use 0xff if optional */
/** Requested offset to apply to the normal heating setpoint
* at the time of the start of the event in + 0.1 Celsius.
*/
zb_uint8_t heating_temperature_offset; /* (O) - use 0xff if optional */
/** Requested cooling set point in 0.01 degrees Celsius. */
zb_int16_t cooling_temperature_set_point; /* (O) - use 0x8000 if optional */
/** Requested heating set point in 0.01 degrees Celsius. */
zb_int16_t heating_temperature_set_point; /* (O) - use 0x8000 if optional */
/** Defines a maximum energy usage limit as a percentage of
* the client implementations specific average energy usage.
*/
zb_int8_t average_load_adjustment_percentage; /* (O) */
/** Defines the maximum on state duty cycle as a percentage of time. */
zb_uint8_t duty_cycle; /* (O) */
/** Identifies additional control options for the event. */
zb_uint8_t event_control; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_drlc_lce_payload_t;
/** @def ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT_IS_VALID
*/
#define ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT_IS_VALID(size) \
((size) >= sizeof(zb_zcl_drlc_lce_payload_t))
/** @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT "CancelLoadControlEvent" command payload
* @see SE spec, Figure D-3
*/
typedef ZB_PACKED_PRE struct zb_zcl_drlc_cancel_lce_payload_s {
/* Mandatory fields. */
/** Unique identifier generated by the Energy provider. The value of
* this field allows matching of Event reports with a specific Demand Response
* and Load Control event.
*/
zb_uint32_t issuer_event_id; /* (M) */
/** Bit encoded field representing the Device Class to apply the
* current Load Control Event. Each bit, if set individually or in combination,
* indicates the class device(s) needing to participate in the event.
*/
zb_uint16_t device_class; /* (M) */
/** This field can be used in conjunction with the Device Class bits
* for providing a mechanism to direct Load Control Events
* to groups of Devices.
*/
zb_uint8_t utility_enrollment_group; /* (M) */
/** This field is used to indicate that the Event is currently in process and
* a cancel command is received.*/
zb_uint8_t cancel_control; /* (M) */
/** UTC Timestamp representing when the canceling of the event is
* scheduled to start. An effective time of 0x00000000 is a special
* time denoting “now.”
*/
zb_uint32_t effective_time; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_drlc_cancel_lce_payload_t;
/** @def ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT_IS_VALID
*/
#define ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT_IS_VALID(size) \
((size) >= sizeof(zb_zcl_drlc_cancel_lce_payload_t))
/** @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS "CancelAllLoadControlEvents" command payload
* @see SE spec, Figure D-3
*/
typedef ZB_PACKED_PRE struct zb_zcl_drlc_cancel_alce_payload_s {
/* Mandatory fields. */
/** Where the Cancel Control field indicates that randomization is to be used, the receiving device should first
* check whether Duration Time was to be randomized and, if so, termination of the event should be adjusted
* according to the value of the DurationRandomizationMinutes attribute.
*/
zb_uint8_t cancel_control; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_drlc_cancel_alce_payload_t;
/** @def ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS_IS_VALID
*/
#define ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS_IS_VALID(size) \
((size) >= sizeof(zb_zcl_drlc_cancel_alce_payload_t))
/** @ref ZB_ZCL_DRLC_CLI_CMD_REPORT_EVENT_STATUS "ReportEventStatus" command payload
* @see SE spec, Figure D-5
*/
typedef ZB_PACKED_PRE struct zb_zcl_drlc_report_event_status_payload_s {
/* Mandatory fields. */
/** Unique identifier generated by the Energy provider. The value of
* this field allows matching of Event reports with a specific Demand Response
* and Load Control event.
*/
zb_uint32_t issuer_event_id; /* (M) */
/** This field stores value from set of event statuses*/
zb_uint8_t event_status; /* (M) */
/** UTC Timestamp representing when the event status
* occurred. This field shall not use the value of 0x00000000.
*/
zb_uint32_t event_status_time; /* (M) */
/** Criticality Level value applied by the device */
zb_uint8_t criticality_level_applied; /* (M) */
/** Defines Cooling Temperature Set Point value applied by the device.
* The value 0x8000 means that this field has not been used by the end device.
*/
zb_uint16_t cooling_temperature_set_point_applied; /* (O) */
/** Defines Heating Temperature Set Point value applied by the device.
* The value 0x8000 means that this field has not been used by
* the end device.
*/
zb_uint16_t heating_temperature_set_point_applied; /* (O) */
/** Defines Average Load Adjustment Percentage value applied by the device.
* The value 0x80 means that this field has not been used by the end device.
*/
zb_int8_t average_load_adjustment_percentage_applied; /* (O) */
/** Defines the maximum on state duty cycle applied by the device.
* The value 0xFF means that this field has not been used by the end device.
*/
zb_uint8_t duty_cycle_applied; /* (O) */
/** Identifies additional control options for the event. */
zb_uint8_t event_control; /* (M) */
/** This field is used to enumerate the type of algorithm use to create the signature.*/
zb_uint8_t signature_type; /* (M) */
/** A non-repudiation signature created by using the Matyas-Meyer-Oseas
* hash function used in conjunction with ECDSA.
*/
zb_uint8_t signature[42]; /* (O) */
} ZB_PACKED_STRUCT zb_zcl_drlc_report_event_status_payload_t;
/** @def ZB_ZCL_DRLC_CLI_CMD_REPORT_EVENT_STATUS_IS_VALID
*/
#define ZB_ZCL_DRLC_CLI_CMD_REPORT_EVENT_STATUS_IS_VALID(size) \
((size) >= sizeof(zb_zcl_drlc_report_event_status_payload_t))
/** @ref ZB_ZCL_DRLC_CLI_CMD_GET_SCHEDULED_EVENTS "GetScheduledEvents" command payload
* @see SE spec, Figure D-6
*/
typedef ZB_PACKED_PRE struct zb_zcl_drlc_get_scheduled_events_payload_s {
/* Mandatory fields. */
/** UTC Timestamp representing the minimum Start Time of events that shall be
* matched and sent by the Server. A Start Time of 0x00000000 has no special
* meaning.
*/
zb_uint32_t start_time; /* (M) */
/** Represents the maximum number of events to be sent. A value of 0 indicates
* no maximum limit.
*/
zb_uint8_t number_of_events; /* (M) */
/** Represents the minimum Issuer Event ID of events to be matched and sent
* by the server with the same Start Time as the Get Scheduled Events command.
* A value of 0xFFFFFFFF indicates this field will not be used.
*/
zb_uint32_t issuer_event_id; /* (O) */
} ZB_PACKED_STRUCT zb_zcl_drlc_get_scheduled_events_payload_t;
/** Initialize @ref ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT "LoadControlEvent" command @ref zb_zcl_drlc_lce_payload_t payload*/
#define ZB_ZCL_DRLC_LCE_PAYLOAD_INIT \
(zb_zcl_drlc_lce_payload_t) \
{ \
.cooling_temperature_offset = 0xFF, \
.heating_temperature_offset = 0xFF, \
.cooling_temperature_set_point = (zb_int16_t) 0x8000, \
.heating_temperature_set_point = (zb_int16_t) 0x8000, \
.average_load_adjustment_percentage = (zb_int8_t) 0x80, \
.duty_cycle = 0xFF, \
}
/** Initialize @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT "CancelLoadControlEvent" command @ref zb_zcl_drlc_cancel_lce_payload_t payload */
#define ZB_ZCL_DRLC_CANCEL_LCE_PAYLOAD_INIT \
(zb_zcl_drlc_cancel_lce_payload_t) {0}
/** Initialize @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS "CancelAllLoadControlEvents" command @ref zb_zcl_drlc_cancel_alce_payload_t payload */
#define ZB_ZCL_DRLC_CANCEL_ALCE_PAYLOAD_INIT \
(zb_zcl_drlc_cancel_alce_payload_t) {0}
/** Initialize @ref ZB_ZCL_DRLC_CLI_CMD_REPORT_EVENT_STATUS "ReportEventStatus" command @ref zb_zcl_drlc_report_event_status_payload_t payload */
#define ZB_ZCL_DRLC_REPORT_EVENT_STATUS_PAYLOAD_INIT \
(zb_zcl_drlc_report_event_status_payload_t) \
{ \
.cooling_temperature_set_point_applied = (zb_uint16_t) 0x8000, \
.heating_temperature_set_point_applied = (zb_uint16_t) 0x8000, \
.average_load_adjustment_percentage_applied = (zb_int8_t) 0x80, \
.duty_cycle_applied = (zb_uint8_t) 0xFF, \
.signature = \
{ \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
}, \
}
/** Check if some size in range of variable size of specified payload.
*/
#define ZB_ZCL_DRLC_GET_SCHEDULED_EVENTS_PAYLOAD_SIZE_IS_VALID(size) \
((size) >= ((zb_int16_t)sizeof(zb_zcl_drlc_get_scheduled_events_payload_t) - \
(zb_int16_t)ZB_SIZEOF_FIELD(zb_zcl_drlc_get_scheduled_events_payload_t, issuer_event_id)))
/** Initialize @ref ZB_ZCL_DRLC_CLI_CMD_GET_SCHEDULED_EVENTS "GetScheduledEvents" command @ref zb_zcl_drlc_get_scheduled_events_payload_t payload */
#define ZB_ZCL_DRLC_CMD_GET_SCHEDULED_EVENTS_PAYLOAD_INIT \
(zb_zcl_drlc_get_scheduled_events_payload_t) \
{ \
.issuer_event_id = 0xFFFFFFFF, \
}
/** Function for send @ref ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT "LoadControlEvent" command.
* On sender's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with @ref ZB_ZCL_DRLC_GET_SCHEDULED_EVENTS_CB_ID
* callback id on reception of @ref ZB_ZCL_DRLC_CLI_CMD_GET_SCHEDULED_EVENTS "GetScheduledEvents" command.
* @n On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_DRLC_LOAD_CONTROL_EVENT_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_drlc_lce_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Handle @ref ZB_ZCL_DRLC_GET_SCHEDULED_EVENTS_CB_ID
* @snippet se/energy_service_interface/se_esi_zc.c handle_get_scheduled_events
* @n Example of sending @ref ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT "LoadControlEvent" command
* @snippet se/energy_service_interface/se_esi_zc.c esi_dev_cmd_send_lce_event1
*/
void zb_drlc_server_send_load_control_event(zb_uint8_t param,
zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_zcl_drlc_lce_payload_t *payload, zb_callback_t cb);
/** Function for send @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT "CancelLoadControlEvent" command.
* On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_DRLC_CANCEL_LOAD_CONTROL_EVENT_CB_ID
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_drlc_cancel_lce_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Example of sending @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT "CancelLoadControlEvent" command
* @snippet se/energy_service_interface/se_esi_zc.c esi_dev_cmd_send_lce_event2
*/
void zb_drlc_server_send_cancel_load_control_event(zb_uint8_t param,
zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_zcl_drlc_cancel_lce_payload_t *payload, zb_callback_t cb);
/** Function for send @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS "CancellAllLoadControlEvents" command.
* On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_DRLC_CANCEL_ALL_LOAD_CONTROL_EVENTS_CB_ID
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload: pointer to zb_uint8_t, where
* "Cancel Control" field value is placed (see SE spec, D.2.2.3.3.1).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Example of sending @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS "CancellAllLoadControlEvents" command
* @snippet se/energy_service_interface/se_esi_zc.c esi_dev_cmd_send_lce_event3
*/
void zb_drlc_server_send_cancel_all_load_control_events(zb_uint8_t param,
zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_uint8_t *payload, zb_callback_t cb);
/** Function for send @ref ZB_ZCL_DRLC_CLI_CMD_REPORT_EVENT_STATUS "ReportEventStatus" command.
* On sender's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with one of @ref ZB_ZCL_DRLC_LOAD_CONTROL_EVENT_CB_ID,
* @ref ZB_ZCL_DRLC_CANCEL_LOAD_CONTROL_EVENT_CB_ID, @ref ZB_ZCL_DRLC_CANCEL_ALL_LOAD_CONTROL_EVENTS_CB_ID
* callback ids on reception of @ref ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT "LoadControlEvent",
* @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT "CancelLoadControlEvent",
* @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS "CancellAllLoadControlEvents" commands respectively.
* @n On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_DRLC_REPORT_EVENT_STATUS_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_drlc_report_event_status_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Handle @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS "CancellAllLoadControlEvents" command
* @snippet se/in_home_display/se_ihd_zr.c ihd_handle_cancel_all_load_control_events
* @n Example of sending @ref ZB_ZCL_DRLC_CLI_CMD_REPORT_EVENT_STATUS "ReportEventStatus" command
* @snippet se/in_home_display/se_ihd_zr.c ihd_send_report_event_status
*/
void zb_drlc_client_send_report_event_status(zb_uint8_t param,
zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_zcl_drlc_report_event_status_payload_t *payload, zb_callback_t cb);
/** Function for send @ref ZB_ZCL_DRLC_SEND_CMD_REPORT_EVENT_STATUS_TSN "ReportEventStatus" command.
* On sender's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with one of @ref ZB_ZCL_DRLC_LOAD_CONTROL_EVENT_CB_ID,
* @ref ZB_ZCL_DRLC_CANCEL_LOAD_CONTROL_EVENT_CB_ID, @ref ZB_ZCL_DRLC_CANCEL_ALL_LOAD_CONTROL_EVENTS_CB_ID
* callback ids on reception of @ref ZB_ZCL_DRLC_SRV_CMD_LOAD_CONTROL_EVENT "LoadControlEvent",
* @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_LOAD_CONTROL_EVENT "CancelLoadControlEvent",
* @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS "CancellAllLoadControlEvents" commands respectively.
* @n On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_DRLC_REPORT_EVENT_STATUS_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_drlc_report_event_status_payload_t).
* @param tsn - transaction sequence number of response
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Handle @ref ZB_ZCL_DRLC_SRV_CMD_CANCEL_ALL_LOAD_CONTROL_EVENTS "CancellAllLoadControlEvents" command
* @snippet se/in_home_display/se_ihd_zr.c ihd_handle_cancel_all_load_control_events
* @n Example of sending @ref ZB_ZCL_DRLC_SEND_CMD_REPORT_EVENT_STATUS_TSN "ReportEventStatus" command
* @snippet se/in_home_display/se_ihd_zr.c ihd_send_report_event_status
*/
void zb_drlc_client_send_report_event_status_tsn(zb_uint8_t param,
zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_zcl_drlc_report_event_status_payload_t *payload, zb_uint8_t tsn, zb_callback_t cb);
/** Function for send @ref ZB_ZCL_DRLC_CLI_CMD_GET_SCHEDULED_EVENTS "GetScheduledEvents" command.
* On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_DRLC_GET_SCHEDULED_EVENTS_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_drlc_get_scheduled_events_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Example of sending @ref ZB_ZCL_DRLC_CLI_CMD_GET_SCHEDULED_EVENTS "GetScheduledEvents"
* @snippet se/in_home_display/se_ihd_zr.c ihd_dev_cmd_get_scheduled_events
*/
void zb_drlc_client_send_get_scheduled_events(zb_uint8_t param,
zb_addr_u *dst_addr, zb_aps_addr_mode_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_zcl_drlc_get_scheduled_events_payload_t *payload, zb_callback_t cb);
/** Macro for call @ref zb_drlc_server_send_load_control_event function
*/
#define ZB_ZCL_DRLC_SEND_CMD_LOAD_CONTROL_EVENT(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload ) \
zb_drlc_server_send_load_control_event(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_drlc_server_send_cancel_load_control_event function
*/
#define ZB_ZCL_DRLC_SEND_CMD_CANCEL_LCE(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload ) \
zb_drlc_server_send_cancel_load_control_event(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_drlc_server_send_cancel_all_load_control_events function
*/
#define ZB_ZCL_DRLC_SEND_CMD_CANCEL_ALL_LCE(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload ) \
zb_drlc_server_send_cancel_all_load_control_events(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_drlc_client_send_get_scheduled_events function
*/
#define ZB_ZCL_DRLC_SEND_CMD_GET_SCHEDULED_EVENTS(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload ) \
zb_drlc_client_send_get_scheduled_events(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_drlc_client_send_report_event_status function
*/
#define ZB_ZCL_DRLC_SEND_CMD_REPORT_EVENT_STATUS( _param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload ) \
zb_drlc_client_send_report_event_status(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_drlc_client_send_report_event_status_tsn function
*/
#define ZB_ZCL_DRLC_SEND_CMD_REPORT_EVENT_STATUS_TSN( _param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload, _tsn ) \
zb_drlc_client_send_report_event_status_tsn(_param, \
_dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _payload, _tsn, NULL)
/** @} */ /* ZB_ZCL_DRLC_COMMANDS_STRUCTURES_AND_DEFINITIONS */
/** @brief Declare attribute list for DRLC cluster
* @param[in] attr_list - attribute list variable name
* @param[in] utility_enrollment_group - pointer to variable to store @ref ZB_ZCL_ATTR_DRLC_UTILITY_ENROLLMENT_GROUP value
* @param[in] start_randomization_munutes - pointer to variable to store @ref ZB_ZCL_ATTR_DRLC_START_RANDOMIZATION_MINUTES value
* @param[in] duration_randomization_minutes - pointer to variable to store @ref ZB_ZCL_ATTR_DRLC_DURATION_RANDOMIZATION_MINUTES value
* @param[in] device_class - pointer to variable to store @ref ZB_ZCL_ATTR_DRLC_DEVICE_CLASS_VALUE value
*/
#define ZB_ZCL_DECLARE_DRLC_ATTRIB_LIST(attr_list, utility_enrollment_group, \
start_randomization_munutes, duration_randomization_minutes, device_class) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_DRLC) \
ZB_ZCL_SET_ATTR_DESC_M(ZB_ZCL_ATTR_DRLC_UTILITY_ENROLLMENT_GROUP, (utility_enrollment_group), ZB_ZCL_ATTR_TYPE_8BIT, ZB_ZCL_ATTR_ACCESS_READ_WRITE) \
ZB_ZCL_SET_ATTR_DESC_M(ZB_ZCL_ATTR_DRLC_START_RANDOMIZATION_MINUTES, (start_randomization_munutes), ZB_ZCL_ATTR_TYPE_8BIT, ZB_ZCL_ATTR_ACCESS_READ_WRITE) \
ZB_ZCL_SET_ATTR_DESC_M(ZB_ZCL_ATTR_DRLC_DURATION_RANDOMIZATION_MINUTES, (duration_randomization_minutes), ZB_ZCL_ATTR_TYPE_8BIT, ZB_ZCL_ATTR_ACCESS_READ_WRITE) \
ZB_ZCL_SET_ATTR_DESC_M(ZB_ZCL_ATTR_DRLC_DEVICE_CLASS_VALUE, (device_class), ZB_ZCL_ATTR_TYPE_16BIT, ZB_ZCL_ATTR_ACCESS_READ_WRITE) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** Initialize @ref zb_zcl_drlc_client_attrs_s DRLC cluster's attributes */
#define ZB_ZCL_DECLARE_DRLC_ATTR_LIST_INIT \
(zb_zcl_drlc_client_attrs_t) \
{ .utility_enrollment_group = 0, \
.start_randomization_munutes = 0x1e, \
.duration_randomization_minutes = 0, }
/**
* @brief DRLC client cluster attributes
*/
typedef struct zb_zcl_drlc_client_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_DRLC_UTILITY_ENROLLMENT_GROUP
* @see ZB_ZCL_ATTR_DRLC_UTILITY_ENROLLMENT_GROUP
*/
zb_uint8_t utility_enrollment_group;
/** @copydoc ZB_ZCL_ATTR_DRLC_START_RANDOMIZATION_MINUTES
* @see ZB_ZCL_ATTR_DRLC_START_RANDOMIZATION_MINUTES
*/
zb_uint8_t start_randomization_munutes;
/** @copydoc ZB_ZCL_ATTR_DRLC_DURATION_RANDOMIZATION_MINUTES
* @see ZB_ZCL_ATTR_DRLC_DURATION_RANDOMIZATION_MINUTES
*/
zb_uint8_t duration_randomization_minutes;
/** @copydoc ZB_ZCL_ATTR_DRLC_DEVICE_CLASS_VALUE
* @see ZB_ZCL_ATTR_DRLC_DEVICE_CLASS_VALUE
*/
zb_uint16_t device_class_value;
} zb_zcl_drlc_client_attrs_t;
/** @brief Declare attribute list for DRLC cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of @ref zb_zcl_drlc_client_attrs_t type (containing DRLC cluster attributes)
*/
#define ZB_ZCL_DECLARE_DRLC_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_DRLC_ATTRIB_LIST(attr_list, &attrs.utility_enrollment_group, \
&attrs.start_randomization_munutes, &attrs.duration_randomization_minutes, \
&attrs.device_class_value)
/** @} */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
/** Internal handler for DRLC Cluster commands */
void zb_zcl_drlc_init_server(void);
void zb_zcl_drlc_init_client(void);
#define ZB_ZCL_CLUSTER_ID_DRLC_SERVER_ROLE_INIT zb_zcl_drlc_init_server
#define ZB_ZCL_CLUSTER_ID_DRLC_CLIENT_ROLE_INIT zb_zcl_drlc_init_client
#endif /* ZB_ZCL_DRLC_H_ */

View File

@@ -0,0 +1,973 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Electrical Measurement cluster definitions
*/
#ifndef ZB_ZCL_ELECTRICAL_MEASUREMENT_H
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/* Cluster ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT */
/*! @addtogroup ZB_ZCL_ELECTRICAL_MEASUREMENT
@{
@name Electrical Measurement cluster attributes
@{
*/
/** @brief Default value for Electrical Measurement cluster revision global attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0003u)
/*! @brief Electrical Measurement cluster attribute identifiers
@see HA spec, subclause 9.2.2.2
*/
enum zb_zcl_electrical_measurement_attr_e
{
/** This attribute indicates a device s measurement capabilities. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASUREMENT_TYPE_ID = 0x0000,
/** The DCVoltage attribute represents the most recent DC voltage reading in Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_ID = 0x0100,
/** The DCVoltageMin attribute represents the lowest DC voltage value measured in Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_MIN_ID = 0x0101,
/** The DCVoltageMax attribute represents the highest DC voltage value measured in Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_MAX_ID = 0x0102,
/** The DCCurrent attribute represents the most recent DC current reading in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_CURRENT_ID = 0x0103,
/** The DCCurrentMin attribute represents the lowest DC current value measured in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_CURRENT_MIN_ID = 0x0104,
/** The DCCurrentMax attribute represents the highest DC current value measured in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_CURRENT_MAX_ID = 0x0105,
/** The @e DCPower attribute represents the most recent DC power reading in @e Watts (W) */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DCPOWER_ID = 0x0106,
/** The DCPowerMin attribute represents the lowest DC power value measured in Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_POWER_MIN_ID = 0x0107,
/** The DCPowerMax attribute represents the highest DC power value measured in Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_POWER_MAX_ID = 0x0108,
/** The DCVoltageMultiplier provides a value to be multiplied against the DCVoltage,
* DCVoltageMin, and DCVoltageMax attributes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_MULTIPLIER_ID = 0x0200,
/** The DCVoltageDivisor provides a value to be divided against the DCVoltage,
* DCVoltageMin, and DCVoltageMax attributes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_DIVISOR_ID = 0x0201,
/** The DCCurrentMultiplier provides a value to be multiplied against the DCCurrent,
* DCCurrentMin, and DCCurrentMax attributes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_CURRENT_MULTIPLIER_ID = 0x0202,
/** The DCCurrentDivisor provides a value to be divided against the DCCurrent,
* DCCurrentMin, and DCCurrentMax attributes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_CURRENT_DIVISOR_ID = 0x0203,
/** The DCPowerMultiplier provides a value to be multiplied against the DCPower,
* DCPowerMin, and DCPowerMax attributes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_POWER_MULTIPLIER_ID = 0x0204,
/** The DCPowerDivisor provides a value to be divided against the DCPower,
* DCPowerMin, and DCPowerMax attributes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_POWER_DIVISOR_ID = 0x0205,
/** The ACFrequency attribute represents the most recent AC Frequency reading in Hertz (Hz). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_ID = 0x0300,
/** The ACFrequencyMin attribute represents the lowest AC Frequency value measured in Hertz (Hz). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_MIN_ID = 0x0301,
/** The ACFrequencyMax attribute represents the highest AC Frequency value measured in Hertz (Hz). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_MAX_ID = 0x0302,
/** The NeutralCurrent attribute represents the AC neutral (Line-Out) current value
* at the moment in time the attribute is read, in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_NEUTRAL_CURRENT_ID = 0x0303,
/** Active power represents the current demand of active power delivered or
* received at the premises, in @e kW */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_TOTAL_ACTIVE_POWER_ID = 0x0304,
/** Reactive power represents the current demand of reactive power delivered or
* received at the premises, in kVAr. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_TOTAL_REACTIVE_POWER_ID = 0x0305,
/** Represents the current demand of apparent power, in @e kVA */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_TOTAL_APPARENT_POWER_ID = 0x0306,
/** Attribute represent the most recent 1st harmonic current reading in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED1ST_HARMONIC_CURRENT_ID = 0x0307,
/** Attribute represent the most recent 3rd harmonic current reading in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED3RD_HARMONIC_CURRENT_ID = 0x0308,
/** Attribute represent the most recent 5th harmonic current reading in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED5TH_HARMONIC_CURRENT_ID = 0x0309,
/** Attribute represent the most recent 7th harmonic current reading in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED7TH_HARMONIC_CURRENT_ID = 0x030a,
/** Attribute represent the most recent 9th harmonic current reading in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED9TH_HARMONIC_CURRENT_ID = 0x030b,
/** Attribute represent the most recent 11th harmonic current reading in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED11TH_HARMONIC_CURRENT_ID = 0x030c,
/** Attribute represent the most recent phase of the 1st harmonic current reading
* in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED_PHASE1ST_HARMONIC_CURRENT_ID = 0x030d,
/** Attribute represent the most recent phase of the 3rd harmonic current reading
* in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED_PHASE3RD_HARMONIC_CURRENT_ID = 0x030e,
/** Attribute represent the most recent phase of the 5th harmonic current reading
* in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED_PHASE5TH_HARMONIC_CURRENT_ID = 0x030f,
/** Attribute represent the most recent phase of the 7th harmonic current reading
* in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED_PHASE7TH_HARMONIC_CURRENT_ID = 0x0310,
/** Attribute represent the most recent phase of the 9th harmonic current reading
* in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED_PHASE9TH_HARMONIC_CURRENT_ID = 0x0311,
/** Attribute represent the most recent phase of the 11th harmonic current reading
* in an AC frequency. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASURED_PHASE11TH_HARMONIC_CURRENT_ID = 0x0312,
/** Provides a value to be multiplied against the ACFrequency attribute. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_MULTIPLIER_ID = 0x0400,
/** Provides a value to be divided against the ACFrequency attribute. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_DIVISOR_ID = 0x0401,
/** Provides a value to be multiplied against a raw or uncompensated
* sensor count of power being measured by the metering device. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_POWER_MULTIPLIER_ID = 0x0402,
/** Provides a value to divide against the results of applying the
* @e Multiplier attribute against a raw or uncompensated sensor
* count of power being measured by the metering device. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_POWER_DIVISOR_ID = 0x0403,
/** Represents the unit value for the MeasuredNthHarmonicCurrent attribute in the
* format MeasuredNthHarmonicCurrent * 10 ^ HarmonicCurrentMultiplier amperes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_HARMONIC_CURRENT_MULTIPLIER_ID = 0x0404,
/** Represents the unit value for the MeasuredPhaseNthHarmonicCurrent attribute in
* the format MeasuredPhaseNthHarmonicCurrent * 10 ^ PhaseHarmonicCurrentMultiplier
* degrees. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_PHASE_HARMONIC_CURRENT_MULTIPLIER_ID = 0x0405,
/** Represents the single phase or Phase A, AC line current (Square root of active and
* reactive current) value at the moment in time the attribute is read, in @e Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_LINE_CURRENT_ID = 0x0501,
/** Represents the single phase or Phase A, AC active/resistive current value at the
* moment in time the attribute is read, in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_CURRENT_ID = 0x0502,
/** Represents the single phase or Phase A, AC reactive current value at the moment
* in time the attribute is read, in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_REACTIVE_CURRENT_ID = 0x0503,
/** Represents the most recent RMS voltage reading in @e Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSVOLTAGE_ID = 0x0505,
/** Represents the lowest RMS voltage value measured in Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MIN_ID = 0x0506,
/** Represents the highest RMS voltage value measured in Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MAX_ID = 0x0507,
/** Represents the most recent RMS current reading in @e Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSCURRENT_ID = 0x0508,
/** Represents the lowest RMS current value measured in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MIN_ID = 0x0509,
/** Represents the highest RMS current value measured in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MAX_ID = 0x050a,
/** Represents the single phase or Phase A, current demand of active power delivered or
* received at the premises, in @e Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_ID = 0x050B,
/** Represents the lowest AC power value measured in Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MIN_ID = 0x050c,
/** Represents the highest AC power value measured in Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MAX_ID = 0x050d,
/** Represents the single phase or Phase A, current demand of reactive power delivered
* or received at the premises, in VAr. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_REACTIVE_POWER_ID = 0x050e,
/** Represents the single phase or Phase A, current demand of apparent (Square root
* of active and reactive power) power, in @e VA. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_APPARENT_POWER_ID = 0x050F,
/** Contains the single phase or PhaseA, Power Factor ratio in 1/100th. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_POWER_FACTOR_ID = 0x0510,
/** The Period in seconds that the RMS voltage is averaged over. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMSVOLTAGE_MEASUREMENT_PERIOD_ID = 0x0511,
/** The number of times the average RMS voltage, has been above the AverageRMS
* OverVoltage threshold since last reset. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_ID = 0x0512,
/** The number of times the average RMS voltage, has been below the AverageRMS
* underVoltage threshold since last reset. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_ID = 0x0513,
/** The duration in seconds used to measure an extreme over voltage condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_EXTREME_OVER_VOLTAGE_PERIOD_ID = 0x0514,
/** The duration in seconds used to measure an extreme under voltage condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_ID = 0x0515,
/** The duration in seconds used to measure a voltage sag condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SAG_PERIOD_ID = 0x0516,
/** The duration in seconds used to measure a voltage swell condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SWELL_PERIOD_ID = 0x0517,
/** Provides a value to be multiplied against the @e InstantaneousVoltage and @e
* RMSVoltage attributes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACVOLTAGE_MULTIPLIER_ID = 0x0600,
/** Provides a value to be divided against the @e InstantaneousVoltage and
* @e RMSVoltage attributes. This attribute must be used in conjunction with the @e
* ACVoltageMultiplier attribute. 0x0000 is an invalid value for this attribute. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACVOLTAGE_DIVISOR_ID = 0x0601,
/** Provides a value to be multiplied against the @e InstantaneousCurrent and @e
* RMSCurrent attributes */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACCURRENT_MULTIPLIER_ID = 0x0602,
/** Provides a value to be divided against the @e ACCurrent, @e InstantaneousCurrent
* and @e RMSCurrent attributes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACCURRENT_DIVISOR_ID = 0x0603,
/** Provides a value to be multiplied against the @e InstantaneousPower and @e
* ActivePower attributes */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACPOWER_MULTIPLIER_ID = 0x0604,
/** Provides a value to be divided against the @e InstantaneousPower and @e
* ActivePower attributes. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACPOWER_DIVISOR_ID = 0x0605,
/** Specifies which configurable alarms may be generated. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_OVERLOAD_ALARMS_MASK_ID = 0x0700,
/** Specifies the alarm threshold, set by the manufacturer, for the maximum output
* voltage supported by device. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_OVERLOAD_ID = 0x0701,
/** Specifies the alarm threshold, set by the manufacturer, for the maximum output
* current supported by device. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DC_CURRENT_OVERLOAD_ID = 0x0702,
/** Specifies which configurable alarms may be generated. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_ALARMS_MASK_ID = 0x0800,
/** Specifies the alarm threshold, set by the manufacturer, for the maximum output
* voltage supported by device. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_VOLTAGE_OVERLOAD_ID = 0x0801,
/** Specifies the alarm threshold, set by the manufacturer, for the maximum output
* current supported by device. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_CURRENT_OVERLOAD_ID = 0x0802,
/** Specifies the alarm threshold, set by the manufacturer, for the maximum output
* active power supported by device. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_ACTIVE_POWER_OVERLOAD_ID = 0x0803,
/** Specifies the alarm threshold, set by the manufacturer, for the maximum output
* reactive power supported by device. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AC_REACTIVE_POWER_OVERLOAD_ID = 0x0804,
/** The average RMS voltage above which an over voltage condition is reported. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_OVER_VOLTAGE_ID = 0x0805,
/** The average RMS voltage below which an under voltage condition is reported. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_UNDER_VOLTAGE_ID = 0x0806,
/** The RMS voltage above which an extreme under voltage condition is reported. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_EXTREME_OVER_VOLTAGE_ID = 0x0807,
/** The RMS voltage below which an extreme under voltage condition is reported. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_EXTREME_UNDER_VOLTAGE_ID = 0x0808,
/** The RMS voltage below which a sag condition is reported. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SAG_ID = 0x0809,
/** The RMS voltage above which a swell condition is reported. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SWELL_ID = 0x080a,
/** Represents the Phase B, AC line current (Square root sum of active and reactive
* currents) value at the moment in time the attribute is read, in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_LINE_CURRENT_PH_B_ID = 0x0901,
/** Represents the Phase B, AC active/resistive current value at the moment in time
* the attribute is read, in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_CURRENT_PH_B_ID = 0x0902,
/** Represents the Phase B, AC reactive current value at the moment in time the
* attribute is read, in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_REACTIVE_CURRENT_PH_B_ID = 0x0903,
/** Represents the most recent RMS voltage reading in @e Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSVOLTAGE_PHB_ID = 0x0905,
/** Represents the lowest RMS voltage value measured in Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MIN_PH_B_ID = 0x0906,
/** Represents the highest RMS voltage value measured in Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MAX_PH_B_ID = 0x0907,
/** Represents the most recent RMS current reading in @e Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSCURRENT_PHB_ID = 0x0908,
/** Represents the lowest RMS current value measured in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MIN_PH_B_ID = 0x0909,
/** Represents the highest RMS current value measured in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MAX_PH_B_ID = 0x090a,
/** Represents the Phase B, current demand of active power delivered or received at
* the premises, in @e Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_PHB_ID = 0x090B,
/** Represents the lowest AC power value measured in Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MIN_PH_B_ID = 0x090c,
/** Represents the highest AC power value measured in Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MAX_PH_B_ID = 0x090d,
/** Represents the Phase B, current demand of reactive power delivered or received
* at the premises, in VAr. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_REACTIVE_POWER_PH_B_ID = 0x090e,
/** Represents the Phase B, current demand of apparent (Square root of active and
* reactive power) power, in @e VA. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_APPARENT_POWER_PHB_ID = 0x090F,
/** Contains the PhaseB, Power Factor ratio in 1/100th. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_POWER_FACTOR_PH_B_ID = 0x0910,
/** The number of times the average RMS voltage, has been above the
* @e AverageRMS @e OverVoltage threshold since last reset. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMSVOLTAGE_MEASUREMENT_PERIOD_PHB_ID = 0x0911,
/** The number of times the average RMS voltage, has been above the AverageRMS
* OverVoltage threshold since last reset. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PH_B_ID = 0x0912,
/** The number of times the average RMS voltage, has been below the AverageRMS
* underVoltage threshold since last reset. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PH_B_ID = 0x0913,
/** The duration in seconds used to measure an extreme over voltage condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PH_B_ID = 0x0914,
/** The duration in seconds used to measure an extreme under voltage condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PH_B_ID = 0x0915,
/** The duration in seconds used to measure a voltage sag condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SAG_PERIOD_PH_B_ID = 0x0916,
/** The duration in seconds used to measure a voltage swell condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SWELL_PERIOD_PH_B_ID = 0x0917,
/** Represents the Phase C, AC line current (Square root of active and reactive
* current) value at the moment in time the attribute is read, in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_LINE_CURRENT_PH_C_ID = 0x0a01,
/** Represents the Phase C, AC active/resistive current value at the moment in time
* the attribute is read, in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_CURRENT_PH_C_ID = 0x0a02,
/** Represents the Phase C, AC reactive current value at the moment in time the
* attribute is read, in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_REACTIVE_CURRENT_PH_C_ID = 0x0a03,
/** Represents the most recent RMS voltage reading in @e Volts (V).*/
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSVOLTAGE_PHC_ID = 0x0A05,
/** Represents the lowest RMS voltage value measured in Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MIN_PH_C_ID = 0x0a06,
/** Represents the highest RMS voltage value measured in Volts (V). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MAX_PH_C_ID = 0x0a07,
/** Represents the most recent RMS current reading in @e Amps (A).*/
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSCURRENT_PHC_ID = 0x0A08,
/** Represents the lowest RMS current value measured in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MIN_PH_C_ID = 0x0a09,
/** Represents the highest RMS current value measured in Amps (A). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MAX_PH_C_ID = 0x0a0a,
/** Represents the Phase C, current demand of active power delivered
* or received at the premises, in @e Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_PHC_ID = 0x0A0B,
/** Represents the lowest AC power value measured in Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MIN_PH_C_ID = 0x0a0c,
/** Represents the highest AC power value measured in Watts (W). */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MAX_PH_C_ID = 0x0a0d,
/** Represents the Phase C, current demand of reactive power delivered or received
* at the premises, in VAr. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_REACTIVE_POWER_PH_C_ID = 0x0a0e,
/** Represents the Phase C, current demand of apparent (Square root of active and
* reactive power) power, in @e VA. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_APPARENT_POWER_PHC_ID = 0x0A0F,
/** Contains the Phase C, Power Factor ratio in 1/100th. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_POWER_FACTOR_PH_C_ID = 0x0a10,
/** The Period in seconds that the RMS voltage is averaged over*/
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMSVOLTAGE_MEASUREMENT_PERIOD_PHC_ID = 0x0A11,
/** The number of times the average RMS voltage, has been above the AverageRMS
* OverVoltage threshold since last reset. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PH_C_ID = 0x0a12,
/** The number of times the average RMS voltage, has been below the AverageRMS
* underVoltage threshold since last reset. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PH_C_ID = 0x0a13,
/** The duration in seconds used to measure an extreme over voltage condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PH_C_ID = 0x0a14,
/** The duration in seconds used to measure an extreme under voltage condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PH_C_ID = 0x0a15,
/** The duration in seconds used to measure a voltage sag condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SAG_PERIOD_PH_C_ID = 0x0a16,
/** The duration in seconds used to measure a voltage swell condition. */
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SWELL_PERIOD_PH_C_ID = 0x0a17,
};
/*! @brief Bit mapping for Measurement Type attribute,
@see HA spec, subclause 9.2.2.2.1.1 */
enum zb_zcl_electrical_measurement_measurement_type_e
{
/*! Active Measurement bit */
ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_MEASUREMENT = 0x00000001,
/*! Reactive Measurement bit */
ZB_ZCL_ELECTRICAL_MEASUREMENT_REACTIVE_MEASUREMENT = 0x00000002,
/*! Apparent Measurement bit */
ZB_ZCL_ELECTRICAL_MEASUREMENT_APPARENT_MEASUREMENT = 0x00000004,
/*! Phase A Measurement bit */
ZB_ZCL_ELECTRICAL_MEASUREMENT_PHASE_A_MEASUREMENT = 0x00000008,
/*! Phase B Measurement bit */
ZB_ZCL_ELECTRICAL_MEASUREMENT_PHASE_B_MEASUREMENT = 0x00000010,
/*! Phase C Measurement bit */
ZB_ZCL_ELECTRICAL_MEASUREMENT_PHASE_C_MEASUREMENT = 0x00000020,
/*! DC Measurement bit */
ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_MEASUREMENT = 0x00000040,
/*! Harmonic Measurement bit */
ZB_ZCL_ELECTRICAL_MEASUREMENT_HARMONIC_MEASUREMENT = 0x00000080,
/*! Power Quality Measurement bit */
ZB_ZCL_ELECTRICAL_MEASUREMENT_POWER_QUALITY_MEASUREMENT = 0x00000100,
ZB_ZCL_ELECTRICAL_MEASUREMENT_RESERVED = 0x00000200
};
/** @brief Default value for Measurement Type attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASUREMENT_TYPE_DEFAULT_VALUE 0x00000000
/** @brief Default value for DCVoltage attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for DCVoltageMin attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_MIN_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for DCVoltageMax attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_MAX_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for DCCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for DCCurrentMin attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_CURRENT_MIN_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for DCCurrentMax attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_CURRENT_MAX_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for DCPowerMin attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_POWER_MIN_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for DCPowerMax attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_POWER_MAX_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for DCVoltageMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_MULTIPLIER_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for DCVoltageDivisor attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_DIVISOR_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for DCCurrentMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_CURRENT_MULTIPLIER_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for DCCurrentDivisor attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_CURRENT_DIVISOR_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for DCPowerMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_POWER_MULTIPLIER_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for DCPowerDivisor attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_POWER_DIVISOR_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for ACFrequency attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for ACFrequencyMin attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_MIN_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for ACFrequencyMax attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_MAX_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for NeutralCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_NEUTRAL_CURRENT_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for DCPower attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DCPOWER_DEFAULT_VALUE 0x8000
/** @brief Default value for Measured1stHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED1ST_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for Measured3rdHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED3RD_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for Measured5thHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED5TH_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for Measured7thHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED7TH_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for Measured9thHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED9TH_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for Measured11thHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED11TH_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for MeasuredPhase1stHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED_PHASE1ST_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for MeasuredPhase3rdHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED_PHASE3RD_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for MeasuredPhase5thHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED_PHASE5TH_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for MeasuredPhase7thHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED_PHASE7TH_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for MeasuredPhase9thHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED_PHASE9TH_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for MeasuredPhase11thHarmonicCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_MEASURED_PHASE11TH_HARMONIC_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ACFrequencyMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_MULTIPLIER_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for ACFrequencyDivisor attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_FREQUENCY_DIVISOR_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for PowerMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_POWER_MULTIPLIER_DEFAULT_VALUE ((zb_uint32_t)0x000001)
/** @brief Default value for PowerDivisor attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_POWER_DIVISOR_DEFAULT_VALUE ((zb_uint32_t)0x000001)
/** @brief Default value for HarmonicCurrentMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_HARMONIC_CURRENT_MULTIPLIER_DEFAULT_VALUE ((zb_int8_t)0x00)
/** @brief Default value for PhaseHarmonicCurrentMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_PHASE_HARMONIC_CURRENT_MULTIPLIER_DEFAULT_VALUE ((zb_int8_t)0x00)
/** @brief Default value for LineCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_LINE_CURRENT_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for ActiveCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ReactiveCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_REACTIVE_CURRENT_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for RMSVoltageMin attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MIN_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for RMSVoltageMax attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MAX_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for RMSCurrentMin attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MIN_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for RMSCurrentMax attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MAX_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for ActivePowerMin attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MIN_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ActivePowerMax attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MAX_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ReactivePower attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_REACTIVE_POWER_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ApparentPower attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_APPARENT_POWER_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for AverageRmsvoltageMeasurementPeriod attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AVERAGE_RMSVOLTAGE_MEASUREMENT_PERIOD_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for AverageRMSOverVoltageCounter attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for AverageRMSUnderVoltageCounter attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSExtremeOverVoltagePeriod attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_EXTREME_OVER_VOLTAGE_PERIOD_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSExtremeUnderVoltagePeriod attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSVoltageSagPeriod attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SAG_PERIOD_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSVoltageSwellPeriod attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SWELL_PERIOD_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for AcvoltageMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACVOLTAGE_MULTIPLIER_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for AcvoltageDivisor attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACVOLTAGE_DIVISOR_DEFAULT_VALUE ((zb_uint16_t)0x0001)
/** @brief Default value for DCOverloadAlarmsMask attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_OVERLOAD_ALARMS_MASK_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for DCVoltageOverload attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_VOLTAGE_OVERLOAD_DEFAULT_VALUE ((zb_int16_t)0xFFFF)
/** @brief Default value for DCCurrentOverload attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_DC_CURRENT_OVERLOAD_DEFAULT_VALUE ((zb_int16_t)0xFFFF)
/** @brief Default value for ACAlarmsMask attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_ALARMS_MASK_DEFAULT_VALUE ((zb_uint16_t)0x00)
/** @brief Default value for ACVoltageOverload attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_VOLTAGE_OVERLOAD_DEFAULT_VALUE ((zb_int16_t)0xFFFF)
/** @brief Default value for ACCurrentOverload attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_CURRENT_OVERLOAD_DEFAULT_VALUE ((zb_int16_t)0xFFFF)
/** @brief Default value for ACActivePowerOverload attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_ACTIVE_POWER_OVERLOAD_DEFAULT_VALUE ((zb_int16_t)0xFFFF)
/** @brief Default value for ACReactivePowerOverload attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AC_REACTIVE_POWER_OVERLOAD_DEFAULT_VALUE ((zb_int16_t)0xFFFF)
/** @brief Default value for RMSVoltage attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMSVOLTAGE_DEFAULT_VALUE 0xffff
/** @brief Default value for RMSCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMSCURRENT_DEFAULT_VALUE 0xffff
/** @brief Default value for ActivePower attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_DEFAULT_VALUE 0xffff
/** @brief Default value for RMSCurrent attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_POWER_FACTOR_DEFAULT_VALUE 0x0
/** @brief Default value for PowerMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACPOWER_MULTIPLIER_DEFAULT_VALUE 0x0001
/** @brief Default value for PowerDivisor attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACPOWER_DIVISOR_DEFAULT_VALUE 0x0001
/** @brief Default value for ACCurrentMultiplier attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACCURRENT_MULTIPLIER_DEFAULT_VALUE 0x0001
/** @brief Default value for ACCurrentDivisor attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACCURRENT_DIVISOR_DEFAULT_VALUE 0x0001
/** @brief Default value for LineCurrentPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_LINE_CURRENT_PH_B_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for ActiveCurrentPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_CURRENT_PH_B_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ReactiveCurrentPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_REACTIVE_CURRENT_PH_B_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for RmsvoltagePHB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMSVOLTAGE_PHB_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for RMSVoltageMinPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MIN_PH_B_DEFAULT_VALUE ((zb_uint16_t)0x8000)
/** @brief Default value for RMSVoltageMaxPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MAX_PH_B_DEFAULT_VALUE ((zb_uint16_t)0x8000)
/** @brief Default value for RmscurrentPHB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMSCURRENT_PHB_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for RMSCurrentMinPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MIN_PH_B_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for RMSCurrentMaxPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MAX_PH_B_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for ActivePowerPHB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_PHB_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ActivePowerMinPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MIN_PH_B_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ActivePowerMaxPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MAX_PH_B_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ReactivePowerPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_REACTIVE_POWER_PH_B_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ApparentPowerPHB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_APPARENT_POWER_PHB_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for PowerFactorPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_POWER_FACTOR_PH_B_DEFAULT_VALUE ((zb_int8_t)0x00)
/** @brief Default value for AverageRmsvoltageMeasurementPeriodPHB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AVERAGE_RMSVOLTAGE_MEASUREMENT_PERIOD_PHB_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for AverageRMSOverVoltageCounterPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PH_B_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for AverageRMSUnderVoltageCounterPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PH_B_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSExtremeOverVoltagePeriodPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PH_B_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSExtremeUnderVoltagePeriodPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PH_B_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSVoltageSagPeriodPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SAG_PERIOD_PH_B_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSVoltageSwellPeriodPhB attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SWELL_PERIOD_PH_B_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for LineCurrentPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_LINE_CURRENT_PH_C_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for ActiveCurrentPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_CURRENT_PH_C_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ReactiveCurrentPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_REACTIVE_CURRENT_PH_C_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for rmsvoltagePHC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMSVOLTAGE_PHC_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for RMSVoltageMinPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MIN_PH_C_DEFAULT_VALUE ((zb_uint16_t)0x8000)
/** @brief Default value for RMSVoltageMaxPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_MAX_PH_C_DEFAULT_VALUE ((zb_uint16_t)0x8000)
/** @brief Default value for rmscurrentPHC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMSCURRENT_PHC_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for RMSCurrentMinPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MIN_PH_C_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for RMSCurrentMaxPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_CURRENT_MAX_PH_C_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for ActivePowerPHC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_PHC_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ActivePowerMinPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MIN_PH_C_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ActivePowerMaxPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_MAX_PH_C_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ReactivePowerPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_REACTIVE_POWER_PH_C_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for ApparentPowerPHC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_APPARENT_POWER_PHC_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for PowerFactorPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_POWER_FACTOR_PH_C_DEFAULT_VALUE ((zb_int8_t)0x00)
/** @brief Default value for AverageRmsvoltageMeasurementPeriodPHC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AVERAGE_RMSVOLTAGE_MEASUREMENT_PERIOD_PHC_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for AverageRMSOverVoltageCounterPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PH_C_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for AverageRMSUnderVoltageCounterPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PH_C_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSExtremeOverVoltagePeriodPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PH_C_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSExtremeUnderVoltagePeriodPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PH_C_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSVoltageSagPeriodPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SAG_PERIOD_PH_C_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for RMSVoltageSwellPeriodPhC attribute */
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_RMS_VOLTAGE_SWELL_PERIOD_PH_C_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/*! @} */ /* Electrical Measurement cluster attributes */
/*! @brief Electrical Measurement cluster server command identifiers
@see ZCL spec, subclause 4.9.2.3.1
*/
enum zb_zcl_electrical_measurement_srv_cmd_e
{
/** This command is generated when the Client command GetProfileInfo is received. */
ZB_ZCL_CMD_ELECTRICAL_MEASUREMENT_GET_PROFILE_INFO_RESPONSE_COMMAND = 0x00,
/** This command is generated when the Client command GetMeasurementProfile is received. */
ZB_ZCL_CMD_ELECTRICAL_MEASUREMENT_GET_MEASUREMENT_PROFILE_RESPONSE_COMMAND = 0x01,
};
/*! @brief Electrical Measurement cluster client command identifiers
@see ZCL spec, subclause 4.9.2.4.1
*/
enum zb_zcl_electrical_measurement_cli_cmd_e
{
/** Get Profile Info Command */
ZB_ZCL_CMD_ELECTRICAL_MEASUREMENT_GET_PROFILE_INFO_COMMAND = 0x00,
/** Get Measurement Profile Command */
ZB_ZCL_CMD_ELECTRICAL_MEASUREMENT_GET_MEASUREMENT_PROFILE_COMMAND = 0x01,
};
/*! @cond internals_doc
@internal @name Electrical Measurement cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASUREMENT_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASUREMENT_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_32BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DCPOWER_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DCPOWER_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSVOLTAGE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSVOLTAGE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSCURRENT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_RMSCURRENT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACTIVE_POWER_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_POWER_FACTOR_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_POWER_FACTOR_ID, \
ZB_ZCL_ATTR_TYPE_S8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACPOWER_MULTIPLIER_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACPOWER_MULTIPLIER_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACPOWER_DIVISOR_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_ACPOWER_DIVISOR_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*!
* @}
* @endcond
*/
/** @brief Declare attribute list for Electrical Measurement cluster
@param attr_list - attribute list name
@param measurement_type - pointer to variable to store Measurement Type attribute value
@param dcpower - pointer to variable to store DCPower attribute value
*/
#define ZB_ZCL_DECLARE_ELECTRICAL_MEASUREMENT_ATTRIB_LIST(attr_list, measurement_type, dcpower) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_ELECTRICAL_MEASUREMENT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_MEASUREMENT_TYPE_ID, (measurement_type)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ELECTRICAL_MEASUREMENT_DCPOWER_ID, (dcpower)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*!
@cond internals_doc
@{
@internal Number of attributes mandatory for reporting in Electrical Measurement cluster
*/
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_REPORT_ATTR_COUNT 2
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_SEND_GET_PROFILE_INFO_RESP( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, \
profile_count, profile_interval_period, max_number_of_intervals, \
list_of_attributes, list_of_attributes_size) \
{ \
zb_uint8_t ind; \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_ELECTRICAL_MEASUREMENT_GET_PROFILE_INFO_RESPONSE_COMMAND); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (profile_count)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (profile_interval_period)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (max_number_of_intervals)); \
for (ind=0; ind < list_of_attributes_size; ind++) \
{ \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (list_of_attributes[ind])); \
} \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, \
prfl_id, ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT, cb); \
}
/**
* @deprecated This function will be removed in the next Major release
* Use @ref ZB_ZCL_ELECTRICAL_MEASUREMENT_SEND_GET_MEASUREMENT_PROFILE_RESP() instead
*/
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_SEND_GET_MEASUREMENT_PROFILE_INFO_RESP( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, \
start_time, status, profile_interval_period, number_of_intervals_delivered, attr_id, \
list_of_intervals) \
{ \
zb_uint8_t ind; \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_ELECTRICAL_MEASUREMENT_GET_MEASUREMENT_PROFILE_RESPONSE_COMMAND); \
ZB_ZCL_PACKET_PUT_DATA32_VAL(ptr, (start_time)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (status)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (profile_interval_period)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (number_of_intervals_delivered)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (attr_id)); \
for (ind=0; ind < number_of_intervals_delivered; ind++) \
{ \
\
} \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, \
prfl_id, ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT, cb); \
}
#define ZB_ZCL_ELECTRICAL_MEASUREMENT_SEND_GET_MEASUREMENT_PROFILE_RESP( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, \
start_time, status, profile_interval_period, number_of_intervals_delivered, attr_id, \
attr_type, list_of_intervals) \
{ \
zb_uint8_t ind; \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_ELECTRICAL_MEASUREMENT_GET_MEASUREMENT_PROFILE_RESPONSE_COMMAND); \
ZB_ZCL_PACKET_PUT_DATA32_VAL(ptr, (start_time)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (status)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (profile_interval_period)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (number_of_intervals_delivered)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (attr_id)); \
for (ind=0; ind < number_of_intervals_delivered; ind++) \
{ \
(ptr) = zb_zcl_put_value_to_packet((ptr), (attr_type), list_of_intervals[ind]); \
} \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, \
prfl_id, ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT, cb); \
}
/*! @}
@endcond */ /* Electrical Measurement cluster internals */
/*! @} */ /* ZCL HA Electrical Measurement cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_el_measurement_init_server(void);
void zb_zcl_el_measurement_init_client(void);
#define ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT_SERVER_ROLE_INIT zb_zcl_el_measurement_init_server
#define ZB_ZCL_CLUSTER_ID_ELECTRICAL_MEASUREMENT_CLIENT_ROLE_INIT zb_zcl_el_measurement_init_client
#endif /* ZB_ZCL_ELECTRICAL_MEASUREMENT_H */

View File

@@ -0,0 +1,454 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: EN50523 Appliance events and alerts cluster definitions
*/
#ifndef ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_H
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_H 1
/** @cond DOXYGEN_ZCL_SECTION */
/*! @addtogroup ZB_ZCL_EN50523_APP_EVENTS_ALERTS
@{
*/
/*! @name EN50523 Appliance events and alerts cluster commands
@{
*/
/*! @brief EN50523 Appliance events and alerts cluster
command received identifiers
@see ZCL 6.0 spec, subclause 15.4.2.3
*/
enum zb_zcl_en50523_appl_ev_and_alerts_recv_cmd_e
{
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_GET_ALERTS_ID = 0x00, /**< "Get alerts" command. */
};
/*! @brief EN50523 Appliance events and alerts cluster
commands generated identifiers
@see ZCL 6.0 spec, subclause 15.4.2.4
*/
enum zb_zcl_en50523_appl_ev_and_alerts_send_cmd_e
{
/*! "Get alerts response" command. */
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_GET_ALERTS_RESP_ID = 0x00,
/*! "Alerts notification" command. */
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_ALERTS_NOTIFICATION_ID = 0x01,
/*! "Event notification" command. */
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_EVENT_NOTIFICATION_ID = 0x02,
};
/** @brief Default value for EN50523 Appliance events and alerts cluster revision global attribute */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/*!
@brief Declare attribute list for EN50523 Appliance events and alerts cluster (only cluster revision attribute)
@param attr_list - attribute list name
*/
#define ZB_ZCL_DECLARE_EN50523_APPL_EV_AND_ALERTS_ATTR_LIST(attr_list) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_EN50523_APPL_EV_AND_ALERTS) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @cond internals_doc */
/* en50523 cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_APPL_EV_AND_ALERTS_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_GET_ALERTS_ID
#define ZB_ZCL_CLUSTER_ID_APPL_EV_AND_ALERTS_SERVER_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_GET_ALERTS_RESP_ID, \
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_ALERTS_NOTIFICATION_ID, \
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_EVENT_NOTIFICATION_ID
#define ZB_ZCL_CLUSTER_ID_APPL_EV_AND_ALERTS_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_APPL_EV_AND_ALERTS_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_APPL_EV_AND_ALERTS_CLIENT_ROLE_GENERATED_CMD_LIST ZB_ZCL_CLUSTER_ID_APPL_EV_AND_ALERTS_SERVER_ROLE_RECEIVED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
/******************************* Get Alerts Command ******************************/
/*! @brief Get Alerts command, ZCL spec 15.4.2.2.1
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_GET_ALERTS_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_GET_ALERTS_ID); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_APPLIANCE_EVENTS_AND_ALERTS, cb); \
}
/******************************* Get Alerts Response Command ******************************/
/*! @brief Maximum number of Alerts */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_MAX_ALERTS_NUM 15
/*! @brief Type of alert */
enum zb_zcl_en50523_appl_ev_and_alerts_alerts_type_e
{
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_TYPE_UNSTRUCTURED = 0x00,
};
/*! @brief Alert category */
enum zb_zcl_en50523_appl_ev_and_alerts_alert_category_e
{
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_CATEGORY_WARNING = 0x01,
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_CATEGORY_DANGER = 0x02,
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_CATEGORY_FAILURE = 0x03,
};
/*! @brief Alert presence recovery */
enum zb_zcl_en50523_appl_ev_and_alerts_alert_presence_e
{
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_RECOVERY = 0x00,
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_PRESENCE = 0x01,
};
/*! @brief Get Number of Alerts */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_COUNT_GET_NUM(_alerts_count) ((_alerts_count) & 0x0F)
/*! @brief Set Number of Alerts */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_COUNT_SET_NUM(_alerts_count, num) ((_alerts_count) |= (num & 0x0F))
/*! @brief Get Type of alert */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_COUNT_GET_TYPE(_alerts_count) (((_alerts_count) & 0xF0) >> 4)
/*! @brief Set Type of alert */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_COUNT_SET_TYPE(_alerts_count, type) ((_alerts_count) |= ((type & 0x0F) << 4))
/*! @brief Get Alert ID */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_STRUCT_GET_ID(_alert_struct) ((_alert_struct).alert[2] & 0xFF)
/*! @brief Set Alert ID */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_STRUCT_SET_ID(_alert_struct, id) ((_alert_struct).alert[2] = (id & 0xFF))
/*! @brief Get Alert Category */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_STRUCT_GET_CATEGORY(_alert_struct) ((_alert_struct).alert[1] & 0x0F)
/*! @brief Set Alert Category */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_STRUCT_SET_CATEGORY(_alert_struct, cat) ((_alert_struct).alert[1] |= (cat & 0x0F))
/*! @brief Get Alert Presence recovery */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_STRUCT_GET_PRESENCE(_alert_struct) (((_alert_struct).alert[1] & 0xF0) >> 4)
/*! @brief Set Alert Presence recovery */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_STRUCT_SET_PRESENCE(_alert_struct, pres) ((_alert_struct).alert[1] |= (pres & 0x0F) << 4)
/*! @brief Get Alert Manufacturer specific bits */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_STRUCT_GET_MANUF_SPEC(_alert_struct) ((_alert_struct).alert[0] & 0xFF)
/*! @brief Set Alert Manufacturer specific bits */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERT_STRUCT_SET_MANUF_SPEC(_alert_struct, val) ((_alert_struct).alert[0] = (val & 0xFF))
/*! @brief Alert structure */
typedef ZB_PACKED_PRE struct zb_zcl_en50523_appl_ev_and_alerts_alert_struct_s
{
/** Alert field - Alert ID, Category, Presence recovery, Manufacturer specific bits */
zb_uint8_t alert[3];
} ZB_PACKED_STRUCT zb_zcl_en50523_appl_ev_and_alerts_alert_struct_t;
/*! @brief Structure representation of Get Alerts Response command */
typedef ZB_PACKED_PRE struct zb_zcl_en50523_appl_ev_and_alerts_get_alerts_resp_s
{
/** Alerts count fields - Number of Alerts, Type of alert */
zb_uint8_t alerts_count;
/** Alert structure fields, see zb_zcl_en50523_appl_ev_and_alerts_alert_struct_t */
zb_zcl_en50523_appl_ev_and_alerts_alert_struct_t alert_struct[ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_MAX_ALERTS_NUM];
} ZB_PACKED_STRUCT zb_zcl_en50523_appl_ev_and_alerts_get_alerts_resp_t;
/*! Get Alerts Response command payload size */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_GET_ALERTS_RESP_PAYLOAD_SIZE(ptr) (sizeof(((zb_zcl_en50523_appl_ev_and_alerts_get_alerts_resp_t *)(ptr))->alerts_count) + \
(ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_COUNT_GET_NUM(((zb_zcl_en50523_appl_ev_and_alerts_get_alerts_resp_t *)(ptr))->alerts_count)* \
sizeof(zb_zcl_en50523_appl_ev_and_alerts_alert_struct_t)))
/*! @brief Start Get Alerts Response command, ZCL spec 15.4.2.3.1
@param buffer - to put packet to
@param seq - sequence
@param alerts_count - Alerts count field
@param ptr - [out] (zb_uint8_t*) current position for @ref ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_GET_ALERTS_RESP_ADD
and @ref ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_GET_ALERTS_RESP_END
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_GET_ALERTS_RESP_START( \
buffer, seq, alerts_count, ptr) \
{ \
(ptr) = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, seq, \
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_GET_ALERTS_RESP_ID); \
ZB_ZCL_PACKET_PUT_DATA8((ptr), (alerts_count)); \
}
/*! @brief Add Alert Structure to Get Alerts Response command, ZCL spec 15.4.2.3.1
@param ptr - [in/out] (zb_uint8_t*) current position
@param alert_struct - pointer to the Alert structure to put into packet
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_GET_ALERTS_RESP_ADD(ptr, alert_struct) \
{ \
ZB_ZCL_PACKET_PUT_DATA24(ptr, (alert_struct)); \
}
/*! @brief End form Get Alerts Response command and send it, ZCL spec 15.4.2.3.1
@param ptr - (zb_uint8_t*) current position
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_GET_ALERTS_RESP_END( \
ptr, buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id) \
{ \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_APPLIANCE_EVENTS_AND_ALERTS, NULL); \
}
/** @brief Macro for getting Get Alerts Response command, ZCL spec 15.4.2.3.1
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_en50523_appl_ev_and_alerts_get_alerts_resp_t
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_GET_GET_ALERTS_RESP(data_ptr, buffer, status) \
{ \
zb_uint8_t *data = zb_buf_begin(buffer); \
if (zb_buf_len((buffer)) < \
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_GET_ALERTS_RESP_PAYLOAD_SIZE(data)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
ZB_ZCL_PACKET_GET_DATA8(&(data_ptr)->alerts_count, data); \
ZB_ZCL_PACKET_GET_DATA_N((data_ptr)->alert_struct, data, \
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_COUNT_GET_NUM((data_ptr)->alerts_count)*sizeof(zb_zcl_en50523_appl_ev_and_alerts_alert_struct_t)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
}
/******************************* Alerts Notification Command ******************************/
/*! @brief Structure representation of Alerts Notification command */
typedef ZB_PACKED_PRE struct zb_zcl_en50523_appl_ev_and_alerts_alerts_notif_s
{
/** Alerts count fields - Number of Alerts, Type of alert */
zb_uint8_t alerts_count;
/** Alert structure fields, see zb_zcl_en50523_appl_ev_and_alerts_alert_struct_t */
zb_zcl_en50523_appl_ev_and_alerts_alert_struct_t alert_struct[ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_MAX_ALERTS_NUM];
} ZB_PACKED_STRUCT zb_zcl_en50523_appl_ev_and_alerts_alerts_notif_t;
/*! Alerts Notification command payload size */
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_NOTIF_PAYLOAD_SIZE(ptr) (sizeof(((zb_zcl_en50523_appl_ev_and_alerts_alerts_notif_t *)(ptr))->alerts_count) + \
(ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_COUNT_GET_NUM(((zb_zcl_en50523_appl_ev_and_alerts_alerts_notif_t *)(ptr))->alerts_count)* \
sizeof(zb_zcl_en50523_appl_ev_and_alerts_alert_struct_t)))
/*! @brief Start Alerts Notification command, ZCL spec 15.4.2.3.2
@param buffer - to put packet to
@param def_resp - enable/disable default response
@param alerts_count - Alerts count field
@param ptr - [out] (zb_uint8_t*) current position for @ref ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_ALERTS_NOTIF_ADD
and @ref ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_ALERTS_NOTIF_END
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_ALERTS_NOTIF_START( \
buffer, def_resp, alerts_count, ptr) \
{ \
(ptr) = zb_zcl_start_command_header(buffer, \
ZB_ZCL_CONSTRUCT_FRAME_CONTROL( \
ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC, \
ZB_ZCL_NOT_MANUFACTURER_SPECIFIC, \
ZB_ZCL_FRAME_DIRECTION_TO_CLI, \
(def_resp)), \
0, /* No manuf_code */ \
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_ALERTS_NOTIFICATION_ID, \
NULL); \
ZB_ZCL_PACKET_PUT_DATA8((ptr), (alerts_count)); \
}
/*! @brief Add Alert Structure to Alerts Notification command, ZCL spec 15.4.2.3.2
@param ptr - [in/out] (zb_uint8_t*) current position
@param alert_struct - pointer to Alert structure to put into packet
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_ALERTS_NOTIF_ADD(ptr, alert_struct) \
{ \
ZB_ZCL_PACKET_PUT_DATA24(ptr, (alert_struct)); \
}
/*! @brief End form Alerts Notification command and send it, ZCL spec 15.4.2.3.2
@param ptr - (zb_uint8_t*) current position
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param cb - callback for getting command send status
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_ALERTS_NOTIF_END( \
ptr, buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, cb) \
{ \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_APPLIANCE_EVENTS_AND_ALERTS, cb); \
}
/** @brief Macro for getting Alerts Notification command, ZCL spec 15.4.2.3.2
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_en50523_appl_ev_and_alerts_alerts_notif_t
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_GET_ALERTS_NOTIF(data_ptr, buffer, status) \
{ \
zb_uint8_t *data = zb_buf_begin(buffer); \
if (zb_buf_len((buffer)) < \
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_NOTIF_PAYLOAD_SIZE(data)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
ZB_ZCL_PACKET_GET_DATA8(&(data_ptr)->alerts_count, data); \
ZB_ZCL_PACKET_GET_DATA_N((data_ptr)->alert_struct, data, \
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_ALERTS_COUNT_GET_NUM((data_ptr)->alerts_count)*sizeof(zb_zcl_en50523_appl_ev_and_alerts_alert_struct_t)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
}
/******************************* Event Notification Command ******************************/
/*! @brief Event Identification */
enum zb_zcl_en50523_appl_ev_and_alerts_event_identification_e
{
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_EVENT_ID_END_OF_CYCLE = 0x01,
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_EVENT_ID_TEMP_REACHED = 0x04,
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_EVENT_ID_END_OF_COOKING = 0x05,
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_EVENT_ID_SWITCHING_OFF = 0x06,
ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_EVENT_ID_WRONG_DATA = 0xf7,
};
/*! @brief Structure representation of Event Notification command
@param event_header - Event header field
@param event_identification - Event Identification field, see zb_zcl_en50523_appl_ev_and_alerts_event_identification_e
*/
typedef ZB_PACKED_PRE struct zb_zcl_en50523_appl_ev_and_alerts_event_notif_s
{
zb_uint8_t event_header;
zb_uint8_t event_identification;
} ZB_PACKED_STRUCT zb_zcl_en50523_appl_ev_and_alerts_event_notif_t;
/*! @brief Event Notification command, ZCL spec 15.4.2.3.3
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param event_identification - Event ID
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_SEND_EVENT_NOTIF( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, \
event_identification) \
{ \
zb_uint8_t* ptr = zb_zcl_start_command_header(buffer, \
ZB_ZCL_CONSTRUCT_FRAME_CONTROL( \
ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC, \
ZB_ZCL_NOT_MANUFACTURER_SPECIFIC, \
ZB_ZCL_FRAME_DIRECTION_TO_CLI, \
(def_resp)), \
0, /* No manuf_code */ \
ZB_ZCL_CMD_EN50523_APPL_EV_AND_ALERTS_EVENT_NOTIFICATION_ID, \
NULL); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, 0); \
ZB_ZCL1_PACKET_PUT_DATA8(ptr, (event_identification)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_APPLIANCE_EVENTS_AND_ALERTS, cb); \
}
/** @brief Macro for getting Event Notification command, see ZCL spec 15.4.2.3.3
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type zb_zcl_en50523_appl_ev_and_alerts_event_notif_e
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_GET_EVENT_NOTIF(data_ptr, buffer, status) \
{ \
zb_uint8_t *data = zb_buf_begin(buffer); \
if (zb_buf_len((buffer)) < \
sizeof(zb_zcl_en50523_appl_ev_and_alerts_event_notif_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
ZB_ZCL_PACKET_GET_DATA8(&(data_ptr)->event_header, data); \
ZB_ZCL_PACKET_GET_DATA8(&(data_ptr)->event_identification, data); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
}
/*! @} */ /* Appliance events and alerts cluster commands */
/*! @} */ /*ZB_ZCL_EN50523_APP_EVENTS_ALERTS */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_en50523_appliance_events_and_alerts_init_server(void);
void zb_zcl_en50523_appliance_events_and_alerts_init_client(void);
#define ZB_ZCL_CLUSTER_ID_APPLIANCE_EVENTS_AND_ALERTS_SERVER_ROLE_INIT zb_zcl_en50523_appliance_events_and_alerts_init_server
#define ZB_ZCL_CLUSTER_ID_APPLIANCE_EVENTS_AND_ALERTS_CLIENT_ROLE_INIT zb_zcl_en50523_appliance_events_and_alerts_init_client
#endif /* ZB_ZCL_EN50523_APPL_EV_AND_ALERTS_H */

View File

@@ -0,0 +1,582 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Energy Management cluster definitions
*/
#ifndef ZB_ZCL_ENERGY_MANAGEMENT_H_
#define ZB_ZCL_ENERGY_MANAGEMENT_H_
#include "zboss_api_core.h" /* ZBOSS core API types */
/* Include this header for zb_zcl_drlc_event_status_t import*/
#include "zcl/zb_zcl_drlc.h"
/** @cond (DOXYGEN_ZCL_SECTION && DOXYGEN_SE_SECTION) */
/** @addtogroup ZB_ZCL_ENERGY_MANAGEMENT
* @{
* @details
* The Energy Management cluster provides a way of modifying DRLC events, energy consumption
* behavior and querying the status of DRLC events.
* @note The ESI is defined as the Client. The DRLC device is a Server
* in this case; it holds the attributes and receives commands.
*/
/** @defgroup ZB_ZCL_ENERGY_MANAGEMENT_ATTRS Energy Management cluster attributes
* @{
*/
/** Energy Management Server Cluster Attributes
* @see SE spec, subclause 12.2.2
*/
typedef enum zb_zcl_energy_management_srv_attr_e
{
/* (M) */
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_LOAD_CONTROL_STATE = 0x0000, /**< This attribute shall be a BitMap showing the current state of the device.
* The attribute shall be read-only.
*/
/* (M) */
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_ID, /**< If an event is in progress (current time is between the Effective Start Time
* and Effective End Time of an event), this attribute SHALL indicate
* the Issuer Event ID of the active event.
*/
/* (M) */
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_STATUS, /**< This attribute represents the value returned in the Event Control field of
* the latest Report Event Status command (see D.2.3.3.1). This attribute provides
* a mechanism to allow a remote device to query whether this client device is
* currently participating in a load control event.
*/
/* (M) */
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CONFORMANCE_LEVEL, /**< This is the minimum criticality level of a DRLC event that the device will observe.
* Events with a criticality level lower than the Conformance Level
* will be opted out.
*/
/* (M) */
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_OFF_TIME, /**< This attribute is measured in seconds and used to determine the duty
* cycling times. It is the shortest times the device should be allowed off.
*/
/* (M) */
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_ON_TIME, /**< This attribute is measured in seconds and used to determine the duty
* cycling times. It is the shortest times the device should be allowed on.
*/
/* (M) */
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_CYCLE_PERIOD /**< This attribute is measured in seconds and used to determine the duty
* cycling times. It is the shortest cycling period allowed for duty cycling
*/
} zb_zcl_energy_management_srv_attr_t;
/** @brief Default value for Energy Management cluster revision global attribute (not defined anywhere) */
#define ZB_ZCL_ENERGY_MANAGEMENT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @endcond */ /* (DOXYGEN_ZCL_SECTION && DOXYGEN_SE_SECTION) */
/** @cond DOXYGEN_INTERNAL_DOC */
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ENERGY_MANAGEMENT_LOAD_CONTROL_STATE(data_ptr) \
{ \
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_LOAD_CONTROL_STATE, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_STATUS(data_ptr) \
{ \
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_STATUS, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CONFORMANCE_LEVEL(data_ptr) \
{ \
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CONFORMANCE_LEVEL, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_OFF_TIME(data_ptr) \
{ \
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_OFF_TIME, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_ON_TIME(data_ptr) \
{ \
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_ON_TIME, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_CYCLE_PERIOD(data_ptr) \
{ \
ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_CYCLE_PERIOD, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @brief Declare attribute list for Energy Management cluster
@param attr_list - attribute list name
@param on_off - pointer to variable to store On/Off attribute value
@param load_control_state - pointer to variable to store load control state attribute
@param current_event_id - pointer to variable to store current event id
@param current_event_status - pointer to variable to store current event status attribute
@param conformance_level - pointer to variable to store conformance level attribute
@param minimum_off_time - pointer to variable to store minimum off time attribute
@param minimum_on_time - pointer to variable to store minimum on time attribute
@param minimum_cycle_period - pointer to variable to store minimum cycle period attribute
*/
#define ZB_ZCL_DECLARE_ENERGY_MANAGEMENT_ATTRIB_LIST(attr_list, load_control_state, current_event_id, \
current_event_status, conformance_level, minimum_off_time, \
minimum_on_time, minimum_cycle_period) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_ENERGY_MANAGEMENT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ENERGY_MANAGEMENT_LOAD_CONTROL_STATE, (load_control_state)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_ID, (current_event_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_STATUS, (current_event_status)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CONFORMANCE_LEVEL, (conformance_level)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_OFF_TIME, (minimum_off_time)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_ON_TIME, (minimum_on_time)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_CYCLE_PERIOD, (minimum_cycle_period)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
#define ZB_ZCL_DECLARE_ENERGY_MANAGEMENT_ATTR_LIST_INIT \
(zb_zcl_energy_management_attr_t) \
{ .load_control_state = 0, \
.current_event_id = 0xFFFFFFFF, \
.current_event_status = 0, \
.conformance_level = 0}
/** @endcond */ /* DOXYGEN_INTERNAL_DOC */
/** @cond (DOXYGEN_ZCL_SECTION && DOXYGEN_SE_SECTION) */
/**
* @brief Energy Management cluster attributes
*/
typedef struct zb_zcl_energy_management_attr_s
{
/** @copydoc ZB_ZCL_ATTR_ENERGY_MANAGEMENT_LOAD_CONTROL_STATE
* @see ZB_ZCL_ATTR_ENERGY_MANAGEMENT_LOAD_CONTROL_STATE
*/
zb_uint8_t load_control_state;
/** @copydoc ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_ID
* @see ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_ID
*/
zb_uint32_t current_event_id;
/** @copydoc ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_STATUS
* @see ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CURRENT_EVENT_STATUS
*/
zb_uint8_t current_event_status;
/** @copydoc ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CONFORMANCE_LEVEL
* @see ZB_ZCL_ATTR_ENERGY_MANAGEMENT_CONFORMANCE_LEVEL
*/
zb_uint8_t conformance_level;
/** @copydoc ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_OFF_TIME
* @note Default values is TBD
* @see ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_OFF_TIME
*/
zb_uint16_t minimum_off_time;
/** @copydoc ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_ON_TIME
* @note Default values is TBD
* @see ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_ON_TIME
*/
zb_uint16_t minimum_on_time;
/** @copydoc ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_CYCLE_PERIOD
* @note Default values is TBD
* @see ZB_ZCL_ATTR_ENERGY_MANAGEMENT_MINIMUM_CYCLE_PERIOD
*/
zb_uint16_t minimum_cycle_period;
} zb_zcl_energy_management_attr_t;
/** @brief Declare attribute list for Energy Management cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of @ref zb_zcl_energy_management_attr_t type (containing Energy Management cluster attributes)
*/
#define ZB_ZCL_DECLARE_ENERGY_MANAGEMENT_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_ENERGY_MANAGEMENT_ATTRIB_LIST(attr_list, &attrs.load_control_state, \
&attrs.current_event_id, &attrs.current_event_status, &attrs.conformance_level, \
&attrs.minimum_off_time, &attrs.minimum_on_time, &attrs.minimum_cycle_period)
/** Load Control State BitMap/Encoding
* @see SE spec, Table D-193
*/
typedef enum zb_zcl_energy_management_load_control_state_encoding_e
{
ZB_ZCL_ENERGY_MANAGEMENT_STATE_RELAY_OPEN = 1 << 0, /**< The device being controlled has been turned off and
* prevented from consuming electric power or another commodity,
* either by opening a relay or some other means.
*/
ZB_ZCL_ENERGY_MANAGEMENT_STATE_EVENT_IN_PROGRESS = 1 << 1, /**< There is an event in progress. The current time is between the Effective Start
* Time and Effective End Time of the event. When this bit is set, the
* CurrentEventStatus attribute is valid.
*/
ZB_ZCL_ENERGY_MANAGEMENT_STATE_POWER_STABILIZING = 1 << 2, /**< The device has automatically reduced consumption of the commodity for an
* automatic reason, to aid in the stability of the system.
*/
ZB_ZCL_ENERGY_MANAGEMENT_STATE_OTHER_LOAD_REDUCTION = 1 << 3, /**< This bit indicates the device has automatically reduced consumption of
* the commodity for some non-consumer-initiated reason.
*/
ZB_ZCL_ENERGY_MANAGEMENT_STATE_CURRENT_FLOW = 1 << 4, /**< This bit indicates that the device is currently consuming the commodity.
* The bit not being set means either no commodity being consumption
* or the device does not have the ability to detect consumption. Support is optional.
*/
ZB_ZCL_ENERGY_MANAGEMENT_STATE_LOAD_CALL = 1 << 5 /**< This bit is set if there is currently no consumption but the device under
* control would consume power if able to. Support is optional.
* The bit shall be cleared if not supported.
*/
} zb_zcl_energy_management_load_control_state_encoding_t;
/** Current Event Status BitMap/Encoding
* @see SE spec, Table D-194
*/
typedef enum zb_zcl_energy_management_current_event_status_encoding_e
{
ZB_ZCL_ENERGY_MANAGEMENT_STATUS_RANDOMIZED_START_TIME = 1 << 0, /**< Set if the current event had a randomized start time. */
ZB_ZCL_ENERGY_MANAGEMENT_STATUS_RANDOMIZED_DURATION = 1 << 1, /**< Set if the duration of the current event is randomized. */
ZB_ZCL_ENERGY_MANAGEMENT_STATUS_EXTENDED_BITS_PRESENT = 1 << 2, /**< This bit will always return 1. This allows the field to be used in DRLC
* Event Status messages.
*/
ZB_ZCL_ENERGY_MANAGEMENT_STATUS_EVENT_ACTIVE = 1 << 3, /**< Set if the current time lies between the Effective Start Time and
* Effective End Time of the event identified by the CurrentEventID attribute
*/
ZB_ZCL_ENERGY_MANAGEMENT_STATUS_DEVICE_PARTICIPATING_IN_EVENT = 1 << 4, /**< Set if the device is (or will be when the event starts) participating in
* the event.
*/
ZB_ZCL_ENERGY_MANAGEMENT_STATUS_REDUCING_LOAD = 1 << 5, /**< Set if the device is currently shedding load in response to a DR event.
* Set if an active load control event is duty cycling and currently off, or if
* the new set points or offsets are lowering demand.
*/
ZB_ZCL_ENERGY_MANAGEMENT_STATUS_ON_AT_END_OF_EVENT = 1 << 6 /**< Set if the device will return to using a normal load after the event has
* completed. For example, this would be False if the device supported the On/Off
* cluster and the On/Off attribute was set to OFF.
*/
} zb_zcl_energy_management_current_event_status_encoding_t;
/** @} */ /* ZB_ZCL_ENERGY_MANAGEMENT_ATTRS */
/** @defgroup ZB_ZCL_ENERGY_MANAGEMENT_COMMANDS Energy Management cluster commands
* @{
*/
/** Commands are generated by Energy Management Client
* @see SE spec, subclause 12.2.4
*/
typedef enum zb_zcl_energy_management_cli_cmd_e
{
ZB_ZCL_ENERGY_MANAGEMENT_CLI_CMD_MANAGE_EVENT = 0x00, /**< The Manage Event command allows a remote device (such as an IHD or web portal)
* to change the behavior of a DRLC cluster client when responding to a
* DRLC Load Control Event.
* @see zb_zcl_energy_management_manage_event_payload_s
*/
} zb_zcl_energy_management_cli_cmd_t;
/** @ref ZB_ZCL_ENERGY_MANAGEMENT_CLI_CMD_MANAGE_EVENT "ManageEvent" command Payload
* @see SE spec, subclause 12.2.4.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_energy_management_manage_event_payload_s
{
/* Mandatory fields. */
/** Unique identifier generated by the Energy provider. The value of this field
* allows the command to be matched with a specific Load Control Event.
*/
zb_uint32_t issuer_event_id; /* (M) */
/** Bit encoded field representing the DRLC client Device Class to apply the
* current Load Control Event. Each bit, if set individually or in combination,
* indicates the class of device(s) the Manage Event command is directed at.
*/
zb_uint16_t device_class; /* (M) */
/** The DRLC client Utility Enrollment Group field can be used in conjunction
* with the Device Class bits. It provides a mechanism to direct the Manage Event
* command to groups of devices.
*/
zb_uint8_t utility_enrollment_group; /* (M) */
/* Optional fields */
/** Bit encoded field indicating the action(s) to be carried out in regard to
* the associated event
*/
zb_uint8_t actions_required; /* (O) */
} ZB_PACKED_STRUCT zb_zcl_energy_management_manage_event_payload_t;
/** @def ZB_ZCL_ENERGY_MANAGEMENT_MANAGE_EVENT_PAYLOAD_SIZE_IS_VALID
*/
#define ZB_ZCL_ENERGY_MANAGEMENT_MANAGE_EVENT_PAYLOAD_SIZE_IS_VALID(size) \
((size) >= sizeof(zb_zcl_energy_management_manage_event_payload_t))
/** Action(s) Required BitMap/Encoding
* @see SE spec, Table D-196
*/
typedef enum zb_zcl_energy_management_actions_required_encoding_e
{
ZB_ZCL_ENERGY_MANAGEMENT_ACTIONS_EVENT_OPT_OUT = 0, /**< Opt Out of Event */
ZB_ZCL_ENERGY_MANAGEMENT_ACTIONS_OPT_INTO_EVENT = 1, /**< Opt Into Event */
ZB_ZCL_ENERGY_MANAGEMENT_ACTIONS_DISABLE_DUTY_CYCLING = 2, /**< Disable Duty Cycling */
ZB_ZCL_ENERGY_MANAGEMENT_ACTIONS_ENABLE_DUTY_CYCLING = 3 /**< Enable Duty Cycling */
} zb_zcl_energy_management_actions_required_encoding_t;
/** Commands are generated by Energy Management Server
* @see SE spec, subclause 12.2.5
*/
typedef enum zb_zcl_energy_management_srv_cmd_e
{
ZB_ZCL_ENERGY_MANAGEMENT_SRV_CMD_REPORT_EVENT_STATUS = 0x00, /**< This command is reused from the DRLC cluster. This command is generated
* in response to the Manage Event command.
* @see zb_zcl_energy_management_report_event_status_payload_s
*/
} zb_zcl_energy_management_srv_cmd_t;
/* Energy mgmt cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_ENERGY_MANAGEMENT_SERVER_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_ENERGY_MANAGEMENT_SRV_CMD_REPORT_EVENT_STATUS
#define ZB_ZCL_CLUSTER_ID_ENERGY_MANAGEMENT_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_ENERGY_MANAGEMENT_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_ENERGY_MANAGEMENT_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_ENERGY_MANAGEMENT_CLI_CMD_MANAGE_EVENT
#define ZB_ZCL_CLUSTER_ID_ENERGY_MANAGEMENT_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_ENERGY_MANAGEMENT_CLIENT_ROLE_GENERATED_CMD_LIST
/** @ref ZB_ZCL_ENERGY_MANAGEMENT_SRV_CMD_REPORT_EVENT_STATUS "ReportEventStatusCommandPayload".
* @see SE spec, subclause 12.2.5.1 and @ref zb_zcl_drlc_report_event_status_payload_t
*/
typedef ZB_PACKED_PRE struct zb_zcl_energy_management_report_event_status_payload_s
{
/* Mandatory fields. */
/** Event ID specified in the Manage Event command or, if the command specified
* the current event, then the current running DRLC Issuer Event ID.
*/
zb_uint32_t issuer_event_id; /* (M) */
/** If the Manage Event command did not change the event, then this field will
* contain the last sent Event Status for the event.
*/
zb_uint8_t event_status; /* (M) */
/** UTC Timestamp representing when the event status was changed. If the device
* does not know the current time but still remembers events, it may return the
* value of 0x00000000.
*/
zb_uint32_t event_status_time; /* (M) */
/** Criticality Level value applied by the device */
zb_uint8_t criticality_level_applied; /* (M) */
/* Optional fields */
/** Cooling Temperature Set Point value applied by the device, see the
* corresponding field in the Load Control Event command for more information.
* The value 0x8000 means that this field has not been used by the end device.
*/
zb_uint16_t cooling_temperature_set_point_applied; /* (O) */
/** Heating Temperature Set Point value applied by the device, see the
* corresponding field in the Load Control Event command for more information.
* The value 0x8000 means that this field has not been used by the end device.
*/
zb_uint16_t heating_temperature_set_point_applied; /* (O) */
/** Average Load Adjustment Percentage value applied by the device, see the
* corresponding field in the Load Control Event command for more information.
* The value 0x80 means that this field has not been used by the end device.
*/
zb_int8_t average_load_adjustment_percentage_applied; /* (O) */
/** Defines the maximum On state duty cycle applied by the device. The value
* 0xFF means that this field has not been used by the end device.
*/
zb_uint8_t duty_cycle_applied; /* (O) */
/* Mandatory field */
/** Identifies additional control options for the event. */
zb_uint8_t event_control; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_energy_management_report_event_status_payload_t;
/** @def ZB_ZCL_ENERGY_MANAGEMENT_REPORT_EVENT_STATUS_PAYLOAD_SIZE_IS_VALID
*/
#define ZB_ZCL_ENERGY_MANAGEMENT_REPORT_EVENT_STATUS_PAYLOAD_SIZE_IS_VALID(size) \
((size) >= sizeof(zb_zcl_energy_management_report_event_status_payload_t))
/** Macro for initialization @ref ZB_ZCL_ENERGY_MANAGEMENT_SRV_CMD_REPORT_EVENT_STATUS "ReportEventStatus" command payload
* @see @ref zb_zcl_energy_management_report_event_status_payload_t
*/
#define ZB_ZCL_ENERGY_MANAGEMENT_REPORT_EVENT_STATUS_PAYLOAD_INIT \
(zb_zcl_energy_management_report_event_status_payload_t) \
{ \
.cooling_temperature_set_point_applied = (zb_uint16_t) 0x8000, \
.heating_temperature_set_point_applied = (zb_uint16_t) 0x8000, \
.average_load_adjustment_percentage_applied = (zb_int8_t) 0x80, \
.duty_cycle_applied = (zb_uint8_t) 0xFF, \
}
/** Macro for initialization @ref ZB_ZCL_ENERGY_MANAGEMENT_CLI_CMD_MANAGE_EVENT "ManageEvent" command payload
* @see @ref zb_zcl_energy_management_manage_event_payload_t
*/
#define ZB_ZCL_ENERGY_MANAGEMENT_MANAGE_EVENT_PAYLOAD_INIT \
(zb_zcl_energy_management_manage_event_payload_t) {0} \
/** Function for send @ref ZB_ZCL_ENERGY_MANAGEMENT_SRV_CMD_REPORT_EVENT_STATUS "ReportEventStatus" command.
* On sender's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with @ref ZB_ZCL_ENERGY_MANAGEMENT_MANAGE_EVENT_CB_ID
* callback id on reception of @ref ZB_ZCL_ENERGY_MANAGEMENT_CLI_CMD_MANAGE_EVENT "ManageEvent" command.
* @n On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_ENERGY_MANAGEMENT_REPORT_EVENT_STATUS_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (ref to @ref
* zb_zcl_drlc_report_event_status_payload_t and @ref zb_zcl_energy_management_report_event_status_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Handle @ref ZB_ZCL_ENERGY_MANAGEMENT_CLI_CMD_MANAGE_EVENT "ManageEvent" command
*/
void zb_zcl_energy_management_server_send_report_event_status(zb_uint8_t param,
zb_addr_u *dst_addr,
zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep,
zb_uint8_t src_ep,
zb_zcl_energy_management_report_event_status_payload_t *payload,
zb_callback_t cb);
/** Function for send @ref ZB_ZCL_ENERGY_MANAGEMENT_CLI_CMD_MANAGE_EVENT "ManageEvent" command.
* On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_ENERGY_MANAGEMENT_MANAGE_EVENT_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_energy_management_manage_event_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Example of sending @ref ZB_ZCL_ENERGY_MANAGEMENT_CLI_CMD_MANAGE_EVENT "ManageEvent" command
*/
void zb_zcl_energy_management_client_send_manage_event(zb_uint8_t param, zb_addr_u *dst_addr,
zb_aps_addr_mode_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep,
zb_zcl_energy_management_manage_event_payload_t *payload,
zb_callback_t cb);
/** Macro for call @ref zb_zcl_energy_management_server_send_report_event_status command */
#define ZB_ZCL_ENERGY_MANAGEMENT_SEND_CMD_REPORT_EVENT_STATUS(_param, _dst_addr, \
_dst_addr_mode, _dst_ep, \
_src_ep, _payload) \
zb_zcl_energy_management_server_send_report_event_status(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_zcl_energy_management_client_send_manage_event command */
#define ZB_ZCL_ENERGY_MANAGEMENT_SEND_CMD_MANAGE_EVENT(_param, _dst_addr, \
_dst_addr_mode, _dst_ep, \
_src_ep, _payload) \
zb_zcl_energy_management_client_send_manage_event(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** @} */ /* ZB_ZCL_ENERGY_MANAGEMENT_COMMANDS */
/** @} */ /* ZCL Energy Management cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION && DOXYGEN_SE_SECTION */
/** Internal handler for Energy Management Cluster commands */
void zb_zcl_energy_management_init_server(void);
void zb_zcl_energy_management_init_client(void);
#define ZB_ZCL_CLUSTER_ID_ENERGY_MANAGEMENT_SERVER_ROLE_INIT zb_zcl_energy_management_init_server
#define ZB_ZCL_CLUSTER_ID_ENERGY_MANAGEMENT_CLIENT_ROLE_INIT zb_zcl_energy_management_init_client
#endif /* ZB_ZCL_ENERGY_MANAGEMENT_H_ */

View File

@@ -0,0 +1,521 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Events cluster definitions
*/
#ifndef ZB_ZCL_EVENTS_H_
#define ZB_ZCL_EVENTS_H_
#include "zboss_api_core.h" /* ZBOSS core API types */
/** @cond DOXYGEN_ZCL_SECTION && DOXYGEN_SE_SECTION */
/** @addtogroup ZB_ZCL_EVENTS
* @{
* @details
* The Events cluster provides an interface for passing event information
* between Zigbee devices. Events are generated and logged by a server device
* and read by a client device.
*/
/** @defgroup ZB_ZCL_EVENTS_COMMANDS Events cluster commands
* @{
*/
/** Commands are generated by Events Server.
* @see SE spec, subclause 11.2.4
*/
typedef enum zb_zcl_events_srv_cmd_e
{
ZB_ZCL_EVENTS_SRV_CMD_PUBLISH_EVENT = 0x00, /**< This command is generated upon an event trigger from within the reporting
* device and if enabled by the associated Event Configuration (bitmap)
* attribute in the Device Management cluster
* @see zb_zcl_events_publish_event_payload_t
*/
ZB_ZCL_EVENTS_SRV_CMD_PUBLISH_EVENT_LOG = 0x01, /**< This command is generated on receipt of a Get Event Log command.
* The command shall return the most recent event first, up to the number
* of events requested.
* @see zb_zcl_events_publish_event_log_payload_t
*/
ZB_ZCL_EVENTS_SRV_CMD_CLEAR_EVENT_LOG_RESPONSE = 0x02, /**< This command is generated on receipt of a Clear Event Log Request command.
* @see zb_zcl_events_clear_event_log_response_t
*/
} zb_zcl_events_srv_cmd_t;
/** Commands are generated by Events Client.
* @see SE spec, subclause 11.2.3
*/
typedef enum zb_zcl_events_cli_cmd_e
{
ZB_ZCL_EVENTS_CLI_CMD_GET_EVENT_LOG = 0x00, /**< The GetEventLog command allows a client to request events from a servers
* event logs. One or more PublishEventLog commands are returned on receipt
* of this command.
* @see zb_zcl_events_get_event_log_payload_t
*/
ZB_ZCL_EVENTS_CLI_CMD_CLEAR_EVENT_LOG_REQUEST = 0x01, /**< This command requests that an Events server device clear the specified
* event log(s). The Events server device SHOULD clear the requested events
* logs, however it is understood that market specific restrictions may be
* applied to prevent this.
* @see zb_zcl_events_clear_event_log_request_s
*/
} zb_zcl_events_cli_cmd_t;
/* EVENTS cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_EVENTS_SERVER_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_EVENTS_SRV_CMD_PUBLISH_EVENT, \
ZB_ZCL_EVENTS_SRV_CMD_PUBLISH_EVENT_LOG, \
ZB_ZCL_EVENTS_SRV_CMD_CLEAR_EVENT_LOG_RESPONSE
#define ZB_ZCL_CLUSTER_ID_EVENTS_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_EVENTS_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_EVENTS_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_EVENTS_CLI_CMD_GET_EVENT_LOG, \
ZB_ZCL_EVENTS_CLI_CMD_CLEAR_EVENT_LOG_REQUEST
#define ZB_ZCL_CLUSTER_ID_EVENTS_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_EVENTS_CLIENT_ROLE_GENERATED_CMD_LIST
/** Log ID enumeration
* @see SE spec, Table D-186
*/
typedef enum zb_zcl_events_log_id_e
{
ZB_ZCL_EVENTS_LOG_ID_ALL_LOGS = 0x00, /**< All logs */
ZB_ZCL_EVENTS_LOG_ID_TAMPER_LOG, /**< Tamper Log */
ZB_ZCL_EVENTS_LOG_ID_FAULT_LOG, /**< Fault Log */
ZB_ZCL_EVENTS_LOG_ID_GENERAL_EVENT_LOG, /**< General Event Log */
ZB_ZCL_EVENTS_LOG_ID_SECURITY_EVENT_LOG, /**< Security Event Log */
ZB_ZCL_EVENTS_LOG_ID_NETWORK_EVENT_LOG /**< Network Event Log */
} zb_zcl_events_log_id_t;
/** @brief Default value for Events cluster revision global attribute */
#define ZB_ZCL_EVENTS_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/*!
@brief Declare attribute list for Events cluster (only cluster revision attribute)
@param attr_list - attribute list name
*/
#define ZB_ZCL_DECLARE_EVENTS_ATTR_LIST(attr_list) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_EVENTS) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** Macro for get log_id value from 8-bit field
* @param x - 8-bit field that contains log_id value in
* the least significant nibble.
* @see @ref zb_zcl_events_publish_event_payload_t, @ref zb_zcl_events_get_event_log_payload_t,
* @ref zb_zcl_events_clear_event_log_request_t, @ref zb_zcl_events_sub_log_payload_t
*/
#define ZB_ZCL_GET_LOG_ID_FIELD(x) ((x) & 0xF)
/** Macro for set log_id value to 8-bit field
* @param x - 8-bit field to store log_id value in the least
* significant nibble
* @param val - value to assigning
* @see @ref zb_zcl_events_publish_event_payload_t, @ref zb_zcl_events_get_event_log_payload_t,
* @ref zb_zcl_events_clear_event_log_request_t, @ref zb_zcl_events_sub_log_payload_t
*/
#define ZB_ZCL_SET_LOG_ID_FIELD(x, val) ((x) &= (0xF0 | ((val) & 0xF)))
/** Macro for get event_control value from 8-bit field
* @param x - 8-bit field that contains event_control value
* in the most significant nibble.
* @see @ref zb_zcl_events_get_event_log_payload_t
*/
#define ZB_ZCL_GET_EVENT_CONTROL_FIELD(x) (((x) & 0xF0) >> 4)
/** Macro for set event_control value to 8-bit field
* @param x - 8-bit field to store event_control value in the most
* significant nibble.
* @param val - value to assigning
* @see @ref zb_zcl_events_get_event_log_payload_t
*/
#define ZB_ZCL_SET_EVENT_CONTROL_FIELD(x, val) ((x) &= (0xF | ((val) & 0xF) << 4)
/** Macro for get log_payload_control value from 8-bit field
* @param x - 8-bit field that contains log_payload_control value
* in the least significant nibble
* @see @ref zb_zcl_events_sub_log_payload_t
*/
#define ZB_ZCL_GET_LOG_PAYLOAD_CONTROL_FIELD(x) ((x) & 0xF)
/** Macro for set log_payload_control value to 8-bit field
* @param x - 8-bit field to store log_payload_control value in
* the least significant nibble.
* @param val - value to assigning
* @see @ref zb_zcl_events_sub_log_payload_t
*/
#define ZB_ZCL_SET_LOG_PAYLOAD_CONTROL_FIELD(x, val) ((x) &= (0xF0 | ((val) & 0xF)))
/** Macro for get number_of_events value from 8-bit field
* @param x - 8-bit field that contains number_of_events value
* in the most significant nibble.
* @see @ref zb_zcl_events_sub_log_payload_t
*/
#define ZB_ZCL_GET_NUMBER_OF_EVENTS(x) (((x) & 0xF0) >> 4)
/** Macro for set number_of_events value to 8-bit field
* @param x - 8-bit field to store number_of_events value in the
* most significant nibble.
* @param val - value to assigning
* @see @ref zb_zcl_events_sub_log_payload_t
*/
#define ZB_ZCL_SET_NUMBER_OF_EVENTS(x, val) ((x) &= (0xF | ((val) & 0xF) << 4))
/** @ref ZB_ZCL_EVENTS_CLI_CMD_GET_EVENT_LOG "GetEventLog" Command payload.
* @see SE spec, subclause 11.2.3.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_events_get_event_log_payload_s
{
/** The least significant nibble is an enumeration indicating
* the Log ID from particular enumeration.
* The most significant nibble is a bitmap indicating
* control options. It determines the detailing level of provided log
* information.
*/
zb_uint8_t event_control_log_id; /* (M) */
/** The Event ID specifies a particular event to be queried; a value of
* 0x0000 is reserved to indicate all Event IDs.
*/
zb_uint16_t event_id; /* (M) */
/**This field specifies the start time (earliest time) of the range of events
* to be returned. Events that match the search criteria and have a timestamp
* greater than or equal to the start time shall be returned.
*/
zb_uint32_t start_time; /* (M) */
/** Specifies the end time (latest time) of the range of events to be reported
* in the response. Events that match the search criteria and have a timestamp
* less than the specified end time shall be returned. Events with a timestamp
* equal to that of the End Time shall not be returned
*/
zb_uint32_t end_time; /* (M) */
/** This parameter indicates the maximum number of events requested i.e.
* the maximum number of events that the client is willing to receive;
* the value 0x00 indicates all events that fall into the defined criteria.
*/
zb_uint8_t number_of_events; /* (M) */
/** The Event Offset field provides a mechanism to allow client devices
* to page through multiple events which match a given search criteria.
*/
zb_uint16_t event_offset; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_events_get_event_log_payload_t;
/** @ref ZB_ZCL_EVENTS_CLI_CMD_CLEAR_EVENT_LOG_REQUEST "ClearEventLogRequest" command payload
* @see SE spec, subclause D.11.2.3.2
*/
typedef ZB_PACKED_PRE struct zb_zcl_events_clear_event_log_request_s
{
/** The least significant nibble specifies the Log to be cleared.
* The most significant nibble is reserved.
*/
zb_uint8_t log_id;
} ZB_PACKED_STRUCT zb_zcl_events_clear_event_log_request_t;
/** @ref ZB_ZCL_EVENTS_SRV_CMD_PUBLISH_EVENT "PublishEvent" Command payload
* @see SE spec, subclause 11.2.4.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_events_publish_event_payload_s {
/** The least significant nibble is an enumeration indicating the Log ID.
* The most significant nibble is reserved.
*/
zb_uint8_t log_id; /* (M) */
/** The Event ID specifies a particular event
*/
zb_uint16_t event_id; /* (M) */
/** The timestamp of the event occurrence in UTC format.
*/
zb_uint32_t event_time; /* (M) */
/** An 8-bit bitmap specifying actions to be taken regarding particular event.
*/
zb_uint8_t event_control; /* (M) */
/** A variable length octet string array used to hold additional
* information captured when the event occurred. The first element (element 0)
* of the array indicates the length of the string, NOT including the first
* element.
*/
zb_uint8_t event_data[44];
} ZB_PACKED_STRUCT zb_zcl_events_publish_event_payload_t;
/** Publish Event Log Sub-Payload
* @see SE spec, Figure D-175
* @see zb_zcl_events_publish_event_log_payload_t::log_payload
*/
typedef ZB_PACKED_PRE struct zb_zcl_events_sub_log_payload_s
{
/*Log Payload representation*/
/******************************************************************************/
/** The least significant nibble represents the Log Payload Control.
* It determines availability of events to cross payload frame boundary.
* The most significant nibble indicates the number of events contained within
* the log payload of this command.
*/
zb_uint8_t number_of_events_log_payload_control;
/** The least significant nibble is an enumeration indicating the Log ID.
* The most significant nibble is reserved.
*/
zb_uint8_t log_id;
/*The Event ID specifies a particular event.*/
zb_uint16_t event_id;
/*The timestamp of the event occurrence in UTC format.*/
zb_uint32_t event_time;
/** A variable length octet string array used to hold additional information
* captured when the event occurred. The first element (element 0) of the
* array indicates the length of the string, NOT including the first element.
*/
zb_uint8_t event_data[47];
/******************************************************************************/
/* Log Payload representation */
} ZB_PACKED_STRUCT zb_zcl_events_sub_log_payload_t;
/** @ref ZB_ZCL_EVENTS_SRV_CMD_PUBLISH_EVENT_LOG "PublishEventLog" Command payload
* @see SE spec, subclause 11.2.4.2
*/
typedef ZB_PACKED_PRE struct zb_zcl_events_publish_event_log_payload_s
{
/** This field indicates the total number of events found which match the
* search criteria received in the associated Get Event Log command.
*/
zb_uint16_t total_number_of_matching_events; /* (M) */
/** In the case where the entire number of events being returned does not
* fit into a single message, the Command Index is used to count the required
* number of Publish Event Log commands.
*/
zb_uint8_t command_index; /* (M) */
/** This parameter indicates the total number of Publish Event Log
* commands that are required to return the requested event logs.
*/
zb_uint8_t total_commands; /* (M) */
/** The Log Payload is a series of events and associated data.
* @see zb_zcl_events_sub_log_payload_t
*/
zb_zcl_events_sub_log_payload_t *log_payload;
} ZB_PACKED_STRUCT zb_zcl_events_publish_event_log_payload_t;
/** Macro for initializing GetEventLog Command payload,
* see @ref zb_zcl_events_get_event_log_payload_t
*/
#define ZB_ZCL_EVENTS_GET_EVENT_LOG_INIT \
(zb_zcl_events_get_event_log_payload_t) {0}
/** Cleared Events Logs Bitmap
* @note It is understood that certain markets may require that event logs
* cannot be cleared; this Bitmask provides a method for the server device
* to indicate which logs have been successfully cleared.
* @see SE spec, Table D-191 and @ref zb_zcl_events_clear_event_log_response_t::cleared_events_logs
*/
typedef enum zb_zcl_events_cleared_events_logs_bitmap_e
{
ZB_ZCL_EVENTS_CLEARED_EVENTS_LOGS_ALL = 1 << 0, /**< All logs cleared */
ZB_ZCL_EVENTS_CLEARED_EVENTS_LOGS_TAMPER = 1 << 1, /**< Tamper log cleared */
ZB_ZCL_EVENTS_CLEARED_EVENTS_LOGS_FAULT = 1 << 2, /**< Fault log cleared */
ZB_ZCL_EVENTS_CLEARED_EVENTS_LOGS_GENERAL = 1 << 3, /**< General event log cleared */
ZB_ZCL_EVENTS_CLEARED_EVENTS_LOGS_SECURITY = 1 << 4, /**< Security event log cleared */
ZB_ZCL_EVENTS_CLEARED_EVENTS_LOGS_NETWORK = 1 << 5, /**< network event log cleared */
/* 6-7 bits are reserved */
} zb_zcl_events_cleared_events_logs_bitmap_t;
/** @ref ZB_ZCL_EVENTS_SRV_CMD_CLEAR_EVENT_LOG_RESPONSE "ClearEventLogResponse" command payload
* @see SE spec, D.11.2.4.3
*/
typedef ZB_PACKED_PRE struct zb_zcl_events_clear_event_log_response_s
{
/** This 8-bit Bitmask indicates which logs have been cleared.
* @see SE spec, Table D-191 and @ref zb_zcl_events_cleared_events_logs_bitmap_t
*/
zb_uint8_t cleared_events_logs;
} ZB_PACKED_STRUCT zb_zcl_events_clear_event_log_response_t;
/** Macro for initializing PublishEventLog Command payload
* see @ref zb_zcl_events_publish_event_log_payload_t
*/
#define ZB_ZCL_EVENTS_PUBLISH_EVENT_LOG_PAYLOAD_INIT \
(zb_zcl_events_publish_event_log_payload_t) {0}
/** Function for send @ref ZB_ZCL_EVENTS_SRV_CMD_PUBLISH_EVENT "PublishEvent" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_events_publish_event_payload_t).
*/
void zb_events_server_send_publish_event(zb_uint8_t param, zb_addr_u *dst_addr,
zb_uint8_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_zcl_events_publish_event_payload_t *payload);
/** Function for send @ref ZB_ZCL_EVENTS_SRV_CMD_PUBLISH_EVENT_LOG "PublishEventLog" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_events_publish_event_log_payload_t).
*/
void zb_events_server_send_publish_event_log(zb_uint8_t param, zb_addr_u *dst_addr,
zb_uint8_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_zcl_events_publish_event_log_payload_t *payload);
/** Function for send @ref ZB_ZCL_EVENTS_SRV_CMD_CLEAR_EVENT_LOG_RESPONSE "ClearEventLogResponse" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload: pointer to zb_uint8_t.
*/
void zb_events_server_send_clear_event_log_response(zb_uint8_t param, zb_addr_u *dst_addr,
zb_uint8_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_uint8_t *payload); /*zb_uint8_t zb_zcl_events_ClearedEventsLogs;*/
/** Function for send @ref ZB_ZCL_EVENTS_CLI_CMD_GET_EVENT_LOG "GetEventLog" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref
* zb_zcl_events_get_event_log_payload_t).
*/
void zb_events_client_send_get_event_log(zb_uint8_t param, zb_addr_u *dst_addr,
zb_uint8_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_zcl_events_get_event_log_payload_t *payload);
/** Function for send @ref ZB_ZCL_EVENTS_CLI_CMD_CLEAR_EVENT_LOG_REQUEST "ClearEventLogRequest" command.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload: pointer to zb_uint8_t.
*/
void zb_events_client_send_clear_event_log_request(zb_uint8_t param, zb_addr_u *dst_addr,
zb_uint8_t dst_addr_mode, zb_uint8_t dst_ep,
zb_uint8_t src_ep, zb_uint8_t *payload); /*zb_uint8_t zb_zcl_events_cel_log_id;*/
/** Macro for call @ref zb_events_server_send_publish_event function */
#define ZB_ZCL_EVENTS_SEND_CMD_PUBLISH_EVENT(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload ) \
zb_events_server_send_publish_event(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload)
/** Macro for call @ref zb_events_server_send_publish_event_log function */
#define ZB_ZCL_EVENTS_SEND_CMD_PUBLISH_EVENT_LOG(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload ) \
zb_events_server_send_publish_event_log(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload)
/** Macro for call @ref zb_events_server_send_clear_event_log_response function */
#define ZB_ZCL_EVENTS_SEND_CMD_CLEAR_EVENT_LOG_RESPONSE(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload ) \
zb_events_server_send_clear_event_log_response(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload)
/** Macro for call @ref zb_events_client_send_get_event_log function */
#define ZB_ZCL_EVENTS_SEND_CMD_GET_EVENT_LOG(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload ) \
zb_events_client_send_get_event_log(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload)
/** Macro for call @ref zb_events_client_send_clear_event_log_request function */
#define ZB_ZCL_EVENTS_SEND_CMD_CLEAR_EVENT_LOG_REQUEST(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload ) \
zb_events_client_send_clear_event_log_request(_param, _dst_addr, _dst_addr_mode, \
_dst_ep, _src_ep, _payload)
/** @} */ /* ZB_ZCL_EVENTS_COMMANDS */
/** @cond internals_doc */
/** Internal handler for Events Cluster commands */
zb_bool_t zb_zcl_process_events_specific_commands(zb_uint8_t param);
/** @endcond */ /* internals_doc */
/** @} */ /* ZB_ZCL_EVENTS */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_events_init_server(void);
void zb_zcl_events_init_client(void);
#define ZB_ZCL_CLUSTER_ID_EVENTS_SERVER_ROLE_INIT zb_zcl_events_init_server
#define ZB_ZCL_CLUSTER_ID_EVENTS_CLIENT_ROLE_INIT zb_zcl_events_init_client
#endif /* ZB_ZCL_EVENTS_H_ */

View File

@@ -0,0 +1,177 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Fan Control cluster definitions
*/
#ifndef ZB_ZCL_FAN_CONTROL_H
#define ZB_ZCL_FAN_CONTROL_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/* Cluster ZB_ZCL_CLUSTER_ID_FAN_CONTROL */
/*! @addtogroup ZB_ZCL_FAN_CONTROL
@{
@name Fan Control cluster attributes
@{
*/
/*! @brief Fan Control cluster attribute identifiers
@see ZCL spec, subclause 6.4.2.2
*/
enum zb_zcl_fan_control_attr_e
{
/*! @brief Fan Mode attribute */
ZB_ZCL_ATTR_FAN_CONTROL_FAN_MODE_ID = 0x0000,
/*! @brief Fan Mode Sequence attribute */
ZB_ZCL_ATTR_FAN_CONTROL_FAN_MODE_SEQUENCE_ID = 0x0001
};
/*! @brief Values for Fan Mode attribute,
@see ZCL spec, subclause 6.4.2.2.1 */
enum zb_zcl_fan_control_fan_mode_e
{
/*! Off value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_OFF = 0x00,
/*! Low value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_LOW = 0x01,
/*! Medium value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_MEDIUM = 0x02,
/*! High value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_HIGH = 0x03,
/*! On value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_ON = 0x04,
/*! Auto value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_AUTO = 0x05,
/*! Smart value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_SMART = 0x06,
ZB_ZCL_FAN_CONTROL_FAN_MODE_RESERVED = 0x07
};
/*! @brief Values for Fan Mode Sequence attribute,
@see ZCL spec, subclause 6.4.2.2.2 */
enum zb_zcl_fan_control_fan_mode_sequence_e
{
/*! Low/Med/High value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_LOW_MED_HIGH = 0x00,
/*! Low/High value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_LOW_HIGH = 0x01,
/*! Low/Med/High/Auto value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_LOW_MED_HIGH_AUTO = 0x02,
/*! Low/High/Auto value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_LOW_HIGH_AUTO = 0x03,
/*! On/Auto value */
ZB_ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_ON_AUTO = 0x04,
ZB_ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_RESERVED = 0x05
};
/** @brief Default value for Fan Control cluster revision global attribute */
#define ZB_ZCL_FAN_CONTROL_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for Fan Mode attribute */
#define ZB_ZCL_FAN_CONTROL_FAN_MODE_DEFAULT_VALUE 0x05
/** @brief Default value for Fan Mode attribute */
#define ZB_ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_DEFAULT_VALUE 0x02
/** @brief Declare attribute list for Fan Control cluster
@param attr_list - attribute list name
@param fan_mode - pointer to variable to store Fan Mode attribute value
@param fan_mode_sequence - pointer to variable to store Fan Mode Sequence attribute value
*/
#define ZB_ZCL_DECLARE_FAN_CONTROL_ATTRIB_LIST(attr_list, fan_mode, fan_mode_sequence) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_FAN_CONTROL) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_FAN_CONTROL_FAN_MODE_ID, (fan_mode)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_FAN_CONTROL_FAN_MODE_SEQUENCE_ID, (fan_mode_sequence)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Fan Control cluster attributes */
/*! @name Fan Control cluster commands
@{
*/
/*! @} */ /* Fan Control cluster commands */
/*! @cond internals_doc
@internal @name Fan Control cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_FAN_CONTROL_FAN_MODE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_FAN_CONTROL_FAN_MODE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_FAN_CONTROL_FAN_MODE_SEQUENCE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_FAN_CONTROL_FAN_MODE_SEQUENCE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in Fan Control cluster */
#define ZB_ZCL_FAN_CONTROL_REPORT_ATTR_COUNT 0
/*! @}
@endcond */ /* Fan Control cluster internals */
/*! @} */ /* ZCL HA Fan Control cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_fan_control_init_server(void);
void zb_zcl_fan_control_init_client(void);
#define ZB_ZCL_CLUSTER_ID_FAN_CONTROL_SERVER_ROLE_INIT zb_zcl_fan_control_init_server
#define ZB_ZCL_CLUSTER_ID_FAN_CONTROL_CLIENT_ROLE_INIT zb_zcl_fan_control_init_client
#endif /* ZB_ZCL_FAN_CONTROL_H */

View File

@@ -0,0 +1,784 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Groups cluster definitions
*/
#ifndef ZB_ZCL_GROUPS_H
#define ZB_ZCL_GROUPS_H 1
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_GROUPS
* @{
* @details
* Groups cluster defined in ZCL spec, clause 3.6. Currently no group name attribute support is
* implemented. However, this attribute must be supported for sending and receiving in commands'
* payload, so it is being sent as zero string (i. e. single zero byte). On receipt of the
* command is able to contain a scene name in the payload, this field will be ignored as a string.
*
* Cluster requests and responses are documented in submodules.
*/
/** @name Groups cluster attributes
@{
*/
/* ZB_ZCL_CLUSTER_ID_GROUPS = 0x0004 */
/** @brief Groups cluster attribute identifiers
@see ZCL spec, subclause 3.6.2.2
*/
enum zb_zcl_groups_attr_e
{
/** @brief NameSupport attribute */
ZB_ZCL_ATTR_GROUPS_NAME_SUPPORT_ID = 0
};
/** @brief Values for NameSupport attribute */
enum zb_zcl_groups_name_support_e
{
/** "Not supported" value */
ZB_ZCL_ATTR_GROUPS_NAME_NOT_SUPPORTED = 0,
/** "On" value */
ZB_ZCL_ATTR_GROUPS_NAME_SUPPORTED = 1 << 7 /* set to 1 the most significant bit */
};
/** @brief Default value for Groups cluster revision global attribute */
#define ZB_ZCL_GROUPS_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0003u)
/**
* @brief Declare attribute list for Groups cluster.
* @param attr_list - attribute list name.
* @param name_support - pointer to variable to store name_support attribute value
*/
#define ZB_ZCL_DECLARE_GROUPS_ATTRIB_LIST(attr_list, name_support) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_GROUPS) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_GROUPS_NAME_SUPPORT_ID, (name_support)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @} */ /* Groups cluster attributes */
/** @name Groups cluster command identifiers
@{
*/
/**
* @brief Groups cluster command identifiers.
* @see ZCL spec, subclause 3.6.2.2.2.
*/
enum zb_zcl_groups_cmd_e
{
ZB_ZCL_CMD_GROUPS_ADD_GROUP = 0x00, /**< Add group command identifier. */
ZB_ZCL_CMD_GROUPS_VIEW_GROUP = 0x01, /**< View group command identifier. */
ZB_ZCL_CMD_GROUPS_GET_GROUP_MEMBERSHIP = 0x02, /**< Get group membership command identifier.
*/
ZB_ZCL_CMD_GROUPS_REMOVE_GROUP = 0x03, /**< Remove group command identifier. */
ZB_ZCL_CMD_GROUPS_REMOVE_ALL_GROUPS = 0x04, /**< Remove all groups command identifier. */
ZB_ZCL_CMD_GROUPS_ADD_GROUP_IF_IDENTIFYING = 0x05 /**< Add group if identifying command
identifier. */
};
/** @brief Groups cluster response command identifiers
@see ZCL spec, subclause 3.6.2.3
*/
enum zb_zcl_groups_cmd_resp_e
{
ZB_ZCL_CMD_GROUPS_ADD_GROUP_RES = 0x00, /**< Add group response command identifier. */
ZB_ZCL_CMD_GROUPS_VIEW_GROUP_RES = 0x01, /**< View group response command identifier.
*/
ZB_ZCL_CMD_GROUPS_GET_GROUP_MEMBERSHIP_RES = 0x02, /**< Get group response membership command
identifier. */
ZB_ZCL_CMD_GROUPS_REMOVE_GROUP_RES = 0x03 /**< Remove group response command identifier.
*/
};
/** @cond internals_doc */
/* GROUPS cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_GROUPS_SERVER_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_GROUPS_ADD_GROUP_RES, \
ZB_ZCL_CMD_GROUPS_VIEW_GROUP_RES, \
ZB_ZCL_CMD_GROUPS_GET_GROUP_MEMBERSHIP_RES, \
ZB_ZCL_CMD_GROUPS_REMOVE_GROUP_RES
#define ZB_ZCL_CLUSTER_ID_GROUPS_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_GROUPS_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_GROUPS_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_GROUPS_ADD_GROUP, \
ZB_ZCL_CMD_GROUPS_VIEW_GROUP, \
ZB_ZCL_CMD_GROUPS_GET_GROUP_MEMBERSHIP, \
ZB_ZCL_CMD_GROUPS_REMOVE_GROUP, \
ZB_ZCL_CMD_GROUPS_REMOVE_ALL_GROUPS, \
ZB_ZCL_CMD_GROUPS_ADD_GROUP_IF_IDENTIFYING
#define ZB_ZCL_CLUSTER_ID_GROUPS_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_GROUPS_CLIENT_ROLE_GENERATED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
/** @} */ /* Groups cluster command identifiers */
/************************** Add group command definitions ****************************/
/** @defgroup ZB_ZCL_GROUPS_ADD_GROUP Add group command definitions
* @{
* @details
* Add group request and response commands have simple payload. Response command is being filled
* and sent by ZCL internals.
*
* @par Examples
*
* Filling and sending Add Group request:
* @snippet HA_samples/door_lock/sample_zed.c send_add_group_req
*
*
*/
/** @brief Add group command structure */
typedef ZB_PACKED_PRE struct zb_zcl_groups_add_group_req_s
{
zb_uint16_t group_id; /**< Group id */
zb_char_t group_name[1]; /**< Group name, optional */
}
ZB_PACKED_STRUCT
zb_zcl_groups_add_group_req_t;
/** @cond internals_doc */
/** @internal Minimum size of Add group request (group name maybe omitted) */
#define ZB_ZCL_ADD_GROUP_REQ_SIZE sizeof(zb_uint16_t)
/** @endcond */ /* internals_doc */
/** @brief Parses Add group command and fills in data request
structure. If request contains invalid data, ZB_ZCL_NULL_ID is stored as group_id.
@param data_buf - pointer to zb_buf_t buffer containing command request data
@param add_group_req - variable to save command request
@note data_buf buffer should contain command request payload without ZCL header.
*/
#define ZB_ZCL_GROUPS_GET_ADD_GROUP_REQ(data_buf, add_group_req) \
{ \
zb_zcl_groups_add_group_req_t *add_group_req_ptr; \
(add_group_req_ptr) = zb_buf_len(data_buf) >= ZB_ZCL_ADD_GROUP_REQ_SIZE ? \
(zb_zcl_groups_add_group_req_t*)zb_buf_begin(data_buf) : NULL; \
\
if (add_group_req_ptr) \
{ \
ZB_HTOLE16(&(add_group_req).group_id, &add_group_req_ptr->group_id);\
/* group name currently is not supported - do not check it */ \
} \
else \
{ \
add_group_req.group_id = ZB_ZCL_NULL_ID; \
} \
}
/** @brief Add group response command structure */
typedef ZB_PACKED_PRE struct zb_zcl_groups_add_group_res_s
{
zb_uint8_t status; /**< Operation status */
zb_uint16_t group_id; /**< Group id */
}
ZB_PACKED_STRUCT
zb_zcl_groups_add_group_res_t;
/** @cond internals_doc */
/** @internal Add group response size */
#define ZB_ZCL_ADD_GROUP_RES_SIZE sizeof(zb_zcl_groups_add_group_res_t)
/** @endcond */ /* internals_doc */
/** @brief Parses Add group response command and returns response data
structure or NULL if request contains invalid data.
@param data_buf - pointer to zb_buf_t buffer containing command response data
@param add_group_res - out pointer to zb_zcl_groups_add_group_res_t, containing command
response record
@note data_buf buffer should contain response command payload without ZCL header
*/
#define ZB_ZCL_GROUPS_GET_ADD_GROUP_RES(data_buf, add_group_res) \
{ \
(add_group_res) = zb_buf_len(data_buf) >= ZB_ZCL_ADD_GROUP_RES_SIZE ? \
(zb_zcl_groups_add_group_res_t*)zb_buf_begin(data_buf) : NULL; \
\
if (add_group_res) \
{ \
ZB_ZCL_HTOLE16_INPLACE(&(add_group_res)->group_id); \
/* group name currently is not supported - do not check it */ \
} \
}
/** @brief Send Add group command
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param group_id - group ID to add
*/
#define ZB_ZCL_GROUPS_SEND_ADD_GROUP_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, group_id) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_GROUPS_ADD_GROUP); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (group_id)); \
/* Group name currently is not supported, put empty string */ \
ZB_ZCL_PACKET_PUT_DATA8(ptr, ZB_ZCL_NULL_STRING); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, ZB_ZCL_CLUSTER_ID_GROUPS, cb); \
}
/** @} */ /* Add group command definitions */
/************************** View group command definitions ****************************/
/** @defgroup ZB_ZCL_GROUPS_VIEW_GROUP View group command definitions
* @{
* @details
* View Group command and response have simple payload. View group command is being processed,
* and View Group response command originates from ZCL internals.
*
* @par Examples
* View Group request command can be formed as:
* @snippet HA_samples/door_lock/sample_zed.c view_group_req
*
*/
/** @brief View group command structure */
typedef ZB_PACKED_PRE struct zb_zcl_groups_view_group_req_s
{
zb_uint16_t group_id; /**< Group id */
}
ZB_PACKED_STRUCT
zb_zcl_groups_view_group_req_t;
/** @cond internals_doc */
/** @internal Size of View group request */
#define ZB_ZCL_VIEW_GROUP_REQ_SIZE sizeof(zb_zcl_groups_view_group_req_t)
/** @endcond */ /* internals_doc */
/** @brief Parses View group command and fills in data request
structure. If request contains invalid data, ZB_ZCL_NULL_ID is stored as group_id.
@param data_buf - pointer to zb_buf_t buffer containing command request data
@param view_group_req - variable to save command request
@note data_buf buffer should contain command request payload without ZCL header.
*/
#define ZB_ZCL_GROUPS_GET_VIEW_GROUP_REQ(data_buf, view_group_req) \
{ \
zb_zcl_groups_view_group_req_t *view_group_req_ptr; \
(view_group_req_ptr) = zb_buf_len(data_buf) >= ZB_ZCL_VIEW_GROUP_REQ_SIZE ? \
(zb_zcl_groups_view_group_req_t*)zb_buf_begin(data_buf) : NULL; \
\
if (view_group_req_ptr) \
{ \
ZB_HTOLE16(&(view_group_req).group_id, &view_group_req_ptr->group_id); \
} \
else \
{ \
view_group_req.group_id = ZB_ZCL_NULL_ID; \
} \
}
/** @brief View group command response structure */
typedef ZB_PACKED_PRE struct zb_zcl_groups_view_group_res_s
{
zb_uint8_t status; /**< Operation status */
zb_uint16_t group_id; /**< Group id */
zb_uint8_t group_name[1]; /**< Group name */
}
ZB_PACKED_STRUCT
zb_zcl_groups_view_group_res_t;
/** @cond internals_doc */
/** @internal View group response size */
#define ZB_ZCL_VIEW_GROUP_RES_SIZE sizeof(zb_zcl_groups_view_group_res_t)
/** @endcond */ /* internals_doc */
/** @brief Parses View group response command and returns response data
structure or NULL if request contains invalid data.
@param data_buf - pointer to zb_buf_t buffer containing command response data
@param view_group_res - out pointer to zb_zcl_groups_add_group_res_t, containing command
response record
@note data_buf buffer should contain response command payload without ZCL header
*/
#define ZB_ZCL_GROUPS_GET_VIEW_GROUP_RES(data_buf, view_group_res) \
{ \
(view_group_res) = zb_buf_len(data_buf) >= ZB_ZCL_VIEW_GROUP_RES_SIZE ? \
(zb_zcl_groups_view_group_res_t*)zb_buf_begin(data_buf) : NULL; \
\
if (view_group_res) \
{ \
ZB_ZCL_HTOLE16_INPLACE(&(view_group_res)->group_id); \
/* group name currently is not supported - empty string is returned */ \
} \
}
/** @brief Send view group command
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param group_id - group ID to add
*/
#define ZB_ZCL_GROUPS_SEND_VIEW_GROUP_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, group_id) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_GROUPS_VIEW_GROUP); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (group_id)); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, ZB_ZCL_CLUSTER_ID_GROUPS, cb); \
}
/** @} */ /* View group command definitions */
/************************** Get Group Membership command definitions ****************************/
/** @defgroup ZB_ZCL_GROUPS_GET_GRP_MEMB Get Group Membership command definitions
* @{
* @details
* Both Get Group Membership command request and response have a complex array-style payload.
*
* @par Examples
* Get Group Membership request can be filled in as:
* @snippet HA_samples/door_lock/sample_zed.c send_get_group_membership_req
*
*
*/
/** @brief Get Group Membership command structure */
typedef ZB_PACKED_PRE struct zb_zcl_groups_get_group_membership_req_s
{
zb_uint8_t group_count; /**< Group count */
zb_uint16_t group_id[1]; /**< Group id list */
}
ZB_PACKED_STRUCT
zb_zcl_groups_get_group_membership_req_t;
/** @cond internals_doc */
/** @internal Minimum size of Get Group Membership request */
#define ZB_ZCL_GET_GROUP_MEMBERSHIP_REQ_SIZE sizeof(zb_uint8_t)
/** @endcond */ /* internals_doc */
/** @brief Parses Get Group Membership command and returns pointer to data request
structure. If request contains invalid data, NULL is returned
@param data_buf - pointer to zb_buf_t buffer containing command request data
@param group_member_req - pointer to command request
@note data_buf buffer should contain command request payload without ZCL header.
*/
#define ZB_ZCL_GROUPS_GET_GROUP_MEMBERSHIP_REQ(data_buf, group_member_req) \
{ \
zb_uint8_t i_tmp; \
zb_uint8_t cmd_size = ZB_ZCL_GET_GROUP_MEMBERSHIP_REQ_SIZE; \
\
(group_member_req) = (zb_buf_len(data_buf) >= cmd_size) ? \
(zb_zcl_groups_get_group_membership_req_t*)zb_buf_begin(data_buf) : NULL; \
\
if (group_member_req) \
{ \
cmd_size += sizeof(zb_uint16_t) * (group_member_req)->group_count; \
if (cmd_size <= zb_buf_len(data_buf)) \
{ \
for(i_tmp = 0; i_tmp < (group_member_req)->group_count; i_tmp++) \
{ \
ZB_ZCL_HTOLE16_INPLACE(&(group_member_req)->group_id[i_tmp]); \
} \
} \
else \
{ \
group_member_req = NULL; \
} \
} \
}
/** @brief Get Group Membership command response structure */
typedef ZB_PACKED_PRE struct zb_zcl_groups_get_group_membership_res_s
{
zb_uint8_t capacity; /**< Capacity of group table */
zb_uint8_t group_count; /**< Group count */
zb_uint16_t group_id[1]; /**< Group id list */
}
ZB_PACKED_STRUCT
zb_zcl_groups_get_group_membership_res_t;
/** @cond internals_doc */
/** @internal Minimum size of Get Group Membership command response */
#define ZB_ZCL_GET_GROUP_MEMBERSHIP_RES_SIZE (2*sizeof(zb_uint8_t))
/** @endcond */ /* internals_doc */
/** @brief Parses Get Group Membership command response and returns pointer to data response
structure. If response contains invalid data, NULL is returned.
@param data_buf - pointer to zb_buf_t buffer containing command response data
@param group_member_res - pointer to command response
@note data_buf buffer should contain command response payload without ZCL header.
*/
#define ZB_ZCL_GROUPS_GET_GROUP_MEMBERSHIP_RES(data_buf, group_member_res) \
{ \
zb_uint8_t i; \
zb_uint8_t cmd_size = ZB_ZCL_GET_GROUP_MEMBERSHIP_RES_SIZE; \
\
(group_member_res) = (zb_buf_len(data_buf) >= cmd_size) ? \
(zb_zcl_groups_get_group_membership_res_t*)zb_buf_begin(data_buf) : NULL; \
\
if (group_member_res) \
{ \
cmd_size += sizeof(zb_uint16_t) * (group_member_res)->group_count; \
if (cmd_size <= zb_buf_len(data_buf)) \
{ \
for(i = 0; i < (group_member_res)->group_count; i++) \
{ \
ZB_ZCL_HTOLE16_INPLACE(&(group_member_res)->group_id[i]); \
} \
} \
else \
{ \
group_member_res = NULL; \
} \
} \
}
/** @brief Initialize Get group membership command
@param buffer to put packet to
@param ptr - command buffer pointer
@param def_resp - enable/disable default response
@param group_cnt - group count
*/
#define ZB_ZCL_GROUPS_INIT_GET_GROUP_MEMBERSHIP_REQ(buffer, ptr, def_resp, group_cnt) \
{ \
ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ( \
ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_GROUPS_GET_GROUP_MEMBERSHIP); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (group_cnt)); \
}
/** @brief Add group id to command payload
@param ptr - command buffer pointer
@param group_id - group ID
*/
#define ZB_ZCL_GROUPS_ADD_ID_GET_GROUP_MEMBERSHIP_REQ(ptr, group_id) \
{ \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (group_id)); \
}
/** @brief Sends Get group membership command
@param buffer to place data to
@param ptr - pointer to the memory area after the command data end
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param cb - callback for getting command send status
*/
#define ZB_ZCL_GROUPS_SEND_GET_GROUP_MEMBERSHIP_REQ( \
buffer, ptr, addr, dst_addr_mode, dst_ep, ep, prfl_id, cb) \
{ \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, ZB_ZCL_CLUSTER_ID_GROUPS, cb); \
}
/** @} */ /* Get Group Membership command definitions */
/************************** Remove Group command definitions ****************************/
/** @defgroup ZB_ZCL_GROUPS_RM_GRP Remove Group command definitions
* @{
* @details
* Remove Group request and response commands have simple payload. Actual request handling takes
* place in ZCL internals.
*
* @par Examples
* Remove Group request sending:
* @snippet HA_samples/door_lock/sample_zed.c send_remove_group_req
*
*
*/
/** @brief Remove Group command structure */
typedef ZB_PACKED_PRE struct zb_zcl_groups_remove_group_req_s
{
zb_uint16_t group_id; /**< Group id */
}
ZB_PACKED_STRUCT
zb_zcl_groups_remove_group_req_t;
/** @cond internals_doc */
/** @internal Minimum size of Get Group Membership request */
#define ZB_ZCL_REMOVE_GROUP_REQ_SIZE sizeof(zb_zcl_groups_remove_group_req_t)
/** @endcond */ /* internals_doc */
/** @brief Parses Remove group command and fills in data request
structure. If request contains invalid data, ZB_ZCL_NULL_ID is stored as group_id.
@param data_buf - pointer to zb_buf_t buffer containing command request data
@param rem_group_req - variable to save command request
@note data_buf buffer should contain command request payload without ZCL header.
*/
#define ZB_ZCL_GROUPS_GET_REMOVE_GROUP_REQ(data_buf, rem_group_req) \
{ \
zb_zcl_groups_remove_group_req_t *rem_group_req_ptr; \
(rem_group_req_ptr) = zb_buf_len(data_buf) >= ZB_ZCL_REMOVE_GROUP_REQ_SIZE ? \
(zb_zcl_groups_remove_group_req_t*)zb_buf_begin(data_buf) : NULL; \
\
if (rem_group_req_ptr) \
{ \
ZB_HTOLE16(&(rem_group_req).group_id, &rem_group_req_ptr->group_id); \
} \
else \
{ \
rem_group_req.group_id = ZB_ZCL_NULL_ID; \
} \
}
/** @brief Remove group response command structure */
typedef ZB_PACKED_PRE struct zb_zcl_groups_remove_group_res_s
{
zb_uint8_t status; /**< Operation status */
zb_uint16_t group_id; /**< Group id */
}
ZB_PACKED_STRUCT
zb_zcl_groups_remove_group_res_t;
/** @cond internals_doc */
/** @internal Add group response size */
#define ZB_ZCL_REMOVE_GROUP_RES_SIZE sizeof(zb_zcl_groups_remove_group_res_t)
/** @endcond */ /* internals_doc */
/** @brief Parses Remove group response command and returns response data
structure or NULL if request contains invalid data.
@param data_buf - pointer to zb_buf_t buffer containing command response data
@param rem_group_res - out pointer to zb_zcl_groups_remove_group_res_t, containing command
response record
@note data_buf buffer should contain response command payload without ZCL header
*/
#define ZB_ZCL_GROUPS_GET_REMOVE_GROUP_RES(data_buf, rem_group_res) \
{ \
(rem_group_res) = zb_buf_len(data_buf) >= ZB_ZCL_REMOVE_GROUP_RES_SIZE ? \
(zb_zcl_groups_remove_group_res_t*)zb_buf_begin(data_buf) : NULL; \
\
if (rem_group_res) \
{ \
ZB_ZCL_HTOLE16_INPLACE(&(rem_group_res)->group_id); \
} \
}
/** @brief Send Remove group command
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param group_id - group ID to remove
*/
#define ZB_ZCL_GROUPS_SEND_REMOVE_GROUP_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, group_id) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_GROUPS_REMOVE_GROUP); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (group_id)); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, ZB_ZCL_CLUSTER_ID_GROUPS, cb); \
}
/** @} */ /* Remove Group command definitions */
/************************** Remove All Groups command definitions ****************************/
/** @defgroup ZB_ZCL_GROUPS_RM_ALL_GRPS Remove All Groups command definitions
* @{
* @details
* Remove All Groups command has only request form, and has no payload. Command is being
* processed in ZCL internals. If not disabled, command can be responded with Default Response
* command.
*
* @par Example
* Remove All Groups command sending:
* @snippet HA_samples/door_lock/sample_zed.c send_remove_all_groups_req
* @par
*
*/
/** @brief Send Remove all groups command
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
*/
#define ZB_ZCL_GROUPS_SEND_REMOVE_ALL_GROUPS_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_GROUPS_REMOVE_ALL_GROUPS); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, ZB_ZCL_CLUSTER_ID_GROUPS, cb); \
}
/** @} */ /* Remove All Groups command definitions */
/************************** Add group if identifying command definitions **************************/
/** @defgroup ZB_ZCL_GROUPS_ADD_IDENT Add group if identifying command definitions
* @{
* @details
* Add Group if Identifying command has simple payload. The command is being processed in ZCL
* internals. Since the command has only request form, it can be responded with Default Response
* command frame, if not disabled explicitly.
*
* @b Example:
* Add Group if Identifying send:
* @snippet HA_samples/door_lock/sample_zed.c add_group_if_ident_req
*
*/
/** @brief Send Add group if identifying command
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param group_id - group ID to add
*/
#define ZB_ZCL_GROUPS_SEND_ADD_GROUP_IF_IDENT_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, group_id) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ( \
ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_GROUPS_ADD_GROUP_IF_IDENTIFYING); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (group_id)); \
/* Group name currently is not supported, put empty string */ \
ZB_ZCL_PACKET_PUT_DATA8(ptr, ZB_ZCL_NULL_STRING); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, ZB_ZCL_CLUSTER_ID_GROUPS, cb); \
}
/** @} */ /* Add group if identifying command definitions */
/**
* Handler for incoming group commands directed to server
*
* @param param - reference to buffer containing command
*
* @return ZB_TRUE - if command was processed
* ZB_FALSE - if command is not for server or is not supported
*/
zb_bool_t zb_zcl_process_groups_commands_srv(zb_uint8_t param);
/**
* Handler for incoming group commands directed to client
*
* @param param - reference to buffer containing command
*
* @return ZB_TRUE - if command was processed
* ZB_FALSE - if command is not for client or is not supported
*/
zb_bool_t zb_zcl_process_groups_commands_cli(zb_uint8_t param);
/** @cond internals_doc
@internal @name Groups cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_GROUPS_NAME_SUPPORT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_GROUPS_NAME_SUPPORT_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @internal @brief Number of attributes mandatory for reporting in Groups cluster. */
#define ZB_ZCL_GROUPS_REPORT_ATTR_COUNT 0
#if defined ZB_ZCL_SUPPORT_CLUSTER_SCENES
/** Scenes fieldset length for Groups cluster */
#define ZB_ZCL_CLUSTER_ID_GROUPS_SCENE_FIELD_SETS_LENGTH 0
#endif /* defined ZB_ZCL_SUPPORT_CLUSTER_SCENES */
/** @}
@endcond */ /* Groups cluster internals */
/** @} */ /* ZCL Groups cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_groups_init_server(void);
void zb_zcl_groups_init_client(void);
#define ZB_ZCL_CLUSTER_ID_GROUPS_SERVER_ROLE_INIT zb_zcl_groups_init_server
#define ZB_ZCL_CLUSTER_ID_GROUPS_CLIENT_ROLE_INIT zb_zcl_groups_init_client
#endif /* ZB_ZCL_GROUPS_H */

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Bed Sensor for GreenPower cluster
*/
#ifndef ZB_ZCL_GRPW_BED_SENSOR_H
#define ZB_ZCL_GRPW_BED_SENSOR_H 1
#define ZB_ZCL_CLUSTER_ID_GRPW_BED_SENSOR 0xfd00
enum zb_zcl_grpw_bed_sensor_attr_e
{
ZB_ZCL_ATTR_GRPW_BED_SENSOR_STATUS_ID = 0x0000,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_CALC_DATA_0_ID = 0x0010,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_CALC_DATA_1_ID = 0x0011,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_SENSITIVITY_SETTING = 0x0020,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_CALC_DATA_SEND_INTERVAL = 0x0021,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_CALC_DATA_SEND_MODE = 0x0022,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_EXIT_DETECT_ADD_DELAY = 0x0023,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_OCCUPANCY_DETECT_ALG_SEL = 0x0024,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_TYPE = 0x0025,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_STATUS_REPORT_INTERVAL = 0x0026,
ZB_ZCL_ATTR_GRPW_BED_SENSOR_COMMANDS_FOR_SENSING_MODULE = 0x0030,
ZB_ZCL_ATTR_GRPW_BED_PENDING_CONFIGURATION = 0x00F0,
};
#define ZB_ZCL_CLUSTER_ID_GRPW_BED_SENSOR_SERVER_ROLE_INIT (zb_zcl_cluster_init_t)NULL
#define ZB_ZCL_CLUSTER_ID_GRPW_BED_SENSOR_CLIENT_ROLE_INIT (zb_zcl_cluster_init_t)NULL
#endif /* ZB_ZCL_GRPW_BED_SENSOR_H */

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Frequency agility for GreenPower cluster
*/
#ifndef ZB_ZCL_GRPW_FREQ_AGILITY_H
#define ZB_ZCL_GRPW_FREQ_AGILITY_H 1
#define ZB_ZCL_CLUSTER_ID_GRPW_FREQ_AGILITY 0xFCFA
enum zb_zcl_grpw_freq_agility_attr_e
{
ZB_ZCL_ATTR_GRPW_FREQ_AGILITY_BRIDGE_ADDR = 0x0000,
ZB_ZCL_ATTR_GRPW_FREQ_AGILITY_ACTIVE_CHANNEL_MASK = 0x0001,
};
#define ZB_ZCL_CLUSTER_ID_GRPW_FREQ_AGILITY_SERVER_ROLE_INIT (zb_zcl_cluster_init_t)NULL
#define ZB_ZCL_CLUSTER_ID_GRPW_FREQ_AGILITY_CLIENT_ROLE_INIT (zb_zcl_cluster_init_t)NULL
#endif /* ZB_ZCL_GRPW_FREQ_AGILITY_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,471 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: IAS WD cluster definitions
*/
#ifndef ZB_ZCL_IAS_WD_H
#define ZB_ZCL_IAS_WD_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_IAS_WD
* @{
* @details
* IAS WD cluster definitions
*/
/* Cluster ZB_ZCL_CLUSTER_ID_IAS_WD */
/*! @name IAS WD cluster attributes
@{
*/
/*! @brief IAS WD cluster attribute identifiers
@see ZCL spec, IAS WD Cluster 8.4.2.2
*/
enum zb_zcl_ias_wd_attr_e
{
/*! @brief Max Duration attribute, ZCL spec 8.4.2.2.1 */
ZB_ZCL_ATTR_IAS_WD_MAX_DURATION_ID = 0x0000,
};
/** @brief Default value for IAS WD cluster revision global attribute */
#define ZB_ZCL_IAS_WD_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief Max Duration attribute default value */
#define ZB_ZCL_ATTR_IAS_WD_MAX_DURATION_DEF_VALUE 240
/** @brief Max Duration attribute minimum value */
#define ZB_ZCL_ATTR_IAS_WD_MAX_DURATION_MIN_VALUE 0
/** @brief Max Duration attribute maximum value */
#define ZB_ZCL_ATTR_IAS_WD_MAX_DURATION_MAX_VALUE 0xfffe
/** @cond internals_doc */
/*! @internal @name IAS WD cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IAS_WD_MAX_DURATION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IAS_WD_MAX_DURATION_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in IAS WD cluster */
#define ZB_ZCL_IAS_WD_REPORT_ATTR_COUNT 0
/*! @} */ /* IAS WD cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for IAS WD cluster - server side
@param attr_list - attribute list name
@param max_duration - pointer to variable to store Max Duration attribute
*/
#define ZB_ZCL_DECLARE_IAS_WD_ATTRIB_LIST(attr_list, \
max_duration) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_IAS_WD) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_WD_MAX_DURATION_ID, (max_duration)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* IAS WD cluster attributes */
/*! @name IAS WD cluster commands
@{
*/
/*! @brief IAS WD cluster command identifiers
@see ZCL spec, IAS WD Cluster, 8.4.2.3
*/
enum zb_zcl_ias_wd_cmd_e
{
ZB_ZCL_CMD_IAS_WD_START_WARNING_ID = 0x00, /**< Start warning command. ZCL spec 8.4.2.3.1 */
ZB_ZCL_CMD_IAS_WD_SQUAWK_ID = 0x01 /**< Squawk command. ZCL spec 8.4.2.3.2 */
};
/** @cond internals_doc */
/* IAS WD cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_IAS_WD_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_IAS_WD_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_IAS_WD_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_IAS_WD_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_IAS_WD_START_WARNING_ID, \
ZB_ZCL_CMD_IAS_WD_SQUAWK_ID
#define ZB_ZCL_CLUSTER_ID_IAS_WD_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_IAS_WD_CLIENT_ROLE_GENERATED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
/******************************* Start warning command ******************************/
/** @brief Warning Mode Field, see ZCL spec 8.4.2.3.1.2 */
enum zb_zcl_ias_wd_warning_mode_e
{
/** Stop */
ZB_ZCL_IAS_WD_WARNING_MODE_STOP = 0x00,
/** Burglar */
ZB_ZCL_IAS_WD_WARNING_MODE_BURGLAR = 0x01,
/** Fire */
ZB_ZCL_IAS_WD_WARNING_MODE_FIRE = 0x02,
/** Emergency */
ZB_ZCL_IAS_WD_WARNING_MODE_EMERGENCY = 0x03,
/* Police panic */
ZB_ZCL_IAS_WD_WARNING_MODE_POLICE_PANIC = 0x04,
/* Fire panic */
ZB_ZCL_IAS_WD_WARNING_MODE_FIRE_PANIC = 0x05,
/* Emergency panic (i.e., medical issue) */
ZB_ZCL_IAS_WD_WARNING_MODE_EMERGENCY_PANIC = 0x06,
};
/** @brief Strobe Field, see ZCL spec 8.4.2.3.1.3 */
enum zb_zcl_ias_wd_strobe_e
{
/** No strobe */
ZB_ZCL_IAS_WD_STROBE_NO_STROBE = 0x00,
/** Use strobe in parallel to warning */
ZB_ZCL_IAS_WD_STROBE_USE_STROBE = 0x01,
};
/** @brief Siren Level Field, see ZCL spec 8.4.2.3.1.4 */
enum zb_zcl_ias_wd_siren_level_e
{
/** Low level sound */
ZB_ZCL_IAS_WD_SIREN_LEVEL_LOW = 0x00,
/** Medium level sound */
ZB_ZCL_IAS_WD_SIREN_LEVEL_MEDIUM = 0x01,
/** High level sound */
ZB_ZCL_IAS_WD_SIREN_LEVEL_HIGH = 0x02,
/** Very high level sound */
ZB_ZCL_IAS_WD_SIREN_LEVEL_VERY_HIGH = 0x03,
};
/**
@brief Strobe Level Field, see ZCL spec 8.4.2.2.1.7
*/
enum zb_zcl_ias_wd_strobe_level_e
{
/** Low level strobe */
ZB_ZCL_IAS_WD_STROBE_LEVEL_LOW = 0x00,
/** Medium level strobe */
ZB_ZCL_IAS_WD_STROBE_LEVEL_MEDIUM = 0x01,
/** High level strobe */
ZB_ZCL_IAS_WD_STROBE_LEVEL_HIGH = 0x02,
/** Very high level strobe */
ZB_ZCL_IAS_WD_STROBE_LEVEL_VERY_HIGH = 0x03,
};
/*! @brief Structure representsation Start warning command. ZCL spec 8.4.2.3.1 */
typedef ZB_PACKED_PRE struct zb_zcl_ias_wd_start_warning_s
{
/** Status - enum flags Warning mode, Strobe and Siren Level, see ZCL spec 8.4.2.3.1 */
zb_uint8_t status;
/** Warning duration*/
zb_uint16_t duration;
/** Strobe Duty Cycle */
zb_uint8_t strobe_duty_cycle;
/** Strobe Level (enum zb_zcl_ias_wd_strobe_level_e) */
zb_uint8_t strobe_level;
} ZB_PACKED_STRUCT zb_zcl_ias_wd_start_warning_t;
/*! @brief Get Warning Mode from payload Start warning command */
#define ZB_ZCL_IAS_WD_GET_WARNING_MODE(status) (((status) >> 4) & 0x0f)
/*! @brief Get Strobe from payload Start warning command */
#define ZB_ZCL_IAS_WD_GET_STROBE(status) (((status) >> 2) & 0x03)
/*! @brief Get Siren level from payload Start warning command */
#define ZB_ZCL_IAS_WD_GET_SIREN_LEVEL(status) ((status) & 0x03)
/*! @brief Make Status field Start warning command from Warning Mode, Strobe and Siren Level */
#define ZB_ZCL_IAS_WD_MAKE_START_WARNING_STATUS(warning_mode, strobe, siren_level) \
(((siren_level) & 0x03) | (((strobe) & 0x03) << 2) | (((warning_mode) & 0x0f) << 4))
/*! @brief Strobe Duty Cycle default value */
#define ZB_ZCL_IAS_WD_STROBE_DUTY_CYCLE_DEFAULT_VALUE 0
/*! @brief Strobe Duty Cycle maximum value */
#define ZB_ZCL_IAS_WD_STROBE_DUTY_CYCLE_MAX_VALUE 100
/*! @brief Start warning command. ZCL spec 8.4.2.3.1
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param status - Status - enum flags Warning mode, Strobe and Siren Level
@param duration - Warning duration
@param strobe_duty_cycle - Strobe Duty Cycle
@param strobe_level - Strobe Level, see @ref zb_zcl_ias_wd_strobe_level_e
*/
#define ZB_ZCL_IAS_WD_SEND_START_WARNING_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, \
status, duration, strobe_duty_cycle, strobe_level) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_IAS_WD_START_WARNING_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (status)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (duration)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (strobe_duty_cycle)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (strobe_level)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_IAS_WD, cb); \
}
/** @brief Macro for getting Start warning command. ZCL spec 8.4.2.3.1
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_ias_wd_start_warning_s.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IAS_WD_GET_START_WARNING_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_ias_wd_start_warning_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_ias_wd_start_warning_t *src_ptr = \
(zb_zcl_ias_wd_start_warning_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(data_ptr)->status = src_ptr->status; \
ZB_HTOLE16(&((data_ptr)->duration), &(src_ptr->duration)); \
(data_ptr)->strobe_duty_cycle = src_ptr->strobe_duty_cycle; \
(data_ptr)->strobe_level = src_ptr->strobe_level; \
} \
}
/******************************* Squawk command ******************************/
/** @brief Squawk Mode Field, see ZCL spec 8.4.2.3.2.2 */
enum zb_zcl_ias_wd_squawk_mode_e
{
/** Notification sound for "System is armed" */
ZB_ZCL_IAS_WD_SQUAWK_MODE_ARMED = 0x00,
/** Notification sound for "System is disarmed" */
ZB_ZCL_IAS_WD_SQUAWK_MODE_DISARMED = 0x01,
};
/** @brief Strobe Field, see ZCL spec 8.4.2.3.2.3 */
enum zb_zcl_ias_wd_squawk_strobe_e
{
/** No strobe*/
ZB_ZCL_IAS_WD_SQUAWK_STROBE_NO_STROBE = 0x00,
/** Use strobe blink in parallel to squawk */
ZB_ZCL_IAS_WD_SQUAWK_STROBE_USE_STROBE = 0x01,
};
/** @brief Squawk level Field, see ZCL spec 8.4.2.3.2.4 */
enum zb_zcl_ias_wd_squawk_level_e
{
/** Low level sound */
ZB_ZCL_IAS_WD_SQUAWK_LEVEL_LOW = 0x00,
/** Medium level sound */
ZB_ZCL_IAS_WD_SQUAWK_LEVEL_MEDIUM = 0x01,
/** High level sound */
ZB_ZCL_IAS_WD_SQUAWK_LEVEL_HIGH = 0x02,
/** Very High level sound */
ZB_ZCL_IAS_WD_SQUAWK_LEVEL_VERY_HIGH = 0x03,
};
/*! @brief Structure representsation Squawk command. ZCL spec 8.4.2.3.2 */
typedef ZB_PACKED_PRE struct zb_zcl_ias_wd_squawk_s
{
/** Status - enum flags Squawk mode, Strobe and Squawk level, see ZCL spec 8.4.2.3.2 */
zb_uint8_t status;
} ZB_PACKED_STRUCT zb_zcl_ias_wd_squawk_t;
/*! @brief Get Squawk Mode from payload Squawk command */
#define ZB_ZCL_IAS_WD_GET_SQUAWK_MODE(status) (((status) >> 4) & 0x0f)
/*! @brief Get Squawk Strobe from payload Squawk command */
#define ZB_ZCL_IAS_WD_GET_SQUAWK_STROBE(status) (((status) >> 3) & 0x01)
/*! @brief Get Squawk Level from payload Squawk command */
#define ZB_ZCL_IAS_WD_GET_SQUAWK_LEVEL(status) ((status) & 0x03)
/*! @brief Make Status field Squawk command from Squawk mode, Strobe and Squawk level */
#define ZB_ZCL_IAS_WD_MAKE_SQUAWK_STATUS(mode, strobe, level) \
(((level) & 0x03) | (((strobe) & 0x01) << 3) | (((mode) & 0x0f) << 4))
/*! @brief Squawk command. ZCL spec 8.4.2.3.2
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param status - Status, see @ref zb_zcl_ias_wd_squawk_s
*/
#define ZB_ZCL_IAS_WD_SEND_SQUAWK_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, \
status) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_IAS_WD_SQUAWK_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (status)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_IAS_WD, cb); \
}
/** @brief Macro for getting Squawk command. ZCL spec 8.4.2.3.2
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_ias_wd_squawk_s.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IAS_WD_GET_SQUAWK_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_ias_wd_squawk_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_ias_wd_squawk_t *src_ptr = \
(zb_zcl_ias_wd_squawk_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(data_ptr)->status = src_ptr->status; \
} \
}
/*! @} */ /* IAS WD cluster commands */
/*! @} */ /* ZCL IAS WD cluster definitions */
/** @brief Declare run Start Warning command for User Application
*/
typedef struct zb_zcl_ias_wd_start_warning_value_param_s
{
zb_uint8_t warning_mode; /*!< Warning Mode */
zb_uint8_t strobe; /*!< Strobe */
zb_uint8_t siren_level; /*!< Siren level */
zb_uint16_t duration; /*!< Duration */
zb_uint8_t strobe_duty_cycle; /*!< Strobe duty cycle */
zb_uint8_t strobe_level; /*!< Strobe level */
} zb_zcl_ias_wd_start_warning_value_param_t;
/*! Struct for invoke User App & continue after */
typedef struct zb_zcl_ias_wd_start_warning_user_app_schedule_e
{
zb_zcl_parsed_hdr_t cmd_info; /**< Parameters for continue command,
see @ref zb_zcl_parsed_hdr_s */
zb_zcl_ias_wd_start_warning_value_param_t param; /**< User App command parameters,
see @ref zb_zcl_ias_wd_start_warning_value_param_s */
} zb_zcl_ias_wd_start_warning_user_app_schedule_t;
#define ZB_ZCL_IAS_WD_START_WARNING_SCHEDULE_USER_APP(buffer, pcmd_info, \
warningMode, strobe_, siren_level_, duration_, strobe_duty_cycle_, strobe_level_) \
{ \
zb_zcl_ias_wd_start_warning_user_app_schedule_t* user_data = \
ZB_BUF_GET_PARAM((buffer), zb_zcl_ias_wd_start_warning_user_app_schedule_t); \
ZB_MEMMOVE(&(user_data->cmd_info), (pcmd_info), sizeof(zb_zcl_parsed_hdr_t)); \
user_data->param.warning_mode = (warningMode); \
user_data->param.strobe = (strobe_); \
user_data->param.siren_level = (siren_level_); \
user_data->param.duration = (duration_); \
user_data->param.strobe_duty_cycle = (strobe_duty_cycle_); \
user_data->param.strobe_level = (strobe_level_); \
ZB_SCHEDULE_CALLBACK(zb_zcl_ias_wd_start_warning_invoke_user_app, (buffer)); \
}
/** @brief Declare run Squawk command for User Application
*/
typedef struct zb_zcl_ias_wd_squawk_value_param_s
{
zb_uint8_t squawk_mode; /*!< Squawk Mode */
zb_uint8_t strobe; /*!< Strobe */
zb_uint8_t squawk_level; /*!< Squawk level */
} zb_zcl_ias_wd_squawk_value_param_t;
/*! Struct for invoke User App & continue after */
typedef struct zb_zcl_ias_wd_squawk_user_app_schedule_e
{
zb_zcl_parsed_hdr_t cmd_info; /**< Parameters for continue command,
see @ref zb_zcl_parsed_hdr_s */
zb_zcl_ias_wd_squawk_value_param_t param; /**< User App command parameters,
see @ref zb_zcl_ias_wd_squawk_value_param_s */
} zb_zcl_ias_wd_squawk_user_app_schedule_t;
#define ZB_ZCL_IAS_WD_SQUAWK_SCHEDULE_USER_APP(buffer, pcmd_info, \
squawkMode, strobe_, level) \
{ \
zb_zcl_ias_wd_squawk_user_app_schedule_t* user_data = \
ZB_BUF_GET_PARAM((buffer), zb_zcl_ias_wd_squawk_user_app_schedule_t); \
ZB_MEMMOVE(&(user_data->cmd_info), (pcmd_info), sizeof(zb_zcl_parsed_hdr_t)); \
user_data->param.squawk_mode = (squawkMode); \
user_data->param.strobe = (strobe_); \
user_data->param.squawk_level = (level); \
ZB_SCHEDULE_CALLBACK(zb_zcl_ias_wd_squawk_invoke_user_app, ((buffer))); \
}
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_ias_wd_init_server(void);
void zb_zcl_ias_wd_init_client(void);
#define ZB_ZCL_CLUSTER_ID_IAS_WD_SERVER_ROLE_INIT zb_zcl_ias_wd_init_server
#define ZB_ZCL_CLUSTER_ID_IAS_WD_CLIENT_ROLE_INIT zb_zcl_ias_wd_init_client
#endif /* ZB_ZCL_IAS_WD_H */

View File

@@ -0,0 +1,934 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: IAS Zone cluster definitions
*/
#ifndef ZB_ZCL_IAS_ZONE_H
#define ZB_ZCL_IAS_ZONE_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_IAS_ZONE
* @{
* @details
* IAS Zone cluster definitions
*/
/** @cond internals_doc */
/** @brief Hook on Write attribute
* send Zone Status Change Notification Command if change ZoneStatus attribute */
void zb_zcl_ias_zone_write_attr_hook(zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t *new_value);
/*! @}
* @endcond */ /* internals_doc */
/* Cluster ZB_ZCL_CLUSTER_ID_IAS_ZONE */
/*! @name IAS Zone cluster attributes
@{
*/
/*! @brief IAS Zone cluster attribute identifiers
@see ZCL spec, IAS Zone Cluster 8.2.2.2
*/
enum zb_zcl_ias_zone_attr_e
{
/*! @brief ZoneState attribute, ZCL spec 8.2.2.2.1.1 */
ZB_ZCL_ATTR_IAS_ZONE_ZONESTATE_ID = 0x0000,
/*! @brief ZoneType attribute, ZCL spec 8.2.2.2.1.2 */
ZB_ZCL_ATTR_IAS_ZONE_ZONETYPE_ID = 0x0001,
/*! @brief ZoneStatus attribute, ZCL spec 8.2.2.2.1.3 */
ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID = 0x0002,
/*! @brief IAS_CIE_Address attribute, ZCL spec 8.2.2.2.2.1. */
ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID = 0x0010,
/*! @brief ZoneID attribute, ZCL spec 8.2.2.1.2.2 */
ZB_ZCL_ATTR_IAS_ZONE_ZONEID_ID = 0x0011,
/*! @brief NumberOfZoneSensitivityLevelsSupported attribute, ZCL spec 8.2.2.1.2.3 */
ZB_ZCL_ATTR_IAS_ZONE_NUMBER_OF_ZONE_SENSITIVITY_LEVELS_SUPPORTED_ID = 0x0012,
/*! @brief CurrentZoneSensitivityLevel attribute, ZCL spec 8.2.2.1.2.4 */
ZB_ZCL_ATTR_IAS_ZONE_CURRENT_ZONE_SENSITIVITY_LEVEL_ID = 0x0013,
/* custom attribute */
ZB_ZCL_ATTR_CUSTOM_ZGP_CALIBRATION = 0x8000,
ZB_ZCL_ATTR_CUSTOM_ZGP_CLOUD_ACK = 0x8003,
/* IAS_CIE_Address can be reassigned via Write attribute only when ZB_ZCL_ATTR_CUSTOM_CIE_ADDR_IS_SET is equal to ZB_FALSE */
ZB_ZCL_ATTR_CUSTOM_CIE_ADDR_IS_SET = 0xE000,
ZB_ZCL_ATTR_CUSTOM_CIE_EP = 0xE001,
ZB_ZCL_ATTR_CUSTOM_CIE_SHORT_ADDR = 0xE002,
/* TODO: move this attribute to IAS Zone ZCL implementation */
/*! @brief Struct with pointers on User App callbacks */
ZB_ZCL_ATTR_IAS_ZONE_INT_CTX_ID = 0xeffe,
};
/**
* @brief IAS Zone ZoneState value
*/
enum zb_zcl_ias_zone_zonestate_e
{
/** @brief ZoneState not enrolled value */
ZB_ZCL_IAS_ZONE_ZONESTATE_NOT_ENROLLED = 0,
/** @brief ZoneState enrolled value */
ZB_ZCL_IAS_ZONE_ZONESTATE_ENROLLED = 1,
};
/** @brief IAS Zone ZoneState attribute default value */
#define ZB_ZCL_IAS_ZONE_ZONESTATE_DEF_VALUE ZB_ZCL_IAS_ZONE_ZONESTATE_NOT_ENROLLED
/** @brief Default value for IAS Zone cluster revision global attribute */
#define ZB_ZCL_IAS_ZONE_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/**
* @brief IAS Zone ZoneType value
*/
enum zb_zcl_ias_zone_zonetype_e
{
/** @brief ZoneType Standard CIE System Alarm value */
ZB_ZCL_IAS_ZONE_ZONETYPE_STANDARD_CIE = 0x0000,
/** @brief ZoneType Motion value */
ZB_ZCL_IAS_ZONE_ZONETYPE_MOTION = 0x000d,
/** @brief ZoneType Contact switch value */
ZB_ZCL_IAS_ZONE_ZONETYPE_CONTACT_SWITCH = 0x0015,
/** @brief ZoneType Fire sensor value */
ZB_ZCL_IAS_ZONE_ZONETYPE_FIRE_SENSOR = 0x0028,
/** @brief ZoneType Water sensor value */
ZB_ZCL_IAS_ZONE_ZONETYPE_WATER_SENSOR = 0x002a,
/** @brief ZoneType Gas sensor value */
ZB_ZCL_IAS_ZONE_ZONETYPE_GAS_SENSOR = 0x002b,
/** @brief ZoneType Personal emergency value */
ZB_ZCL_IAS_ZONE_ZONETYPE_PERSONAL_EMERGENCY = 0x002c,
/** @brief ZoneType Vibration / Movement sensor value */
ZB_ZCL_IAS_ZONE_ZONETYPE_VIBRATION_MOVEMENT = 0x002d,
/** @brief ZoneType Remote Control value */
ZB_ZCL_IAS_ZONE_ZONETYPE_REMOTE_CONTROL = 0x010f,
/** @brief ZoneType Key fob value */
ZB_ZCL_IAS_ZONE_ZONETYPE_KEY_FOB = 0x0115,
/** @brief ZoneType Keypad value */
ZB_ZCL_IAS_ZONE_ZONETYPE_KEYPAD = 0x021d,
/** @brief ZoneType Standard Warning Device value */
ZB_ZCL_IAS_ZONE_ZONETYPE_STANDARD_WARNING = 0x0225,
/** @brief Manufacturer specific ZoneType value */
ZB_ZCL_IAS_ZONE_ZONETYPE_MANUF_SPEC = 0x8000,
/** @brief ZoneType Invalid Zone Type value */
ZB_ZCL_IAS_ZONE_ZONETYPE_INVALID = 0xffff,
};
/*! @brief IAS Zone ZoneStatus attribute flags
@see ZCL spec 8.2.2.2.1.3
*/
enum zb_zcl_ias_zone_zonestatus_e
{
/** Alarm 1 */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM1 = 1 << 0,
/** Alarm 2 */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM2 = 1 << 1,
/** Tamper */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_TAMPER = 1 << 2,
/** Battery */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_BATTERY = 1 << 3,
/** Supervision reports */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_SUPERVISION = 1 << 4,
/** Restore reports */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_RESTORE = 1 << 5,
/** Trouble */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_TROUBLE = 1 << 6,
/** AC (mains) */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_AC_MAINS = 1 << 7,
/** Test */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_TEST = 1 << 8,
/** Battery Defect */
ZB_ZCL_IAS_ZONE_ZONE_STATUS_BATTERY_DEFECT = 1 << 9,
};
/** @brief IAS Zone ZoneStatus attribute default value */
#define ZB_ZCL_IAS_ZONE_ZONE_STATUS_DEF_VALUE 0
/** @brief Min value for NumberOfZoneSensitivityLevelsSupported attribute */
#define ZB_ZCL_IAS_ZONE_NUMBER_OF_ZONE_SENSITIVITY_LEVELS_SUPPORTED_MIN_VALUE ((zb_uint8_t)0x02)
/** @brief Default value for NumberOfZoneSensitivityLevelsSupported attribute */
#define ZB_ZCL_IAS_ZONE_NUMBER_OF_ZONE_SENSITIVITY_LEVELS_SUPPORTED_DEFAULT_VALUE \
ZB_ZCL_IAS_ZONE_NUMBER_OF_ZONE_SENSITIVITY_LEVELS_SUPPORTED_MIN_VALUE
/** @brief Default value for CurrentZoneSensitivityLevel attribute */
#define ZB_ZCL_IAS_ZONE_CURRENT_ZONE_SENSITIVITY_LEVEL_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief IAS Zone ZoneID attribute default value */
#define ZB_ZCL_IAS_ZONEID_ID_DEF_VALUE 0xff
/** @cond internals_doc */
/** This macros should not be used by the user application directly */
/*! @internal @name IAS Zone cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CUSTOM_CIE_ADDR_IS_SET(data_ptr) \
{ \
ZB_ZCL_ATTR_CUSTOM_CIE_ADDR_IS_SET, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_INTERNAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CUSTOM_CIE_EP(data_ptr) \
{ \
ZB_ZCL_ATTR_CUSTOM_CIE_EP, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_INTERNAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_CUSTOM_CIE_SHORT_ADDR(data_ptr) \
{ \
ZB_ZCL_ATTR_CUSTOM_CIE_SHORT_ADDR, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_INTERNAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IAS_ZONE_ZONESTATE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IAS_ZONE_ZONETYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IAS_ZONE_ZONETYPE_ID, \
ZB_ZCL_ATTR_TYPE_16BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, \
ZB_ZCL_ATTR_TYPE_16BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID, \
ZB_ZCL_ATTR_TYPE_IEEE_ADDR, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IAS_ZONE_ZONEID_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IAS_ZONE_ZONEID_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IAS_ZONE_NUMBER_OF_ZONE_SENSITIVITY_LEVELS_SUPPORTED_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IAS_ZONE_NUMBER_OF_ZONE_SENSITIVITY_LEVELS_SUPPORTED_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IAS_ZONE_CURRENT_ZONE_SENSITIVITY_LEVEL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IAS_ZONE_CURRENT_ZONE_SENSITIVITY_LEVEL_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IAS_ZONE_INT_CTX_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IAS_ZONE_INT_CTX_ID, \
ZB_ZCL_ATTR_TYPE_NULL, \
ZB_ZCL_ATTR_ACCESS_INTERNAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in IAS Zone cluster */
#define ZB_ZCL_IAS_ZONE_REPORT_ATTR_COUNT 1
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for IAS Zone cluster - server side
@param attr_list - attribute list name
@param zone_state - pointer to variable to store ZoneState attribute
@param zone_type - pointer to variable to store ZoneType attribute
@param zone_status - pointer to variable to store ZoneStatus attribute
@param ias_cie_address - pointer to variable to store IAS-CIE address attribute
@param cie_short_addr - custom attribute to store CIE short address
@param cie_ep - custom attribute to store CIE Endpoint number
*/
/* FIXME: declare custom attributes internally */
#define ZB_ZCL_DECLARE_IAS_ZONE_ATTRIB_LIST( \
attr_list, zone_state, zone_type, zone_status,ias_cie_address, \
cie_short_addr, cie_ep) \
zb_uint8_t cie_addr_is_set_##attr_list; \
ZB_ZCL_START_DECLARE_ATTRIB_LIST(attr_list) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_ZONESTATE_ID, (zone_state)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_ZONETYPE_ID, (zone_type)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, (zone_status)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID, (ias_cie_address)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CUSTOM_CIE_SHORT_ADDR, (cie_short_addr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CUSTOM_CIE_EP, (cie_ep)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CUSTOM_CIE_ADDR_IS_SET, &(cie_addr_is_set_##attr_list)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @brief Declare attribute list for IAS Zone cluster - server side (extended attribute set)
@param attr_list - attribute list name
@param zone_state - pointer to variable to store ZoneState attribute
@param zone_type - pointer to variable to store ZoneType attribute
@param zone_status - pointer to variable to store ZoneStatus attribute
@param ias_cie_address - pointer to variable to store IAS-CIE address attribute
@param zone_id - pointer to variable to store Zone ID attribute
@param number_of_zone_sens_levels_supported - pointer to variable to store
NumberOfZoneSensitivityLevelsSupported attribute
@param current_zone_sens_level - pointer to variable to store CurrentZoneSensitivityLevel attribute
@param cie_short_addr - custom attribute to store CIE short address
@param cie_ep - custom attribute to store CIE Endpoint number
*/
/* FIXME: declare custom attributes internally */
#define ZB_ZCL_DECLARE_IAS_ZONE_ATTRIB_LIST_EXT( \
attr_list, zone_state, zone_type, zone_status, number_of_zone_sens_levels_supported, current_zone_sens_level, \
ias_cie_address, zone_id, cie_short_addr, cie_ep) \
zb_uint8_t cie_addr_is_set_##attr_list; \
zb_uint16_t last_change_##attr_list; \
zb_zcl_ias_zone_int_ctx_t int_ctx_##attr_list; \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_IAS_ZONE) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_ZONESTATE_ID, (zone_state)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_ZONETYPE_ID, (zone_type)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, (zone_status)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID, (ias_cie_address)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_ZONEID_ID, (zone_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_NUMBER_OF_ZONE_SENSITIVITY_LEVELS_SUPPORTED_ID, \
(number_of_zone_sens_levels_supported)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_CURRENT_ZONE_SENSITIVITY_LEVEL_ID, \
(current_zone_sens_level)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IAS_ZONE_INT_CTX_ID, &(int_ctx_##attr_list)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CUSTOM_CIE_SHORT_ADDR, (cie_short_addr)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CUSTOM_CIE_EP, (cie_ep)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_CUSTOM_CIE_ADDR_IS_SET, &(cie_addr_is_set_##attr_list)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* IAS Zone cluster attributes */
/*! @name IAS Zone cluster commands
@{
*/
/*! @brief IAS Zone cluster command identifiers
@see ZCL spec, IAS Zone Cluster, 8.2.2.3
*/
enum zb_zcl_ias_zone_cmd_e
{
ZB_ZCL_CMD_IAS_ZONE_ZONE_ENROLL_RESPONSE_ID = 0x00, /**< "Zone Enroll Response" command,
* ZCL spec 8.2.2.3.1 */
/**< "Initiate Normal Operation Mode" command, ZCL spec 8.2.2.2.1 */
ZB_ZCL_CMD_IAS_ZONE_INITIATE_NORMAL_OPERATION_MODE_ID = 0x01,
/**< "Initiate Test Mode" command, ZCL spec 8.2.2.2.2.3 */
ZB_ZCL_CMD_IAS_ZONE_INITIATE_TEST_MODE_ID = 0x02,
};
/*! @brief IAS Zone cluster response command identifiers
@see ZCL spec, IAS Zone Cluster, 8.2.2.4
*/
enum zb_zcl_ias_zone_resp_cmd_e
{
ZB_ZCL_CMD_IAS_ZONE_ZONE_STATUS_CHANGE_NOT_ID = 0x00, /**< "Zone Status Change Notification" command.
ZCL spec 8.2.2.4.1 */
ZB_ZCL_CMD_IAS_ZONE_ZONE_ENROLL_REQUEST_ID = 0x01 /**< "Zone Enroll Request" command.
ZCL spec 8.2.2.4.2 */
};
/** @cond internals_doc */
/* Ias zone cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_IAS_ZONE_SERVER_ROLE_RECEIVED_CMD_LIST \
ZB_ZCL_CMD_IAS_ZONE_ZONE_ENROLL_RESPONSE_ID, \
ZB_ZCL_CMD_IAS_ZONE_INITIATE_NORMAL_OPERATION_MODE_ID, \
ZB_ZCL_CMD_IAS_ZONE_INITIATE_TEST_MODE_ID
#define ZB_ZCL_CLUSTER_ID_IAS_ZONE_CLIENT_ROLE_RECEIVED_CMD_LIST \
ZB_ZCL_CMD_IAS_ZONE_ZONE_STATUS_CHANGE_NOT_ID, \
ZB_ZCL_CMD_IAS_ZONE_ZONE_ENROLL_REQUEST_ID
#define ZB_ZCL_CLUSTER_ID_IAS_ZONE_SERVER_ROLE_GENERATED_CMD_LIST ZB_ZCL_CLUSTER_ID_IAS_ZONE_CLIENT_ROLE_RECEIVED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_IAS_ZONE_CLIENT_ROLE_GENERATED_CMD_LIST ZB_ZCL_CLUSTER_ID_IAS_ZONE_SERVER_ROLE_RECEIVED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
/*! @brief Structure representsation of Initiate Test Mode - Errata to 05-3520-29 Spec, 1.1.23.2.2.1 */
typedef ZB_PACKED_PRE struct zb_zcl_ias_zone_init_test_mode_ha_s
{
/** Test mode duration */
zb_uint8_t test_mode_duration;
/** Current Zone Sensitivity Level */
zb_uint8_t current_zone_sens_level;
} ZB_PACKED_STRUCT zb_zcl_ias_zone_init_test_mode_t;
/** @brief Macro for getting "Initiate Test Mode" command
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_ias_zone_init_test_mode_t.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IAS_ZONE_GET_INITIATE_TEST_MODE_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_ias_zone_init_test_mode_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_ias_zone_init_test_mode_t *src_ptr = \
(zb_zcl_ias_zone_init_test_mode_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(data_ptr)->test_mode_duration = src_ptr->test_mode_duration; \
(data_ptr)->current_zone_sens_level = src_ptr->current_zone_sens_level; \
} \
}
/*! @brief Initiate Test Mode command
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param cb - callback for getting command send status
@param test_mode_duration - Test Mode duration
@param current_zone_sens_level - CurrentZoneSensitivityLevel
*/
#define ZB_ZCL_IAS_ZONE_SEND_INITIATE_TEST_MODE_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, cb, \
test_mode_duration, current_zone_sens_level) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, ZB_ZCL_ENABLE_DEFAULT_RESPONSE) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_IAS_ZONE_INITIATE_TEST_MODE_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (test_mode_duration)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (current_zone_sens_level)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_IAS_ZONE, cb); \
}
/*! @brief Initiate Normal Operation Mode command
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param cb - callback for getting command send status
*/
#define ZB_ZCL_IAS_ZONE_SEND_INITIATE_NORMAL_OPERATION_MODE_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, ZB_ZCL_ENABLE_DEFAULT_RESPONSE) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_IAS_ZONE_INITIATE_NORMAL_OPERATION_MODE_ID); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_IAS_ZONE, cb); \
}
/******************************* Zone Status Change Notification ******************************/
/*! @brief Structure representsation of Zone Status Change Notification
* see ZCL spec 8.2.2.4.1.1 */
typedef ZB_PACKED_PRE struct zb_zcl_ias_zone_status_change_not_s
{
/** Zone Status, see @ref zb_zcl_ias_zone_zonestatus_e*/
zb_uint16_t zone_status;
/** Extended Status */
zb_uint8_t extended_status;
/** Zone ID*/
zb_uint8_t zone_id;
/** Delay */
zb_uint16_t delay;
} ZB_PACKED_STRUCT zb_zcl_ias_zone_status_change_not_t;
/*! @brief Zone Status Change Notification command
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param cb - callback for getting command send status
@param zone_status - Zone Status, see @ref zb_zcl_ias_zone_zonestatus_e
@param extended_status - Extended Status
@param zone_id - Zone ID
@param delay - Delay
*/
#define ZB_ZCL_IAS_ZONE_SEND_STATUS_CHANGE_NOTIFICATION_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, cb, \
zone_status, extended_status, zone_id, delay ) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_IAS_ZONE_ZONE_STATUS_CHANGE_NOT_ID); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (zone_status)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (extended_status)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (zone_id)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (delay)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_IAS_ZONE, cb); \
}
/** @brief Macro for getting Zone Status Change Notification command
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_ias_zone_status_change_not_s.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IAS_ZONE_GET_STATUS_CHANGE_NOTIFICATION_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_ias_zone_status_change_not_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_ias_zone_status_change_not_t *src_ptr = \
(zb_zcl_ias_zone_status_change_not_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_HTOLE16(&((data_ptr)->zone_status), &(src_ptr->zone_status)); \
(data_ptr)->extended_status = src_ptr->extended_status; \
(data_ptr)->zone_id = src_ptr->zone_id; \
ZB_HTOLE16(&((data_ptr)->delay), &(src_ptr->delay)); \
} \
}
/******************************* Zone Enroll Request command ******************************/
/*! @brief Structure representsation of "Zone Enroll Request" command
* see ZCL spec 8.2.2.4.1.2 */
typedef ZB_PACKED_PRE struct zb_zcl_ias_zone_enroll_request_s
{
/** Zone Type, see @ref zb_zcl_ias_zone_zonetype_e*/
zb_uint16_t zone_type;
/** Manufacturer code */
zb_uint16_t manufacturer_code;
} ZB_PACKED_STRUCT zb_zcl_ias_zone_enroll_request_t;
/*! @brief Zone "Zone Enroll Request" command, see ZCL spec 8.2.2.4.2
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param cb - callback for getting command send status
@param zone_type - Zone Type, see @ref zb_zcl_ias_zone_zonetype_e
@param manufacturer_code - Manufacture code
*/
#define ZB_ZCL_IAS_ZONE_SEND_ZONE_ENROLL_REQUEST_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, cb, \
zone_type, manufacturer_code) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_IAS_ZONE_ZONE_ENROLL_REQUEST_ID); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (zone_type)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (manufacturer_code)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_IAS_ZONE, cb); \
}
/** @brief Macro for getting Zone Status Change Notification command, see ZCL spec 8.2.2.4.1
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_ias_zone_enroll_request_s.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IAS_ZONE_GET_ZONE_ENROLL_REQUEST_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_ias_zone_enroll_request_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_ias_zone_enroll_request_t *src_ptr = \
(zb_zcl_ias_zone_enroll_request_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_HTOLE16(&((data_ptr)->zone_type), &(src_ptr->zone_type)); \
ZB_HTOLE16(&((data_ptr)->manufacturer_code), &(src_ptr->manufacturer_code)); \
} \
}
/******************************* Zone Enroll response ******************************/
/** @brief Values of the Enroll Response Code
* see ZCL spec 8.2.2.3.1.1 */
enum zb_zcl_ias_zone_enroll_responce_code_e
{
/** Success */
ZB_ZCL_IAS_ZONE_ENROLL_RESPONCE_CODE_SUCCESS = 0x00,
/** Not supported */
ZB_ZCL_IAS_ZONE_ENROLL_RESPONCE_CODE_NOT_SUPPORTED = 0x01,
/** No enroll permit */
ZB_ZCL_IAS_ZONE_ENROLL_RESPONCE_CODE_NO_ENROLL = 0x02,
/** Too many zones */
ZB_ZCL_IAS_ZONE_ENROLL_RESPONCE_CODE_TOO_MANY_ZONES = 0x03,
};
/*! @brief Structure representsation of Enroll response command payload
* see ZCL spec 8.2.2.3.1.1 */
typedef ZB_PACKED_PRE struct zb_zcl_ias_zone_enroll_res_s
{
/** Enroll response code */
zb_uint8_t code;
/** Zone ID */
zb_uint8_t zone_id;
} ZB_PACKED_STRUCT zb_zcl_ias_zone_enroll_res_t;
/*! @brief Send "Zone Enroll response" command, see ZCL spec 8.2.2.3.1
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback
@param code - Enroll response code, see @ref zb_zcl_ias_zone_enroll_responce_code_e
@param zone_id - Zone ID
*/
#define ZB_ZCL_IAS_ZONE_SEND_ZONE_ENROLL_RES( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, \
code, zone_id) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_IAS_ZONE_ZONE_ENROLL_RESPONSE_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (code)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (zone_id)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_IAS_ZONE, cb); \
}
/*! @brief Send "Zone Enroll response with add parameters - sequency" command, see ZCL spec 8.2.2.3.1
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback
@param code - Enroll response code, see @ref zb_zcl_ias_zone_enroll_responce_code_e
@param zone_id - Zone ID
@param seq - known sequency
*/
#define ZB_ZCL_IAS_ZONE_SEND_ZONE_ENROLL_RES_EXT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, \
code, zone_id, seq) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, (seq), \
ZB_ZCL_CMD_IAS_ZONE_ZONE_ENROLL_RESPONSE_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (code)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (zone_id)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_IAS_ZONE, cb); \
}
/** @brief Macro for getting "Zone Enroll response" command
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_ias_zone_enroll_res_s.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IAS_ZONE_GET_ZONE_ENROLL_RES(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_ias_zone_enroll_res_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_ias_zone_enroll_res_t *src_ptr = \
(zb_zcl_ias_zone_enroll_res_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(data_ptr)->code = src_ptr->code; \
(data_ptr)->zone_id = src_ptr->zone_id; \
} \
}
/*! @} */ /* IAS Zone cluster commands */
/******************************* Set/Clear Zone Status bits ******************************/
/* Set or clear Zone Status bits
*/
void zb_zcl_ias_zone_change_status(zb_uint8_t param);
/** @brief Declare Set/Clear Zone Status bits
*/
typedef struct zb_zcl_ias_zone_status_param_s
{
zb_uint16_t bits; /*!< Bits map, see @ref zb_zcl_ias_zone_zonestatus_e */
zb_bool_t is_set; /*!< true - set, false - clean */
zb_uint8_t endpoint; /*!< endpoint */
} zb_zcl_ias_zone_status_param_t;
/*! @brief Set Zone Status bits custom server command
@param buffer - to put packet to
@param ep - endpoint
@param set_bits - flag set of Zone Status, see @ref zb_zcl_ias_zone_zonestatus_e
*/
#define ZB_ZCL_IAS_ZONE_SET_BITS(buffer, ep, set_bits) \
{ \
zb_zcl_ias_zone_status_param_t* cmd_data = \
ZB_BUF_GET_PARAM((buffer), zb_zcl_ias_zone_status_param_t); \
cmd_data->endpoint = (ep); \
cmd_data->bits = (set_bits); \
cmd_data->is_set = ZB_TRUE; \
ZB_SCHEDULE_CALLBACK(zb_zcl_ias_zone_change_status, ((buffer))); \
}
/*! @brief Clear Zone Status bits custom server command
@param buffer - to put packet to
@param ep - sending endpoint
@param set_bits - flag set of Zone Status, see @ref zb_zcl_ias_zone_zonestatus_e
*/
#define ZB_ZCL_IAS_ZONE_CLEAR_BITS(buffer, ep, set_bits) \
{ \
zb_zcl_ias_zone_status_param_t* cmd_data = \
ZB_BUF_GET_PARAM((buffer), zb_zcl_ias_zone_status_param_t); \
cmd_data->endpoint = (ep); \
cmd_data->bits = (set_bits); \
cmd_data->is_set = ZB_FALSE; \
ZB_SCHEDULE_CALLBACK(zb_zcl_ias_zone_change_status, ((buffer))); \
}
/**
@brief Structure is used to pass parameters for ZoneStatus
notification command
*/
typedef struct zb_zcl_ias_zone_notification_param_s
{
zb_uint8_t ep; /*!< endpoint number */
zb_uint16_t status_val; /*!< new value of zone_zone_status, see @ref zb_zcl_ias_zone_zonestatus_e */
zb_uint16_t delay; /*!< Delay */
}
zb_zcl_ias_zone_notification_param_t;
/**
@brief Use this function to change IAS Zone status. This function
will set new value of ZoneStatus and will send Zone status change
notification.
@note If another API (ZB_ZCL_SET_ATTRIBUTE()) is used for modifying
ZoneStatus, notification will NOT be send. This is limitation of
the current implementation.
@param ep - local endpoint number
@param new_val - new value for ZoneStatus
@param delay - delay in quarter seconds (actual only for HA ZCL
version, is ignored for pure ZCL implementation)
@param buf_param - reference to a buffer that will be used for
sending notification. If buffer reference is not specified,
notification will NOT be sent
@return Returns ZB_TRUE if notification is scheduled for send,
ZB_FALSE otherwise
@note Notification send result is reported to user App using
callback that is registered with zb_zcl_ias_zone_register_cb()
*/
zb_bool_t zb_zcl_ias_zone_set_status(
zb_uint8_t ep,
zb_uint16_t new_val,
zb_uint16_t delay,
zb_uint8_t buf_param);
enum zb_zcl_general_cb_params_e
{
ZB_ZCL_VALID_CIE_ADDR_SET = 1,
ZB_ZCL_CURR_ZONE_SENSITIVITY_LEVEL_SET = 2,
ZB_ZCL_INIT_TEST_MODE = 3,
ZB_ZCL_INIT_NORMAL_MODE = 4,
};
typedef zb_ret_t (ZB_CODE * zb_ias_zone_app_callback_t)(zb_uint8_t param, zb_uint16_t general_val);
typedef struct zb_zcl_ias_zone_int_ctx_s
{
zb_callback_t process_result_cb;
zb_ias_zone_app_callback_t general_cb;
zb_uint8_t restore_current_zone_sens_level;
zb_uint8_t new_current_zone_sens_level;
}
zb_zcl_ias_zone_int_ctx_t;
/** @brief Declare run Enroll Response command for User Application
*/
typedef struct zb_zcl_ias_zone_enroll_response_value_param_s
{
zb_uint8_t enroll_response; /*!< Enroll response code */
zb_uint8_t zone_id; /*!< Zone ID */
} zb_zcl_ias_zone_enroll_response_value_param_t;
/*! Struct for invoke User App & continue after */
typedef struct zb_zcl_ias_zone_enroll_response_user_app_schedule_e
{
/**< Parameters for continue command, see @ref zb_zcl_parsed_hdr_s */
zb_zcl_parsed_hdr_t cmd_info;
/**< User App command parameters, see @ref zb_zcl_ias_zone_enroll_response_value_param_s */
zb_zcl_ias_zone_enroll_response_value_param_t param;
} zb_zcl_ias_zone_enroll_response_user_app_schedule_t;
#define ZB_ZCL_IAS_ZONE_ENROLL_RESPONSE_SCHEDULE_USER_APP(buffer, pcmd_info, enroll_response_, zone_id_) \
{ \
zb_zcl_ias_zone_enroll_response_user_app_schedule_t* user_data = \
ZB_BUF_GET_PARAM((buffer), zb_zcl_ias_zone_enroll_response_user_app_schedule_t); \
ZB_MEMMOVE(&(user_data->cmd_info), (pcmd_info), sizeof(zb_zcl_parsed_hdr_t)); \
user_data->param.enroll_response = (enroll_response_); \
user_data->param.zone_id = (zone_id_); \
ZB_SCHEDULE_CALLBACK(zb_zcl_ias_zone_enroll_response_invoke_user_app, ((buffer))); \
}
/** @brief Registry callbacks to get status of Zone Status Change Notification command
@param endpoint - local endpoint number
@param process_result_cb - notification sent callback function
@param general_cb - general callback function
*/
void zb_zcl_ias_zone_register_cb(
zb_uint8_t endpoint,
zb_callback_t process_result_cb,
zb_ias_zone_app_callback_t general_cb);
/**
@brief checks, if Zone Status change notification should be sent
and schedules command if it is needed
@return ZB_TRUE if command is sent
*/
zb_bool_t zb_zcl_ias_zone_check_attr_notify(
zb_uint8_t buf_param);
/**
@brief fills in notification command and sends it
*/
void zb_zcl_ias_zone_send_status_change_not(zb_uint8_t param);
/**
@brief checks cie address on zcl initialization
*/
void zb_zcl_ias_zone_check_cie_addr_on_zcl_initialization(zb_uint8_t ep_id);
/**
@brief puts cie command to binding whitelist table
*/
zb_ret_t zb_zcl_ias_zone_put_cie_address_to_binding_whitelist(zb_uint8_t endpoint);
/**
@brief IAS Zone specific set attribute value postprocessing
*/
void zb_zcl_ias_set_attr_val_post_process(zb_zcl_parsed_hdr_t *cmd_info, zb_uint16_t attr_id, zb_uint8_t *value);
/*! @} */ /* ZCL IAS Zone cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_ias_zone_init_server(void);
void zb_zcl_ias_zone_init_client(void);
#define ZB_ZCL_CLUSTER_ID_IAS_ZONE_SERVER_ROLE_INIT zb_zcl_ias_zone_init_server
#define ZB_ZCL_CLUSTER_ID_IAS_ZONE_CLIENT_ROLE_INIT zb_zcl_ias_zone_init_client
zb_bool_t zb_zcl_process_ias_zone_specific_commands(zb_uint8_t param);
#endif /* ZB_ZCL_IAS_ZONE_H */

View File

@@ -0,0 +1,464 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: ZCL "Identify cluster" definitions
*/
#ifndef ZB_ZCL_IDENTIFY_H
#define ZB_ZCL_IDENTIFY_H 1
#if defined(ZB_ZCL_SUPPORT_CLUSTER_IDENTIFY) || defined(DOXYGEN)
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_IDENTIFY
* @{
* @details
* Identify cluster implementation supports Identify command and Identify Query request-response
* command pair. All these commands have simple payload. Both Identify and Identify Query
* request are being processed, and Identify Query response is being generated in ZCL internals.
*
* @par Example
* Identify sending:
* @snippet HA_samples/door_lock/sample_zed.c send_identify_req
*
* Identify Query request sending:
* @snippet HA_samples/on_off_switch/sample_zed.c identify_send_identify_query_req
*/
/** @name Identify cluster attributes
* @{
*/
/** @brief Identify cluster attribute identifier
@see ZCL8 spec, subclause 3.5.2.2
*/
enum zb_zcl_identify_attr_e
{
/*! Identify time attribute */
ZB_ZCL_ATTR_IDENTIFY_IDENTIFY_TIME_ID = 0x0000
};
/** @brief Default value for Identify cluster revision global attribute */
#define ZB_ZCL_IDENTIFY_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief Default value for Identify attribute */
#define ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE 0x0000
/** @} */ /* Identify cluster attributes */
/*! @name Identify cluster command structures and definitions
@{
*/
/** @brief Command identifiers for "Identify" cluster
@see ZCL8 spec, subclauses 3.5.2.3, 3.5.2.4
*/
enum zb_zcl_identify_cmd_e
{
ZB_ZCL_CMD_IDENTIFY_IDENTIFY_ID = 0x00, /**< Identify command */
ZB_ZCL_CMD_IDENTIFY_IDENTIFY_QUERY_ID = 0x01, /**< Identify query command */
ZB_ZCL_CMD_IDENTIFY_TRIGGER_EFFECT_ID = 0x40, /**< "Trigger effect" command identifier. */
ZB_ZCL_CMD_IDENTIFY_IDENTIFY_QUERY_RSP_ID = 0x00 /**< Identify query response */
};
/** @cond internals_doc */
/* Identify cluster commands lists : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_IDENTIFY_SERVER_ROLE_RECEIVED_CMD_LIST \
ZB_ZCL_CMD_IDENTIFY_IDENTIFY_ID, \
ZB_ZCL_CMD_IDENTIFY_IDENTIFY_QUERY_ID, \
ZB_ZCL_CMD_IDENTIFY_TRIGGER_EFFECT_ID,
#define ZB_ZCL_CLUSTER_ID_IDENTIFY_CLIENT_ROLE_RECEIVED_CMD_LIST \
ZB_ZCL_CMD_IDENTIFY_IDENTIFY_QUERY_RSP_ID,
#define ZB_ZCL_CLUSTER_ID_IDENTIFY_SERVER_ROLE_GENERATED_CMD_LIST ZB_ZCL_CLUSTER_ID_IDENTIFY_CLIENT_ROLE_RECEIVED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_IDENTIFY_CLIENT_ROLE_GENERATED_CMD_LIST ZB_ZCL_CLUSTER_ID_IDENTIFY_SERVER_ROLE_RECEIVED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
/** Effect identifier enum
* @see ZCL8 spec 3.5.2.3.3.1 */
enum zb_zcl_identify_trigger_effect_e
{
/**< Effect identifier field value: Light is turned on/off once */
ZB_ZCL_IDENTIFY_EFFECT_ID_BLINK = 0x00,
/**< Effect identifier field value: Light turned on/off over 1 second and
* repeated 15 times */
ZB_ZCL_IDENTIFY_EFFECT_ID_BREATHE = 0x01,
/**< Effect identifier field value: Colored light turns green for 1 second;
* non-colored light flashes twice */
ZB_ZCL_IDENTIFY_EFFECT_ID_OKAY = 0x02,
/**< Effect identifier field value: Colored light turns orange for 8 seconds; non-colored
* light switches to maximum brightness for 0.5s and then minimum brightness for 7.5s */
ZB_ZCL_IDENTIFY_EFFECT_ID_CHANNEL_CHANGE = 0x0b,
/**< Effect identifier field value: Complete the current effect sequence before terminating.
* E.g., if in the middle of a breathe effect (as above), first complete the current 1s
* breathe effect and then terminate the effect*/
ZB_ZCL_IDENTIFY_EFFECT_ID_FINISH_EFFECT = 0xfe,
/**< Effect identifier field value: Terminate the effect as soon as possible */
ZB_ZCL_IDENTIFY_EFFECT_ID_STOP = 0xff,
};
/** Effect variant enum
* @see ZCL8 spec 3.5.2.3.3.2 */
enum zb_zcl_identify_trigger_variant_e
{
/**< Effect variant field value: Default */
ZB_ZCL_IDENTIFY_EFFECT_ID_VARIANT_DEFAULT = 0x00,
};
/*! @brief Structured representation of Trigger effect command payload */
typedef ZB_PACKED_PRE struct zb_zcl_identify_effect_req_s
{
zb_uint8_t effect_id; /*!< Effect identify, see @ref zb_zcl_identify_trigger_effect_e */
zb_uint8_t effect_variant; /*!< Effect variant, see @ref zb_zcl_identify_trigger_variant_e */
} ZB_PACKED_STRUCT zb_zcl_identify_effect_req_t;
/*! @brief Send Trigger effect command
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prof_id - profile identifier
@param def_resp - flag "Default response required"
@param cb - callback for getting command send status
@param effect_id - effect identify, see @ref zb_zcl_identify_trigger_effect_e
@param effect_var - effect variant, see @ref zb_zcl_identify_trigger_variant_e
*/
#define ZB_ZCL_IDENTIFY_SEND_TRIGGER_VARIANT_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, def_resp, cb, effect_id, effect_var) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_IDENTIFY_TRIGGER_EFFECT_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (effect_id)); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (effect_var)); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_IDENTIFY, cb); \
}
/** @brief Parses Trigger effect command
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_identify_effect_req_s.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IDENTIFY_GET_TRIGGER_VARIANT_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_identify_effect_req_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_identify_effect_req_t *src_ptr = \
(zb_zcl_identify_effect_req_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_MEMCPY((data_ptr), src_ptr, sizeof(zb_zcl_identify_effect_req_t)); \
} \
}
/**
* @name Inform User App about ZCL Identify cluster command and change attributes.
* Internal structures and define-procedure for inform User App about ZCL Identify
* cluster command and change attributes.
* @internal
* @{
*/
/** @brief Declare change Identify attribute for User Application
*/
typedef struct zb_zcl_identify_effect_value_param_s
{
zb_uint8_t effect_id; /*!< Effect identify */
zb_uint8_t effect_variant; /*!< Effect variant */
} zb_zcl_identify_effect_value_param_t;
/*! Struct for invoke User App & continue after */
typedef struct zb_zcl_identify_effect_user_app_schedule_e
{
zb_zcl_parsed_hdr_t cmd_info; /**< Parameters for continue command,
see @ref zb_zcl_parsed_hdr_s */
zb_zcl_identify_effect_value_param_t param; /**< User App command parameters,
see @ref zb_zcl_identify_effect_value_param_s */
} zb_zcl_identify_effect_user_app_schedule_t;
#define ZB_ZCL_IDENTIFY_EFFECT_SCHEDULE_USER_APP(buffer, pcmd_info, effectId, effectVar) \
{ \
zb_zcl_identify_effect_user_app_schedule_t* data = \
ZB_BUF_GET_PARAM((buffer), zb_zcl_identify_effect_user_app_schedule_t); \
ZB_MEMMOVE(&(data->cmd_info), (pcmd_info), sizeof(zb_zcl_parsed_hdr_t)); \
data->param.effect_id = (effectId); \
data->param.effect_variant = (effectVar); \
ZB_SCHEDULE_CALLBACK(zb_zcl_identify_effect_invoke_user_app, (buffer)); \
}
/*! @} */ /* internal */
/*! @brief Send Identify command
@param buffer to put packet to
@param time the device will be identifying
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - flag "Default response required"
@param cb - callback for getting command send status
*/
#define ZB_ZCL_IDENTIFY_SEND_IDENTIFY_REQ( \
buffer, time, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_IDENTIFY_IDENTIFY_ID); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, time); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, ZB_ZCL_CLUSTER_ID_IDENTIFY, cb); \
}
/*! @brief Send Identify Query command
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - flag "Default response required"
@param cb - callback for getting command send status
@snippet on_off_switch/sample_zed.c identify_send_identify_query_req
*/
#define ZB_ZCL_IDENTIFY_SEND_IDENTIFY_QUERY_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ( \
ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_IDENTIFY_IDENTIFY_QUERY_ID); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, ZB_ZCL_CLUSTER_ID_IDENTIFY, cb); \
}
/*! @brief Send Identify Query Response command
@param buffer to put packet to
@param time the device will be identifying
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param seq_num - sequence number
@param aps_secured - APS security mode
*/
#define ZB_ZCL_IDENTIFY_SEND_IDENTIFY_QUERY_RES( \
buffer, time, addr, dst_addr_mode, dst_ep, ep, prfl_id, seq_num, aps_secured) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, seq_num, ZB_ZCL_CMD_IDENTIFY_IDENTIFY_QUERY_RSP_ID); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, time); \
ZB_ZCL_FINISH_N_SEND_PACKET_NEW(buffer, ptr, \
addr, dst_addr_mode, dst_ep, ep, prfl_id, ZB_ZCL_CLUSTER_ID_IDENTIFY, NULL, aps_secured, \
ZB_FALSE, 0); \
}
/**
* @brief Start identify process on given endpoint
*
* @param endpoint - endpoint to start identifying on
* @param timeout - time (in seconds) after which identifying will stop
*/
zb_uint8_t zb_zcl_start_identifying(zb_uint8_t endpoint, zb_uint16_t timeout);
/**
* @brief Stop identify process on given endpoint
* Complimentary function to @ref zb_zcl_start_identifying.
* Used to force identify termination before timeout provided to
* @ref zb_zcl_start_identifying is elapsed
*
* @param endpoint Endpoint
*/
void zb_zcl_stop_identifying(zb_uint8_t endpoint);
/**
* @brief Indicates that endpoint supports Identify cluster and is identifying
* @param endpoint number to analyze
* @return ZB_TRUE if endpoint is in the "identifying" state, ZB_FALSE otherwise.
*/
zb_uint8_t zb_zcl_is_identifying(zb_uint8_t endpoint);
/*! @brief Structured representation of Identify command payload */
typedef ZB_PACKED_PRE struct zb_zcl_identify_req_s
{
zb_uint16_t timeout; /*!< Time to identify */
} ZB_PACKED_STRUCT zb_zcl_identify_req_t;
/*! @brief Structured representation of Identify Query Response command payload */
typedef ZB_PACKED_PRE struct zb_zcl_identify_query_res_s
{
zb_uint16_t timeout; /*!< Reported time to identify */
} ZB_PACKED_STRUCT zb_zcl_identify_query_res_t;
/*! @brief Identify cluster Identify command payload structured read
* @param data_ptr - pointer to a variable of type @ref zb_zcl_identify_req_t
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IDENTIFY_GET_IDENTIFY_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_identify_req_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_identify_req_t *src_ptr = \
(zb_zcl_identify_req_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_HTOLE16(&((data_ptr)->timeout), &(src_ptr->timeout)); \
} \
}
/*! @brief Identify cluster Identify Query Response command payload structured
read
* @param data_ptr - pointer to a variable of type @ref zb_zcl_identify_query_res_t
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IDENTIFY_GET_IDENTIFY_QUERY_RES(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_identify_query_res_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_identify_query_res_t *src_ptr = \
(zb_zcl_identify_query_res_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_HTOLE16(&((data_ptr)->timeout), &(src_ptr->timeout)); \
} \
}
/*! @} */ /* Identify cluster command structures and definitions */
/** @cond internals_doc */
/*!
@name Identify cluster internals
@internal
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_IDENTIFY_IDENTIFY_TIME_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_IDENTIFY_IDENTIFY_TIME_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#if defined ZB_ZCL_SUPPORT_CLUSTER_SCENES
/*! Scenes fieldset length for Identify cluster */
#define ZB_ZCL_CLUSTER_ID_IDENTIFY_SCENE_FIELD_SETS_LENGTH 0
#endif /* defined ZB_ZCL_SUPPORT_CLUSTER_SCENES */
/*! @} */ /* Identify cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for Identify cluster
@param attr_list - attribute list name
@param identify_time - pointer to variable to store identify time attribute value
*/
#define ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST(attr_list, identify_time) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_IDENTIFY) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_IDENTIFY_IDENTIFY_TIME_ID, (identify_time)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/**
* @brief Identify cluster attributes
*/
typedef struct zb_zcl_identify_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_IDENTIFY_IDENTIFY_TIME_ID
* @see ZB_ZCL_ATTR_IDENTIFY_IDENTIFY_TIME_ID
*/
zb_uint16_t identify_time;
} zb_zcl_identify_attrs_t;
/** @brief Declare attribute list for Identify cluster cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of zb_zcl_identify_attrs_t type (containing Identify cluster attributes)
*/
#define ZB_ZCL_DECLARE_IDENTIFY_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST(attr_list, &attrs.identify_time)
#if defined ZB_ENABLE_HA
zb_uint8_t zb_zcl_get_cmd_list_identify(zb_bool_t is_client_generated, zb_uint8_t **cmd_list);
#endif /* defined ZB_ENABLE_HA */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_identify_init_server(void);
void zb_zcl_identify_init_client(void);
#define ZB_ZCL_CLUSTER_ID_IDENTIFY_SERVER_ROLE_INIT zb_zcl_identify_init_server
#define ZB_ZCL_CLUSTER_ID_IDENTIFY_CLIENT_ROLE_INIT zb_zcl_identify_init_client
#endif /* defined(ZB_ZCL_SUPPORT_CLUSTER_IDENTIFY) */
#endif /* ZB_ZCL_IDENTIFY_H */

View File

@@ -0,0 +1,185 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Illuminance Measurement cluster definitions
*/
#ifndef ZB_ZCL_ILLUMINANCE_MEASUREMENT_H
#define ZB_ZCL_ILLUMINANCE_MEASUREMENT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_ILLUMINANCE_MEASUREMENT
* @{
*/
/* Cluster ZB_ZCL_CLUSTER_ID_ILLUMINANCE_MEASUREMENT */
/*! @name Illuminance Measurement cluster attributes
@{
*/
/*! @brief Illuminance Measurement cluster attribute identifiers
@see ZCL spec, Illuminance Measurement Cluster 4.2.2.2.1
*/
enum zb_zcl_illuminance_measurement_attr_e
{
/** @brief MeasuredValue, ZCL spec 4.2.2.2.1.1 */
ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_ID = 0x0000,
/** @brief MinMeasuredValue, ZCL spec 4.2.2.2.1.2 */
ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MIN_MEASURED_VALUE_ID = 0x0001,
/** @brief MaxMeasuredValue, ZCL spec 4.2.2.2.1.3 */
ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MAX_MEASURED_VALUE_ID = 0x0002,
/** The Tolerance attribute SHALL indicate the magnitude of the
* possible error that is associated with MeasuredValue, using the
* same units and resolution. */
ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_TOLERANCE_ID = 0x0003,
/** The LightSensorType attribute specifies the electronic type of
* the light sensor. */
ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_LIGHT_SENSOR_TYPE_ID = 0x0004,
};
/** @brief Default value for Illuminance Measurement cluster revision global attribute */
#define ZB_ZCL_ILLUMINANCE_MEASUREMENT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief MeasuredValue attribute too-low value */
#define ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_TOO_LOW 0
/** @brief MeasuredValue attribute invalid value */
#define ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_INVALID 0xFFFF
/** @brief MeasuredValue attribute default value */
#define ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_DEFAULT \
ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_TOO_LOW
/** @brief Default value for LightSensorType attribute */
#define ZB_ZCL_ILLUMINANCE_MEASUREMENT_LIGHT_SENSOR_TYPE_DEFAULT_VALUE ((zb_uint8_t)0xFF)
/** @brief MinMeasuredValue attribute minimum value */
#define ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MIN_MEASURED_VALUE_MIN_VALUE 0x0001
/** @brief MinMeasuredValue attribute maximum value */
#define ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MIN_MEASURED_VALUE_MAX_VALUE 0xFFFD
/** @brief MinMeasuredValue attribute not-defined value */
#define ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MIN_MEASURED_VALUE_UNDEFINED 0xFFFF
/** @brief MaxMeasuredValue attribute minimum value */
#define ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MAX_MEASURED_VALUE_MIN_VALUE 0x0002
/** @brief MaxMeasuredValue attribute maximum value */
#define ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MAX_MEASURED_VALUE_MAX_VALUE 0xFFFE
/** @brief MaxMeasuredValue attribute not-defined value */
#define ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MAX_MEASURED_VALUE_UNDEFINED 0xFFFF
/** @cond internals_doc */
/*! @internal @name Illuminance Measurement cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MIN_MEASURED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MIN_MEASURED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MAX_MEASURED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MAX_MEASURED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_ZCL_ILLUMINANCE_MEASUREMENT_REPORT_ATTR_COUNT 1
/*! @} */ /* Illuminance Measurement cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for Illuminance Measurement cluster - server side
@param attr_list - attribute list name
@param value - pointer to variable to store MeasuredValue attribute
@param min_value - pointer to variable to store MinMeasuredValue attribute
@param max_value - pointer to variable to store MAxMeasuredValue attribute
*/
#define ZB_ZCL_DECLARE_ILLUMINANCE_MEASUREMENT_ATTRIB_LIST(attr_list, \
value, min_value, max_value) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_ILLUMINANCE_MEASUREMENT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_ID, (value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MIN_MEASURED_VALUE_ID, (min_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MAX_MEASURED_VALUE_ID, (max_value)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Illuminance Measurement cluster attributes */
/*! @name Illuminance Measurement cluster commands
@{
*/
/*! @} */ /* Illuminance Measurement cluster commands */
/*! @} */ /* ZCL Illuminance Measurement cluster definitions */
/** @endcond */
void zb_zcl_illuminance_measurement_init_server(void);
void zb_zcl_illuminance_measurement_init_client(void);
#define ZB_ZCL_CLUSTER_ID_ILLUMINANCE_MEASUREMENT_SERVER_ROLE_INIT zb_zcl_illuminance_measurement_init_server
#define ZB_ZCL_CLUSTER_ID_ILLUMINANCE_MEASUREMENT_CLIENT_ROLE_INIT zb_zcl_illuminance_measurement_init_client
#endif /* ZB_ZCL_ILLUMINANCE_MEASUREMENT_H */

View File

@@ -0,0 +1,334 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: ZBOSS specific IR Blaster cluster, purpose: send IR Control commands.
*/
#ifndef ZB_ZCL_IR_BLASTER_H
#define ZB_ZCL_IR_BLASTER_H 1
#if defined ZB_ZCL_SUPPORT_CLUSTER_IR_BLASTER || defined DOXYGEN
/** @cond DOXYGEN_INTERNAL_DOC */
/** @addtogroup ZB_ZCL_IR_BLASTER
* @{
* @details
* Manufacture specific cluster for transmit IR codes
* Model: One (client) to More (servers)
*/
/*! @name Ir_Blaster cluster commands
@{
*/
#define ZB_ZCL_IR_BLASTER_IR_SIGNATURE_SIZE 22
/**
* @brief Ir_Blaster cluster commands
*/
enum zb_zcl_ir_blaster_cmd_e
{
ZB_ZCL_CMD_IR_BLASTER_TRANSMIT_IR_DATA = 0x00,
ZB_ZCL_CMD_IR_BLASTER_TRANSMISSION_STATUS = 0x01,
ZB_ZCL_CMD_IR_BLASTER_GET_IR_SIGNATURE = 0x02,
ZB_ZCL_CMD_IR_BLASTER_GET_IR_SIGNATURE_RESP = 0x03,
};
/** Ir_Blaster status */
typedef enum zb_zcl_ir_blaster_transmission_status_e
{
ZB_ZCL_IR_BLASTER_TRANSMISSION_STATUS_COMPLETED = 0x30,
ZB_ZCL_IR_BLASTER_TRANSMISSION_STATUS_ERROR = 0x40,
}
zb_zcl_ir_blaster_transmit_status_t;
/************* Ir_Blaster cluster command structures **************/
typedef ZB_PACKED_PRE struct zb_zcl_ir_blaster_transmit_ir_data_s
{
zb_uint8_t ir_code_id[16];
}
ZB_PACKED_STRUCT
zb_zcl_ir_blaster_transmit_ir_data_t;
typedef struct zb_zcl_ir_blaster_transmit_ir_data_value_param_s
{
zb_zcl_parsed_hdr_t cmd_info;
zb_zcl_ir_blaster_transmit_ir_data_t payload;
} zb_zcl_ir_blaster_transmit_ir_data_value_param_t;
/*! @brief Send Transfer Data command
@param _buffer - to put packet to
@param _addr - address to send packet to
@param _dst_addr_mode - addressing mode
@param _dst_ep - destination endpoint
@param _ep - sending endpoint
@param _prfl_id - profile identifier
@param _cb - callback for getting command send status
@param _manufacturer_id - Manufacturer code
@param _flag - command flag, see @ref zb_zcl_ir_blaster_tx_flags_e
@param _byte_num - all transfer length or current offset, see @ref zb_zcl_ir_blaster_transfer_data_header_t
@param _data_size - data size
@param _image_data - image data
*/
#define ZB_ZCL_IR_BLASTER_SEND_TRANSMIT_IR_DATA( \
_buffer, _addr, _dst_addr_mode, _dst_ep, _ep, _prfl_id, _def_resp, _cb, \
_manufacturer_id, _ir_code_id) \
{ \
zb_uint8_t* __ptr = ZB_ZCL_START_PACKET((_buffer)); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL_A(__ptr, \
ZB_ZCL_FRAME_DIRECTION_TO_SRV, ZB_ZCL_MANUFACTURER_SPECIFIC, (_def_resp)); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(__ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_MANUFACTURER_SPECIFIC, (_manufacturer_id), \
ZB_ZCL_CMD_IR_BLASTER_TRANSMIT_IR_DATA); \
ZB_ZCL_PACKET_PUT_DATA_N(__ptr, (_ir_code_id), \
(sizeof(zb_zcl_ir_blaster_transmit_ir_data_t))); \
ZB_ZCL_FINISH_PACKET((_buffer), __ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(_buffer), (_addr), (_dst_addr_mode), (_dst_ep), (_ep), (_prfl_id), \
ZB_ZCL_CLUSTER_ID_IR_BLASTER, (_cb)); \
}
/** @brief Macro for getting Send Transfer Data command
* @attention Assumes that ZCL header already cut.
* @param _data_ptr - pointer to a variable of type @ref
* zb_zcl_ir_blaster_transfer_data_internal_t.
* @param _buffer containing the packet (by pointer).
* @param _status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*
* NOTE file data place`s in buffer, payload saves pointer to data only!
*/
#define ZB_ZCL_IR_BLASTER_GET_TRANSMIT_IR_DATA(_data_ptr, _buffer, _status) \
{ \
zb_zcl_ir_blaster_transmit_ir_data_t *src_ptr = \
(zb_zcl_ir_blaster_transmit_ir_data_t*)zb_buf_begin((_buffer)); \
\
if (zb_buf_len((_buffer)) != sizeof(zb_zcl_ir_blaster_transmit_ir_data_t)) \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_MEMCPY((_data_ptr)->ir_code_id, (src_ptr), \
sizeof(zb_zcl_ir_blaster_transmit_ir_data_t)); \
} \
}
typedef ZB_PACKED_PRE struct zb_zcl_ir_blaster_transmission_status_s
{
zb_uint8_t status; /**< enum @ref zb_zcl_ir_blaster_status_e */
}
ZB_PACKED_STRUCT
zb_zcl_ir_blaster_transmission_status_t;
typedef struct zb_zcl_ir_blaster_transmission_status_value_param_s
{
/* zb_zcl_parsed_hdr_t cmd_info; */
zb_zcl_ir_blaster_transmission_status_t payload;
} zb_zcl_ir_blaster_transmission_status_value_param_t;
/*! @brief Send Transfer Data response command
@param _buffer - to put packet to
@param _addr - address to send packet to
@param _dst_addr_mode - addressing mode
@param _dst_ep - destination endpoint
@param _ep - sending endpoint
@param _prfl_id - profile identifier
@param _seq - request sequence
@param _cb - callback for getting command send status
@param _manufacturer_id - Manufacturer code
@param _tun_status - command status, see @ref zb_zcl_ir_blaster_status_e
*/
#define ZB_ZCL_IR_BLASTER_SEND_TRANSMISSION_STATUS( \
_buffer, _addr, _dst_addr_mode, _dst_ep, _ep, _prfl_id, _seq, _cb, \
_manufacturer_id, _status) \
{ \
zb_uint8_t* __ptr = ZB_ZCL_START_PACKET((_buffer)); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RESP_FRAME_CONTROL_A(__ptr, \
ZB_ZCL_FRAME_DIRECTION_TO_CLI, ZB_ZCL_MANUFACTURER_SPECIFIC); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(__ptr, (_seq), ZB_ZCL_MANUFACTURER_SPECIFIC, \
(_manufacturer_id), ZB_ZCL_CMD_IR_BLASTER_TRANSMISSION_STATUS); \
ZB_ZCL_PACKET_PUT_DATA8(__ptr, (_status)); \
ZB_ZCL_FINISH_PACKET((_buffer), __ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(_buffer), (_addr), (_dst_addr_mode), (_dst_ep), (_ep), (_prfl_id), \
ZB_ZCL_CLUSTER_ID_IR_BLASTER, (_cb)); \
}
/** @brief Macro for getting Send Transfer Data response command
* @attention Assumes that ZCL header already cut.
* @param _data_ptr - pointer to a variable of type @ref
* zb_zcl_ir_blaster_transfer_data_resp_t.
* @param _buffer containing the packet (by pointer).
* @param _status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IR_BLASTER_GET_TRANSMISSION_STATUS(_data_ptr, _buffer, _status) \
{ \
zb_zcl_ir_blaster_transmission_status_t *src_ptr = \
(zb_zcl_ir_blaster_transmission_status_t*)zb_buf_begin((_buffer)); \
\
if (zb_buf_len((_buffer)) != sizeof(zb_zcl_ir_blaster_transmission_status_t) ) \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(_data_ptr)->status = src_ptr->status; \
} \
}
typedef struct zb_zcl_ir_blaster_get_ir_signature_value_param_s
{
zb_zcl_parsed_hdr_t cmd_info;
} zb_zcl_ir_blaster_get_ir_signature_value_param_t;
/*! @brief Send Get IR Signature command
@param _buffer - to put packet to
@param _addr - address to send packet to
@param _dst_addr_mode - addressing mode
@param _dst_ep - destination endpoint
@param _ep - sending endpoint
@param _prfl_id - profile identifier
@param _cb - callback for getting command send status
@param _manufacturer_id - Manufacturer code
*/
#define ZB_ZCL_IR_BLASTER_SEND_GET_IR_SIGNATURE( \
_buffer, _addr, _dst_addr_mode, _dst_ep, _ep, _prfl_id, _def_resp, _cb, \
_manufacturer_id) \
{ \
zb_uint8_t* __ptr = ZB_ZCL_START_PACKET((_buffer)); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL_A(__ptr, \
ZB_ZCL_FRAME_DIRECTION_TO_SRV, ZB_ZCL_MANUFACTURER_SPECIFIC, (_def_resp)); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(__ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_MANUFACTURER_SPECIFIC, (_manufacturer_id), \
ZB_ZCL_CMD_IR_BLASTER_GET_IR_SIGNATURE); \
ZB_ZCL_FINISH_PACKET((_buffer), __ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(_buffer), (_addr), (_dst_addr_mode), (_dst_ep), (_ep), (_prfl_id), \
ZB_ZCL_CLUSTER_ID_IR_BLASTER, (_cb)); \
}
typedef ZB_PACKED_PRE struct zb_zcl_ir_blaster_get_ir_signature_resp_s
{
zb_uint8_t status;
zb_uint8_t ir_signature[ZB_ZCL_IR_BLASTER_IR_SIGNATURE_SIZE];
}
ZB_PACKED_STRUCT
zb_zcl_ir_blaster_get_ir_signature_resp_t;
typedef struct zb_zcl_ir_blaster_get_ir_signature_resp_value_param_s
{
zb_zcl_parsed_hdr_t cmd_info;
zb_zcl_ir_blaster_get_ir_signature_resp_t payload;
} zb_zcl_ir_blaster_get_ir_signature_resp_value_param_t;
/*! @brief Send Transfer Data response command
@param _buffer - to put packet to
@param _addr - address to send packet to
@param _dst_addr_mode - addressing mode
@param _dst_ep - destination endpoint
@param _ep - sending endpoint
@param _prfl_id - profile identifier
@param _seq - request sequence
@param _cb - callback for getting command send status
@param _manufacturer_id - Manufacturer code
@param _tun_status - command status, see @ref zb_zcl_ir_blaster_status_e
*/
#define ZB_ZCL_IR_BLASTER_SEND_GET_IR_SIGNATURE_RESP( \
_buffer, _addr, _dst_addr_mode, _dst_ep, _ep, _prfl_id, _seq, _cb, \
_manufacturer_id, _status, _ir_signature) \
{ \
zb_uint8_t* __ptr = ZB_ZCL_START_PACKET((_buffer)); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RESP_FRAME_CONTROL_A(__ptr, \
ZB_ZCL_FRAME_DIRECTION_TO_CLI, ZB_ZCL_MANUFACTURER_SPECIFIC); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(__ptr, (_seq), ZB_ZCL_MANUFACTURER_SPECIFIC, \
(_manufacturer_id), ZB_ZCL_CMD_IR_BLASTER_GET_IR_SIGNATURE_RESP); \
ZB_ZCL_PACKET_PUT_DATA8(__ptr, _status); \
if (_status == ZB_ZCL_IR_BLASTER_TRANSMISSION_STATUS_COMPLETED) \
{ \
ZB_ZCL_PACKET_PUT_DATA_N(__ptr, (_ir_signature), ZB_ZCL_IR_BLASTER_IR_SIGNATURE_SIZE); \
} \
ZB_ZCL_FINISH_PACKET((_buffer), __ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(_buffer), (_addr), (_dst_addr_mode), (_dst_ep), (_ep), (_prfl_id), \
ZB_ZCL_CLUSTER_ID_IR_BLASTER, (_cb)); \
}
/** @brief Macro for getting Send Transfer Data response command
* @attention Assumes that ZCL header already cut.
* @param _data_ptr - pointer to a variable of type @ref
* zb_zcl_ir_blaster_transfer_data_resp_t.
* @param _buffer containing the packet (by pointer).
* @param _status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_IR_BLASTER_GET_GET_IR_SIGNATURE_RESP(_data_ptr, _buffer, _status) \
{ \
zb_zcl_ir_blaster_get_ir_signature_resp_t *src_ptr = \
(zb_zcl_ir_blaster_get_ir_signature_resp_t*)zb_buf_begin((_buffer)); \
\
if (zb_buf_len((_buffer)) == sizeof(zb_zcl_ir_blaster_get_ir_signature_resp_t) || \
zb_buf_len((_buffer)) == sizeof(zb_uint8_t)) \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(_data_ptr)->status = src_ptr->status; \
if (src_ptr->status == ZB_ZCL_IR_BLASTER_TRANSMISSION_STATUS_COMPLETED) \
{ \
ZB_MEMCPY((_data_ptr)->ir_signature, src_ptr->ir_signature, ZB_ZCL_IR_BLASTER_IR_SIGNATURE_SIZE); \
} \
} \
else \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
}
void zb_zcl_ir_blaster_init_server();
void zb_zcl_ir_blaster_init_client();
#define ZB_ZCL_CLUSTER_ID_IR_BLASTER_SERVER_ROLE_INIT zb_zcl_ir_blaster_init_server
#define ZB_ZCL_CLUSTER_ID_IR_BLASTER_CLIENT_ROLE_INIT zb_zcl_ir_blaster_init_client
/*! @} */ /* Ir_Blaster cluster commands */
/*! @} */ /* addtogroup */
/* @endcond */
#endif /*defined ZB_ZCL_SUPPORT_CLUSTER_IR_BLASTER */
#endif /* ZB_ZCL_IR_BLASTER_H */

View File

@@ -0,0 +1,164 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Keep-Alive cluster (ZCL8 spec, 3.18, previously SE spec, Annex A.3)
*/
#ifndef ZB_ZCL_KEEP_ALIVE_H
#define ZB_ZCL_KEEP_ALIVE_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_KEEP_ALIVE
* @{
* @details
* This cluster supports the commands and attributes directed to the network Trust Center in
* order to determine whether communication with the Trust Center is still available.
*
*/
/* Cluster ZB_ZCL_CLUSTER_ID_KEEP_ALIVE */
/*! @name Keep-Alive cluster attributes
@{
*/
/*! @brief Keep-Alive cluster attribute identifiers
@see SE spec, subclause A.3.2
*/
enum zb_zcl_keep_alive_attr_e
{
/*! @brief TC Keep-Alive Base attribute */
ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_BASE_ID = 0,
/*! @brief TC Keep-Alive Jitter attribute */
ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_JITTER_ID = 1
};
/** @brief Default value for Keep alive cluster revision global attribute */
#define ZB_ZCL_KEEP_ALIVE_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for TC Keep-Alive Base attribute */
#define ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_BASE_DEFAULT_VALUE 0x0a
/** @brief Default value for TC Keep-Alive Jitter attribute */
#define ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_JITTER_DEFAULT_VALUE 0x012c
/*! @} */ /* Keep-Alive cluster attributes */
/*! @name Keep-Alive cluster commands
@{
*/
/*! @} */ /* Keep-Alive cluster commands */
/*! @cond internals_doc
@internal @name Keep-Alive cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_BASE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_BASE_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_JITTER_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_JITTER_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @internal @brief Declare attribute list for Keep-Alive cluster
@param attr_list - attribute list name
@param base - pointer to variable to store TC Keep-Alive Base attribute value
@param jitter - pointer to variable to store TC Keep-Alive Jitter attribute value
*/
#define ZB_ZCL_DECLARE_KEEP_ALIVE_ATTR_LIST_FULL(attr_list, base, jitter) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_KEEP_ALIVE) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_BASE_ID, (base)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_JITTER_ID, (jitter)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @internal Number of attributes mandatory for reporting in Keep-Alive cluster */
#define ZB_ZCL_KEEP_ALIVE_REPORT_ATTR_COUNT 0
/*! @}
@endcond */ /* Keep-Alive cluster internals */
/**
* @brief Keep-Alive cluster attributes
*/
typedef struct zb_zcl_keep_alive_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_BASE_ID
* @see ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_BASE_ID
*/
zb_uint8_t base;
/** @copydoc ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_JITTER_ID
* @see ZB_ZCL_ATTR_KEEP_ALIVE_TC_KEEP_ALIVE_JITTER_ID
*/
zb_uint16_t jitter;
} zb_zcl_keep_alive_attrs_t;
/** @brief Declare attribute list for Keep-Alive cluster cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - pointer to @ref zb_zcl_keep_alive_attrs_s structure
*/
#define ZB_ZCL_DECLARE_KEEP_ALIVE_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_KEEP_ALIVE_ATTR_LIST_FULL(attr_list, &attrs.base, &attrs.jitter )
/*! @} */ /* Keep-Alive cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
#define ZB_ZCL_CLUSTER_ID_KEEP_ALIVE_SERVER_ROLE_INIT (zb_zcl_cluster_init_t)NULL
#define ZB_ZCL_CLUSTER_ID_KEEP_ALIVE_CLIENT_ROLE_INIT (zb_zcl_cluster_init_t)NULL
#endif /* ZB_ZCL_KEEP_ALIVE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,288 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: ZCL MDU (Multiple dwelling units) Pairing cluster
Allow devices joining the NAN to acquire a list of the devices
forming the 'virtual HAN' for the respective household.
*/
#ifndef ZB_ZCL_MDU_PAIRING_H
#define ZB_ZCL_MDU_PAIRING_H 1
#include "zcl/zb_zcl_common.h"
/** @cond DOXYGEN_ZCL_SECTION && DOXYGEN_SE_SECTION */
/** @addtogroup ZB_ZCL_MDU_PAIRING
* @{
* @details
* When operating within a multi-dwelling unit (MDU), the commands within
* this cluster allow devices joining the NAN to acquire a list of the
* devices forming the 'virtual HAN' for the respective household.
*/
/** @defgroup ZB_ZCL_MDU_PAIRING_ATTRS MDU Pairing cluster attributes
* @{
* @brief MDU Pairing cluster attribute identifiers
* @see SE spec, subclause 13.2.2 - No attributes
*
*/
/** @} */ /* ZB_ZCL_MDU_PAIRING_ATTRS */
/** @defgroup ZB_ZCL_MDU_PAIRING_COMMANDS MDU Pairing cluster commands
* @{
*/
/** @brief MDU Pairing cluster client commands
* @see SE spec, subclause 13.3.3
*/
enum zb_zcl_mdu_pairing_cmd_client_e
{
/** The @e PairingRequest command allows a device joining a MDU network to
* determine the devices that will constitute the 'virtual HAN' for the
* household in which it is to operate.
*/
ZB_ZCL_MDU_PAIRING_CLI_CMD_PAIRING_REQUEST = 0x00, /**< Pairing Request */
};
/** @brief MDU Pairing cluster server commands
* @see SE spec, subclause 13.2.3
*/
enum zb_zcl_mdu_pairing_cmd_server_e
{
/** The @e PairingResponse command provides a device joining a MDU network with
* a list of the devices that will constitute the 'virtual HAN' for the
* household in which the joining device is to operate.
*/
ZB_ZCL_MDU_PAIRING_SRV_CMD_PAIRING_RESPONSE = 0x00, /**< Pairing Request response */
};
/* MDU PAIRING cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_MDU_PAIRING_SERVER_ROLE_GENERATED_CMD_LIST ZB_ZCL_MDU_PAIRING_SRV_CMD_PAIRING_RESPONSE
#define ZB_ZCL_CLUSTER_ID_MDU_PAIRING_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_MDU_PAIRING_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_MDU_PAIRING_CLIENT_ROLE_GENERATED_CMD_LIST ZB_ZCL_MDU_PAIRING_CLI_CMD_PAIRING_REQUEST
#define ZB_ZCL_CLUSTER_ID_MDU_PAIRING_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_MDU_PAIRING_CLIENT_ROLE_GENERATED_CMD_LIST
/************* MDU Pairing cluster command structures **************/
/** @brief Pairing Request command payload
* @see SE spec, subclause 13.3.3.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_mdu_pairing_request_s
{
zb_uint32_t lpi_version; /**< Identifies the version of pairing information currently held on the requesting device. */
zb_ieee_addr_t eui64; /**< Identifies the MAC address of the requesting device. */
}
ZB_PACKED_STRUCT zb_zcl_mdu_pairing_request_t;
/** @brief Pairing Response command payload
* @see SE spec, subclause 13.2.3.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_mdu_pairing_response_s
{
zb_uint32_t lpi_version; /**< Identifies the version of pairing information included in this command. */
zb_uint8_t total_number_of_devices; /**< The total number of devices expected to form the 'virtual HAN'
* (including the device to which this command is being sent) */
zb_uint8_t command_index; /**< The CommandIndex is uses to count the payload fragments in the
* case where the entire payload does not fit into one message. */
zb_uint8_t total_number_of_commands; /**< In the case where the entire payload does not fit into one
* message, the Total Number of Commands field indicates the
* total number of sub-commands in the message. */
zb_ieee_addr_t *eui64; /**< EUI64 of Device 1 to EUI64 of Device N represent the MAC address
* of devices that belong to the 'virtual HAN' of the requesting
* device; these include the requesting device itself and all other
* devices the requesting device shall perform service discovery
* and binding with. */
zb_uint8_t num_dev_cmd; /**< Number of devices in current command */
}
ZB_PACKED_STRUCT zb_zcl_mdu_pairing_response_t;
/** @def ZB_ZCL_MDU_PAIRING_SEND_PAIRING_REQUEST
* @brief Send @e PairingRequest command
* @param _param - Reference to buffer.
* @param _addr - Address of the device to send command to.
* @param _dst_addr_mode - Address mode for _dst_addr.
* @param _dst_ep - Destination endpoint.
* @param _ep - Current endpoint.
* @param _prfl_id - profile identifier
* @param _def_resp - enable/disable default zcl response
* @param _cb - Callback which should be called when the ZCL stack receives
* APS ack.
* @param _lpi_version - lpi_version field from @ref zb_zcl_mdu_pairing_response_t payload
* @param _eui64 - eui64 field from @ref zb_zcl_mdu_pairing_response_t payload
* @par Example
* @code{C}
* // The command is used as is
* ZB_ZCL_MDU_PAIRING_SEND_PAIRING_REQUEST(param, remote.addr, ZB_APS_ADDR_MODE_16_ENDP_PRESENT, remote.ep, this.ep, ZB_AF_SE_PROFILE_ID, 0, NULL, lpi, this.addr);
* @endcode
*/
#define ZB_ZCL_MDU_PAIRING_SEND_PAIRING_REQUEST( \
_param, _addr, _dst_addr_mode, _dst_ep, _ep, _prfl_id, _def_resp, _cb, \
_lpi_version, _eui64) \
{ \
zb_bufid_t buffer = ZB_BUF_FROM_REF(_param); \
zb_uint8_t* __ptr = zb_zcl_start_command_header(buffer, \
ZB_ZCL_CONSTRUCT_FRAME_CONTROL(ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC, \
ZB_ZCL_NOT_MANUFACTURER_SPECIFIC, \
ZB_ZCL_FRAME_DIRECTION_TO_SRV, (_def_resp)), \
0, /* No manuf_code */ \
ZB_ZCL_MDU_PAIRING_CLI_CMD_PAIRING_REQUEST, NULL); \
ZB_ZCL_PACKET_PUT_DATA32(__ptr, (_lpi_version)); \
ZB_ZCL_PACKET_PUT_DATA64(__ptr, (_eui64)); \
ZB_ZCL_FINISH_PACKET((buffer), __ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(_buffer), (_addr), (_dst_addr_mode), (_dst_ep), (_ep), (_prfl_id), \
ZB_ZCL_CLUSTER_ID_MDU_PAIRING, (_cb)); \
}
/** @def ZB_ZCL_MDU_PAIRING_GET_PAIRING_REQUEST
* @brief Macro for parsing payload of @e PairingRequest command
* @param _data_ptr - pointer to @ref zb_zcl_mdu_pairing_request_t structure
* @param _buffer - pointer to buffer where Pairing Request command's payload is stored.
* @param _status - status of payload parsing
* @par Example
* @code{C}
* zb_bufid_t buf;
* zb_zcl_mdu_pairing_request_t req;
* zb_uint8_t status;
*
* ZB_ZCL_MDU_PAIRING_GET_PAIRING_REQUEST(req, buf, status);
*
* if (status == ZB_ZCL_PARSE_STATUS_SUCCESS)
* {
* (void)req.eui64; // use it
* (void)req.lpi_version; // use it
* }
* @endcode
*/
#define ZB_ZCL_MDU_PAIRING_GET_PAIRING_REQUEST(_data_ptr, _buffer, _status) \
{ \
zb_uint8_t *src_ptr = (zb_uint8_t*)zb_buf_begin((_buffer)); \
\
if (zb_buf_len((_buffer)) < sizeof(zb_zcl_mdu_pairing_request_t)) \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_HTOLE32(&(_data_ptr)->lpi_version, src_ptr); \
ZB_HTOLE64(&(_data_ptr)->eui64, src_ptr+4); \
} \
}
/** @} */ /* ZB_ZCL_MDU_PAIRING_COMMANDS */
/** @} */ /* addtogroup */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
/* @brief Send Pairing Response command */
/*
#define ZB_ZCL_MDU_PAIRING_SEND_PAIRING_RESPONSE( \
_param, _addr, _dst_addr_mode, _dst_ep, _ep, _prfl_id, _def_resp, _cb, \
_lpi_version, _eui64) \
{ \
zb_bufid_t buffer = ZB_BUF_FROM_REF(_param); \
zb_uint8_t* __ptr = zb_zcl_start_command_header(buffer, \
ZB_ZCL_CONSTRUCT_FRAME_CONTROL(ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC, \
ZB_ZCL_NOT_MANUFACTURER_SPECIFIC, \
ZB_ZCL_FRAME_DIRECTION_TO_SRV, (_def_resp)), \
0, / No manuf_code / \
ZB_ZCL_MDU_PAIRING_CLI_CMD_PAIRING_REQUEST, NULL); \
ZB_ZCL_PACKET_PUT_DATA32(__ptr, (_lpi_version)); \
ZB_ZCL_PACKET_PUT_DATA64(__ptr, (_eui64)); \
ZB_ZCL_FINISH_PACKET((buffer), __ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(_buffer), (_addr), (_dst_addr_mode), (_dst_ep), (_ep), (_prfl_id), \
ZB_ZCL_CLUSTER_ID_MDU_PAIRING, (_cb)); \
}
*/
/* @brief Macro for getting Pairing Response command data */
/*
#define ZB_ZCL_MDU_PAIRING_GET_PAIRING_RESPONSE(_data_ptr, _buffer, _status)\
{ \
zb_zcl_mdu_pairing_response_t *src_ptr = (zb_zcl_mdu_pairing_response_t*)zb_buf_begin((_buffer)); \
\
if (zb_buf_len((_buffer)) < sizeof(zb_zcl_mdu_pairing_response_t)) \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_HTOLE32(&(_data_ptr)->lpi_version, src_ptr); \
(_data_ptr)->total_number_of_devices = src_ptr->total_number_of_devices; \
(_data_ptr)->command_index = src_ptr->command_index; \
(_data_ptr)->total_number_of_commands = src_ptr->total_number_of_commands;\
ZB_HTOLE64(&(_data_ptr)->eui64,&(src_ptr->eui64)); \
} \
}
*/
zb_ret_t zb_zcl_mdu_pairing_send_cmd_pairing_request(
zb_uint8_t param,
const zb_addr_u *dst_addr,
zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep,
zb_uint8_t src_ep,
const zb_zcl_mdu_pairing_request_t *payload,
zb_ieee_addr_t *buf,
zb_uint8_t buf_len_in_elements,
zb_callback_t cb
);
/************************* MDU Pairing internal *******************************/
zb_uint8_t zb_zcl_process_mdu_pairing_specific_commands(zb_uint8_t param);
void zb_zcl_mdu_pairing_init_server(void);
void zb_zcl_mdu_pairing_init_client(void);
#define ZB_ZCL_CLUSTER_ID_MDU_PAIRING_SERVER_ROLE_INIT zb_zcl_mdu_pairing_init_server
#define ZB_ZCL_CLUSTER_ID_MDU_PAIRING_CLIENT_ROLE_INIT zb_zcl_mdu_pairing_init_client
#endif /* ZB_ZCL_MDU_PAIRING_H */

View File

@@ -0,0 +1,636 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Messaging cluster definitions
*/
#ifndef ZB_ZCL_MESSAGING_H_
#define ZB_ZCL_MESSAGING_H_
#include "zboss_api_core.h" /* ZBOSS core API types */
#include "zboss_api_aps.h"
#define ZB_ZCL_MESSAGING_DISPLAY_MSG_MAX_NON_FRAG_SIZE 48
#define ZB_ZCL_MESSAGING_MSG_CONFIRM_RESP_MSG_MAX_SIZE 21
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_MESSAGING
* @{
* @details
* The Messaging cluster provides an interface for passing text messages
* between Zigbee devices.
*/
/** @defgroup ZB_ZCL_MESSAGING_COMMANDS Messaging cluster commands
* @{
*/
/** Commands generated by Messaging Server
* @see SE spec, subclause D.5.2.3
*/
typedef enum zb_zcl_messaging_srv_cmd_e
{
/** @see SE spec, subclause D.5.2.3.1
* @see zb_zcl_messaging_display_message_payload_s
*/
ZB_ZCL_MESSAGING_SRV_CMD_DISPLAY_MESSAGE = 0x00,
/** @e TheCancelMessage command provides the ability
* to cancel the sending or acceptance of previously sent messages. When this
* message is received the recipient device has the option of clearing any
* display or user interfaces it supports, or has the option of logging the
* message for future reference.
* @see SE spec, subclause D.5.2.3.2
* @see zb_zcl_messaging_cancel_message_payload_s
*/
ZB_ZCL_MESSAGING_SRV_CMD_CANCEL_MESSAGE = 0x01,
/** The Display Protected Message command is for use with messages that are
* protected by a password or PIN.
* @see zb_zcl_messaging_display_message_payload_s
*/
ZB_ZCL_MESSAGING_SRV_CMD_DISPLAY_PROTECTED_MESSAGE = 0x02,
/** @e TheCancelAllMessages command indicates to a client device that it should
* cancel all display messages currently held by it.
* @note @e TheCancelAllMessages command in this revision of this specification
* is provisional and not certifiable. This feature may change before reaching
* certifiable status in a future revision of this specification.
* @see zb_zcl_messaging_cancel_all_message_payload_s
*/
ZB_ZCL_MESSAGING_SRV_CMD_CANCEL_ALL_MESSAGES = 0x03
} zb_zcl_messaging_srv_cmd_t;
/** Commands generated by Messaging Client
* @see SE spec, D.5.3.3
*/
typedef enum zb_zcl_messaging_cli_cmd_e
{
/** On receipt of this command, the device shall send a @e DisplayMessage or
* @e DisplayProtectedMessage command as appropriate. A ZCL Default Response
* with status @e NOT_FOUND shall be returned if no message is available.
* @see SE spec, subclause D.5.3.3.1
* @note This command has no payload.
*/
ZB_ZCL_MESSAGING_CLI_CMD_GET_LAST_MESSAGE = 0x00,
/** @e TheMessageConfirmation command provides an indication that a Utility
* Customer has acknowledged and/or accepted the contents of a message
* previously received from the Messaging cluster server. Enhanced Message
* Confirmation commands shall contain an answer of NO, YES and/or a
* message confirmation string.
* If the optional Message Confirmation Response is required, the Message
* Confirmation Control field shall also be present.
* @see SE spec, subclause D.5.3.3.2
* @see zb_zcl_messaging_message_confirm_payload_s
*/
ZB_ZCL_MESSAGING_CLI_CMD_MESSAGE_CONFIRMATION = 0x01,
/** This command initiates the return of the first (and maybe only) @e
* CancelAllMessages command held on the associated server, and which has an
* implementation time equal to or later than the value indicated in the payload.
* @note The @e GetMessageCancellation command in this revision of this
* specification is provisional and not certifiable. This feature may change
* before reaching certifiable status in a future revision of this specification.
* @see zb_zcl_messaging_get_message_cancellation_payload_s
*/
ZB_ZCL_MESSAGING_CLI_CMD_GET_MESSAGE_CANCELLATION = 0x02
} zb_zcl_messaging_cli_cmd_t;
/* MESSAGING cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_MESSAGING_SERVER_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_MESSAGING_SRV_CMD_CANCEL_MESSAGE, \
ZB_ZCL_MESSAGING_SRV_CMD_DISPLAY_MESSAGE
#define ZB_ZCL_CLUSTER_ID_MESSAGING_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_MESSAGING_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_MESSAGING_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_MESSAGING_CLI_CMD_GET_LAST_MESSAGE, \
ZB_ZCL_MESSAGING_CLI_CMD_MESSAGE_CONFIRMATION
#define ZB_ZCL_CLUSTER_ID_MESSAGING_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_MESSAGING_CLIENT_ROLE_GENERATED_CMD_LIST
/* Payload description */
/** Extended Message Control Field values
* @see SE spec, Table D-118
* @see zb_zcl_messaging_display_message_payload_t::extended_message_control
*/
typedef enum zb_zcl_messaging_extended_message_control_e
{
ZB_ZCL_MESSAGING_MESSAGE_HAS_NOT_BEEN_CONFIRMED = 0, /**< Message has not been confirmed */
ZB_ZCL_MESSAGING_MESSAGE_HAS_BEEN_CONFIRMED = 1, /**< Message has been confirmed */
} zb_zcl_messaging_extended_message_control_field_t;
/** Extended Message Control Field Bit Map
* @see SE spec, Table D-118
*/
enum zb_zcl_messaging_extended_message_control_field_bitmap_e
{
ZB_ZCL_MESSAGING_MESSAGE_CONFIRMATION_STATUS = 0, /**< @see zb_zcl_messaging_extended_message_control_field_e*/
};
/** @ref ZB_ZCL_MESSAGING_SRV_CMD_DISPLAY_MESSAGE "DisplayMessage" command payload
* @see SE spec, subclause D.5.2.3.1.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_messaging_display_message_payload_s
{
/** 32-bit number identifier for the message. */
zb_uint32_t message_id; /* (M) */
/** BitMap field indicating control information related to the message */
zb_uint8_t message_control; /* (M) */
/** The time at which the message becomes valid */
zb_uint32_t start_time; /* (M) */
/** The amount of time in minutes after the Start Time during which
* the message is displayed */
zb_uint16_t duration_in_minutes; /* (M) */
/** Message (variable): Character String
* WARNING: Variable length of message supported, but remember to pass strings in global memory only!
*/
zb_uint8_t message_len; /* (M) */
zb_uint8_t *message; /* (M) */
/** BitMap field indicating additional control
* and status information for a given message.
*/
zb_uint8_t extended_message_control; /* (O) */
} ZB_PACKED_STRUCT zb_zcl_messaging_display_message_payload_t;
/** @e MessageControl field's transmission mechanism values
* @see SE spec, Table D-117
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_SET_TRANSMISSION_MECHANISM
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_GET_TRANSMISSION_MECHANISM
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_CLR_TRANSMISSION_MECHANISM
*/
typedef enum zb_zcl_messaging_message_control_transmission_mechanism_e
{
ZB_ZCL_MESSAGING_NORMAL_TRANSMISSION_ONLY = 0, /**< Send message through normal command
* function to client.
*/
ZB_ZCL_MESSAGING_NORMAL_AND_INTERNAL_PAN_TRANSMISSION = 1, /**< Send message through normal command
* function to client and pass message onto the
* Inter-PAN transmission mechanism.
*/
ZB_ZCL_MESSAGING_INTER_PAN_TRANSMISSION_ONLY = 2, /**< Send message through the Inter-PAN
* transmission mechanism.
*/
} zb_zcl_messaging_control_field_transmission_mechanism_t;
/** @brief Default value for Messaging cluster revision global attribute */
#define ZB_ZCL_MESSAGING_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/*!
@brief Declare attribute list for Messaging cluster (only cluster revision attribute)
@param attr_list - attribute list name
*/
#define ZB_ZCL_DECLARE_MESSAGING_ATTR_LIST(attr_list) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_MESSAGING) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/**
* Set @e MessageControl's transmission mechanism value
* @param x - variable to store transmission mechanism value
* @param val - @ref zb_zcl_messaging_control_field_transmission_mechanism_t value
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_SET_TRANSMISSION_MECHANISM(x, val) ((x) &= (0xFC | ((val) & 0x03)))
/**
* Get @e MessageControl's transmission mechanism value
* @param x - variable that stores transmission mechanism value
* @see zb_zcl_messaging_control_field_transmission_mechanism_t
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_GET_TRANSMISSION_MECHANISM(x) ((x) & 0x03)
/**
* Clear @e MessageControl's transmission mechanism value
* @param x - variable that stores transmission mechanism value
* @see zb_zcl_messaging_control_field_transmission_mechanism_t
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_CLR_TRANSMISSION_MECHANISM(x) ((x) &= 0xFC)
/** @e MessageControl field's control importance values
* @see SE spec, Table D-117
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_SET_IMPORTANCE_LEVEL
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_GET_IMPORTANCE_LEVEL
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_CLR_IMPORTANCE_LEVEL
*/
typedef enum zb_zcl_messaging_message_control_importance_level_e
{
ZB_ZCL_MESSAGING_IMPORTANCE_LEVEL_LOW = 0, /**< Low importance level */
ZB_ZCL_MESSAGING_IMPORTANCE_LEVEL_MEDIUM = 1, /**< Medium importance level */
ZB_ZCL_MESSAGING_IMPORTANCE_LEVEL_HIGH = 2, /**< High importance level */
ZB_ZCL_MESSAGING_IMPORTANCE_LEVEL_CRITICAL = 3, /**< Critical importance level */
} zb_zcl_messaging_message_control_importance_level_t;
/**
* Set @e MessageControl's control importance value
* @param x - variable to store control importance value
* @param val - @ref zb_zcl_messaging_message_control_importance_level_t value
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_SET_IMPORTANCE_LEVEL(x, val) ((x) &= (0xF3 | ((val) & 0x03) << 2)
/**
* Get @e MessageControl's control importance value
* @param x - variable that stores control importance value
* @see zb_zcl_messaging_message_control_importance_level_t
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_GET_IMPORTANCE_LEVEL(x) (((x) >> 2) & 0x03)
/**
* Clear @e MessageControl's control importance value
* @param x - variable that stores control importance value
* @see zb_zcl_messaging_message_control_importance_level_t
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_CLR_IMPORTANCE_LEVEL(x) ((x) &= 0xF3)
/** @e MessageControl field's enhanced confirmation values
* @see SE spec, Table D-117
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_SET_ENHANCED_CONFIRMATION
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_GET_ENHANCED_CONFIRMATION
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_CLR_ENHANCED_CONFIRMATION
*/
typedef enum zb_zcl_messaging_message_control_enhanced_confirmation_e
{
ZB_ZCL_MESSAGING_ENHANCED_CONFIRMATION_NOT_REQUIRED = 0, /**< Enhanced Confirmation not required */
ZB_ZCL_MESSAGING_ENHANCED_CONFIRMATION_REQUIRED = 1, /**< Enhanced Confirmation required */
} zb_zcl_messaging_message_control_enhanced_confirmation_t;
/**
* Set @e MessageControl's enhanced confirmation value
* @param x - variable to store enhanced confirmation value
* @param val - @ref zb_zcl_messaging_message_control_enhanced_confirmation_t value
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_SET_ENHANCED_CONFIRMATION(x, val) ((x) &= (0xDF | ((val) & 0x01) << 5)
/**
* Get @e MessageControl's enhanced confirmation value
* @param x - variable that stores enhanced confirmation value
* @see zb_zcl_messaging_message_control_enhanced_confirmation_t
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_GET_ENHANCED_CONFIRMATION(x) (((x) >> 5) & 0x01)
/**
* Clear @e MessageControl's enhanced confirmation value
* @param x - variable that stores enhanced confirmation value
* @see zb_zcl_messaging_message_control_enhanced_confirmation_t
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_CLR_ENHANCED_CONFIRMATION(x) ((x) &= 0xDF )
/** @e MessageControl field's message confirmation values
* @see SE spec, Table D-117
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_SET_MESSAGE_CONFIRMATION
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_GET_MESSAGE_CONFIRMATION
* @see ZB_ZCL_MESSAGING_MESSAGE_CONTROL_CLR_MESSAGE_CONFIRMATION
*/
typedef enum zb_zcl_messaging_message_control_message_confirmation_e
{
ZB_ZCL_MESSAGING_MESSAGE_CONFIRMATION_NOT_REQUIRED = 0x00, /**< Message Confirmation not required. */
ZB_ZCL_MESSAGING_MESSAGE_CONFIRMATION_REQUIRED = 0x01, /**< Message Confirmation required. */
} zb_zcl_messaging_message_control_message_confirmation_t;
/**
* Set @e MessageControl's message confirmation value
* @param x - variable to store message confirmation value
* @param val - @ref zb_zcl_messaging_message_control_message_confirmation_t value
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_SET_MESSAGE_CONFIRMATION(x, val) ((x) &= (0x7F | ((val) & 0x01) << 7)
/**
* Get @e MessageControl's message confirmation value
* @param x - variable that stores message confirmation value
* @see zb_zcl_messaging_message_control_message_confirmation_t
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_GET_MESSAGE_CONFIRMATION(x) (((x) >> 7) & 0x01)
/**
* Clear @e MessageControl's message confirmation value
* @param x - variable that stores message confirmation value
* @see zb_zcl_messaging_message_control_message_confirmation_t
*/
#define ZB_ZCL_MESSAGING_MESSAGE_CONTROL_CLR_MESSAGE_CONFIRMATION(x) ((x) &= 0x7F)
/** Check if some size in range of variable size of specified payload.
*/
#define ZB_ZCL_MESSAGING_DISPLAY_MSG_PAYLOAD_SIZE_IS_VALID(size) \
((size) >= ((zb_int16_t)sizeof(zb_zcl_messaging_display_message_payload_t) - \
(zb_int16_t)ZB_SIZEOF_FIELD(zb_zcl_messaging_display_message_payload_t, message) -\
(zb_int16_t)ZB_SIZEOF_FIELD(zb_zcl_messaging_display_message_payload_t, extended_message_control)))
/* 8/16/2017 NK CR:MINOR Do all compilers support such initializing? More common way to initialize
* is to provide pointer as parameter and operate with it inside the macro. */
/* 8/21/2017 IA: It is C99 features. I hope, they are supported by all "our" compilers. */
/** @ref zb_zcl_messaging_display_message_payload_t initializer */
#define ZB_ZCL_MESSAGING_DISPLAY_MSG_PAYLOAD_INIT \
(zb_zcl_messaging_display_message_payload_t)\
{ \
.extended_message_control = 0x00, \
}
/** @ref ZB_ZCL_MESSAGING_SRV_CMD_CANCEL_MESSAGE "CancelMessage" command payload
* @see SE spec, subclause D.5.2.3.2.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_messaging_cancel_message_payload_s
{
/** 32-bit number identifier for the message. */
zb_uint32_t message_id; /* (M) */
/** This field is deprecated and should be set to 0x00 */
zb_uint8_t message_control; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_messaging_cancel_message_payload_t;
/** @ref zb_zcl_messaging_cancel_message_payload_t initializer */
#define ZB_ZCL_MESSAGING_CANCEL_MSG_PAYLOAD_INIT \
(zb_zcl_messaging_cancel_message_payload_t) {0}
/** Check if some size in range of variable size of specified payload. */
#define ZB_ZCL_MESSAGING_MSG_CANCEL_MESSAGE_SIZE_IS_VALID(size) \
((size) >= sizeof(zb_zcl_messaging_cancel_message_payload_t))
/** Message Confirmation Control
* @see SE spec, Table D-120
* @see zb_zcl_messaging_message_confirm_payload_t::message_confirmation_control
*/
typedef enum zb_zcl_messaging_message_confirmation_control_e
{
ZB_ZCL_MESSAGING_NO_RETURNED = 1 << 0, /**< The answer is NO */
ZB_ZCL_MESSAGING_YES_RETURNED = 1 << 1, /**< The answer is YES */
} zb_zcl_messaging_message_confirmation_control_t;
/** @ref ZB_ZCL_MESSAGING_CLI_CMD_MESSAGE_CONFIRMATION "MessageConfirmation" command payload
* @see SE spec, subclause D.5.3.3.2.1
*/
typedef ZB_PACKED_PRE struct zb_zcl_messaging_message_confirm_payload_s
{
/** 32-bit number identifier for the message being confirmed. */
zb_uint32_t message_id; /* (M) */
/** UTCTime of user confirmation of message */
zb_uint32_t confirmation_time; /* (M) */
/** BitMap field indicating the simple confirmation that is
* contained within the response.
*/
zb_uint8_t message_confirmation_control; /* (O) */
/** ZCL Octet String containing the message to be returned.
* The first Octet indicates length (21 is max).
* The string shall be encoded in the UTF-8 format.
* If this optional field is not available, a default value of 0x00 shall be used.
*/
zb_uint8_t message_confirmation_response[ZB_ZCL_MESSAGING_MSG_CONFIRM_RESP_MSG_MAX_SIZE]; /* (O) */
} ZB_PACKED_STRUCT zb_zcl_messaging_message_confirm_payload_t;
/** @ref ZB_ZCL_MESSAGING_SRV_CMD_CANCEL_ALL_MESSAGES "CancelAllMessages" command payload
* @see SE spec, subclause D.5.2.3.4.2
*/
typedef ZB_PACKED_PRE struct zb_zcl_messaging_cancel_all_message_payload_s
{
/** A UTC Time field to indicate the date/time at which all existing display
* messages should be cleared.
*/
zb_uint32_t implementation_date; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_messaging_cancel_all_message_payload_t;
/** @ref ZB_ZCL_MESSAGING_CLI_CMD_GET_MESSAGE_CANCELLATION "GetMessageCancellation" command payload
* @see SE spec, subclause D.5.3.3.3.2
*/
typedef ZB_PACKED_PRE struct zb_zcl_messaging_get_message_cancellation_payload_s
{
/** UTC Timestamp indicating the earliest implementation time of a @e CancelAllMessages
* command to be returned.
*/
zb_uint32_t earliest_implementation_time; /* (M) */
} ZB_PACKED_STRUCT zb_zcl_messaging_get_message_cancellation_payload_t;
/** Check if some size in range of variable size of specified payload. */
#define ZB_ZCL_MESSAGING_MSG_CONFIRM_PAYLOAD_SIZE_IS_VALID(size) \
((size) >= sizeof(zb_zcl_messaging_message_confirm_payload_t) - \
ZB_SIZEOF_FIELD(zb_zcl_messaging_message_confirm_payload_t, message_confirmation_control) -\
ZB_SIZEOF_FIELD(zb_zcl_messaging_message_confirm_payload_t, message_confirmation_response))
typedef enum zb_zcl_messaging_response_type_e {
ZB_ZCL_MESSAGING_RESPONSE_TYPE_NORMAL,
ZB_ZCL_MESSAGING_RESPONSE_TYPE_PROTECTED,
ZB_ZCL_MESSAGING_RESPONSE_TYPE_NOT_FOUND,
} zb_zcl_messaging_response_type_t;
/** According to SE spec, server could send following responses to
* @ref ZB_ZCL_MESSAGING_CLI_CMD_GET_LAST_MESSAGE "GetLastMessage" command:
* <ul>
* <li>
* \b NOT_FOUND as default response
* </li>
* <li>
* \b DisplayMessage command
* </li>
* <li>
* \b DisplayProtectedMessage command
* </li>
* </ul>
*/
typedef struct zb_zcl_messaging_get_last_message_response_s {
zb_zcl_messaging_response_type_t resp_type;
union {
zb_zcl_messaging_display_message_payload_t display_message;
zb_zcl_messaging_display_message_payload_t display_protected_message;
} resp;
} zb_zcl_messaging_get_last_message_response_t;
/** @ref zb_zcl_messaging_get_last_message_response_t initializer */
#define ZB_ZCL_MESSAGING_GET_LAST_MESSAGE_RESPONSE_INIT \
(zb_zcl_messaging_get_last_message_response_t) \
{ \
.resp_type = ZB_ZCL_MESSAGING_RESPONSE_TYPE_NOT_FOUND, \
.resp.display_message = ZB_ZCL_MESSAGING_DISPLAY_MSG_PAYLOAD_INIT, \
}
/** @ref zb_zcl_messaging_message_confirm_payload_t initializer */
#define ZB_ZCL_MESSAGING_MSG_CONFIRM_PAYLOAD_INIT \
(zb_zcl_messaging_message_confirm_payload_t) \
{\
.message_confirmation_response = {0x00} \
}
/** Function for send @ref ZB_ZCL_MESSAGING_CLI_CMD_GET_LAST_MESSAGE "GetLastMessage" command
* @n On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_MESSAGING_GET_LAST_MSG_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Example of sending ZB_ZCL_MESSAGING_CLI_CMD_GET_LAST_MESSAGE "GetLastMessage" command
*/
void zb_zcl_messaging_send_get_last_msg(zb_uint8_t param,
const zb_addr_u *dst_addr,
zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep,
zb_uint8_t src_ep,
zb_callback_t cb);
/** Function for send @ref ZB_ZCL_MESSAGING_SRV_CMD_DISPLAY_MESSAGE "DisplayMessage" command.
* On sender's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with @ref ZB_ZCL_MESSAGING_GET_LAST_MSG_CB_ID
* callback id on reception of @ref ZB_ZCL_MESSAGING_CLI_CMD_GET_LAST_MESSAGE "GetLastMessage" command.
* @n On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_MESSAGING_DISPLAY_MSG_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_messaging_display_message_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
* @par Usage
* @n Handle @ref ZB_ZCL_MESSAGING_CLI_CMD_GET_LAST_MESSAGE "GetLastMessage" command
*/
void zb_zcl_messaging_send_display_msg(zb_uint8_t param,
const zb_addr_u *dst_addr,
zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep,
zb_uint8_t src_ep,
const zb_zcl_messaging_display_message_payload_t *payload,
zb_callback_t cb);
/** Function for send @ref ZB_ZCL_MESSAGING_CLI_CMD_MESSAGE_CONFIRMATION "MessageConfirmation" command
* On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_MESSAGING_MSG_CONFIRMATION_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_messaging_message_confirm_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
*/
void zb_zcl_messaging_send_msg_confirmation(zb_uint8_t param,
const zb_addr_u *dst_addr,
zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep,
zb_uint8_t src_ep,
const zb_zcl_messaging_message_confirm_payload_t *payload,
zb_callback_t cb);
/** Function for send @ref ZB_ZCL_MESSAGING_SRV_CMD_CANCEL_MESSAGE "CancelMessage" command
* On receiver's side callback ZCL device callback @ref ZB_ZCL_REGISTER_DEVICE_CB will be called with
* @ref ZB_ZCL_MESSAGING_CANCEL_MSG_CB_ID callback id.
* @param param - Reference to buffer.
* @param dst_addr - Address of the device to send command to.
* @param dst_addr_mode - Address mode for dst_addr.
* @param dst_ep - Destination endpoint.
* @param src_ep - Current endpoint.
* @param payload - Packet payload (@ref zb_zcl_messaging_cancel_message_payload_t).
* @param cb - Callback which should be called when the ZCL stack receives APS ack.
*/
void zb_zcl_messaging_send_cancel_msg(zb_uint8_t param,
const zb_addr_u *dst_addr,
zb_aps_addr_mode_t dst_addr_mode,
zb_uint8_t dst_ep,
zb_uint8_t src_ep,
const zb_zcl_messaging_cancel_message_payload_t *payload,
zb_callback_t cb);
/** Macro for call @ref zb_zcl_messaging_send_get_last_msg function */
#define ZB_ZCL_MESSAGING_SEND_GET_LAST_MSG(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep) \
zb_zcl_messaging_send_get_last_msg(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, NULL) \
/** Macro for call @ref zb_zcl_messaging_send_display_msg function */
#define ZB_ZCL_MESSAGING_SEND_DISPLAY_MSG(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload) \
zb_zcl_messaging_send_display_msg(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_zcl_messaging_send_msg_confirmation function */
#define ZB_ZCL_MESSAGING_SEND_MSG_CONFIRMATION(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload) \
zb_zcl_messaging_send_msg_confirmation(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** Macro for call @ref zb_zcl_messaging_send_cancel_msg function */
#define ZB_ZCL_MESSAGING_SEND_CANCEL_MSG(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload) \
zb_zcl_messaging_send_cancel_msg(_param, _dst_addr, _addr_mode, \
_dst_ep, _src_ep, _payload, NULL)
/** @cond internals_doc */
void zb_zcl_messaging_init_server(void);
void zb_zcl_messaging_init_client(void);
#define ZB_ZCL_CLUSTER_ID_MESSAGING_SERVER_ROLE_INIT zb_zcl_messaging_init_server
#define ZB_ZCL_CLUSTER_ID_MESSAGING_CLIENT_ROLE_INIT zb_zcl_messaging_init_client
/** @endcond */ /* internal_doc */
/** @} */ /* ZB_ZCL_MESSAGING_COMMANDS */
/** @} */ /* ZCL Messaging cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
#endif /* ZB_ZCL_MESSAGING_H_ */

View File

@@ -0,0 +1,299 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Meter Identification cluster definitions
*/
#ifndef ZB_ZCL_METER_IDENTIFICATION_H
#define ZB_ZCL_METER_IDENTIFICATION_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/* Cluster ZB_ZCL_CLUSTER_ID_METER_IDENTIFICATION */
/** @addtogroup ZB_ZCL_METER_IDENTIFICATION
* @{
* @name Meter Identification cluster attributes
* @{
*/
/** @brief Meter Identification server attributes identifiers
@see ZCL spec, subclause 3.18.2.1
*/
enum zb_zcl_meter_identification_attr_e
{
/* (M) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_COMPANY_NAME = 0x0000, /**< @e CompanyName is a ZCL Octet String field capable
* of storing up to 16 character string (the first
* Octet indicates length) encoded in the UTF-8 format.
* Company Name defines the meter manufacturer name,
* decided by manufacturer
*/
/* (M) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_METER_TYPE_ID = 0x0001, /**< @e MeterTypeID defines the Meter installation features,
* decided by manufacturer.
*/
/* (M) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_DATA_QUALITY_ID = 0x0004, /**< @e DataQualityID defines the Meter Simple Metering
* information certification type, decided by manufacturer.
*/
/* (O) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_CUSTOMER_NAME = 0x0005, /**< @e CustomerName is a ZCL Character String field capable
* of storing up to 16 character string (the first Octet
* indicates length) encoded in the ASCII format.
*/
/* (O) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_MODEL = 0x0006, /**< @e Model is a ZCL Octet String field capable of storing
* up to 16 character string (the first Octet indicates length)
* encoded in the UTF-8 format. @e Model defines the meter model
* name, decided by manufacturer.
*/
/* (O) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_PART_NUMBER = 0x0007, /**< @e PartNumber is a ZCL Octet String field capable of storing
* up to 16 character string (the first Octet indicates length)
* encoded in the UTF-8 format. @e PartNumber defines the meter part
* number, decided by manufacturer.
*/
/* (O) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_PRODUCT_REVISION = 0x0008, /**< @e ProductRevision is a ZCL Octet String field capable
* of storing up to 6 character string (the first Octet
* indicates length) encoded in the UTF-8 format.
* @e ProductRevision defines the meter revision code,
* decided by manufacturer.
*/
/* (O) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_SOFTWARE_REVISION = 0x000A, /**< @e SoftwareRevision is a ZCL Octet String field capable
* of storing up to 6 character string (the first Octet indicates
* length) encoded in the UTF-8 format. SoftwareRevision defines
* the meter software revision code, decided by manufacturer.
*/
/* (O) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_UTILITY_NAME = 0x000B, /**< @e UtilityName is a ZCL Character String field capable of
* storing up to 16 character string (the first Octet indicates
* length) encoded in the ASCII format.
*/
/* (M) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_POD = 0x000C, /**< @e POD (Point of Delivery) is a ZCL Character String field
* capable of storing up to 16 character string (the first Octet
* indicates length) encoded in the ASCII format. POD is the unique
* identification ID of the premise connection point. It is also a
* contractual information known by the clients and indicated in the bill.
*/
/* (M) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_AVAILABLE_POWER = 0x000D, /**< @e AvailablePower represents the @e InstantaneousDemand that
* can be distributed to the customer (e.g., @e 3.3KW power)
* without any risk of overload. The Available Power SHALL use
* the same formatting conventions as the one used in the simple
* metering cluster formatting attribute set for the
* @e InstantaneousDemand attribute, i.e.,
* the @e UnitOfMeasure and @e DemandFormatting.
*/
/* (M) */
ZB_ZCl_ATTR_METER_IDENTIFICATION_POWER_THRESHOLD = 0x000E /**< @e PowerThreshold represents a threshold of @e InstantaneousDemand
* distributed to the customer (e.g., 4.191KW) that will lead to an
* imminent risk of overload.
*/
};
/** @ref ZB_ZCl_ATTR_METER_IDENTIFICATION_METER_TYPE_ID "MeterTypeID" attribute values
* @see ZCL spec, subclause 3.18.2.1.2
*/
typedef enum zb_zcl_meter_identification_meter_type_e
{
ZB_ZCL_METER_TYPE_UTILITY_PRIMARY = 0x0000, /**< Utility Primary Meter */
ZB_ZCL_METER_TYPE_UTILITY_PRODUCTION = 0x0001, /**< Utility Production Meter */
ZB_ZCL_METER_TYPE_UTILITY_SECONDARY = 0x0002, /**< Utility Secondary Meter */
ZB_ZCL_METER_TYPE_PRIVATE_PRIMARY = 0x0100, /**< Private Primary Meter */
ZB_ZCL_METER_TYPE_PRIVATE_PRODUCTION = 0x0101, /**< Private Production Meter */
ZB_ZCL_METER_TYPE_PRIVATE_SECONDARY = 0x0102, /**< Private Secondary Meters */
ZB_ZCL_METER_TYPE_GENERIC = 0x0110 /**< Generic Meter */
} zb_zcl_meter_identification_meter_type_t;
/** @ref ZB_ZCl_ATTR_METER_IDENTIFICATION_DATA_QUALITY_ID "DataQualityID" attribute values
* @see ZCL spec, subclause 3.18.2.1.3
*/
typedef enum zb_zcl_meter_identification_data_quality_e
{
ZB_ZCL_DATA_QUALITY_ALL_DATA_CERTIFIED = 0x0000, /**< All Data Certified */
ZB_ZCL_DATA_QUALITY_ONLY_INSTANTANEOUS_POWER_NOT_CERTIFIED = 0x0001, /**< Only Instantaneous Power not Certified */
ZB_ZCL_DATA_QUALITY_ONLY_CUMULATED_CONSUMPTION_NOT_CERTIFIED = 0x0002, /**< Only Cumulated Consumption not Certified */
ZB_ZCL_DATA_QUALITY_NOT_CERTIFIED_DATA = 0x0003 /**< Not Certified data */
} zb_zcl_meter_identification_data_quality_t;
/** @brief Default value for Meter Identification cluster revision global attribute */
#define ZB_ZCL_METER_IDENTIFICATION_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief Default value for Company Name attribute */
#define ZB_ZCl_ATTR_METER_IDENTIFICATION_COMPANY_NAME_DEFAULT_VALUE { 0 }
/** @brief Default value for Meter Type ID attribute */
#define ZB_ZCl_ATTR_METER_IDENTIFICATION_METER_TYPE_ID_DEFAULT_VALUE 0
/** @brief Default value for Data Quality ID attribute */
#define ZB_ZCl_ATTR_METER_IDENTIFICATION_DATA_QUALITY_ID_DEFAULT_VALUE 0
/** @brief Default value for POD (Point of Delivery) attribute */
#define ZB_ZCl_ATTR_METER_IDENTIFICATION_POD_DEFAULT_VALUE { 0 }
/** @brief Default value for Available Power attribute */
#define ZB_ZCl_ATTR_METER_IDENTIFICATION_AVAILABLE_POWER_DEFAULT_VALUE ZB_INIT_UINT24(0,0)
/** @brief Default value for Power Threshold attribute */
#define ZB_ZCl_ATTR_METER_IDENTIFICATION_POWER_THRESHOLD_DEFAULT_VALUE ZB_INIT_UINT24(0, 0)
/** @brief Max length of Company Name attribute */
#define ZB_ZCl_ATTR_METER_IDENTIFICATION_COMPANY_NAME_MAX_LENGTH 16
/** @brief Max length of POD (Point of Delivery) attribute */
#define ZB_ZCl_ATTR_METER_IDENTIFICATION_POD_MAX_LENGTH 16
/** @brief Declare attribute list for Thermostat cluster
@param attr_list - attribute list name
@param company_name - pointer to variable to store Company Name attribute value
@param meter_type_id - pointer to variable to store Meter Type ID attribute value
@param data_quality_id - pointer to variable to store Data Quality ID attribute value
@param pod - pointer to variable to store POD (Point of Delivery) attribute value
@param available_power - pointer to variable to store Available Power attribute value
@param power_threshold - pointer to variable to store Power Threshold attribute value
*/
#define ZB_ZCL_DECLARE_METER_IDENTIFICATION_ATTRIB_LIST(attr_list, \
company_name, meter_type_id, data_quality_id, \
pod, available_power, power_threshold) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_METER_IDENTIFICATION) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_METER_IDENTIFICATION_COMPANY_NAME, (company_name)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_METER_IDENTIFICATION_METER_TYPE_ID, (meter_type_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_METER_IDENTIFICATION_DATA_QUALITY_ID, (data_quality_id)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_METER_IDENTIFICATION_POD, (pod)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_METER_IDENTIFICATION_AVAILABLE_POWER, (available_power)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_METER_IDENTIFICATION_POWER_THRESHOLD, (power_threshold)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @} */ /* Meter Identification cluster attributes */
/*! @name Meter Identification cluster commands
@{
*/
/*! @} */ /* Meter Identification cluster commands */
/*!
@cond internals_doc
@internal @name Meter Identification cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_METER_IDENTIFICATION_COMPANY_NAME(data_ptr) \
{ \
ZB_ZCl_ATTR_METER_IDENTIFICATION_COMPANY_NAME, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_METER_IDENTIFICATION_METER_TYPE_ID(data_ptr) \
{ \
ZB_ZCl_ATTR_METER_IDENTIFICATION_METER_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_METER_IDENTIFICATION_DATA_QUALITY_ID(data_ptr) \
{ \
ZB_ZCl_ATTR_METER_IDENTIFICATION_DATA_QUALITY_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_METER_IDENTIFICATION_POD(data_ptr) \
{ \
ZB_ZCl_ATTR_METER_IDENTIFICATION_POD, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_METER_IDENTIFICATION_AVAILABLE_POWER(data_ptr) \
{ \
ZB_ZCl_ATTR_METER_IDENTIFICATION_AVAILABLE_POWER, \
ZB_ZCL_ATTR_TYPE_S24, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_METER_IDENTIFICATION_POWER_THRESHOLD(data_ptr) \
{ \
ZB_ZCl_ATTR_METER_IDENTIFICATION_POWER_THRESHOLD, \
ZB_ZCL_ATTR_TYPE_S24, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in Meter Identification cluster */
#define ZB_ZCL_METER_IDENTIFICATION_REPORT_ATTR_COUNT 0
/*! @}
@endcond */ /* Thermostat cluster internals */
/*! @} */ /* ZB_ZCL_METER_IDENTIFICATION */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_meter_identification_init_server(void);
void zb_zcl_meter_identification_init_client(void);
#define ZB_ZCL_CLUSTER_ID_METER_IDENTIFICATION_SERVER_ROLE_INIT zb_zcl_meter_identification_init_server
#define ZB_ZCL_CLUSTER_ID_METER_IDENTIFICATION_CLIENT_ROLE_INIT zb_zcl_meter_identification_init_client
#endif /* ZB_ZCL_METER_IDENTIFICATION_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,435 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Multistate Input cluster definitions
*/
#ifndef ZB_ZCL_MULTISTATE_INPUT_H
#define ZB_ZCL_MULTISTATE_INPUT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_MULTISTATE_INPUT
* @{
* @details
* The Multistate Input cluster provides an interface for reading the value
* of a multistate measurement and accessing various characteristics of that
* measurement. No cluster specific commands are received or generated.
*/
/* Cluster ZB_ZCL_CLUSTER_ID_MULTI_INPUT */
/** @defgroup ZB_ZCL_MULTISTATE_INPUT_ATTRS_GROUP Multistate Input cluster attributes
* @{
*/
/** @brief Multistate Input cluster attribute identifiers
* @see ZCL spec, Multistate Input (Basic) Cluster 3.14.8.4.2
*/
enum zb_zcl_multi_input_attr_e
{
/** @brief StateText attribute, ZCL spec 3.14.11.18 */
ZB_ZCL_ATTR_MULTI_INPUT_STATE_TEXT_ID = 0x000e,
/** @brief Description attribute, ZCL spec 3.14.11.4 */
ZB_ZCL_ATTR_MULTI_INPUT_DESCRIPTION_ID = 0x001c,
/** @brief NumberOfStates attribute, ZCL spec 3.14.11.17 */
ZB_ZCL_ATTR_MULTI_INPUT_NUM_OF_STATES_ID = 0x004a,
/** @brief OutOfService attribute, ZCL spec 3.14.11.1 */
ZB_ZCL_ATTR_MULTI_INPUT_OUT_OF_SERVICE_ID = 0x0051,
/** @brief PresentValue attribute, ZCL spec 3.14.11.2 */
ZB_ZCL_ATTR_MULTI_INPUT_PRESENT_VALUE_ID = 0x0055,
/** @brief Reliability attribute, ZCL spec 3.14.11.9 */
ZB_ZCL_ATTR_MULTI_INPUT_RELIABILITY_ID = 0x0067,
/** @brief StatusFlags attribute, ZCL spec 3.14.11.3 */
ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID = 0x006f,
/** @brief ApplicationType attribute, ZCL spec 3.14.11.19 */
ZB_ZCL_ATTR_MULTI_INPUT_APPLICATION_TYPE_ID = 0x0100,
};
/**
* @brief StatusFlags attribute values.
* @see ZCL spec 3.14.11.3 for details.
*/
enum zb_zcl_multi_input_status_flags_value_e
{
ZB_ZCL_MULTI_INPUT_STATUS_FLAG_NORMAL = 0x00, /**< Normal (default) state. */
ZB_ZCL_MULTI_INPUT_STATUS_FLAG_IN_ALARM = 0x01, /**< In alarm bit. */
ZB_ZCL_MULTI_INPUT_STATUS_FLAG_FAULT = 0x02, /**< Fault bit. */
ZB_ZCL_MULTI_INPUT_STATUS_FLAG_OVERRIDDEN = 0x04, /**< Overridden bit. */
ZB_ZCL_MULTI_INPUT_STATUS_FLAG_OUT_OF_SERVICE = 0x08, /**< Out of service bit. */
};
/** @brief Reliability attribute values.
* @see ZCL spec 3.14.11.9 for details.
*/
enum zb_zcl_multi_input_reliability_value_e
{
ZB_ZCL_MULTI_INPUT_RELIABILITY_NO_FAULT_DETECTED = 0x00,
ZB_ZCL_MULTI_INPUT_RELIABILITY_NO_SENSOR = 0x01,
ZB_ZCL_MULTI_INPUT_RELIABILITY_OVER_RANGE = 0x02,
ZB_ZCL_MULTI_INPUT_RELIABILITY_UNDER_RANGE = 0x03,
ZB_ZCL_MULTI_INPUT_RELIABILITY_OPEN_LOOP = 0x04,
ZB_ZCL_MULTI_INPUT_RELIABILITY_SHORTED_LOOP = 0x05,
ZB_ZCL_MULTI_INPUT_RELIABILITY_NO_OUTPUT = 0x06,
ZB_ZCL_MULTI_INPUT_RELIABILITY_UNRELIABLE_OTHER = 0x07,
ZB_ZCL_MULTI_INPUT_RELIABILITY_PROCESS_ERROR = 0x08,
ZB_ZCL_MULTI_INPUT_RELIABILITY_MULTI_STATE_FAULT = 0x09,
ZB_ZCL_MULTI_INPUT_RELIABILITY_CONFIGURATION_ERROR = 0x0a,
};
/** @defgroup ZB_ZCL_MULTISTATE_INPUT_APPLICATION_TYPES Multistate Input cluster application types
* @{
* @details
* The ApplicationType attribute indicates the specific application usage
* for the cluster. ApplicationType is subdivided into Group, Type and
* an Index number, as follows:
*
* Group = Bits 24 to 31
* An indication of the cluster this attribute is part of. Multistate Input
* clusters have Group = 0x0d.
*
* Type = Bits 16 to 23
* The physical quantity that the PresentValue attribute of the cluster
* represents.
*
* Index = Bits 0 to 15
* The specific application usage of the cluster.
*/
#define ZB_ZCL_MI_GROUP_ID 0x0d
/* TODO: Consider adding common macro for all application types */
#define ZB_ZCL_MI_SET_APP_TYPE_WITH_ID(_type, _id) ((ZB_ZCL_MI_GROUP_ID << 24) | ((_type & 0xff) << 16) | (_id & 0xffff))
/** @brief Type values for Multistate Input cluster applications
* @see ZCL spec 3.14.11.19.7
*/
enum zb_zcl_mi_application_types_e
{
ZB_ZCL_MI_APP_TYPE_APP_DOMAIN_HVAC,
/* Types 0x01 to 0xfe are reserved */
ZB_ZCL_MI_APP_TYPE_OTHER = 0xff
};
/** @defgroup ZB_ZCL_MI_APP_DOMAIN_HVAC_TYPE Multistate Input cluster representing HVAC domain
* @{
*/
/** @brief Values for 'Application Domain HVAC' type of Multistate Input cluster
* @see ZCL spec 3.14.11.19.7.1
* @note
* This application domain is specific for Heating, Ventilation, Air
* Conditioning (HVAC) type of applications and the enumeration lists possible
* application usage states.
*/
enum zb_zcl_mi_app_domain_hvac_e
{
/** @brief On, Off, Auto states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_0 = ZB_ZCL_MI_SET_APP_TYPE_WITH_ID(ZB_ZCL_MI_APP_TYPE_APP_DOMAIN_HVAC, 0x0000),
/** @brief Off, Low, Medium, High states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_1,
/** @brief Auto, Heat, Cool, Off, Emergency Heat, Fan Only, Max Heat states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_2,
/** @brief Occupied, Unoccupied, Standby, Bypass states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_3,
/** @brief Inactive, Active, Hold states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_4,
/** @brief
* Auto, Warm-up, Water Flush, Autocalibration, Shutdown Open, Shutdown
* Closed, Low Limit, Test and Balance states
*/
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_5,
/** @brief Off, Auto, Heat Control, Heat Only, Cool Only, Fan Only states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_6,
/** @brief High, Normal, Low states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_7,
/** @brief Occupied, Unoccupied, Startup, Shutdown states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_8,
/** @brief Night, Day, Hold states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_9,
/** @brief Off, Cool, Heat, Auto, Emergency Heat states */
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_10,
/** @brief
* Shutdown Closed, Shutdown Open, Satisfied, Mixing, Cooling, Heating,
* Supplemental Heat states
*/
ZB_ZCL_MI_APP_DOMAIN_HVAC_STATES_GROUP_11,
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_MI_APP_DOMAIN_HVAC_OTHER = ZB_ZCL_MI_SET_APP_TYPE_WITH_ID(ZB_ZCL_MI_APP_TYPE_APP_DOMAIN_HVAC, 0xffff)
};
/** @} */ /* end of ZB_ZCL_MI_APP_DOMAIN_HVAC_TYPE group */
/** @} */ /* end of ZB_ZCL_MULTISTATE_INPUT_APPLICATION_TYPES */
/** @brief Default value for Multistate Input cluster revision global attribute */
#define ZB_ZCL_MULTI_INPUT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for Description attribute */
#define ZB_ZCL_MULTI_INPUT_DESCRIPTION_DEFAULT_VALUE {0}
/** @brief Default value for NumberOfStates attribute */
#define ZB_ZCL_MULTI_INPUT_NUM_OF_STATES_DEFAULT_VALUE ((zb_uint16_t)0x0000u)
/** @brief Default value for OutOfService attribute */
#define ZB_ZCL_MULTI_INPUT_OUT_OF_SERVICE_DEFAULT_VALUE ZB_FALSE
/** @brief Default value for Reliability attribute */
#define ZB_ZCL_MULTI_INPUT_RELIABILITY_DEFAULT_VALUE ZB_ZCL_MULTI_INPUT_RELIABILITY_NO_FAULT_DETECTED
/** @brief Default value for StatusFlags attribute */
#define ZB_ZCL_MULTI_INPUT_STATUS_FLAGS_DEFAULT_VALUE ZB_ZCL_MULTI_INPUT_STATUS_FLAG_NORMAL
/** @brief StatusFlags attribute minimum value */
#define ZB_ZCL_MULTI_INPUT_STATUS_FLAGS_MIN_VALUE 0
/** @brief StatusFlags attribute maximum value */
#define ZB_ZCL_MULTI_INPUT_STATUS_FLAGS_MAX_VALUE 0x0f
/** @cond internals_doc */
/** @name Multistate Input cluster internals
* Internal structures for Multistate Input cluster
* @{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_INPUT_DESCRIPTION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_INPUT_DESCRIPTION_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_INPUT_NUM_OF_STATES_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_INPUT_NUM_OF_STATES_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_INPUT_OUT_OF_SERVICE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_INPUT_OUT_OF_SERVICE_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_INPUT_PRESENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_INPUT_PRESENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_INPUT_RELIABILITY_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_INPUT_RELIABILITY_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_INPUT_APPLICATION_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_INPUT_APPLICATION_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** Number of attributes mandatory for reporting in Multistate Input cluster */
#define ZB_ZCL_MULTI_INPUT_REPORT_ATTR_COUNT 0
/** @} */
/** @endcond */ /* Multistate Input cluster internals */
/** @brief Declare attribute list for Multistate Input cluster
* @param attr_list - attribute list name
* @param description - pointer to variable storing Description attribute value
* @param num_of_states - pointer to variable storing NumberOfStates attribute value
* @param out_of_service - pointer to variable storing OutOfService attribute value
* @param present_value - pointer to variable storing PresentValue attribute value
* @param reliability - pointer to variable storing Reliability attribute value
* @param status_flags - pointer to variable storing StatusFlags attribute value
* @param app_type - pointer to variable storing ApplicationType attribute value
*/
#define ZB_ZCL_DECLARE_MULTI_INPUT_ATTRIB_LIST( \
attr_list, \
description, \
num_of_states, \
out_of_service, \
present_value, \
reliability, \
status_flags, \
app_type) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_MULTI_INPUT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_INPUT_DESCRIPTION_ID, (description)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_INPUT_NUM_OF_STATES_ID, (num_of_states)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_INPUT_OUT_OF_SERVICE_ID, (out_of_service)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_INPUT_PRESENT_VALUE_ID, (present_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_INPUT_RELIABILITY_ID, (reliability)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID, (status_flags)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_INPUT_APPLICATION_TYPE_ID, (app_type)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @} */ /* end of ZB_ZCL_MULTISTATE_INPUT_ATTRS_GROUP group */
/** @defgroup ZB_ZCL_MULTISTATE_INPUT_ATTR_API Multistate Input cluster attribute value manipulation API
* @{
*/
/** @brief Set normal operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_MULTI_INPUT_SET_NORMAL_MODE(ep) \
{ \
zb_uint8_t val; \
\
val = ZB_FALSE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_INPUT_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
val = ZB_ZCL_MULTI_INPUT_STATUS_FLAG_NORMAL; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
}
/** @brief Set Out of service operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_MULTI_INPUT_SET_OUT_OF_SERVICE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
val = ZB_TRUE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_INPUT_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_MULTI_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_MULTI_INPUT_STATUS_FLAG_OUT_OF_SERVICE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @brief Set overridden operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_MULTI_INPUT_SET_OVERRIDDEN_MODE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_MULTI_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_MULTI_INPUT_STATUS_FLAG_OVERRIDDEN;\
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @brief Set fault status flag
* @param ep - endpoint number
*/
#define ZB_ZCL_MULTI_INPUT_SET_FAULT_STATUS(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_MULTI_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_MULTI_INPUT_STATUS_FLAG_FAULT; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_INPUT, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_INPUT_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @} */ /* end of ZB_ZCL_MULTISTATE_INPUT_ATTR_API group */
/** @} */ /* ZCL Multistate Input cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_multi_input_init_server(void);
void zb_zcl_multi_input_init_client(void);
#define ZB_ZCL_CLUSTER_ID_MULTI_INPUT_SERVER_ROLE_INIT zb_zcl_multi_input_init_server
#define ZB_ZCL_CLUSTER_ID_MULTI_INPUT_CLIENT_ROLE_INIT zb_zcl_multi_input_init_client
#endif /* ZB_ZCL_MULTISTATE_INPUT_H */

View File

@@ -0,0 +1,489 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Multistate Value cluster definitions */
#ifndef ZB_ZCL_MULTISTATE_VALUE_H
#define ZB_ZCL_MULTISTATE_VALUE_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_MULTISTATE_VALUE
* @{
* @details
* The Multistate Value (Basic) cluster provides an interface for setting
* a multistate value, typically used as a control system parameter, and
* accessing characteristics of that value.
*/
/* ZB_ZCL_CLUSTER_ID_MULTI_VALUE = 0x000e defined in zb_zcl_common.h ZCL spec 3.14.4 */
/** @name Multistate Value cluster attributes
* @{
*/
/** @brief Multistate Value cluster attribute identifiers
* @see ZCL spec, Multistate Value (Basic) Cluster 3.14.4.4.2
*/
enum zb_zcl_multi_value_attr_e
{
// TODO: Support Text/NumberOfs attribute
// @brief Text attribute, ZCL spec 3.14.11.18
// ZB_ZCL_ATTR_MULTI_VALUE_STATE_TEXT_ID = 0x000e,
/** @brief Description attribute, ZCL spec 3.14.11.4 */
ZB_ZCL_ATTR_MULTI_VALUE_DESCRIPTION_ID = 0x001c,
// TODO: Support Text/NumberOfs attribute
// @brief NumberOfs attribute, ZCL spec 3.14.11.17
// ZB_ZCL_ATTR_MULTI_VALUE_NUMBER_OF_STATE_ID = 0x0051,
/** @brief OutOfService attribute, ZCL spec 3.14.11.1 */
ZB_ZCL_ATTR_MULTI_VALUE_OUT_OF_SERVICE_ID = 0x0051,
/** @brief PresentValue attribute, ZCL spec 3.14.11.2 */
ZB_ZCL_ATTR_MULTI_VALUE_PRESENT_VALUE_ID = 0x0055,
// TODO: Support PriorityArray attribute
// /** @brief PriorityArray attribute, ZCL spec 3.14.11.6 */
// ZB_ZCL_ATTR_MULTI_VALUE_PRIORITY_ARRAY_ID = 0x0057,
/** @brief Reliability attribute, ZCL spec 3.14.11.9 */
ZB_ZCL_ATTR_MULTI_VALUE_RELIABILITY_ID = 0x0067,
/** @brief Reliability attribute, ZCL spec 3.14.11.7 */
ZB_ZCL_ATTR_MULTI_VALUE_RELINQUISH_DEFAULT_ID = 0x0068,
/** @brief StatusFlags attribute, ZCL spec 3.14.11.3 */
ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID = 0x006f,
/** @brief ApplicationType attribute, ZCL spec 3.14.11.19 */
ZB_ZCL_ATTR_MULTI_VALUE_APPLICATION_TYPE_ID = 0x0100,
};
/**
* @brief StatusFlags attribute values.
* @see ZCL spec 3.14.11.3 for details.
*/
enum zb_zcl_multi_value_status_flags_value_e
{
ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_NORMAL = 0x00, /**< Normal (default) . */
ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_IN_ALARM = 0x01, /**< In alarm bit. */
ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_FAULT = 0x02, /**< Fault bit. */
ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_OVERRIDDEN = 0x04, /**< Overridden bit. */
ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_OUT_OF_SERVICE = 0x08, /**< Out of service bit. */
};
/** @brief Reliability attribute values.
* @see ZCL spec 3.14.11.9 for details.
*/
enum zb_zcl_multi_value_reliability_value_e
{
ZB_ZCL_MULTI_VALUE_RELIABILITY_NO_FAULT_DETECTED = 0x00, /**< No fault detected */
ZB_ZCL_MULTI_VALUE_RELIABILITY_NO_SENSOR = 0x01, /**< No sensor */
ZB_ZCL_MULTI_VALUE_RELIABILITY_OVER_RANGE = 0x02, /**< Over range */
ZB_ZCL_MULTI_VALUE_RELIABILITY_UNDER_RANGE = 0x03, /**< Under range */
ZB_ZCL_MULTI_VALUE_RELIABILITY_OPEN_LOOP = 0x04, /**< Open loop */
ZB_ZCL_MULTI_VALUE_RELIABILITY_SHORTED_LOOP = 0x05, /**< Shorted loop */
ZB_ZCL_MULTI_VALUE_RELIABILITY_NO_OUTPUT = 0x06, /**< No output */
ZB_ZCL_MULTI_VALUE_RELIABILITY_UNRELIABLE_OTHER = 0x07, /**< Unreliable other */
ZB_ZCL_MULTI_VALUE_RELIABILITY_PROCESS_ERROR = 0x08, /**< Process error */
ZB_ZCL_MULTI_VALUE_RELIABILITY_MULTI_STATE_FAULT = 0x09, /**< Mutlistate fault */
ZB_ZCL_MULTI_VALUE_RELIABILITY_CONFIGURATION_ERROR = 0x0a, /**< Configuration error */
};
/** @name Multistate Value cluster application types
* @{
* @details
* The ApplicationType attribute indicates the specific application usage
* for the cluster. ApplicationType is subdivided into Group, Type and
* an Index number, as follows:
*
* - Group = Bits 24 to 31
* An indication of the cluster this attribute is part of. Multistate Value
* clusters have Group = 0x0d.
*
* - Type = Bits 16 to 23
* The physical quantity that the PresentValue attribute of the cluster
* represents.
*
* - Index = Bits 0 to 15
* The specific application usage of the cluster.
*/
#define ZB_ZCL_MV_GROUP_ID 0x0d
#define ZB_ZCL_MV_SET_APP_TYPE_WITH_ID(_type, _id) ((ZB_ZCL_MV_GROUP_ID << 24) | ((_type & 0xff) << 16) | (_id & 0xffff))
/** @brief Type values for Multistate Value cluster applications
* @see ZCL spec 3.16.11.19.9
*/
enum zb_zcl_mv_application_types_e
{
ZB_ZCL_MV_APP_TYPE_APP_DOMAIN_HVAC = 0x0000, /**< Application Domain HVAC */
/* All other group values are currently reserved. */
};
enum zb_zcl_mv_app_domain_hvac_e
{
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_0 /**< On, Off, Auto state */
= ZB_ZCL_MV_SET_APP_TYPE_WITH_ID(ZB_ZCL_MV_APP_TYPE_APP_DOMAIN_HVAC, 0x0000),
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_1, /**< Off, Low, Medium, High state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_2, /**< Auto, Heat, Cool, Off, Emergency Heat,
Fan Only, Max Heat state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_3, /**< Occupied, Unoccupied, Standby, Bypass state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_4, /**< Inactive, Active, Hold state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_5, /**< Auto, Warm-up, Water Flush, Autocalibration,
Shutdown Open, Shutdown Closed, Low Limit,
Test and Balance state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_6, /**< Off, Auto, Heat Control, Heat Only, Cool Only,
Fan Only state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_7, /**< High, Normal, Low state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_8, /**< Occupied, Unoccupied, Startup, Shutdown state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_9, /**< Night, Day, Hold state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_10, /**< Off, Cool, Heat, Auto, Emergency Heat state */
ZB_ZCL_MV_APP_DOMAIN_HVAC_STATES_GROUP_11, /**< Shutdown Closed, Shutdown Open, Satisfied,
Mixing, Cooling, Heating,
Supplemental Heat state */
/* 0x0200 to 0xfffe are Vendor defined */
ZB_ZCL_MV_APP_DOMAIN_HVAC_OTHER /**< Other */
= ZB_ZCL_MV_SET_APP_TYPE_WITH_ID(ZB_ZCL_MV_APP_TYPE_APP_DOMAIN_HVAC, 0xffff),
};
/** @} */ /* end of ZB_ZCL_MULTI_VALUE_APP_TYPE */
/** @brief Default value for Multistate Value cluster revision global attribute */
#define ZB_ZCL_MULTI_VALUE_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for Description attribute */
#define ZB_ZCL_MULTI_VALUE_DESCRIPTION_DEFAULT_VALUE {0}
/** @brief Default value for OutOfService attribute */
#define ZB_ZCL_MULTI_VALUE_OUT_OF_SERVICE_DEFAULT_VALUE ZB_FALSE
/** @brief Default value for Reliability attribute */
#define ZB_ZCL_MULTI_VALUE_RELIABILITY_DEFAULT_VALUE ZB_ZCL_MULTI_VALUE_RELIABILITY_NO_FAULT_DETECTED
/** @brief Default value for StatusFlags attribute */
#define ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_DEFAULT_VALUE ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_NORMAL
/** @brief StatusFlags attribute minimum value */
#define ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_MIN_VALUE 0
/** @brief StatusFlags attribute maximum value */
#define ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_MAX_VALUE 0x0f
/** @cond internals_doc */
/** @name Multistate Value cluster internals
* Internal structures for Multistate Value cluster
* @{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_VALUE_DESCRIPTION_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_VALUE_DESCRIPTION_ID, \
ZB_ZCL_ATTR_TYPE_CHAR_STRING, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_VALUE_OUT_OF_SERVICE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_VALUE_OUT_OF_SERVICE_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_VALUE_PRESENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_VALUE_PRESENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_VALUE_RELIABILITY_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_VALUE_RELIABILITY_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_VALUE_RELINQUISH_DEFAULT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_VALUE_RELINQUISH_DEFAULT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_WRITE_OPTIONAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_MULTI_VALUE_APPLICATION_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_MULTI_VALUE_APPLICATION_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** Number of attributes mandatory for reporting in Multistate Value cluster */
#define ZB_ZCL_MULTI_VALUE_REPORT_ATTR_COUNT 0
/** @} */
/** @endcond */ /* Multistate Value cluster internalstate */
/** @brief Declare attribute list for Multistate Value cluster
* @param attr_list - attribute list name
* @param description - pointer to variable storing Description attribute value
* @param out_of_service - pointer to variable storing OutOfService attribute value
* @param present_value - pointer to variable storing PresentValue attribute value
* @param reliability - pointer to variable storing Reliability attribute value
* @param relinquish_default - pointer to variable storing RelinquishDefault attribute value
* @param status_flags - pointer to variable storing StatusFlags attribute value
* @param app_type - pointer to variable storing ApplicationType attribute value
*/
#define ZB_ZCL_DECLARE_MULTI_VALUE_ATTRIB_LIST(attr_list, \
description, \
out_of_service, \
present_value, \
reliability, \
relinquish_default, \
status_flags, \
app_type) \
\
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_MULTI_VALUE) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_VALUE_DESCRIPTION_ID, (description)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_VALUE_OUT_OF_SERVICE_ID, (out_of_service)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_VALUE_PRESENT_VALUE_ID, (present_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_VALUE_RELIABILITY_ID, (reliability)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_VALUE_RELINQUISH_DEFAULT_ID, (relinquish_default)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID, (status_flags)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_MULTI_VALUE_APPLICATION_TYPE_ID, (app_type)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! Maximum length of Description string field */
#define ZB_ZCL_MULTI_VALUE_DESCRIPTION_MAX_LEN 16
/**
* @brief Multistate Value cluster attributes
*/
typedef struct zb_zcl_multi_value_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_MULTI_VALUE_DESCRIPTION_ID
* @see ZB_ZCL_ATTR_MULTI_VALUE_DESCRIPTION_ID
*/
zb_char_t description[ZB_ZCL_MULTI_VALUE_DESCRIPTION_MAX_LEN + 1];
/** @copydoc ZB_ZCL_ATTR_MULTI_VALUE_OUT_OF_SERVICE_ID
* @see ZB_ZCL_ATTR_MULTI_VALUE_OUT_OF_SERVICE_ID
*/
zb_bool_t out_of_service;
/** @copydoc ZB_ZCL_ATTR_MULTI_VALUE_PRESENT_VALUE_ID
* @see ZB_ZCL_ATTR_MULTI_VALUE_PRESENT_VALUE_ID
*/
zb_single_t present_value;
/** @copydoc ZB_ZCL_ATTR_MULTI_VALUE_RELIABILITY_ID
* @see ZB_ZCL_ATTR_MULTI_VALUE_RELIABILITY_ID
*/
zb_uint8_t reliability;
/** @copydoc ZB_ZCL_ATTR_MULTI_VALUE_RELINQUISH_DEFAULT_ID
* @see ZB_ZCL_ATTR_MULTI_VALUE_RELINQUISH_DEFAULT_ID
*/
zb_single_t relinquish_default;
/** @copydoc ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID
* @see ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID
*/
zb_uint8_t status_flags;
/** @copydoc ZB_ZCL_ATTR_MULTI_VALUE_APPLICATION_TYPE_ID
* @see ZB_ZCL_ATTR_MULTI_VALUE_APPLICATION_TYPE_ID
*/
zb_uint32_t application_type;
} zb_zcl_multi_value_attrs_t;
/** @brief Declare attribute list for Multistate Value cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of @ref zb_zcl_multi_value_attrs_t type
* (containing Multistate Value cluster attributes)
*/
#define ZB_ZCL_DECLARE_MULTI_VALUE_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_MULTI_VALUE_ATTRIB_LIST(attr_list, \
&attrs.description, \
&attrs.out_of_service, \
&attrs.present_value, \
&attrs.reliability, \
&attrs.relinquish_default, \
&attrs.status_flags, \
&attrs.application_type)
/** @} */ /* end of ZB_ZCL_MULTI_VALUE_ATTRSTATE_GROUP group */
/** @name Multistate Value cluster attribute value manipulation API
* @{
*/
/** @brief Set normal operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_MULTI_VALUE_SET_NORMAL_MODE(ep) \
{ \
zb_uint8_t val; \
\
val = ZB_FALSE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_VALUE_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
val = ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_NORMAL; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
}
/** @brief Set Out of service operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_MULTI_VALUE_SET_OUT_OF_SERVICE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
val = ZB_TRUE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_VALUE_OUT_OF_SERVICE_ID, \
&val, ZB_FALSE); \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_MULTI_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_OUT_OF_SERVICE; \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @brief Set overridden operating mode
* @param ep - endpoint number
*/
#define ZB_ZCL_MULTI_VALUE_SET_OVERRIDDEN_MODE(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_MULTI_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_OVERRIDDEN \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @brief Set fault status flag
* @param ep - endpoint number
*/
#define ZB_ZCL_MULTI_VALUE_SET_FAULT_STATUS(ep) \
{ \
zb_zcl_attr_t *attr_desc; \
zb_uint8_t val; \
\
attr_desc = zb_zcl_get_attr_desc_a(ep, ZB_ZCL_CLUSTER_ID_MULTI_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID); \
if (attr_desc) \
{ \
val = *(zb_uint8_t*)attr_desc->data_p | ZB_ZCL_MULTI_VALUE_STATUS_FLAGS_FAULT \
ZB_ZCL_SET_ATTRIBUTE(ep, ZB_ZCL_CLUSTER_ID_MULTI_VALUE, \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_ATTR_MULTI_VALUE_STATUS_FLAGS_ID, \
&val, ZB_FALSE); \
} \
}
/** @} */
/** @} */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_multi_value_init_server(void);
void zb_zcl_multi_value_init_client(void);
#define ZB_ZCL_CLUSTER_ID_MULTI_VALUE_SERVER_ROLE_INIT zb_zcl_multi_value_init_server
#define ZB_ZCL_CLUSTER_ID_MULTI_VALUE_CLIENT_ROLE_INIT zb_zcl_multi_value_init_client
#endif /* ZB_ZCL_MULTISTATE_VALUE_H */

View File

@@ -0,0 +1,330 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Occupancy Sensing definitoins
*/
#ifndef ZB_ZCL_OCCUPANCY_SENSING_H
#define ZB_ZCL_OCCUPANCY_SENSING_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_OCCUPANCY_SENSING
* @{
* @details
* Occupancy Sensing cluster has no cluster-specific command support. Cluster
* attributes can be queried with @ref ZB_ZCL_COMMANDS "common commands".
*/
/*! @name Occupancy Sensing cluster attributes
@{
*/
/*! @brief Occupancy Sensing cluster attribute identifiers
@see ZCL spec, subclause 4.8.2.2
*/
enum zb_zcl_occupancy_sensing_attr_e
{
/** Occupancy attribute identifier */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_ID = 0x0000,
/** Occupancy Sensor Type attribute identifier */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_ID = 0x0001,
/** The OccupancySensorTypeBitmap attribute specifies the types of the occupancy
* sensor. */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_BITMAP_ID = 0x0002,
/** PIROccupiedToUnoccupiedDelay identifier */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_PIR_OCC_TO_UNOCC_DELAY_ID = 0x0010,
/** PIRUnoccupiedToOccupiedDelay identifier */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_DELAY_ID = 0x0011,
/** PIRUnoccupiedToOccupiedThreshold identifier */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_THRESHOLD_ID = 0x0012,
/** The UltrasonicOccupiedToUnoccupiedDelay attribute is 16 bits in length and
* specifies the time delay, in seconds, before the Ultrasonic sensor changes to its
* unoccupied state after the last detection of movement in the sensed area. */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_ULTRASONIC_OCCUPIED_TO_UNOCCUPIED_DELAY_ID = 0x0020,
/** The UltrasonicUnoccupiedToOccupiedDelay attribute is 16 bits in length and
* specifies the time delay, in seconds, before the Ultrasonic sensor changes
* to its occupied state after the detection of movement in the sensed area. */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_DELAY_ID = 0x0021,
/** The UltrasonicUnoccupiedToOccupiedThreshold attribute is 8 bits in length and
* specifies the number of movement detection events that must occur in the period
* UltrasonicUnoccupiedToOccupiedDelay, before the Ultrasonic sensor changes to its
* occupied state. */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_ID = 0x0022,
/** The PhysicalContactOccupiedToUnoccupiedDelay attribute is 16 bits in length and
* specifies the time delay, in seconds, before the physical contact occupancy sensor
* changes to its unoccupied state after detecting the unoccupied event. */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_PHYSICAL_CONTACT_OCCUPIED_TO_UNOCCUPIED_DELAY_ID = 0x0030,
/** The PhysicalContactUnoccupiedToOccupiedDelay attribute is 16 bits in length and
* specifies the time delay, in seconds, before the physical contact sensor changes
* to its occupied state after the detection of the occupied event. */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_DELAY_ID = 0x0031,
/** The PhysicalContactUnoccupiedToOccupiedThreshold attribute is 8 bits in length and
* specifies the number of movement detection events that must occur in the period
* PhysicalContactUnoccupiedToOccupiedDelay, before the PIR sensor changes to its
* occupied state. */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_ID = 0x0032,
/* Parking Sensor, Attributes for device Configuration, 2.5.1 */
/** @cond internals_doc */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_REPORTING_MODE_ID = 0x8001,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_DEBUG_MODE_ID = 0x8002,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_SENSING_INTERVAL_ID = 0x8003,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_MAX_NBR_CONFIRM_PINGS_ID = 0x8004,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_CONFIRM_PING_DELAY_ID = 0x8005,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_NBR_CONFIRM_PINGS_TO_VALID_ID = 0x8006,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_LOCAL_TEMPERATURE_OVERRIDE_ID = 0x8007,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_REMOTE_TEMPERATURE_VALUE_ID = 0x8008,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_HUMIDITY_COMPENSATION_ID = 0x800A,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_TRANDUCER_SENSITIVITY_CALIBRATION_SOURCE_ID = 0x800B,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_TRANDUCER_SENSITIVITY_CALIBRATION_OVERRIDE_VALUE_ID = 0x800C,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_SENSOR_TIME_VS_GAIN_LUT_ID = 0x800D,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_LEARN_ID = 0x800E,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_RINGDOWN_DISTANCE_ID = 0x800F,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_REFERENCE_FLOOR_DISTANCE_ID = 0x8010,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_DETECTION_ALGORITHM_SELECTOR_ID = 0x8011,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_FLOOR_DEADBAND_ID = 0x8012,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_MAIN_OBJECT_DEADBAND_ID = 0x8013,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_DETECTION_THRESHOLD_ID = 0x8014,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_FORCE_REPORT_ID = 0x801C,
/* Parking Sensor, Reportable Attributes, 2.5.2 */
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_LOCAL_TEMPERATURE_VALUE_ID = 0x8009,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_CONFIDENCE_ID = 0x8015,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_ECHO_RETURN_ARRAY_ID = 0x8017,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_RX_SAMPLES_ARRAY_1_ID = 0x8018,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_RX_SAMPLES_ARRAY_2_ID = 0x8019,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_RX_SAMPLES_ARRAY_3_ID = 0x801A,
ZB_ZCL_ATTR_OCCUPANCY_SENSING_CUSTOM_RX_SAMPLES_ARRAY_4_ID = 0x801B
/*! @}
* @endcond */ /* internals_doc */
};
/** @brief Default value for Occupancy Sensing cluster revision global attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief Minimal value for PIROccToUnoccDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PIR_OCC_TO_UNOCC_DELAY_MIN_VALUE ((zb_uint16_t)0x0000)
/** @brief Maximal value for PIROccToUnoccDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PIR_OCC_TO_UNOCC_DELAY_MAX_VALUE ((zb_uint16_t)0xfffe)
/** @brief Default value for PIROccToUnoccDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PIR_OCC_TO_UNOCC_DELAY_DEFAULT_VALUE ZB_ZCL_OCCUPANCY_SENSING_PIR_OCC_TO_UNOCC_DELAY_MIN_VALUE
/** @brief Minimal value for PIRUnoccToOccDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_DELAY_MIN_VALUE ((zb_uint16_t)0x0000)
/** @brief Maximal value for PIRUnoccToOccDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_DELAY_MAX_VALUE ((zb_uint16_t)0xfffe)
/** @brief Default value for PIRUnoccToOccDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_DELAY_DEFAULT_VALUE ZB_ZCL_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_DELAY_MIN_VALUE
/** @brief Minimal value for PIRUnoccToOccThreshold attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_THRESHOLD_MIN_VALUE ((zb_uint8_t)0x01)
/** @brief Maximal value for PIRUnoccToOccThreshold attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_THRESHOLD_MAX_VALUE ((zb_uint8_t)0xfe)
/** @brief Default value for PIRUnoccToOccThreshold attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_THRESHOLD_DEFAULT_VALUE ZB_ZCL_OCCUPANCY_SENSING_PIR_UNOCC_TO_OCC_THRESHOLD_MIN_VALUE
/** @brief Minimal value for UltrasonicOccupiedToUnoccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_OCCUPIED_TO_UNOCCUPIED_DELAY_MIN_VALUE ((zb_uint16_t)0x0000)
/** @brief Maximal value for UltrasonicOccupiedToUnoccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_OCCUPIED_TO_UNOCCUPIED_DELAY_MAX_VALUE ((zb_uint16_t)0xfffe)
/** @brief Default value for UltrasonicOccupiedToUnoccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_OCCUPIED_TO_UNOCCUPIED_DELAY_DEFAULT_VALUE ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_OCCUPIED_TO_UNOCCUPIED_DELAY_MIN_VALUE
/** @brief Minimal value for UltrasonicUnoccupiedToOccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_DELAY_MIN_VALUE ((zb_uint16_t)0x0000)
/** @brief Maximal value for UltrasonicUnoccupiedToOccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_DELAY_MAX_VALUE ((zb_uint16_t)0xfffe)
/** @brief Default value for UltrasonicUnoccupiedToOccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_DELAY_DEFAULT_VALUE ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_DELAY_MIN_VALUE
/** @brief Minimal value for UltrasonicUnoccupiedToOccupiedThreshold attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_MIN_VALUE ((zb_uint8_t)0x01)
/** @brief Maximal value for UltrasonicUnoccupiedToOccupiedThreshold attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_MAX_VALUE ((zb_uint8_t)0xfe)
/** @brief Default value for UltrasonicUnoccupiedToOccupiedThreshold attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_DEFAULT_VALUE ZB_ZCL_OCCUPANCY_SENSING_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_MIN_VALUE
/** @brief Default value for PhysicalContactOccupiedToUnoccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PHYSICAL_CONTACT_OCCUPIED_TO_UNOCCUPIED_DELAY_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief No-reporting value for PhysicalContactOccupiedToUnoccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PHYSICAL_CONTACT_OCCUPIED_TO_UNOCCUPIED_DELAY_NO_REPORTING_VALUE ((zb_uint16_t)0xffff)
/** @brief Default value for PhysicalContactUnoccupiedToOccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_DELAY_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief No-reporting value for PhysicalContactUnoccupiedToOccupiedDelay attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_DELAY_NO_REPORTING_VALUE ((zb_uint16_t)0xffff)
/** @brief Minimal value for PhysicalContactUnoccupiedToOccupiedThreshold attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_MIN_VALUE ((zb_uint8_t)0x01)
/** @brief Maximal value for PhysicalContactUnoccupiedToOccupiedThreshold attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_MAX_VALUE ((zb_uint8_t)0xfe)
/** @brief Default value for PhysicalContactUnoccupiedToOccupiedThreshold attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_DEFAULT_VALUE ZB_ZCL_OCCUPANCY_SENSING_PHYSICAL_CONTACT_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_DEFAULT_VALUE
/*! @brief Permissible values for Occupancy attribute
@see ZCL spec, subclause 4.8.2.2.1.1
*/
enum zb_zcl_occupancy_sensing_occupancy_e
{
/*! Unoccupied value */
ZB_ZCL_OCCUPANCY_SENSING_OCCUPANCY_UNOCCUPIED = 0,
/*! Occupied value */
ZB_ZCL_OCCUPANCY_SENSING_OCCUPANCY_OCCUPIED = 1
};
/* Custom Attributes values */
/*! @brief Maximal value for switch type attribute */
#define ZB_ZCL_OCCUPANCY_SENSING_OCCUPANCY_MAX_VALUE \
(ZB_ZCL_OCCUPANCY_SENSING_OCCUPANCY_UNOCCUPIED)
/* Switch type attribute has no default value */
/*! @brief Permissible values for Occupancy Sensor Type attribute
@see ZCL spec, subclause 4.8.2.2.1.2
*/
enum zb_zcl_occupancy_sensing_occupancy_sensor_type_e
{
/*! PIR value */
ZB_ZCL_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_PIR = 0,
/*! Ultrasonic value */
ZB_ZCL_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_ULTRASONIC = 1,
/*! PIR and Ultrasonic value */
ZB_ZCL_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_PIR_AND_ULTRASONIC = 2,
/*! Reserved value */
ZB_ZCL_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_RESERVED = 3
};
/** @cond internals_doc */
enum zb_zcl_custom_reporting_mode_type_e
{
ZB_ZCL_CUSTOM_OCCUPANCY_SENSING_REPORING_MODE_TYPE_REGULAR_REPORTING = 0,
ZB_ZCL_CUSTOM_OCCUPANCY_SENSING_REPORING_MODE_TYPE_LOW_POWER_REPORTING = 1
};
enum zb_zcl_custom_debug_mode_type_e
{
ZB_ZCL_OCCUPANCY_SENSING_CUSTOM_DEBUG_MODE_TYPE_SHORT = 0,
ZB_ZCL_OCCUPANCY_SENSING_CUSTOM_DEBUG_MODE_TYPE_ENHANCED = 1,
ZB_ZCL_OCCUPANCY_SENSING_CUSTOM_DEBUG_MODE_TYPE_DEBUG = 2
};
enum zb_zcl_custom_learn_type_e
{
ZB_ZCL_OCCUPANCY_SENSING_CUSTOM_LEARN_NOT_YET_PERFORMED = 0,
ZB_ZCL_OCCUPANCY_SENSING_CUSTOM_LEARN_IN_PROGRESS = 1,
ZB_ZCL_OCCUPANCY_SENSING_CUSTOM_LEARN_FINISHED_WITH_A_FAILURE = 2,
ZB_ZCL_OCCUPANCY_SENSING_CUSTOM_LEARN_FINISHED_SUCCSESSFULLY = 3
};
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_BITMAP_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_BITMAP_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @internal Number of attributes mandatory for reporting on Occupancy Sensing cluster */
#define ZB_ZCL_OCCUPANCY_SENSING_REPORT_ATTR_COUNT 1
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for Occupancy Sensing cluster
@param attr_list - attribute list name
@param occupancy - pointer to variable to store Occupancy attribute value
@param occupancy_sensor_type - pointer to variable to store Occupancy Sensor Type attribute value
@param occupancy_sensor_type_bitmap - pointer to variable to store Occupancy Sensor Type Bitmap attribute value
*/
#define ZB_ZCL_DECLARE_OCCUPANCY_SENSING_ATTRIB_LIST(attr_list, occupancy, occupancy_sensor_type, occupancy_sensor_type_bitmap) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_OCCUPANCY_SENSING) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_ID, (occupancy)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_ID, (occupancy_sensor_type)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_OCCUPANCY_SENSING_OCCUPANCY_SENSOR_TYPE_BITMAP_ID, (occupancy_sensor_type_bitmap)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Occupancy Sensing cluster attribute structures */
/*! @} */ /* ZCL Occupancy Sensing cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
#define ZB_ZCL_CLUSTER_ID_OCCUPANCY_SENSING_SERVER_ROLE_INIT (zb_zcl_cluster_init_t)NULL
#define ZB_ZCL_CLUSTER_ID_OCCUPANCY_SENSING_CLIENT_ROLE_INIT (zb_zcl_cluster_init_t)NULL
#endif /* ZB_ZCL_OCCUPANCY_SENSING_H */

View File

@@ -0,0 +1,512 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: On/Off cluster definitions
*/
#ifndef ZB_ZCL_ON_OFF_H
#define ZB_ZCL_ON_OFF_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_ON_OFF
* @{
* @details
* All commands in the cluster have only request form, and carry no payload.
*
* @par Example
* On command sending:
* @snippet HA_samples/on_off_output/sample_zed.c onoff_server_send_on_req_param
* @snippet HA_samples/on_off_output/sample_zed.c onoff_server_send_on_req_command
* @par
*
* Other two commands can be sent in the same way using appropriate macros.
*
*/
/* Cluster ZB_ZCL_CLUSTER_ID_ON_OFF */
/*! @name On/Off cluster attributes
@{
*/
/*! @brief On/Off cluster attribute identifiers
@see ZCL spec, subclause 3.8.2.2
*/
enum zb_zcl_on_off_attr_e
{
/*! @brief OnOff attribute */
ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID = 0,
/*! Global Scene Control attribute identifier. */
ZB_ZCL_ATTR_ON_OFF_GLOBAL_SCENE_CONTROL = 0x4000,
/*! On Time attribute identifier. */
ZB_ZCL_ATTR_ON_OFF_ON_TIME = 0x4001,
/*! Off Wait Time attribute identifier. */
ZB_ZCL_ATTR_ON_OFF_OFF_WAIT_TIME = 0x4002,
/*! The StartUpOnOff attribute SHALL define the desired startup behavior of a lamp
* device when it is supplied with power and this state SHALL be reflected in the OnOff attribute. */
ZB_ZCL_ATTR_ON_OFF_START_UP_ON_OFF = 0x4003,
};
/*! @brief Permissible values for OnOff attribute */
enum zb_zcl_on_off_on_off_e
{
/*! "Off" value */
ZB_ZCL_ON_OFF_IS_OFF = 0,
/*! "On" value */
ZB_ZCL_ON_OFF_IS_ON = 1
};
enum zb_zcl_on_off_start_up_on_off_e
{
/*! "Off" value */
ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_OFF = 0,
/*! "ON" value */
ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_ON = 1,
/*! "Toggle" value */
ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_TOGGLE = 2,
/*! "Previous" value */
ZB_ZCL_ON_OFF_START_UP_ON_OFF_IS_PREVIOUS = 0xFF
};
/** @brief Default value for OnOff cluster revision global attribute */
#define ZB_ZCL_ON_OFF_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief Default value for OnOff attribute */
#define ZB_ZCL_ON_OFF_ON_OFF_DEFAULT_VALUE (ZB_ZCL_ON_OFF_IS_OFF)
/** @brief Default value for GlobalSceneControl attribute */
#define ZB_ZCL_ON_OFF_GLOBAL_SCENE_CONTROL_DEFAULT_VALUE ((zb_bool_t)0x01)
/** @brief Default value for OnTime attribute */
#define ZB_ZCL_ON_OFF_ON_TIME_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for OffWaitTime attribute */
#define ZB_ZCL_ON_OFF_OFF_WAIT_TIME_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Declare attribute list for On/Off cluster
@param attr_list - attribute list name
@param on_off - pointer to variable to store On/Off attribute value
*/
#define ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST(attr_list, on_off) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_ON_OFF) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID, (on_off)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/**
* @brief Declare attribute list for On/Off cluster (extended attribute set).
* @param attr_list [IN] - attribute list name being declared by this macro.
* @param on_off [IN] - pointer to a boolean variable storing on/off attribute value.
* @param global_scene_ctrl [IN] - pointer to a boolean variable storing global scene control attribute value.
* @param on_time [IN] - pointer to a unsigned 16-bit integer variable storing on time attribute value.
* @param off_wait_time [IN] - pointer to a unsigned 16-bit integer variable storing off wait time attribute value.
*/
#define ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST_EXT( \
attr_list, on_off, global_scene_ctrl, on_time, off_wait_time \
) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_ON_OFF) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID, (on_off)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_GLOBAL_SCENE_CONTROL, (global_scene_ctrl)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_ON_TIME, (on_time)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_OFF_WAIT_TIME, (off_wait_time)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* On/Off cluster attributes */
/*! @name On/Off cluster commands
@{
*/
/*! @brief On/Off cluster command identifiers
@see ZCL spec, subclause 3.8.2.3
*/
enum zb_zcl_on_off_cmd_e
{
ZB_ZCL_CMD_ON_OFF_OFF_ID = 0x00, /**< "Turn off" command. */
ZB_ZCL_CMD_ON_OFF_ON_ID = 0x01, /**< "Turn on" command. */
ZB_ZCL_CMD_ON_OFF_TOGGLE_ID = 0x02, /**< "Toggle state" command. */
ZB_ZCL_CMD_ON_OFF_OFF_WITH_EFFECT_ID = 0x40, /**< "Off with effect" command. */
ZB_ZCL_CMD_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE_ID = 0x41, /**< "On with recall global scene" command. */
ZB_ZCL_CMD_ON_OFF_ON_WITH_TIMED_OFF_ID = 0x42, /**< "On with timed off" command. */
};
/** @cond internals_doc */
/* ON OFF cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_ON_OFF_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_ON_OFF_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_ON_OFF_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_ON_OFF_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_ON_OFF_OFF_ID, \
ZB_ZCL_CMD_ON_OFF_ON_ID, \
ZB_ZCL_CMD_ON_OFF_TOGGLE_ID, \
ZB_ZCL_CMD_ON_OFF_OFF_WITH_EFFECT_ID, \
ZB_ZCL_CMD_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE_ID, \
ZB_ZCL_CMD_ON_OFF_ON_WITH_TIMED_OFF_ID
#define ZB_ZCL_CLUSTER_ID_ON_OFF_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_ON_OFF_CLIENT_ROLE_GENERATED_CMD_LIST
/** @endcond */ /* internals_doc */
/*! @brief General macro for sending On/Off cluster command
@param buffer to put data to
@param addr - address of the device to send command to
@param dst_addr_mode - addressing mode
@param dst_ep destination endpoint
@param ep - current endpoint
@param prof_id - profile identifier
@param dis_default_resp - "Disable default response" flag
@param command_id - command identifier
@param cb - callback to call to report send status
*/
#define ZB_ZCL_ON_OFF_SEND_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, command_id, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), command_id); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ON_OFF, cb); \
}
/*! Specific macro for sending Off command */
#define ZB_ZCL_ON_OFF_SEND_OFF_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, dis_default_resp, cb) \
ZB_ZCL_ON_OFF_SEND_REQ( \
buffer, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
dis_default_resp, \
ZB_ZCL_CMD_ON_OFF_OFF_ID, \
cb)
/*! Specific macro for sending On command */
#define ZB_ZCL_ON_OFF_SEND_ON_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, dis_default_resp, cb) \
ZB_ZCL_ON_OFF_SEND_REQ( \
buffer, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
dis_default_resp, \
ZB_ZCL_CMD_ON_OFF_ON_ID, \
cb)
/*! Specific macro for sending Toggle command */
#define ZB_ZCL_ON_OFF_SEND_TOGGLE_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, dis_default_resp, cb) \
ZB_ZCL_ON_OFF_SEND_REQ( \
buffer, \
addr, \
dst_addr_mode, \
dst_ep, \
ep, \
prfl_id, \
dis_default_resp, \
ZB_ZCL_CMD_ON_OFF_TOGGLE_ID, \
cb)
/*! Specific macro for sending Off with effect command */
#define ZB_ZCL_ON_OFF_SEND_OFF_WITH_EFFECT_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, effect_id, effect_var, cb)\
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ON_OFF_OFF_WITH_EFFECT_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, effect_id); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, effect_var); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ON_OFF, cb); \
}
/*! Specific macro for sending On with recall global scene command */
#define ZB_ZCL_ON_OFF_SEND_ON_WITH_RECALL_GLOBAL_SCENE_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, cb) \
ZB_ZCL_ON_OFF_SEND_REQ(buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, \
ZB_ZCL_CMD_ON_OFF_ON_WITH_RECALL_GLOBAL_SCENE_ID, cb)
/*! Specific macro for sending On with timed off command */
#define ZB_ZCL_ON_OFF_SEND_ON_WITH_TIMED_OFF_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, on_off, on_time, off_wait_time, cb)\
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), ZB_ZCL_CMD_ON_OFF_ON_WITH_TIMED_OFF_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, on_off); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, on_time); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, off_wait_time); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, ZB_ZCL_CLUSTER_ID_ON_OFF, cb); \
}
/** Effect identifier enum
* @see ZCL spec 3.8.2.3.4.1 */
enum zb_zcl_on_off_effect_e
{
/**< Effect identifier field value: Delayed all off */
ZB_ZCL_ON_OFF_EFFECT_ID_DELAYED_ALL_OFF = 0x00,
/**< Effect identifier field value: Dying light */
ZB_ZCL_ON_OFF_EFFECT_ID_DYING_LIGHT = 0x01
};
/** Effect variant field for delayed enum
* @see ZCL spec 3.8.2.3.4.2 */
enum zb_zcl_on_off_effect_variant_delayed_e
{
/**< Effect variant field value: Fade to off in 0.8 seconds */
ZB_ZCL_ON_OFF_EFFECT_VARIANT_FADE = 0x00,
/**< Effect variant field value: No fade */
ZB_ZCL_ON_OFF_EFFECT_VARIANT_NO_FADE = 0x01,
/**< Effect variant field value: 50% dim down in 0.8 seconds then fade to off in 12 seconds */
ZB_ZCL_ON_OFF_EFFECT_VARIANT_50PART_FADE = 0x02
};
/** Effect variant field for delayed enum
* @see ZCL spec 3.8.2.3.4.2 */
enum zb_zcl_on_off_effect_variant_dying_e
{
/**< Effect variant field value: 20% dim up in 0.5s then fade to off in 1 second */
ZB_ZCL_ON_OFF_EFFECT_VARIANT_20PART_FADE = 0x00
};
/** Accept only when on
* @see ZCL spec 3.8.2.3.6.1 */
#define ZB_ZCL_ON_OFF_ACCEPT_ONLY_WHEN_ON 1
/*! @brief Structured representation of Off with effect command payload */
typedef ZB_PACKED_PRE struct zb_zcl_on_off_off_with_effect_req_s
{
/** Effect identify */
zb_uint8_t effect_id;
/** Effect variant */
zb_uint8_t effect_variant;
} ZB_PACKED_STRUCT zb_zcl_on_off_off_with_effect_req_t;
/*! @brief Structured representation of On with timed off command payload */
typedef ZB_PACKED_PRE struct zb_zcl_on_off_on_with_timed_off_req_s
{
/** On/off control */
zb_uint8_t on_off;
/** On time variable */
zb_uint16_t on_time;
/** Off wait time variable */
zb_uint16_t off_wait_time;
} ZB_PACKED_STRUCT zb_zcl_on_off_on_with_timed_off_req_t;
/** @brief Parses Off with Effect command
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_on_off_off_with_effect_req_s.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_ON_OFF_GET_OFF_WITH_EFFECT_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_on_off_off_with_effect_req_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_on_off_off_with_effect_req_t *src_ptr = \
(zb_zcl_on_off_off_with_effect_req_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_MEMCPY((data_ptr), src_ptr, sizeof(zb_zcl_on_off_off_with_effect_req_t)); \
} \
}
/** @brief Parses On with timed off command
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_on_off_on_with_timed_off_req_s.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_ON_OFF_GET_ON_WITH_TIMED_OFF_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_on_off_on_with_timed_off_req_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_on_off_on_with_timed_off_req_t *src_ptr = \
(zb_zcl_on_off_on_with_timed_off_req_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(data_ptr)->on_off = src_ptr->on_off; \
ZB_LETOH16(&((data_ptr)->on_time), &(src_ptr->on_time)); \
ZB_LETOH16(&((data_ptr)->off_wait_time), &(src_ptr->off_wait_time)); \
} \
}
/** @cond internals_doc */
/**
* @name Inform User App about On/Off cluster command and change attributes.
* Internal structures and define-procedure for inform User App about On/Off
* cluster command and change attributes.
* @internal
* @{
*/
/** @brief Declare run Set Effect command for User Application
*/
typedef struct zb_zcl_on_off_set_effect_value_param_s
{
zb_uint8_t effect_id; /*!< Effect identify */
zb_uint8_t effect_variant; /*!< Effect variant */
} zb_zcl_on_off_set_effect_value_param_t;
/*! Struct for invoke User App & continue after */
typedef struct zb_zcl_on_off_effect_user_app_schedule_e
{
zb_zcl_parsed_hdr_t cmd_info; /**< Parameters for continue command,
see @ref zb_zcl_parsed_hdr_s */
zb_zcl_on_off_set_effect_value_param_t param; /**< User App command parameters,
see @ref zb_zcl_on_off_set_effect_value_param_s */
} zb_zcl_on_off_effect_user_app_schedule_t;
#define ZB_ZCL_ON_OFF_EFFECT_SCHEDULE_USER_APP(buffer, pcmd_info, effectId, effectVar) \
{ \
zb_zcl_on_off_effect_user_app_schedule_t* user_data = \
ZB_BUF_GET_PARAM((buffer), zb_zcl_on_off_effect_user_app_schedule_t); \
ZB_MEMMOVE(&(user_data->cmd_info), (pcmd_info), sizeof(zb_zcl_parsed_hdr_t)); \
user_data->param.effect_id = (effectId); \
user_data->param.effect_variant = (effectVar); \
ZB_SCHEDULE_CALLBACK(zb_zcl_on_off_effect_invoke_user_app, (buffer)); \
}
/*! @}
* @endcond */ /* internals_doc */
/*! @} */ /* On/Off cluster commands */
/*! @cond internals_doc
@internal @name On/Off cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING | ZB_ZCL_ATTR_ACCESS_SCENE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ON_OFF_GLOBAL_SCENE_CONTROL(data_ptr) \
{ \
ZB_ZCL_ATTR_ON_OFF_GLOBAL_SCENE_CONTROL, \
ZB_ZCL_ATTR_TYPE_BOOL, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ON_OFF_ON_TIME(data_ptr) \
{ \
ZB_ZCL_ATTR_ON_OFF_ON_TIME, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ON_OFF_OFF_WAIT_TIME(data_ptr) \
{ \
ZB_ZCL_ATTR_ON_OFF_OFF_WAIT_TIME, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @struct zb_zcl_on_off_attrs_s
* @brief On/Off cluster attributes
*/
typedef struct zb_zcl_on_off_attrs_s
{
zb_uint8_t on_off;
} zb_zcl_on_off_attrs_t;
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ON_OFF_START_UP_ON_OFF(data_ptr) \
{ \
ZB_ZCL_ATTR_ON_OFF_START_UP_ON_OFF, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_ZCL_DECLARE_ON_OFF_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST(attr_list, &attrs.on_off)
/*! @internal Number of attributes mandatory for reporting in On/Off cluster */
#define ZB_ZCL_ON_OFF_REPORT_ATTR_COUNT 1
/*! @internal Struct for invoke User App & continue after */
typedef struct zb_on_off_user_app_schedule_e
{
zb_zcl_parsed_hdr_t cmd_info;
zb_uint8_t new_value;
zb_bool_t is_run_timer;
} zb_on_off_user_app_schedule_t;
/*! @}
@endcond */ /* On/Off cluster internals */
/*! @} */ /* ZCL On/Off cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_on_off_init_server(void);
void zb_zcl_on_off_init_client(void);
#define ZB_ZCL_CLUSTER_ID_ON_OFF_SERVER_ROLE_INIT zb_zcl_on_off_init_server
#define ZB_ZCL_CLUSTER_ID_ON_OFF_CLIENT_ROLE_INIT zb_zcl_on_off_init_client
#endif /* ZB_ZCL_ON_OFF_H */

View File

@@ -0,0 +1,187 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: On/Off switch configuration definitions
*/
#ifndef ZB_ZCL_ON_OFF_SWITCH_CONF_H
#define ZB_ZCL_ON_OFF_SWITCH_CONF_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_OOSC
* @{
* @details
* On/Off Switch Configuration cluster has no cluster-specific command support. Cluster
* attributes can be queried with @ref ZB_ZCL_COMMANDS "common commands".
*
* Sample switch config cluster attributes data
* @code
* zb_uint8_t attr_switch_type = ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_TOGGLE;
* zb_uint8_t attr_switch_actions = ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_DEFAULT_VALUE;
*
* ZB_ZCL_DECLARE_ON_OFF_SWITCH_CONFIGURATION_ATTRIB_LIST(switch_cfg_attr_list, &attr_switch_type, &attr_switch_actions);
* @endcode
*
*
*/
/*! @name On/off switch configuration cluster attributes
@{
*/
/*! @brief On/off switch configuration cluster attribute identifiers
@see ZCL spec, subclause 3.9.2.2
*/
enum zb_zcl_on_off_switch_configuration_attr_e
{
/*! Switch type attribute identifier (switch information) */
ZB_ZCL_ATTR_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_ID = 0x0000,
/*! Switch actions attribute identifier (switch settings) */
ZB_ZCL_ATTR_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_ID = 0x0010
};
/*! @brief Permissible values for switch type attribute
@see ZCL spec, subclause 3.9.2.2.2
*/
enum zb_zcl_on_off_switch_configuration_switch_type_e
{
/*! Toggle switch */
ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_TOGGLE = 0,
/*! Momentary switch */
ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_MOMENTARY = 1,
/*! Multifunction switch */
ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_MULTIFUNCTION = 2
};
/** @brief Default value for On/off switch configuration cluster revision global attribute */
#define ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/*! @brief Maximal value for switch type attribute */
#define ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_MAX_VALUE \
(ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_MULTIFUNCTION)
/* Switch type attribute has no default value */
/*! @brief Permissible values for switch actions attribute
@see ZCL spec, subclause 3.9.2.2.3.1
*/
enum zb_zcl_on_off_switch_configuration_switch_actions_e
{
/*! @brief First type command pattern
@li Send "On" on arriving to State2 from State1;
@li Send "Off" on arriving to State1 from State2.
*/
ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_TYPE1 = 0,
/*! @brief Second type command pattern
@li Send "On" on arriving to State1 from State2;
@li Send "Off" on arriving to State2 from State1.
*/
ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_TYPE2 = 1,
/*! @brief Toggle command pattern
Send "Toggle" on state change
*/
ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_TOGGLE = 2
};
/*! @brief Maximal value for switch actions attribute */
#define ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_MAX_VALUE \
(ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_TOGGLE)
/** @brief Default value for Switch actions attribute */
#define ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_DEFAULT_VALUE \
(ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_TYPE1)
/*! @} */ /* On/off switch configuration cluster attributes */
/** @cond internals_doc
@internal @name On/off switch configuration cluster attribute structures
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @internal Number of attributes mandatory for reporting on On/Off switch configuration cluster */
#define ZB_ZCL_ON_OFF_SWITCH_CONFIG_REPORT_ATTR_COUNT 0
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for ON/OFF Switch configuration cluster
@param attr_list - attribute list name
@param switch_type - pointer to variable to store switch type attribute value
@param switch_actions - pointer to variable to store switch action attribute value
*/
#define ZB_ZCL_DECLARE_ON_OFF_SWITCH_CONFIGURATION_ATTRIB_LIST(attr_list, switch_type, switch_actions) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_ID, (switch_type)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_ID, (switch_actions)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_on_off_switch_config_init_server(void);
void zb_zcl_on_off_switch_config_init_client(void);
#define ZB_ZCL_CLUSTER_ID_ON_OFF_SWITCH_CONFIG_SERVER_ROLE_INIT zb_zcl_on_off_switch_config_init_server
#define ZB_ZCL_CLUSTER_ID_ON_OFF_SWITCH_CONFIG_CLIENT_ROLE_INIT zb_zcl_on_off_switch_config_init_client
#endif /* ZB_ZCL_ON_OFF_SWITCH_CONF_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,227 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: PM2.5 Measurement cluster definitions */
#ifndef ZB_ZCL_PM2_5_MEASUREMENT_H
#define ZB_ZCL_PM2_5_MEASUREMENT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_CONCENTRATION_MEASUREMENT
* @{
* @details
* The server cluster provides an interface to concentration measurement
* functionality. The measurement is reportable and may be configured for
* reporting. Concentration measurements include, but are not limited to,
* levels in gases, such as CO, CO2, and ethylene, or in fluids and
* solids, such as dissolved oxygen, chemi8721 cals & pesticides.
*
* PM2.5 (Particulate Matter 2.5 microns or less)
*/
/* Cluster ZB_ZCL_CLUSTER_ID_PM2_5_MEASUREMENT */
/** @name PM2.5 Measurement cluster attributes
* @{
*/
/** @brief PM2.5 Measurement cluster attribute identifiers
* @see ZCL spec, PM2.5 Measurement Cluster 4.14.1.4
*/
enum zb_zcl_pm2_5_measurement_attr_e
{
/** @brief MeasuredValue attribute, ZCL spec 4.13.2.1.1 */
ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MEASURED_VALUE_ID = 0x0000,
/** @brief MinMeasuredValue attribute, ZCL spec 4.13.2.1.2 */
ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MIN_MEASURED_VALUE_ID = 0x0001,
/** @brief MaxMeasuredValue attribute, ZCL spec 4.13.2.1.3 */
ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MAX_MEASURED_VALUE_ID = 0x0002,
/** @brief Tolerance attribute, ZCL spec 4.13.2.1.4 */
ZB_ZCL_ATTR_PM2_5_MEASUREMENT_TOLERANCE_ID = 0x0003,
};
/** @brief Default value for PM2.5 Measurement cluster revision global attribute */
#define ZB_ZCL_PM2_5_MEASUREMENT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for MeasuredValue attribute */
#define ZB_ZCL_PM2_5_MEASUREMENT_MEASURED_VALUE_DEFAULT_VALUE (.0/.0)
/** @brief Default value for MinMeasuredValue attribute */
#define ZB_ZCL_PM2_5_MEASUREMENT_MIN_MEASURED_VALUE_DEFAULT_VALUE (.0/.0)
/** @brief Default value for MaxMeasuredValue attribute */
#define ZB_ZCL_PM2_5_MEASUREMENT_MAX_MEASURED_VALUE_DEFAULT_VALUE (.0/.0)
/** @brief MeasuredValue attribute unknown */
#define ZB_ZCL_PM2_5_MEASUREMENT_MEASURED_VALUE_UNKNOWN (.0/.0)
/** @brief MinMeasuredValue attribute undefined */
#define ZB_ZCL_PM2_5_MEASUREMENT_MIN_MEASURED_VALUE_UNDEFINED (.0/.0)
/** @brief MaxMeasuredValue attribute undefined */
#define ZB_ZCL_PM2_5_MEASUREMENT_MAX_MEASURED_VALUE_UNDEFINED (.0/.0)
/** @brief MinMeasuredValue attribute minimum value */
#define ZB_ZCL_PM2_5_MEASUREMENT_MIN_MEASURED_VALUE_MIN_VALUE 0.0
/** @brief MaxMeasuredValue attribute maximum value */
#define ZB_ZCL_PM2_5_MEASUREMENT_MAX_MEASURED_VALUE_MAX_VALUE 1.0
/** @cond internals_doc */
/** @name PM2.5 Measurement cluster internals
* Internal structures for PM2.5 Measurement cluster
* @{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MEASURED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MEASURED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MIN_MEASURED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MIN_MEASURED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MAX_MEASURED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MAX_MEASURED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PM2_5_MEASUREMENT_TOLERANCE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PM2_5_MEASUREMENT_TOLERANCE_ID, \
ZB_ZCL_ATTR_TYPE_SINGLE, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** Number of attributes mandatory for reporting in PM2.5 Measurement cluster */
#define ZB_ZCL_PM2_5_MEASUREMENT_REPORT_ATTR_COUNT 1
/** @} */
/** @endcond */ /* PM2.5 Measurement cluster internals */
/** @brief Declare attribute list for PM2.5 Measurement cluster
* @param attr_list - attribute list name
* @param measured_value - pointer to variable storing MeasuredValue attribute value
* @param min_measured_value - pointer to variable storing MinMeasuredValue attribute value
* @param max_measured_value - pointer to variable storing MaxMeasuredValue attribute value
* @param tolerance - pointer to variable storing Tolerance attribute value
*/
#define ZB_ZCL_DECLARE_PM2_5_MEASUREMENT_ATTRIB_LIST( \
attr_list, \
measured_value, \
min_measured_value, \
max_measured_value, \
tolerance) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_PM2_5_MEASUREMENT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MEASURED_VALUE_ID, (measured_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MIN_MEASURED_VALUE_ID, (min_measured_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MAX_MEASURED_VALUE_ID, (max_measured_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_PM2_5_MEASUREMENT_TOLERANCE_ID, (tolerance)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/**
* @brief PM2.5 Measurement cluster attributes
*/
typedef struct zb_zcl_pm2_5_measurement_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MEASURED_VALUE_ID
* @see ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MEASURED_VALUE_ID
*/
zb_single_t measured_value;
/** @copydoc ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MIN_MEASURED_VALUE_ID
* @see ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MIN_MEASURED_VALUE_ID
*/
zb_single_t min_measured_value;
/** @copydoc ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MAX_MEASURED_VALUE_ID
* @see ZB_ZCL_ATTR_PM2_5_MEASUREMENT_MAX_MEASURED_VALUE_ID
*/
zb_single_t max_measured_value;
/** @copydoc ZB_ZCL_ATTR_PM2_5_MEASUREMENT_TOLERANCE_ID
* @see ZB_ZCL_ATTR_PM2_5_MEASUREMENT_TOLERANCE_ID
*/
zb_single_t tolerance;
} zb_zcl_pm2_5_measurement_attrs_t;
/** @brief Declare attribute list for PM2.5 Measurement cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of @ref zb_zcl_pm2_5_measurement_attrs_t type
* (containing PM2.5 Measurement cluster attributes)
*/
#define ZB_ZCL_DECLARE_PM2_5_MEASUREMENT_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_PM2_5_MEASUREMENT_ATTRIB_LIST(attr_list, \
&attrs.measured_value, \
&attrs.min_measured_value, \
&attrs.max_measured_value, \
&attrs.tolerance)
/** @} */ /* end of ZB_ZCL_PM2_5_MEASUREMENT_ATTRS_GROUP group */
/** @} */ /* ZCL PM2.5 Measurement cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_pm2_5_measurement_init_server(void);
void zb_zcl_pm2_5_measurement_init_client(void);
#define ZB_ZCL_CLUSTER_ID_PM2_5_MEASUREMENT_SERVER_ROLE_INIT zb_zcl_pm2_5_measurement_init_server
#define ZB_ZCL_CLUSTER_ID_PM2_5_MEASUREMENT_CLIENT_ROLE_INIT zb_zcl_pm2_5_measurement_init_client
#endif /* ZB_ZCL_PM2_5_MEASUREMENT_H */

View File

@@ -0,0 +1,698 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Poll Control cluster definitions
*/
#ifndef ZB_ZCL_POLL_CONTROL_H
#define ZB_ZCL_POLL_CONTROL_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_POLL_CONTROL
* @{
* @details
* All commands in the cluster have only request form, and carry no payload.
*
*/
#if defined ZB_HA_ENABLE_POLL_CONTROL_SERVER || defined DOXYGEN
/*! @brief Schedule poll control process on given endpoint
* First check-in will occur after one check-in interval
* Poll Control process also starts automatically during ZCL periodic activities
* initialization if Poll Control server cluster is declared
* @param param - buffer for check-in command
* @param endpoint - endpoint to start poll control process on */
void zb_zcl_poll_control_start(zb_uint8_t param, zb_uint8_t endpoint);
/**
* @brief Stop Poll control processing
*
* Checking already scheduled will be canceled
* @return reference to buffer which was previously reserved for check-in.
* It must be reused or explicitly freed.
*/
zb_uint8_t zb_zcl_poll_control_stop(void);
/*! @brief Start Poll Control process on Server side
* @param param - buffer for Poll Process
*/
void zb_zcl_poll_control_start_check_in(zb_uint8_t param);
/**
@brief Register callback for Poll control cluster.
This callback will be called when check-in command is sent.
@param cb - pointer to callback
*/
void zb_zcl_poll_controll_register_cb(zb_callback_t cb);
#endif /* defined ZB_HA_ENABLE_POLL_CONTROL_SERVER || defined DOXYGEN */
/* Cluster ZB_ZCL_CLUSTER_ID_POLL_CONTROL */
/**
* @name Poll Control cluster attribute identifiers
* @anchor zcl_poll_control_attr
* @see HA spec, Poll Control Cluster 9.5.4.1
*
* Note: These values were members of `enum zb_zcl_poll_control_attr_e` type but were converted to a
* set of macros due to MISRA violations.
*/
/** @{ */
/** Check-in Interval attribute, HA spec 9.5.4.1.1 */
#define ZB_ZCL_ATTR_POLL_CONTROL_CHECKIN_INTERVAL_ID 0x0000U
/** Long Poll Interval attribute, HA spec 9.5.4.1.2 */
#define ZB_ZCL_ATTR_POLL_CONTROL_LONG_POLL_INTERVAL_ID 0x0001U
/** Short Poll Interval attribute, HA spec 9.5.4.1.3 */
#define ZB_ZCL_ATTR_POLL_CONTROL_SHORT_POLL_INTERVAL_ID 0x0002U
/** Fast Poll Timeout attribute, HA spec 9.5.4.1. */
#define ZB_ZCL_ATTR_POLL_CONTROL_FAST_POLL_TIMEOUT_ID 0x0003U
/** Check-in Interval Min attribute, HA spec 9.5.4.1.4 */
#define ZB_ZCL_ATTR_POLL_CONTROL_MIN_CHECKIN_INTERVAL_ID 0x0004U
/** Long Poll Interval Min attribute, HA spec 9.5.4.1.5 */
#define ZB_ZCL_ATTR_POLL_CONTROL_LONG_POLL_MIN_INTERVAL_ID 0x0005U
/** Fast Poll Timeout Max attribute, HA spec 9.5.4.1.6 */
#define ZB_ZCL_ATTR_POLL_CONTROL_FAST_POLL_MAX_TIMEOUT_ID 0x0006U
/** Status Data - custom non-spec parameters */
#define ZB_ZCL_ATTR_POLL_CONTROL_STATUS_DATA_ID 0xefffU
/** Status Data - custom non-spec parameters for server side */
#define ZB_ZCL_ATTR_POLL_CONTROL_ADDR_DATA_ID 0xeffeU
/** @} */
/** @name Poll Control cluster attributes */
/** @{ */
/** @brief Default value for Poll Control cluster revision global attribute */
#define ZB_ZCL_POLL_CONTROL_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0003u)
/** @brief Value for stop Check-in process for Check-in Interval attribute */
#define ZB_ZCL_POLL_CONTROL_CHECKIN_INTERVAL_NO_CHECK_IN_VALUE 0x0000
/** @brief Default value for Check-in Interval attribute */
#define ZB_ZCL_POLL_CONTROL_CHECKIN_INTERVAL_DEFAULT_VALUE 0x3840
/** @brief Maximum value for Check-in Interval attribute */
#define ZB_ZCL_POLL_CONTROL_CHECKIN_INTERVAL_MAX_VALUE 0x6e0000
/** @brief Minimum value for Long Poll Interval attribute */
#define ZB_ZCL_POLL_CONTROL_LONG_POLL_INTERVAL_MIN_VALUE ZB_PIM_MINIMUM_LONG_POLL_INTERVAL_IN_QS
/** @brief Default value for Long Poll Interval attribute */
#define ZB_ZCL_POLL_CONTROL_LONG_POLL_INTERVAL_DEFAULT_VALUE ZB_PIM_DEFAULT_LONG_POLL_INTERVAL_IN_QS
/** @brief Maximum value for Long Poll Interval attribute */
#define ZB_ZCL_POLL_CONTROL_LONG_POLL_INTERVAL_MAX_VALUE ZB_PIM_MAXIMUM_LONG_POLL_INTERVAL_IN_QS
/** @brief Minimum value for Short Poll Interval attribute */
#define ZB_ZCL_POLL_CONTROL_SHORT_POLL_INTERVAL_MIN_VALUE ZB_PIM_MINIMUM_SHORT_POLL_INTERVAL_IN_QS
/** @brief Default value for Short Poll Interval attribute */
#define ZB_ZCL_POLL_CONTROL_SHORT_POLL_INTERVAL_DEFAULT_VALUE ZB_PIM_DEFAULT_SHORT_POLL_INTERVAL_IN_QS
/** @brief Maximum value for Short Poll Interval attribute */
#define ZB_ZCL_POLL_CONTROL_SHORT_POLL_INTERVAL_MAX_VALUE ZB_PIM_MAXIMUM_SHORT_POLL_INTERVAL_IN_QS
/** @brief Minimum value for Fast Poll Timeout attribute */
#define ZB_ZCL_POLL_CONTROL_FAST_POLL_TIMEOUT_MIN_VALUE 0x01
/** @brief Default value for Fast Poll Timeout attribute */
#define ZB_ZCL_POLL_CONTROL_FAST_POLL_TIMEOUT_DEFAULT_VALUE 0x0028
/** @brief Maximum value for Fast Poll Timeout attribute */
#define ZB_ZCL_POLL_CONTROL_FAST_POLL_TIMEOUT_MAX_VALUE 0xffff
/** @brief Default value for CheckinIntervalMin attribute */
#define ZB_ZCL_POLL_CONTROL_CHECKIN_MIN_INTERVAL_DEFAULT_VALUE ((zb_uint32_t)0)
/** @brief Default value for LongPollIntervalMin attribute */
#define ZB_ZCL_POLL_CONTROL_LONG_POLL_MIN_INTERVAL_DEFAULT_VALUE ((zb_uint32_t)0)
/** @brief Default value for FastPollTimeoutMax attribute */
#define ZB_ZCL_POLL_CONTROL_FAST_POLL_MAX_TIMEOUT_DEFAULT_VALUE ((zb_uint16_t)0)
/** @} */
/** @cond DOXYGEN_INTERNAL_DOC */
/** @name Poll Control cluster internals
* Internal structures for attribute representation in cluster definitions. */
/** @{ */
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POLL_CONTROL_CHECKIN_INTERVAL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POLL_CONTROL_CHECKIN_INTERVAL_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POLL_CONTROL_LONG_POLL_INTERVAL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POLL_CONTROL_LONG_POLL_INTERVAL_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POLL_CONTROL_SHORT_POLL_INTERVAL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POLL_CONTROL_SHORT_POLL_INTERVAL_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POLL_CONTROL_FAST_POLL_TIMEOUT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POLL_CONTROL_FAST_POLL_TIMEOUT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POLL_CONTROL_MIN_CHECKIN_INTERVAL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POLL_CONTROL_MIN_CHECKIN_INTERVAL_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POLL_CONTROL_LONG_POLL_MIN_INTERVAL_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POLL_CONTROL_LONG_POLL_MIN_INTERVAL_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POLL_CONTROL_FAST_POLL_MAX_TIMEOUT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POLL_CONTROL_FAST_POLL_MAX_TIMEOUT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POLL_CONTROL_STATUS_DATA_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POLL_CONTROL_STATUS_DATA_ID, \
ZB_ZCL_ATTR_TYPE_NULL, \
ZB_ZCL_ATTR_ACCESS_INTERNAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POLL_CONTROL_ADDR_DATA_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POLL_CONTROL_ADDR_DATA_ID, \
ZB_ZCL_ATTR_TYPE_NULL, \
ZB_ZCL_ATTR_ACCESS_INTERNAL, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @brief Structure representation of Client Status attributes */
typedef ZB_PACKED_PRE struct zb_zcl_poll_control_client_status_s
{
/** Client is In Poll Mode */
zb_bool_t is_poll_mode;
/** Client Fast Poll timeout*/
zb_uint16_t fast_poll_timeout;
} ZB_PACKED_STRUCT zb_zcl_poll_control_client_status_t;
#define ZB_ZCL_POLL_CTRL_INVALID_ADDR 0xFFFF
#define ZB_ZCL_POLL_INVALID_EP 0xFF
/*! @brief Address information that is used for sending check-in command */
/* Currently not only address info is stored - also status information */
typedef struct zb_zcl_poll_control_srv_cfg_data_s
{
/** Short address of the Poll control client */
zb_uint16_t poll_addr;
/** Endpoint number of the Poll control client */
zb_uint8_t poll_ep;
/** Flag to check if check-in command is being sent currently */
zb_bitfield_t sending_cmd:4;
/** Flag to determine fast poll mode / long poll mode */
zb_bitfield_t fast_poll_mode:1;
}
zb_zcl_poll_control_srv_cfg_data_t;
/** @brief Default value for Fast Poll Timeout for Client command */
#define ZB_ZCL_POLL_CONTROL_FAST_POLL_TIMEOUT_CLIENT_DEFAULT_VALUE 0x00f0
/*! @internal Number of attributes mandatory for reporting in Poll Control cluster */
#define ZB_ZCL_POLL_CONTROL_REPORT_ATTR_COUNT 0
/** @} */
/** @endcond */ /* DOXYGEN_INTERNAL_DOC */ /* Poll Control cluster internals */
/** @name Poll Control cluster attributes */
/** @{ */
/** @brief Declare attribute list for Poll Control cluster - server side
@param attr_list - attribute list name
@param checkin_interval - pointer to variable to store Check-in Interval attribute
@param long_poll_interval - pointer to variable to store Long Poll Interval attribute
@param short_poll_interval - pointer to variable to store Short Poll Interval attribute
@param fast_poll_timeout - pointer to variable to store Fast Poll Timeout attribute
@param checkin_interval_min - pointer to variable to store Check-in Interval Min attribute
@param long_poll_interval_min- pointer to variable to store Long Poll Interval Min attribute
@param fast_poll_timeout_max - pointer to variable to store Fast Poll Timeout Max attribute
*/
#define ZB_ZCL_DECLARE_POLL_CONTROL_ATTRIB_LIST(attr_list, \
checkin_interval, long_poll_interval, short_poll_interval, fast_poll_timeout, \
checkin_interval_min, long_poll_interval_min, fast_poll_timeout_max) \
zb_zcl_poll_control_srv_cfg_data_t srv_cfg_data_ctx_##attr_list = \
{ ZB_ZCL_POLL_CTRL_INVALID_ADDR, ZB_ZCL_POLL_INVALID_EP, 0, 0 }; \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_POLL_CONTROL) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POLL_CONTROL_CHECKIN_INTERVAL_ID, (checkin_interval)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POLL_CONTROL_LONG_POLL_INTERVAL_ID, (long_poll_interval)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POLL_CONTROL_SHORT_POLL_INTERVAL_ID, (short_poll_interval)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POLL_CONTROL_FAST_POLL_TIMEOUT_ID, (fast_poll_timeout)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POLL_CONTROL_MIN_CHECKIN_INTERVAL_ID, (checkin_interval_min)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POLL_CONTROL_LONG_POLL_MIN_INTERVAL_ID, (long_poll_interval_min)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POLL_CONTROL_FAST_POLL_MAX_TIMEOUT_ID, (fast_poll_timeout_max)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POLL_CONTROL_ADDR_DATA_ID, &(srv_cfg_data_ctx_##attr_list)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @brief Declare attribute list for Poll Control cluster - client side
@param attr_list - attribute list name
*/
#define ZB_ZCL_DECLARE_POLL_CONTROL_ATTRIB_LIST_CLIENT(attr_list) \
zb_zcl_poll_control_client_status_t client_status_data_ctx_##attr_list = \
{ ZB_FALSE, ZB_ZCL_POLL_CONTROL_FAST_POLL_TIMEOUT_CLIENT_DEFAULT_VALUE }; \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_POLL_CONTROL) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POLL_CONTROL_STATUS_DATA_ID, \
(&(client_status_data_ctx_##attr_list))) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @} */ /* Poll Control cluster attributes */
/** @name Poll Control cluster commands */
/** @{ */
/*! @brief Poll Control cluster command identifiers
@see HA spec, Poll Control Cluster, 9.5.4.3
*/
enum zb_zcl_poll_control_cmd_e
{
ZB_ZCL_CMD_POLL_CONTROL_CHECK_IN_ID = 0x00 /**< "Check-in" command. HA spec 9.5.4.4 */
};
/*! @brief Poll Control cluster response command identifiers
@see HA spec, Poll Control Cluster, 9.5.5.2
*/
enum zb_zcl_poll_control_resp_cmd_e
{
ZB_ZCL_CMD_POLL_CONTROL_CHECK_IN_RESPONSE_ID = 0x00, /**< "Check-in response" command, HA spec 9.5.5.3 */
ZB_ZCL_CMD_POLL_CONTROL_FAST_POLL_STOP_ID = 0x01, /**< "Fast Poll Stop" command, HA spec 9.5.5.4 */
ZB_ZCL_CMD_POLL_CONTROL_SET_LONG_POLL_INTERVAL_ID = 0x02, /**< "Set Long Poll Interval" command, HA spec 9.5.5.5 */
ZB_ZCL_CMD_POLL_CONTROL_SET_SHORT_POLL_INTERVAL_ID = 0x03, /**< "Set Short Poll Interval" command, HA spec 9.5.5.6 */
};
/** @cond DOXYGEN_INTERNAL_DOC */
/* Poll control cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_POLL_CONTROL_SERVER_ROLE_GENERATED_CMD_LIST ZB_ZCL_CMD_POLL_CONTROL_CHECK_IN_ID
#define ZB_ZCL_CLUSTER_ID_POLL_CONTROL_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_POLL_CONTROL_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_POLL_CONTROL_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_POLL_CONTROL_CHECK_IN_RESPONSE_ID, \
ZB_ZCL_CMD_POLL_CONTROL_FAST_POLL_STOP_ID, \
ZB_ZCL_CMD_POLL_CONTROL_SET_LONG_POLL_INTERVAL_ID, \
ZB_ZCL_CMD_POLL_CONTROL_SET_SHORT_POLL_INTERVAL_ID
#define ZB_ZCL_CLUSTER_ID_POLL_CONTROL_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_POLL_CONTROL_CLIENT_ROLE_GENERATED_CMD_LIST
/** @endcond */ /* DOXYGEN_INTERNAL_DOC */
/******************************* Check-in ******************************/
/*! @brief Send Check-in command, see HA spec 9.5.4.4
@param _buffer - to put packet to
@param _dst_addr - destination address
@param _dst_addr_mode - addressing mode
@param _dst_ep - destination endpoint
@param _local_ep - source endpoint
@param _prfl_id - profile identifier
@param _cb - callback for getting command send status
*/
#define ZB_ZCL_POLL_CONTROL_SEND_CHECK_IN_REQ( \
_buffer, _dst_addr, _dst_addr_mode, _dst_ep, _local_ep, _prfl_id, _cb) \
{ \
zb_uint8_t* _ptr = ZB_ZCL_START_PACKET(_buffer); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(_ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(_ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_POLL_CONTROL_CHECK_IN_ID); \
ZB_ZCL_FINISH_PACKET((_buffer), _ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
_buffer, _dst_addr, _dst_addr_mode, _dst_ep, _local_ep, _prfl_id, \
ZB_ZCL_CLUSTER_ID_POLL_CONTROL, _cb); \
}
/*! @brief Parameters to pass to device callback for incoming check in */
typedef struct zb_zcl_poll_control_check_in_cli_param_s
{
zb_uint16_t fast_poll_timeout;
zb_uint16_t short_addr;
zb_uint8_t ep;
}
zb_zcl_poll_control_check_in_cli_param_t;
/** @cond DOXYGEN_INTERNAL_DOC */
#define ZB_ZCL_POLL_CONTROL_CLI_CALL_USER_APP( \
_buffer, _short_addr, _ep, _fast_poll_timeout, _result) \
{ \
TRACE_MSG(TRACE_ZCL1, "ZB_ZCL_POLL_CONTROL_CLI_CALL_USER_APP", (FMT__0)); \
if (ZCL_CTX().device_cb) \
{ \
zb_zcl_device_callback_param_t *user_app_data = \
ZB_BUF_GET_PARAM((_buffer), zb_zcl_device_callback_param_t); \
zb_zcl_poll_control_check_in_cli_param_t *value = \
&(user_app_data->cb_param.checkin_cli_param); \
value->fast_poll_timeout = (_fast_poll_timeout); \
value->short_addr = (_short_addr); \
value->ep = (_ep); \
user_app_data->device_cb_id = ZB_ZCL_POLL_CONTROL_CHECK_IN_CLI_CB_ID; \
user_app_data->endpoint = (_ep); \
user_app_data->status = RET_OK; \
(ZCL_CTX().device_cb)(param); \
_result = user_app_data->status; \
} \
else \
{ \
_result = RET_OK; \
} \
}
/** @endcond */ /* DOXYGEN_INTERNAL_DOC */
/******************************* Check-in response ******************************/
/*! @brief Structure representation of Check-in response command payload */
typedef ZB_PACKED_PRE struct zb_zcl_poll_control_check_in_res_s
{
/** Start Fast Polling */
zb_uint8_t is_start;
/** Fast Poll Timeout */
zb_uint16_t timeout;
} ZB_PACKED_STRUCT zb_zcl_poll_control_check_in_res_t;
/*! @brief Send "Check-in response" command, see HA spec 9.5.5.3
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback
@param is_start - Start Fast Polling
@param timeout - Fast Poll Timeout
*/
#define ZB_ZCL_POLL_CONTROL_SEND_CHECK_IN_RES( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, \
is_start, timeout) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_POLL_CONTROL_CHECK_IN_RESPONSE_ID); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, (is_start)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (timeout)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_POLL_CONTROL, cb); \
}
/** @brief Macro for getting Check-in response command
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_poll_control_check_in_res_s.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_POLL_CONTROL_GET_CHECK_IN_RES(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_poll_control_check_in_res_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_poll_control_check_in_res_t *src_ptr = \
(zb_zcl_poll_control_check_in_res_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(data_ptr)->is_start = src_ptr->is_start; \
ZB_HTOLE16(&((data_ptr)->timeout), &(src_ptr->timeout)); \
} \
}
/******************************* Fast Poll Stop ******************************/
/*! @brief Send "Fast Poll Stop" command, see HA spec 9.5.5.4
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback
*/
#define ZB_ZCL_POLL_CONTROL_SEND_FAST_POLL_STOP_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_POLL_CONTROL_FAST_POLL_STOP_ID); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_POLL_CONTROL, cb); \
}
/******************************* Set Long Poll Interval ******************************/
/*! @brief Structure representation of Set Long Poll Interval command payload */
typedef ZB_PACKED_PRE struct zb_zcl_poll_control_set_long_poll_interval_req_s
{
/** New Long Poll Interval */
zb_uint32_t interval;
} ZB_PACKED_STRUCT zb_zcl_poll_control_set_long_poll_interval_t;
/*! @brief Send "Set Long Poll Interval" command, see HA spec 9.5.5.5
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback
@param interval - New Long Poll Interval
*/
#define ZB_ZCL_POLL_CONTROL_SEND_SET_LONG_POLL_INTERVAL_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, interval) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_POLL_CONTROL_SET_LONG_POLL_INTERVAL_ID); \
ZB_ZCL_PACKET_PUT_DATA32_VAL(ptr, (interval)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_POLL_CONTROL, cb); \
}
/** @brief Macro for getting "Set Long Poll Interval" command
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_poll_control_set_long_poll_interval_t.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_POLL_CONTROL_GET_SET_LONG_POLL_INTERVAL_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_poll_control_set_long_poll_interval_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_poll_control_set_long_poll_interval_t *src_ptr = \
(zb_zcl_poll_control_set_long_poll_interval_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_HTOLE32(&((data_ptr)->interval), &(src_ptr->interval)); \
} \
}
/******************************* Set Short Poll Interval ******************************/
/*! @brief Structure representation of Set Short Poll Interval command payload */
typedef ZB_PACKED_PRE struct zb_zcl_poll_control_set_short_poll_interval_req_s
{
/** New Short Poll Interval */
zb_uint16_t interval;
} ZB_PACKED_STRUCT zb_zcl_poll_control_set_short_poll_interval_t;
/*! @brief Send "Set Short Poll Interval" command, see HA spec 9.5.5.6
@param buffer to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback
@param interval - New Short Poll Interval
*/
#define ZB_ZCL_POLL_CONTROL_SEND_SET_SHORT_POLL_INTERVAL_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, interval) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, (def_resp)) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_POLL_CONTROL_SET_SHORT_POLL_INTERVAL_ID); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, (interval)); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, \
ZB_ZCL_CLUSTER_ID_POLL_CONTROL, cb); \
}
/** @brief Macro for getting "Set Short Poll Interval" command
* @attention Assumes that ZCL header already cut.
* @param data_ptr - pointer to a variable of type @ref
* zb_zcl_poll_control_set_short_poll_interval_t.
* @param buffer containing the packet (by pointer).
* @param status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_POLL_CONTROL_GET_SET_SHORT_POLL_INTERVAL_REQ(data_ptr, buffer, status) \
{ \
if (zb_buf_len((buffer)) < sizeof(zb_zcl_poll_control_set_short_poll_interval_t)) \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
zb_zcl_poll_control_set_short_poll_interval_t *src_ptr = \
(zb_zcl_poll_control_set_short_poll_interval_t*)zb_buf_begin((buffer)); \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
ZB_HTOLE16(&((data_ptr)->interval), &(src_ptr->interval)); \
} \
}
#if defined ZB_HA_ENABLE_POLL_CONTROL_SERVER || defined DOXYGEN
/**
* @brief Set client address information. This address is used to
* send Check-in command. If address information is NOT sent,
* check-in command will be sent assuming binding with client is
* created
* @param local_ep - local endpoint number, is used to find particular attribute
* @param addr - poll control client short address
* @param ep - poll control client end point
* @return RET_ERROR if addr is not a TC (WWAH requirement).
* RET_OK otherwise.
*/
zb_ret_t zb_zcl_poll_control_set_client_addr(zb_uint8_t local_ep, zb_uint16_t addr, zb_uint8_t ep);
#endif
#if defined ZB_ZCL_SUPPORT_CLUSTER_POLL_CONTROL || defined DOXYGEN
/**
@brief Function is used by Poll control client to set Fast poll
timeout value. This value is included into Check-in response
command
@param ep - local endpoint number, running Poll control client
@param fast_poll_timeout - Fast poll timeout value (in quarterseconds)
*/
void zb_zcl_set_fast_poll_timeout(zb_uint8_t ep, zb_uint16_t fast_poll_timeout);
#if defined ZB_USE_NVRAM || defined DOXYGEN
/**
@brief Save to NVRAM Poll Control dataset
@param param
@note ignore param, set it to 0
*/
void zb_zcl_poll_control_save_nvram(zb_uint8_t param);
#endif /* ZB_USE_NVRAM */
#endif /* ZB_ZCL_SUPPORT_CLUSTER_POLL_CONTROL */
/*! @} */ /* Poll Control cluster commands */
/*! @} */ /* ZCL Poll Control cluster definitions */
#if defined ZB_ENABLE_HA
zb_uint8_t zb_zcl_get_cmd_list_poll_control(zb_bool_t is_client_generated, zb_uint8_t **cmd_list);
#endif /* defined ZB_ENABLE_HA */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
#if defined ZB_ZCL_SUPPORT_CLUSTER_POLL_CONTROL
void zb_zcl_poll_control_init_server(void);
void zb_zcl_poll_control_init_client(void);
#define ZB_ZCL_CLUSTER_ID_POLL_CONTROL_SERVER_ROLE_INIT zb_zcl_poll_control_init_server
#define ZB_ZCL_CLUSTER_ID_POLL_CONTROL_CLIENT_ROLE_INIT zb_zcl_poll_control_init_client
#endif /* ZB_ZCL_SUPPORT_CLUSTER_POLL_CONTROL */
#endif /* ZB_ZCL_POLL_CONTROL_H */

View File

@@ -0,0 +1,757 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Power Configuration cluster definitions
*/
#ifndef ZB_ZCL_POWER_CONFIG_H
#define ZB_ZCL_POWER_CONFIG_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_POWER_CONFIG
* @{
*/
/**
* @brief Hook on Write attribute
* @param endpoint - endpoint number
* @param attr_id - ID of attribute being written
* @param new_value - pointer to new value of attribute
*/
void zb_zcl_power_config_write_attr_hook(zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t *new_value);
/* Cluster ZB_ZCL_CLUSTER_ID_POWER_CONFIG */
/*! @name Power Configuration cluster attributes
@{
*/
/*! @brief Power Configuration cluster attribute identifiers
@see ZCL spec, Power Configuration Cluster 3.3.2.2
*/
enum zb_zcl_power_config_attr_e
{
/** @brief MainsVoltage attribute, ZCL spec 3.3.2.2.1.1 */
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_ID = 0x0000,
/** @brief MainsFrequency attribute, ZCL spec 3.3.2.2.1.2 */
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_FREQUENCY_ID = 0x0001,
/** @brief MainsAlarmMask attribute, ZCL spec 3.3.2.2.2.1 */
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_ALARM_MASK_ID = 0x0010,
/** @brief MainsVoltageMinThreshold attribute, ZCL spec 3.3.2.2.2.2 */
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_MIN_THRESHOLD = 0x0011,
/** @brief MainsVoltageMaxThreshold attribute, ZCL spec 3.3.2.2.2.3 */
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_MAX_THRESHOLD = 0x0012,
/** @brief MainsVoltageDwellTripPoint attribute, ZCL spec 3.3.2.2.2.4 */
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_DWELL_TRIP_POINT = 0x0013,
/** @brief BatteryVoltage attribute, ZCL spec 3.3.2.2.3.1 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID = 0x0020,
/*! @brief BatteryPercentageRemaining attribute, ZCL spec 3.3.2.2.3.2 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_REMAINING_ID = 0x0021,
/** The BatteryManufacturer attribute is a maximum of 16 bytes in length
* and specifies the name of the battery manufacturer as a character string. */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_MANUFACTURER_ID = 0x0030,
/** @brief BatterySize attribute, ZCL spec 3.3.2.2.4.2 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_SIZE_ID = 0x0031,
/** The BatteryAHrRating attribute is 16 bits in length and specifies
* the Ampere-hour rating of the battery, measured in units of 10mAHr. */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_A_HR_RATING_ID = 0x0032,
/** @brief BatteryQuantity attribute, ZCL spec 3.3.2.2.4.4 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_QUANTITY_ID = 0x0033,
/** @brief BatteryRatedVoltage attribute, ZCL spec 3.3.2.2.4.5 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_RATED_VOLTAGE_ID = 0x0034,
/** @brief BatteryAlarmMask attribute, ZCL spec 3.3.2.2.4.6 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_ALARM_MASK_ID = 0x0035,
/** @brief BatteryVoltageMinThreshold attribute, ZCL spec 3.3.2.2.4.7 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_MIN_THRESHOLD_ID = 0x0036,
/*! @brief BatteryVoltageThreshold1 attribute, ZCL spec 3.3.2.2.4.8 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD1_ID = 0x0037,
/*! @brief BatteryVoltageThreshold2 attribute, ZCL spec 3.3.2.2.4.8 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD2_ID = 0x0038,
/*! @brief BatteryVoltageThreshold3 attribute, ZCL spec 3.3.2.2.4.8 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD3_ID = 0x0039,
/*! @brief BatteryPercentageMinThreshold attribute, ZCL spec 3.3.2.2.4.9 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_MIN_THRESHOLD_ID = 0x003a,
/*! @brief BatteryPercentageThreshold1 attribute, ZCL spec 3.3.2.2.4.10 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD1_ID = 0x003b,
/*! @brief BatteryPercentageThreshold2 attribute, ZCL spec 3.3.2.2.4.10 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD2_ID = 0x003c,
/*! @brief BatteryPercentageThreshold3 attribute, ZCL spec 3.3.2.2.4.10 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD3_ID = 0x003d,
/*! @brief BatteryAlarmState attribute, ZCL spec 3.3.2.2.4.11 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_ALARM_STATE_ID = 0x003e,
/*! @brief Battery Information 2 attribute set, ZCL spec 3.3.2.2.5 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_VOLTAGE_ID = 0x0040,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_PERCENTAGE_REMAINING_ID = 0x0041,
/*! @brief Battery Settings 2 attribute set, ZCL spec 3.3.2.2.6 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_MANUFACTURER_ID = 0x0050,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_SIZE_ID = 0x0051,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_A_HR_RATING_ID = 0x0052,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_QUANTITY_ID = 0x0053,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_RATED_VOLTAGE_ID = 0x0054,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_ALARM_MASK_ID = 0x0055,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_VOLTAGE_MIN_THRESHOLD_ID = 0x0056,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_VOLTAGE_THRESHOLD1_ID = 0x0057,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_VOLTAGE_THRESHOLD2_ID = 0x0058,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_VOLTAGE_THRESHOLD3_ID = 0x0059,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_PERCENTAGE_MIN_THRESHOLD_ID = 0x005a,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_PERCENTAGE_THRESHOLD1_ID = 0x005b,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_PERCENTAGE_THRESHOLD2_ID = 0x005c,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_PERCENTAGE_THRESHOLD3_ID = 0x005d,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY2_ALARM_STATE_ID = 0x005e,
/*! @brief Battery Information 3 attribute set, ZCL spec 3.3.2.2.7 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_VOLTAGE_ID = 0x0060,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_PERCENTAGE_REMAINING_ID = 0x0061,
/*! @brief Battery Settings 3 attribute set, ZCL spec 3.3.2.2.8 */
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_MANUFACTURER_ID = 0x0070,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_SIZE_ID = 0x0071,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_A_HR_RATING_ID = 0x0072,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_QUANTITY_ID = 0x0073,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_RATED_VOLTAGE_ID = 0x0074,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_ALARM_MASK_ID = 0x0075,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_VOLTAGE_MIN_THRESHOLD_ID = 0x0076,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_VOLTAGE_THRESHOLD1_ID = 0x0077,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_VOLTAGE_THRESHOLD2_ID = 0x0078,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_VOLTAGE_THRESHOLD3_ID = 0x0079,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_PERCENTAGE_MIN_THRESHOLD_ID = 0x007a,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_PERCENTAGE_THRESHOLD1_ID = 0x007b,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_PERCENTAGE_THRESHOLD2_ID = 0x007c,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_PERCENTAGE_THRESHOLD3_ID = 0x007d,
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY3_ALARM_STATE_ID = 0x007e,
/** @cond internals_doc */
/* Custom attributes */
ZB_ZCL_ATTR_POWER_CONFIG_CUSTOM_BATTERY_VOLTAGE_SHARP_ID = 0x8020
/*! @}
* @endcond */ /* internals_doc */
};
/**
* @brief Power Configuration MainsAlarmMask value
* see ZCL spec 3.3.2.2.4.7
*/
enum zb_zcl_power_config_mains_alarm_mask_e
{
/** @brief MainsAlarmMask - Mains Voltage too low */
ZB_ZCL_POWER_CONFIG_MAINS_ALARM_MASK_VOLTAGE_LOW = 0x01,
/** @brief MainsAlarmMask - Mains Voltage too high */
ZB_ZCL_POWER_CONFIG_MAINS_ALARM_MASK_VOLTAGE_HIGH = 0x02,
/** @brief MainsAlarmMask - Mains power supply lost/unavailable */
ZB_ZCL_POWER_CONFIG_MAINS_ALARM_MASK_VOLTAGE_UNAVAIL = 0x04,
};
/** @brief Default value for Power Configuration cluster revision global attribute */
#define ZB_ZCL_POWER_CONFIG_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief Default value for MainsAlarmMask attribute */
#define ZB_ZCL_POWER_CONFIG_MAINS_ALARM_MASK_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for MainsVoltageMinThreshold attribute */
#define ZB_ZCL_POWER_CONFIG_MAINS_VOLTAGE_MIN_THRESHOLD_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for MainsVoltageMaxThreshold attribute */
#define ZB_ZCL_POWER_CONFIG_MAINS_VOLTAGE_MAX_THRESHOLD_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for MainsDwellTripPoint attribute */
#define ZB_ZCL_POWER_CONFIG_MAINS_DWELL_TRIP_POINT_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief BatteryVoltage attribute invalid value */
#define ZB_ZCL_POWER_CONFIG_BATTERY_VOLTAGE_INVALID 0xff
/** @brief Power Configuration BatteryPercentageRemaining attribute unknown value */
#define ZB_ZCL_POWER_CONFIG_BATTERY_REMAINING_UNKNOWN 0xff
/** @brief Default value for BatteryRemainingHA attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_REMAINING_HA_DEFAULT_VALUE ((zb_uint8_t)0)
/** @brief Default value for BatteryManufacturer attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_MANUFACTURER_DEFAULT_VALUE {0}
/** @brief BatterySize attribute default value */
#define ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_DEFAULT_VALUE 0xff
/** @brief BatteryAlarmMask attribute default value */
#define ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_MASK_DEFAULT_VALUE 0x00
/** @brief Default value for BatteryVoltageMinThreshold attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_VOLTAGE_MIN_THRESHOLD_DEFAULT_VALUE ((zb_uint8_t)0x0000)
/** @brief Default value for BatteryVoltageThreshold1 attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD1_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for BatteryVoltageThreshold2 attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD2_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for BatteryVoltageThreshold3 attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD3_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for BatteryPercentageMinThreshold attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_PERCENTAGE_MIN_THRESHOLD_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for BatteryPercentageThreshold1 attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD1_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for BatteryPercentageThreshold2 attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD2_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for BatteryPercentageThreshold3 attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD3_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Default value for BatteryAlarmState attribute */
#define ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_DEFAULT_VALUE ((zb_uint32_t)0x00000000)
/** @brief MainsVoltageMinThreshold and MainsVoltageMaxThreshold values when alarm should not be generated*/
#define ZB_ZCL_POWER_CONFIG_THRESHOLD_ALARM_OMISSION_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Mains attribute set the least significant nibble*/
#define ZB_ZCL_POWER_CONFIG_MAINS_ATTRIBUTE_SET 0
/** @brief Battery attribute set the least significant nibble*/
#define ZB_ZCL_POWER_CONFIG_BATTERY_ATTRIBUTE_SET 0
/** @brief Battery Source 2 attribute set the least significant nibble*/
#define ZB_ZCL_POWER_CONFIG_BATTERY_SOURCE_2_ATTRIBUTE_SET 0x20
/** @brief Battery Source 3 attribute set the least significant nibble*/
#define ZB_ZCL_POWER_CONFIG_BATTERY_SOURCE_3_ATTRIBUTE_SET 0x40
/**
* @brief Power Configuration BatterySize value
* see ZCL spec 3.3.2.2.4.2
*/
enum zb_zcl_power_config_battery_size_e
{
/** @brief BatterySize - no battery*/
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_NO_BATTERY = 0,
/** @brief BatterySize - built in */
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_BUILT_IN = 1,
/** @brief BatterySize - other */
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_OTHER = 2,
/** @brief BatterySize - AA */
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_AA = 3,
/** @brief BatterySize - AAA */
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_AAA = 4,
/** @brief BatterySize - C */
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_C = 5,
/** @brief BatterySize - D */
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_D = 6,
/** @brief BatterySize - CR2 */
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_CR2 = 7,
/** @brief BatterySize - CR123A */
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_CR123A = 8,
/** @brief BatterySize - unknown */
ZB_ZCL_POWER_CONFIG_BATTERY_SIZE_UNKNOWN = 0xff,
};
/**
* @brief Power Configuration BatteryAlarmMask value
* see ZCL spec 3.3.2.2.4.7
*/
enum zb_zcl_power_config_battery_alarm_mask_e
{
/** @brief BatteryAlarmMask - Battery voltage too low */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_MASK_VOLTAGE_LOW = 0,
/** @brief BatteryAlarmMask - Alarm1 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_MASK_ALARM1 = 1,
/** @brief BatteryAlarmMask - Alarm2 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_MASK_ALARM2 = 2,
/** @brief BatteryAlarmMask - Alarm3 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_MASK_ALARM3 = 3,
};
/*! @brief Power Configuration Alarm Code for Alarm
@see ZCL spec 3.3.2.2.4.7, Table 3-25
*/
enum zb_zcl_power_config_battery_alarm_code_e
{
/** @brief MainsVoltageAlarmCode - MainsVoltageMinThreshold reached for Mains Voltage**/
ZB_ZCL_POWER_CONFIG_MAINS_VOLTAGE_ALARM_CODE_MIN_THRESHOLD = 0x00,
/** @brief MainsVoltageAlarmCode - MainsVoltageMaxThreshold reached for Mains Voltage**/
ZB_ZCL_POWER_CONFIG_MAINS_VOLTAGE_ALARM_CODE_MAX_THRESHOLD = 0x01,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold or
* BatteryPercentageMinThreshold reached for Battery Source 1 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE1_MIN_THRESHOLD = 0x10,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold1 or
* BatteryPercentageMinThreshold1 reached for Battery Source 1 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE1_VOLTAGE1 = 0x11,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold2 or
* BatteryPercentageMinThreshold2 reached for Battery Source 1 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE1_VOLTAGE2 = 0x12,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold3 or
* BatteryPercentageMinThreshold3 reached for Battery Source 1 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE1_VOLTAGE3 = 0x13,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold or
* BatteryPercentageMinThreshold reached for Battery Source 2 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE2_MIN_THRESHOLD = 0x20,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold1 or
* BatteryPercentageMinThreshold1 reached for Battery Source 2 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE2_VOLTAGE1 = 0x21,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold2 or
* BatteryPercentageMinThreshold2 reached for Battery Source 2 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE2_VOLTAGE2 = 0x22,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold3 or
* BatteryPercentageMinThreshold3 reached for Battery Source 2 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE2_VOLTAGE3 = 0x23,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold or
* BatteryPercentageMinThreshold reached for Battery Source 3 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE3_MIN_THRESHOLD = 0x30,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold1 or
* BatteryPercentageMinThreshold1 reached for Battery Source 3 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE3_VOLTAGE1 = 0x31,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold2 or
* BatteryPercentageMinThreshold2 reached for Battery Source 3 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE3_VOLTAGE2 = 0x32,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold3 or
* BatteryPercentageMinThreshold3 reached for Battery Source 3 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_SOURCE3_VOLTAGE3 = 0x33,
/** @brief Mains power supply lost/unavailable (i.e., device is running on battery) */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_CODE_MAINS_POWER_SUPPLY_LOST_UNAVAILABLE = 0x3a,
};
/*! @brief Power Configuration BatteryAlarmState
@see ZCL spec 3.3.2.2.4.11, Table 3-26
*/
enum zb_zcl_power_config_battery_alarm_state_e
{
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold or
* BatteryPercentageMinThreshold reached for Battery Source 1 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE1_MIN_THRESHOLD = 1 << 0,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold1 or
* BatteryPercentageMinThreshold1 reached for Battery Source 1 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE1_VOLTAGE1 = 1 << 1,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold2 or
* BatteryPercentageMinThreshold2 reached for Battery Source 1 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE1_VOLTAGE2 = 1 << 2,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold3 or
* BatteryPercentageMinThreshold3 reached for Battery Source 1 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE1_VOLTAGE3 = 1 << 3,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold or
* BatteryPercentageMinThreshold reached for Battery Source 2 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE2_MIN_THRESHOLD = 1 << 10,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold1 or
* BatteryPercentageMinThreshold1 reached for Battery Source 2 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE2_VOLTAGE1 = 1 << 11,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold2 or
* BatteryPercentageMinThreshold2 reached for Battery Source 2 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE2_VOLTAGE2 = 1 << 12,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold3 or
* BatteryPercentageMinThreshold3 reached for Battery Source 2 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE2_VOLTAGE3 = 1 << 13,
/* use 1l to exclude overflow at 16-bit CPU: force 32-bit enum */
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold or
* BatteryPercentageMinThreshold reached for Battery Source 3 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE3_MIN_THRESHOLD = 1l << 20,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold1 or
* BatteryPercentageMinThreshold1 reached for Battery Source 3 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE3_VOLTAGE1 = 1l << 21,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold2 or
* BatteryPercentageMinThreshold2 reached for Battery Source 3 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE3_VOLTAGE2 = 1l << 22,
/** @brief BatteryAlarmCode - BatteryVoltageMinThreshold3 or
* BatteryPercentageMinThreshold3 reached for Battery Source 3 */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_SOURCE3_VOLTAGE3 = 1l << 23,
/** @brief Mains power supply lost/unavailable (i.e., device is running on battery) */
ZB_ZCL_POWER_CONFIG_BATTERY_ALARM_STATE_MAINS_POWER_SUPPLY_LOST_UNAVAILABLE = 1l << 30,
};
/** @cond internals_doc */
/*! @internal @name Power Configuration cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_MAINS_FREQUENCY_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_FREQUENCY_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_MAINS_ALARM_MASK_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_ALARM_MASK_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_MIN_THRESHOLD(data_ptr) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_MIN_THRESHOLD, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_MAX_THRESHOLD(data_ptr) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_MAX_THRESHOLD, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_MAINS_DWELL_TRIP_POINT(data_ptr) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_MAINS_DWELL_TRIP_POINT, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_VOLTAGE_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_SIZE_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_SIZE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_QUANTITY_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_QUANTITY_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_RATED_VOLTAGE_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_RATED_VOLTAGE_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/* DA: HA12 change */
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_ALARM_MASK_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_ALARM_MASK_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_MIN_THRESHOLD_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_VOLTAGE_MIN_THRESHOLD_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_REMAINING_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_PERCENTAGE_REMAINING_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD1_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_VOLTAGE_THRESHOLD1_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD2_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_VOLTAGE_THRESHOLD2_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD3_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_VOLTAGE_THRESHOLD3_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_MIN_THRESHOLD_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_PERCENTAGE_MIN_THRESHOLD_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD1_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_PERCENTAGE_THRESHOLD1_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD2_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_PERCENTAGE_THRESHOLD2_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD3_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_PERCENTAGE_THRESHOLD3_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_ALARM_STATE_ID(data_ptr, bat_num) \
{ \
ZB_ZCL_ATTR_POWER_CONFIG_BATTERY##bat_num##_ALARM_STATE_ID, \
ZB_ZCL_ATTR_TYPE_32BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in Power
* Configuration cluster for 1 battery pack */
#undef ZB_ZCL_POWER_CONFIG_REPORT_ATTR_COUNT
#define ZB_ZCL_POWER_CONFIG_REPORT_ATTR_COUNT 2 /* Voltage + Alarm State */
/*! @internal Number of attributes mandatory for reporting in Power
* Configuration cluster for 2 Battery packs included */
#define ZB_ZCL_POWER_CONFIG_BAT_PACK_2_REPORT_ATTR_COUNT 4 /* Voltage + Voltage 2 + Alarm State +
* Alarm State 2 */
/*! @internal Number of attributes mandatory for reporting in Power
* Configuration cluster for 3 Battery packs included */
#define ZB_ZCL_POWER_CONFIG_BAT_PACK_3_REPORT_ATTR_COUNT 6 /* Voltage + Voltage 2 + Voltage 3 +
* Alarm State + Alarm State 2 + Alarm State 3*/
/*! @internal Alarm Code for Power Configuration cluster */
#define ZB_ZCL_POWER_CONFIG_MAINS_VOLTAGE_MIN_THRESHOLD_ALARM_CODE 0x00
#define ZB_ZCL_POWER_CONFIG_MAINS_VOLTAGE_MAX_THRESHOLD_ALARM_CODE 0x01
/*! @} */ /* Power Configuration cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for Power Configuration cluster - server side
@param attr_list - attribute list name
@param voltage - pointer to variable to store BatteryVoltage attribute
@param size - pointer to variable to store BatterySize attribute
@param quantity - pointer to variable to store BatteryQuantity attribute
@param rated_voltage - pointer to variable to store BatteryRatedVoltage attribute
@param alarm_mask - pointer to variable to store BatteryAlarmMask attribute
@param voltage_min_threshold - pointer to variable to store BatteryVoltageMinThreshold attribute
*/
#define ZB_ZCL_DECLARE_POWER_CONFIG_ATTRIB_LIST(attr_list, \
voltage, size, quantity, rated_voltage, \
alarm_mask, voltage_min_threshold) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_POWER_CONFIG) \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID(voltage, ), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_SIZE_ID(size, ), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_QUANTITY_ID(quantity, ), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_RATED_VOLTAGE_ID(rated_voltage, ), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_ALARM_MASK_ID(alarm_mask, ), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_MIN_THRESHOLD_ID(voltage_min_threshold, ), \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @cond internals_doc */
#define ZB_ZCL_POWER_CONFIG_MAINS_ATTRIB_LIST(voltage, frequency, alarm_mask, \
voltage_min_threshold, voltage_max_threshold, \
dwell_trip_point) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_ID, (voltage)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POWER_CONFIG_MAINS_FREQUENCY_ID, (frequency)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POWER_CONFIG_MAINS_ALARM_MASK_ID, (alarm_mask)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_MIN_THRESHOLD, (voltage_min_threshold)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POWER_CONFIG_MAINS_VOLTAGE_MAX_THRESHOLD, (voltage_max_threshold)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_POWER_CONFIG_MAINS_DWELL_TRIP_POINT, (dwell_trip_point))
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for Power Configuration cluster - server side (Mains
attribute set)
@param attr_list - attribute list name
@param voltage - pointer to variable to store MainsVoltage attribute
@param frequency - pointer to variable to store MainsFrequency attribute
@param alarm_mask - pointer to variable to store BatteryAlarmMask attribute
@param voltage_min_threshold - pointer to variable to store MainsVoltageMinThreshold attribute
@param voltage_max_threshold - pointer to variable to store MainsVoltageMaxThreshold attribute
@param dwell_trip_point - pointer to variable to store MainsVoltageDwellTripPoint attribute
*/
#define ZB_ZCL_DECLARE_POWER_CONFIG_MAINS_ATTRIB_LIST(attr_list, voltage, frequency, alarm_mask, \
voltage_min_threshold, voltage_max_threshold, \
dwell_trip_point) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_POWER_CONFIG) \
ZB_ZCL_POWER_CONFIG_MAINS_ATTRIB_LIST(voltage, frequency, alarm_mask, \
voltage_min_threshold, voltage_max_threshold, \
dwell_trip_point) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @cond internals_doc */
#define ZB_ZCL_POWER_CONFIG_BATTERY_ATTRIB_LIST_EXT(bat_num, \
voltage, size, quantity, rated_voltage, alarm_mask, voltage_min_threshold, \
remaining, threshold1, threshold2, threshold3, min_threshold, percent_threshold1, \
percent_threshold2, percent_threshold3, alarm_state) \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_ID(voltage, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_SIZE_ID(size, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_QUANTITY_ID(quantity, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_RATED_VOLTAGE_ID(rated_voltage, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_ALARM_MASK_ID(alarm_mask, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_MIN_THRESHOLD_ID(voltage_min_threshold, bat_num), \
/* ext attribute */ \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_REMAINING_ID(remaining, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD1_ID(threshold1, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD2_ID(threshold2, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_VOLTAGE_THRESHOLD3_ID(threshold3, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_MIN_THRESHOLD_ID(min_threshold, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD1_ID(percent_threshold1, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD2_ID(percent_threshold2, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_PERCENTAGE_THRESHOLD3_ID(percent_threshold3, bat_num), \
ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_POWER_CONFIG_BATTERY_ALARM_STATE_ID(alarm_state, bat_num),
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for Power Configuration cluster - server side (Battery attribute
list extended)
@param attr_list - attribute list name
@param voltage - pointer to variable to store BatteryVoltage attribute
@param size - pointer to variable to store BatterySize attribute
@param quantity - pointer to variable to store BatteryQuantity attribute
@param rated_voltage - pointer to variable to store BatteryRatedVoltage attribute
@param alarm_mask - pointer to variable to store BatteryAlarmMask attribute
@param voltage_min_threshold - pointer to variable to store BatteryVoltageMinThreshold attribute
@param remaining - pointer to variable to store BatteryPercentageRemaining attribute
@param threshold1 - pointer to variable to store BatteryVoltageThreshold1 attribute
@param threshold2 - pointer to variable to store BatteryVoltageThreshold2 attribute
@param threshold3 - pointer to variable to store BatteryVoltageThreshold3 attribute
@param min_threshold - pointer to variable to store BatteryPercentageMinThreshold attribute
@param percent_threshold1 - pointer to variable to store BatteryPercentageThreshold1 attribute
@param percent_threshold2 - pointer to variable to store BatteryPercentageThreshold2 attribute
@param percent_threshold3 - pointer to variable to store BatteryPercentageThreshold3 attribute
@param alarm_state - pointer to variable to store BatteryAlarmState attribute
*/
#define ZB_ZCL_DECLARE_POWER_CONFIG_BATTERY_ATTRIB_LIST_EXT(attr_list, \
voltage, size, quantity, rated_voltage, alarm_mask, voltage_min_threshold, \
remaining, threshold1, threshold2, threshold3, min_threshold, percent_threshold1, \
percent_threshold2, percent_threshold3, alarm_state) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_POWER_CONFIG) \
ZB_ZCL_POWER_CONFIG_BATTERY_ATTRIB_LIST_EXT(bat_num, \
voltage, size, quantity, rated_voltage, alarm_mask, voltage_min_threshold, \
remaining, threshold1, threshold2, threshold3, min_threshold, percent_threshold1, \
percent_threshold2, percent_threshold3, alarm_state) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Power Configuration cluster attributes */
/*! @name Power Configuration cluster commands
@{
*/
/*! @} */ /* Power Configuration cluster commands */
/*! @} */ /* ZCL Power Configuration cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_power_config_init_server(void);
void zb_zcl_power_config_init_client(void);
#define ZB_ZCL_CLUSTER_ID_POWER_CONFIG_SERVER_ROLE_INIT zb_zcl_power_config_init_server
#define ZB_ZCL_CLUSTER_ID_POWER_CONFIG_CLIENT_ROLE_INIT zb_zcl_power_config_init_client
#endif /* ZB_ZCL_POWER_CONFIG_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,322 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Pressure Measurement cluster definitions
*/
#ifndef ZB_ZCL_PRESSURE_MEASUREMENT_H
#define ZB_ZCL_PRESSURE_MEASUREMENT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_PRESSURE_MEASUREMENT
* @{
* @details
* All commands in the cluster have only request form, and carry no payload.
*/
/* Cluster ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT */
/*! @name Pressure Measurement cluster attributes
@{
*/
#if !defined(ZB_DISABLE_PRESSURE_MEASUREMENT_SCALE_TOLERANCE_ID) && defined(ZB_DISABLE_PRESSURE_MEASUREMENT_SCALE_ID)
# error If scale tolerance attribute is enabled, all scale attributes shall be enabled
#endif
/*! @brief Pressure Measurement cluster attribute identifiers
@see ZCL spec, Pressure Measurement Cluster 4.5.2.2.1
*/
enum zb_zcl_pressure_measurement_attr_e
{
/*! @brief MeasuredValue, ZCL spec 4.5.2.2.1.1 */
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_VALUE_ID = 0x0000,
/*! @brief MinMeasuredValue, ZCL spec 4.5.2.2.1.2 */
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_VALUE_ID = 0x0001,
/*! @brief MaxMeasuredValue, ZCL spec 4.5.2.2.1.3 */
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_VALUE_ID = 0x0002,
/*! @brief Tolerance, ZCL spec 4.5.2.2.1.4 */
#ifndef ZB_DISABLE_PRESSURE_MEASUREMENT_TOLERANCE_ID
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_TOLERANCE_ID = 0x0003,
#else
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_TOLERANCE_ID = 0xF003,
#endif
/*! @brief ScaledValue, ZCL spec 4.5.2.1.2.1 */
#ifndef ZB_DISABLE_PRESSURE_MEASUREMENT_SCALE_ID
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_VALUE_ID = 0x0010,
#else
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_VALUE_ID = 0xF010,
#endif
/*! @brief MinScaledValue, ZCL spec 4.5.2.1.2.2 */
#ifndef ZB_DISABLE_PRESSURE_MEASUREMENT_SCALE_ID
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_SCALED_VALUE_ID = 0x0011,
#else
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_SCALED_VALUE_ID = 0xF011,
#endif
/*! @brief MaxScaledValue, ZCL spec 4.5.2.1.2.3 */
#ifndef ZB_DISABLE_PRESSURE_MEASUREMENT_SCALE_ID
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_SACLED_VALUE_ID = 0x0012,
#else
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_SACLED_VALUE_ID = 0xF012,
#endif
/*! @brief ScaledTolerance, ZCL spec 4.5.2.1.2.4 */
#ifndef ZB_DISABLE_PRESSURE_MEASUREMENT_SCALE_TOLERANCE_ID
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_TOLERANCE_ID = 0x0013,
#else
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_TOLERANCE_ID = 0xF013,
#endif
/*! @brief Scale, ZCL spec 4.5.2.1.2.5 */
#ifndef ZB_DISABLE_PRESSURE_MEASUREMENT_SCALE_ID
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALE_ID = 0x0014,
#else
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALE_ID = 0xF014,
#endif
};
/** @brief Default value for Pressure Measurement cluster revision global attribute */
#define ZB_ZCL_PRESSURE_MEASUREMENT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/* (See: Table 4.15 Pressure Measurement Information Attribute Set) */
/** @brief MeasuredValue attribute unknown value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_VALUE_UNKNOWN ((zb_int16_t)0x8000)
/** @brief MinMeasuredValue attribute minimum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_VALUE_MIN_VALUE ((zb_int16_t)0x8001)
/** @brief MinMeasuredValue attribute maximum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_VALUE_MAX_VALUE ((zb_int16_t)0x7ffe)
/** @brief MinMeasuredValue attribute invalid value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_VALUE_INVALID ((zb_int16_t)0x8000)
/** @brief MaxMeasuredValue attribute minimum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_VALUE_MIN_VALUE ((zb_int16_t)0x8002)
/** @brief MaxMeasuredValue attribute maximum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_VALUE_MAX_VALUE ((zb_int16_t)0x7fff)
/** @brief MaxMeasuredValue attribute invalid value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_VALUE_INVALID ((zb_int16_t)0x8000)
/** @brief Tolerance attribute minimum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_TOLERANCE_MIN_VALUE ((zb_uint16_t)0x0000)
/** @brief Tolerance attribute maximum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_TOLERANCE_MAX_VALUE ((zb_uint16_t)0x0800)
/** @brief Default value for Value attribute */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_VALUE_DEFAULT_VALUE ((zb_int16_t)0xFFFF)
/** @brief Default value for MinValue attribute */
#define ZB_ZCL_PATTR_RESSURE_MEASUREMENT_MIN_VALUE_DEFAULT_VALUE ((zb_int16_t)0x8000)
/** @brief Default value for MaxValue attribute */
#define ZB_ZCL_PATTR_RESSURE_MEASUREMENT_MAX_VALUE_DEFAULT_VALUE ((zb_int16_t)0x8000)
/* (See: Table 4.16 Extended Pressure Measurement Information Attribute Set) */
/** @brief MinScaledValue attribute unknown value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_SCALED_VALUE_UNKNOWN ((zb_int16_t)0x8000)
/** @brief MinScaledValue attribute minimum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_SCALED_VALUE_MIN_VALUE ((zb_int16_t)0x8001)
/** @brief MinScaledValue attribute maximum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_SCALED_VALUE_MAX_VALUE ((zb_int16_t)0x7ffe)
/** @brief MaxScaledValue attribute unknown value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_SCALED_VALUE_UNKNOWN ((zb_int16_t)0x8000)
/** @brief MaxScaledValue attribute minimum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_SCALED_VALUE_MIN_VALUE ((zb_int16_t)0x8002)
/** @brief MaxScaledValue attribute maximum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_SCALED_VALUE_MAX_VALUE ((zb_int16_t)0x7fff)
/** @brief MaxScaledValue attribute minimum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_TOLERANCE_MIN_VALUE ((zb_uint16_t)0x0000)
/** @brief MaxScaledValue attribute maximum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_TOLERANCE_MAX_VALUE ((zb_uint16_t)0x0800)
/** @brief MaxScaledValue attribute minimum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALE_MIN_VALUE ((zb_int8_t)0x81)
/** @brief MaxScaledValue attribute maximum value */
#define ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALE_MAX_VALUE ((zb_int8_t)0x7f)
/** @cond internals_doc */
/*! @internal @name Pressure Measurement cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_TOLERANCE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_TOLERANCE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_SCALED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_SCALED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_SCALED_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_SCALED_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_TOLERANCE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALED_TOLERANCE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_SCALE_ID, \
ZB_ZCL_ATTR_TYPE_S8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in Pressure Measurement cluster */
#define ZB_ZCL_PRESSURE_MEASUREMENT_REPORT_ATTR_COUNT 1
/*! Write attribute hook is used to set min/max Pressure values */
void zb_zcl_pressure_measurement_write_attr_hook(
zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t *new_value);
/*! @} */ /* Pressure Measurement cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for Pressure Measurement cluster - server side
@param attr_list - attribute list name
@param value - pointer to variable to store MeasuredValue attribute
@param min_value - pointer to variable to store MinMeasuredValue attribute
@param max_value - pointer to variable to store MAxMeasuredValue attribute
@param tolerance - pointer to variable to store Tolerance attribute
*/
#define ZB_ZCL_DECLARE_PRESSURE_MEASUREMENT_ATTRIB_LIST(attr_list, \
value, min_value, max_value, tolerance) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_PRESSURE_MEASUREMENT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_VALUE_ID, (value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MIN_VALUE_ID, (min_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_MAX_VALUE_ID, (max_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_PRESSURE_MEASUREMENT_TOLERANCE_ID, (tolerance)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Pressure Measurement cluster attributes */
/*! @name Pressure Measurement cluster commands
@{
*/
/*! @} */ /* Pressure Measurement cluster commands */
/*! @} */ /* ZCL Pressure Measurement cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_pressure_measurement_init_server(void);
void zb_zcl_pressure_measurement_init_client(void);
#define ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT_SERVER_ROLE_INIT zb_zcl_pressure_measurement_init_server
#define ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT_CLIENT_ROLE_INIT zb_zcl_pressure_measurement_init_client
#endif /* ZB_ZCL_PRESSURE_MEASUREMENT_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,181 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Relative Humidity Measurement cluster definitions
*/
#ifndef ZB_ZCL_REL_HUMIDITY_MEASUREMENT_H
#define ZB_ZCL_REL_HUMIDITY_MEASUREMENT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_WATER_CONTENT_MEASUREMENT
* @{
*/
/* Cluster ZB_ZCL_WATER_CONTENT_MEASUREMENT */
/*! @name Water Content Measurement cluster attributes
@{
*/
/*! @brief Water Content Measurement cluster attribute identifiers
@see ZCL specification revision 7, Relative Humidity MeasuremenWater Content Measurement Cluster 4.7.2.1
*/
enum zb_zcl_rel_humidity_measurement_attr_e
{
/** @brief MeasuredValue, ZCL specification revision 7 subsection 4.7.2.1.1 MeasuredValue Attribute */
ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID = 0x0000,
/** @brief MinMeasuredValue, ZCL specification revision 7 subsection 4.7.2.1.2 MinMeasuredValue Attribute*/
ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_ID = 0x0001,
/** @brief MaxMeasuredValue, ZCL specification revision 7 subsection 4.7.2.1.3 MaxMeasuredValue Attribute*/
ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID = 0x0002,
/** The Tolerance attribute SHALL indicate the magnitude of the
* possible error that is associated with MeasuredValue, using
* the same units and resolution.
* @brief Tolerance, ZCL specification revision 7 subsection 4.7.2.1.4 Tolerance Attribute
*/
ZB_ZCL_ATTR_REL_HUMIDITY_TOLERANCE_ID = 0x0003,
};
/** @brief Default value for Water Content Measurement cluster revision global attribute */
#define ZB_ZCL_WATER_CONTENT_MEASUREMENT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief MeasuredValue attribute unknown value */
#define ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_UNKNOWN 0xFFFF
/** @brief MinMeasuredValue attribute minimum value */
#define ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_MIN_VALUE 0x0000
/** @brief MinMeasuredValue attribute maximum value */
#define ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_MAX_VALUE 0x270F
/** @brief MinMeasuredValue attribute undefined value */
#define ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_UNDEFINED 0xFFFF
/** @brief MaxMeasuredValue attribute minimum value */
#define ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_MIN_VALUE 0x0001
/** @brief MaxMeasuredValue attribute maximum value */
#define ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_MAX_VALUE 0x2710
/** @brief MaxMeasuredValue attribute value not defined */
#define ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_UNDEFINED 0xFFFF
/** @brief Default value for MeasurementValue attribute */
#define ZB_ZCL_REL_HUMIDITY_MEASUREMENT_VALUE_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for MeasurementMinValue attribute */
#define ZB_ZCL_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @brief Default value for MeasurementMaxValue attribute */
#define ZB_ZCL_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_DEFAULT_VALUE ((zb_uint16_t)0xFFFF)
/** @cond internals_doc */
/*! @internal @name Relative Humidity Measurement cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_ZCL_REL_HUMIDITY_MEASUREMENT_REPORT_ATTR_COUNT 1
/*! @} */ /* Relative Humidity Measurement cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for Relative Humidity Measurement cluster - server side
@param attr_list - attribute list name
@param value - pointer to variable to store MeasuredValue attribute
@param min_value - pointer to variable to store MinMeasuredValue attribute
@param max_value - pointer to variable to store MAxMeasuredValue attribute
*/
#define ZB_ZCL_DECLARE_REL_HUMIDITY_MEASUREMENT_ATTRIB_LIST(attr_list, \
value, min_value, max_value) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_WATER_CONTENT_MEASUREMENT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID, (value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_ID, (min_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID, (max_value)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Relative Humidity Measurement cluster attributes */
/*! @name Relative Humidity Measurement cluster commands
@{
*/
/*! @} */ /* Relative Humidity Measurement cluster commands */
/*! @} */ /* ZCL Relative Humidity Measurement cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_rel_humidity_init_server(void);
void zb_zcl_rel_humidity_init_client(void);
#define ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT_SERVER_ROLE_INIT zb_zcl_rel_humidity_init_server
#define ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT_CLIENT_ROLE_INIT zb_zcl_rel_humidity_init_client
#endif /* ZB_ZCL_REL_HUMIDITY_MEASUREMENT_H */

View File

@@ -0,0 +1,372 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Zigbee cluster library definitions for reporting functionality
*/
#ifndef ZB_ZCL_REPORTING_H
#define ZB_ZCL_REPORTING_H 1
#if !(defined ZB_ZCL_DISABLE_REPORTING) || defined(DOXYGEN)
/** @cond DOXYGEN_ZCL_SECTION */
/**
* @addtogroup ZB_ZCL_REPORTING
* @{
* @details
* ZCL attribute reporting being described in ZCL spec, subclauses 2.4.7 through 2.4.11, and
* subclauses covering clusters with reportable attributes.
*
* API for attribute reporting configuring and configuration details reading documented in: @ref
* cfg_reporting_cmd, and @ref report_attr_cmd respectively.
*
* Since all events related to attribute reporting are being handled internally, application can
* be provided with information on attribute report receipt event, and attribute report not
* received within predefined interval event. To handle these events, application may set
* "report attribute" and "no reporting" callbacks with @ref ZB_ZCL_SET_REPORT_ATTR_CB() and
* @ref ZB_ZCL_SET_NO_REPORTING_CB() macros respectively.
*
* @par Example
* @snippet light_sample/dimmable_light/bulb.c zb_zcl_set_report_attr_cb
* @snippet light_sample/dimmable_light/bulb.c zb_zcl_set_report_attr_cb_example
* @par
*/
/* Boundary and default values are defined by application profile */
/*! Default value for minimum reporting interval */
#define ZB_ZCL_MIN_REPORTING_INTERVAL_DEFAULT 0x0005
/*! Default value for maximum reporting interval */
#define ZB_ZCL_MAX_REPORTING_INTERVAL_DEFAULT 0x0000
union zb_zcl_attr_var_u
{
zb_uint8_t u8;
zb_int8_t s8;
zb_uint16_t u16;
zb_int16_t s16;
zb_uint24_t u24;
zb_int24_t s24;
zb_uint32_t u32;
zb_int32_t s32;
zb_uint48_t u48;
zb_uint8_t data_buf[4];
zb_uint32_t data_buf_crc32;
zb_single_t f32;
};
/** @cond internals_doc */
/** @brief Structure for storing Reporting information */
typedef struct zb_zcl_reporting_info_s
{
zb_uint8_t direction; /*!< Direction: report is send or received */
zb_uint8_t ep; /*!< Endpoint number */
zb_uint16_t cluster_id; /*!< Cluster ID for reporting */
zb_uint8_t cluster_role;
zb_uint16_t attr_id; /*!< Attribute ID for reporting */
zb_uint8_t flags; /*!< Flags to inform status of reporting */
zb_time_t run_time; /*!< Time to run next reporting activity */
union
{
struct
{
zb_uint16_t min_interval; /*!< Actual minimum reporting interval */
zb_uint16_t max_interval; /*!< Actual maximum reporting interval */
union zb_zcl_attr_var_u delta; /*!< Actual reportable change */
union zb_zcl_attr_var_u reported_value; /*!< The last reported value */
zb_uint16_t def_min_interval; /*!< Default minimum reporting interval */
zb_uint16_t def_max_interval; /*!< Default maximum reporting interval */
}
send_info; /*!< send_info is stored on cluster server side (as usual) and describes how
attribute should be reported */
struct
{
zb_uint16_t timeout; /*!< Timeout period */
}
recv_info; /*!< recv_info is stored on cluster client side (as usual) and describes how
attribute report is received */
}
u;
struct
{
zb_uint16_t short_addr; /*!< Destination short address */
zb_uint8_t endpoint; /*!< Destination endpoint */
zb_uint16_t profile_id; /*!< Profile id */
}
dst;
zb_uint16_t manuf_code; /*!< Manufacturer specific code */
}
zb_zcl_reporting_info_t;
#if defined ZB_USE_NVRAM
/* FIXME: Dataset is not aligned (21 bytes)! Fix align and use u48 instead of u32 for delta! */
/** @brief Structure for storing Reporting information to NVRAM */
typedef ZB_PACKED_PRE struct zb_zcl_reporting_info_nvram_s
{
zb_uint8_t direction; /*!< Direction: report is send or received */
zb_uint8_t ep; /*!< Endpoint number */
zb_uint16_t cluster_id; /*!< Cluster ID for reporting */
zb_uint8_t cluster_role; /*!< Cluster role */
zb_uint16_t attr_id; /*!< Attribute ID for reporting */
zb_uint16_t manuf_code; /*!< Manufacturer specific code */
zb_uint8_t flags; /*!< Flags to inform status of reporting */
zb_uint16_t min_interval; /*!< Minimum reporting interval or timeout for client*/
zb_uint16_t max_interval; /*!< Maximum reporting interval */
/* FIXME: Should be U48 here! Leave it as is to do not perform migration! U32 delta is enough for
* the most cases... */
zb_uint32_t delta; /*!< Reportable change */
zb_uint16_t short_addr_dest; /*!< Destination short address */
zb_uint8_t endpoint_dest; /*!< Destination endpoint */
zb_uint16_t profile_id_dest; /*!< Profile id */
zb_uint8_t align[1];
} ZB_PACKED_STRUCT zb_zcl_reporting_info_nvram_t;
#endif /* defined ZB_USE_NVRAM */
typedef struct zb_zcl_reporting_ctx_s
{
zb_uint16_t min_interval;
zb_uint16_t max_interval;
zb_uint16_t timeout;
zb_uint8_t buf_ref;
}
zb_zcl_reporting_ctx_t;
/** @endcond */ /* internals_doc */
/** @brief Informs application that some attribute value was not reported during defined time
interval
@param ep - endpoint number
@param cluster_id - cluster ID
@param attr_id - attribute ID
*/
typedef void (*zb_zcl_no_reporting_cb_t)(
zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint16_t attr_id);
/** @brief Informs application about received attribute report
@param addr - source address
@param src_ep - source endpoint number
@param dst_ep - destination endpoint number
@param cluster_id - cluster ID
@param attr_id - attribute ID
@param attr_type - attribute type
@param value - pointer to reported data value
*/
typedef void (*zb_zcl_report_attr_cb_t)(
zb_zcl_addr_t *addr, zb_uint8_t src_ep, zb_uint8_t dst_ep, zb_uint16_t cluster_id, zb_uint16_t attr_id, zb_uint8_t attr_type, zb_uint8_t *value);
/** @cond internals_doc */
/** Enumeration of reporting info flag values */
typedef enum zb_zcl_reporting_flags_e
{
ZB_ZCL_REPORTING_SLOT_BUSY = 0x01, /*!< Reporting info slot is busy */
ZB_ZCL_REPORT_ATTR = 0x01 << 1, /*!< Current attribute should be reported */
ZB_ZCL_REPORT_IS_ALLOWED = 0x01 << 2, /*!< Reporting for attribute is allowed if
* min_interval timeout condition is met */
ZB_ZCL_REPORTING_STOP = 0x01 << 3, /*!< Stop reporting this attribute */
ZB_ZCL_REPORT_TIMER_STARTED = 0x01 << 4,
ZB_ZCL_REPORT_IS_SENT = 0x01 << 5,
ZB_ZCL_REPORT_IS_FIRST = 0x01 << 6, /*!< First report for this attribute */
}
zb_zcl_reporting_flags_t;
#define ZB_ZCL_SET_REPORTING_FLAG(rep_info, f) ((rep_info)->flags |= (zb_uint8_t)(f))
#define ZB_ZCL_CLR_REPORTING_FLAG(rep_info, f) ((rep_info)->flags &= (zb_uint8_t)(f^0xFF))
#define ZB_ZCL_GET_REPORTING_FLAG(rep_info, f) ((rep_info)->flags & (zb_uint8_t)(f))
#define ZB_ZCL_CLR_ALL_REPORTING_FLAGS(rep_info) ((rep_info)->flags = 0)
/*! @internal min_interval zero value */
#define ZB_ZCL_MIN_INTERVAL_ZERO 0x0000
/*! @internal Check, if min_interval should be taken into account */
#define ZB_ZCL_MIN_INTERVAL_SPECIFIED \
(ZCL_CTX().reporting_ctx.min_interval != ZB_ZCL_MIN_INTERVAL_ZERO)
/** @endcond */ /* internals_doc */
/** @brief If Maximum reporting interval is set to value 0xFFFF,reporting is not needed for current
attribute
*/
#define ZB_ZCL_REPORTING_NOT_NEEDED 0xFFFF
/** @cond internals_doc */
#define ZB_ZCL_TIMEOUT_ZERO 0x0000
#define ZB_ZCL_INVALID_TIMEOUT 0xFFFF
#define ZB_ZCL_UNDEFINED_REPORTING_SLOT 0xFF
#define ZB_ZCL_MAX_REPORTING_SLOTS_BY_EP (ZB_ZCL_UNDEFINED_REPORTING_SLOT / ZB_ZCL_MAX_EP_NUMBER)
/************************** Reporting functions declarations **********************************/
#ifdef ZB_ZCL_ENABLE_DEFAULT_REPORT_ATTR_PROCESSING
void zb_zcl_report_attr_cmd_handler(zb_uint8_t param);
#endif
void zb_zcl_report_received(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id);
void zb_zcl_report_received_manuf(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id, zb_uint16_t manuf_code);
zb_ret_t zb_zcl_put_reporting_info(zb_zcl_reporting_info_t* rep_info_ptr, zb_bool_t override);
zb_ret_t zb_zcl_put_reporting_info_from_req(zb_zcl_configure_reporting_req_t *config_rep_req,
zb_zcl_attr_addr_info_t* attr_addr_info);
void zb_zcl_init_reporting_info(void);
zb_zcl_reporting_info_t* zb_zcl_find_reporting_info( zb_uint8_t ep,
zb_uint16_t cluster_id,
zb_uint8_t cluster_role,
zb_uint16_t attr_id);
zb_zcl_reporting_info_t* zb_zcl_find_reporting_info_manuf( zb_uint8_t ep,
zb_uint16_t cluster_id,
zb_uint8_t cluster_role,
zb_uint16_t attr_id,
zb_uint16_t manuf_code);
zb_zcl_reporting_info_t* zb_zcl_get_next_reporting_info(
zb_zcl_reporting_info_t *rep_info_init, zb_uint8_t is_manuf_spec);
void zb_zcl_reporting_cb(zb_uint8_t param);
void zb_zcl_save_reported_value(zb_zcl_reporting_info_t *rep_info, zb_zcl_attr_t* attr_desc);
void zb_zcl_mark_attr_for_reporting(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id);
void zb_zcl_mark_attr_for_reporting_manuf(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id, zb_uint16_t manuf_code);
/** @endcond */ /* internals_doc */
/** @brief Start attribute reporting
@deprecated This function will be removed in the next Major release after February 2023
Use @ref zb_zcl_start_attr_reporting_manuf() instead
@param ep - endpoint number
@param cluster_id - cluster ID
@param cluster_role - cluster role
@param attr_id - attribute ID
@return RET_OK if reporting is successfully started \n
RET_DOES_NOT_EXIST if reporting can't be configured with given parameters (i.e cluster not present)
*/
zb_ret_t zb_zcl_start_attr_reporting(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id);
/** @brief Start attribute reporting
@param ep - endpoint number
@param cluster_id - cluster ID
@param cluster_role - cluster role
@param attr_id - attribute ID
@param manuf_code - manufacturer specific code
@return RET_OK if reporting is successfully started \n
RET_DOES_NOT_EXIST if reporting can't be configured with given parameters (i.e cluster not present)
*/
zb_ret_t zb_zcl_start_attr_reporting_manuf(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id, zb_uint16_t manuf_code);
/** @brief Stop attribute reporting
@deprecated This function will be removed in the next Major release after February 2023
Use @ref zb_zcl_stop_attr_reporting_manuf() instead
@param ep - endpoint number
@param cluster_id - cluster ID
@param cluster_role - cluster role
@param attr_id - attribute ID
@return RET_OK if reporting is successfully stopped \n
RET_DOES_NOT_EXIST if reporting was not set up with given parameters
*/
zb_ret_t zb_zcl_stop_attr_reporting(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id);
/** @brief Stop attribute reporting
@param ep - endpoint number
@param cluster_id - cluster ID
@param cluster_role - cluster role
@param attr_id - attribute ID
@param manuf_code - manufacturer specific code
@return RET_OK if reporting is successfully stopped \n
RET_DOES_NOT_EXIST if reporting was not set up with given parameters
*/
zb_ret_t zb_zcl_stop_attr_reporting_manuf(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id, zb_uint16_t manuf_code);
/** @brief Check if an attribute is configured for reporting or not
@deprecated This function will be removed in the next Major release after February 2023
Use @ref zcl_is_attr_reported_manuf() instead
@param ep - endpoint number
@param cluster_id - cluster ID
@param cluster_role - cluster role
@param attr_id - attribute ID
@return ZB_TRUE if attribute is reported
*/
zb_bool_t zcl_is_attr_reported(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id);
/** @brief Check if an attribute is configured for reporting or not
@param ep - endpoint number
@param cluster_id - cluster ID
@param cluster_role - cluster role
@param attr_id - attribute ID
@param manuf_code - manufacturer specific code
@return ZB_TRUE if attribute is reported
*/
zb_bool_t zcl_is_attr_reported_manuf(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id, zb_uint16_t manuf_code);
/* TODO: Document */
zb_ret_t zb_zcl_put_reporting_info(zb_zcl_reporting_info_t* rep_info_ptr, zb_bool_t override);
/** @} */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
#endif /* !(defined ZB_ZCL_DISABLE_REPORTING) || defined(DOXYGEN) */
#endif /* ZB_ZCL_REPORTING_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,296 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Shade Configuration cluster definitions
*/
#ifndef ZB_ZCL_SHADE_CONFIG_H
#define ZB_ZCL_SHADE_CONFIG_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/* Logically most opened value */
#define ZB_ZCL_SHADE_CONFIG_LOGICALLY_MOST_OPENED 0
/* Logically most closed value */
#define ZB_ZCL_SHADE_CONFIG_LOGICALLY_MOST_CLOSED 0xffff
/** @defgroup ZB_ZCL_SHADE_CONFIG ZCL Shade Configuration cluster
@ingroup ZB_ZCL_CLUSTERS
@addtogroup ZB_ZCL_SHADE_CONFIG
@{
*/
/** @name Shade Configuration cluster attributes
@{
*/
/** @brief Shade Configuration cluster information attribute set identifiers
@see ZCL spec, subclause 7.2.2.2.1
*/
enum zb_zcl_shade_config_info_attr_e
{
/** The PhysicalClosedLimit attribute indicates the most closed (numerically lowest)
* position that the shade can physically move to. */
ZB_ZCL_ATTR_SHADE_CONFIG_PHYSICAL_CLOSED_LIMIT_ID = 0x0000,
/** The MotorStepSize attribute indicates the angle the shade motor moves for one step,
* measured in 1/10th of a degree. */
ZB_ZCL_ATTR_SHADE_CONFIG_MOTOR_STEP_SIZE_ID = 0x0001,
/** @brief Status attribute */
ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_ID = 0x0002
};
/** @brief Bit values for Status attribute
* @see ZCL spec, subclause 7.2.2.2.1.3
*/
enum zb_zcl_shade_config_status_type_e
{
/** Shade operational value */
ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_SHADE_OPERATIONAL = 0x00,
/** Shade Adjusting value */
ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_SHADE_ADJUSTING = 0x01,
/** Shade Direction value */
ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_SHADE_DIRECTION = 0x02,
/** Forward Direction of Motor value */
ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_FORWARD_DIRECTION_OF_MOTOR = 0x03,
/** Reserved values */
ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_RESERVED = 0x04
};
/** @cond internals_doc */
/** @internal Set bits from conf_var variable to type_value */
#define ZB_ZCL_SET_BIT(conf_var, type_value) \
{ \
(conf_var) = (conf_var) | (type_value); \
}
/** @internal Get type_value bits from conf_var variable */
#define ZB_ZCL_GET_BIT(conf_var, type_value) ((conf_var) & (type_value))
/** @internal Clear type_value bits in conf_var variable */
#define ZB_ZCL_CLR_BIT(conf_var, type_value) \
{ \
(conf_var) = (conf_var) & ~(type_value); \
}
/*! @}
* @endcond */ /* internals_doc */
/** @brief Sets bits of Status parameter
@param type_value - bit to set
@param conf_var - config variable
*/
#define ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_SET(conf_var, type_value) \
ZB_ZCL_SET_BIT(conf_var, type_value)
/** @brief Gets bit value of Status parameter
@param type_value - bit value to check
@param conf_var - config variable
*/
#define ZB_ZCL_ATTR_SHADE_CONFIG_GET_STATUS_BIT_VAL(conf_var, type_value) \
ZB_ZCL_GET_BIT(conf_var, type_value)
/** @brief Clear bit of Status parameter
@param type_value - bit to clear
@param conf_var - config variable
*/
#define ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_CLEAR(conf_var, type_value) \
ZB_ZCL_CLR_BIT(conf_var, type_value)
/** @brief Shade cluster settings attribute set identifiers
@see ZCL spec, subclause 7.2.2.2.2
*/
enum zb_zcl_shade_config_settings_attr_e
{
/** @brief ClosedLimit attribute */
ZB_ZCL_ATTR_SHADE_CONFIG_CLOSED_LIMIT_ID = 0x0010,
/** @brief Mode attribute */
ZB_ZCL_ATTR_SHADE_CONFIG_MODE_ID = 0x0011
};
/** @brief Permissible values for Mode attribute
@see ZCL spec, subclause 7.2.2.2.2.2 */
enum zb_zcl_shade_config_mode_e
{
/** Normal value */
ZB_ZCL_ATTR_SHADE_CONFIG_MODE_NORMAL = 0x00,
/** Configure value */
ZB_ZCL_ATTR_SHADE_CONFIG_MODE_CONFIGURE = 0x01,
/** Reserved values */
ZB_ZCL_ATTR_SHADE_CONFIG_MODE_RESERVED = 0x02
};
/** @cond internals_doc */
typedef struct zb_zcl_shade_set_value_param_s
{
zb_uint16_t new_value;
zb_bool_t is_config;
} zb_zcl_shade_set_value_param_t;
typedef struct zb_zcl_shade_get_value_param_s
{
zb_uint16_t ret_value;
} zb_zcl_shade_get_value_param_t;
/*! @}
* @endcond */ /* internals_doc */
/** @brief Default value for Shade Configuration cluster revision global attribute */
#define ZB_ZCL_SHADE_CONFIG_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Shade Configuration Status attribute default value */
#define ZB_ZCL_SHADE_CONFIG_STATUS_DEFAULT_VALUE 0x00
/** @brief ClosedLimit attribute default value */
#define ZB_ZCL_SHADE_CONFIG_CLOSED_LIMIT_DEFAULT_VALUE 0x0001
/** @brief Zero Point attribute default value */
#define ZB_ZCL_SHADE_CONFIG_ZERO_POINT_DEFAULT_VALUE 0x0000
/** @brief Mode attribute default value */
#define ZB_ZCL_SHADE_CONFIG_MODE_DEFAULT_VALUE ZB_ZCL_ATTR_SHADE_CONFIG_MODE_NORMAL
/** @brief Declare attribute list for Shade Configuration cluster
@param attr_list - attribute list name
@param status - pointer to variable to store Status attribute value
@param closed_limit - pointer to variable to store ClosedLimit attribute value
@param mode - pointer to variable to store Mode attribute value
*/
#define ZB_ZCL_DECLARE_SHADE_CONFIG_ATTRIB_LIST(attr_list, status, closed_limit, mode) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_SHADE_CONFIG) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_ID, (status)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_SHADE_CONFIG_CLOSED_LIMIT_ID, (closed_limit)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_SHADE_CONFIG_MODE_ID, (mode)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @} */ /* Shade Configuration cluster attributes */
/* Descriptors for server side */
/** @cond internals_doc */
/** @name Shade Configuration cluster internals
Internal structures for Shade Configuration cluster
@internal
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_SHADE_CONFIG_STATUS_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_SHADE_CONFIG_CLOSED_LIMIT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_SHADE_CONFIG_CLOSED_LIMIT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_SHADE_CONFIG_MODE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_SHADE_CONFIG_MODE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** Number of attributes mandatory for reporting in Shade Configuration cluster */
#define ZB_ZCL_SHADE_CONFIG_REPORT_ATTR_COUNT 0
/** Macro for setting Mode attribute
@param ep - endpoint id
@param mode_val - mode value
*/
/** @brief Shade Configuration cluster command identifiers
@see ZCL spec, subclause ?
*/
/*enum zb_zcl_shade_config_cmd_e
{
};*/
/** Mandatory commands defines */
/*! @internal Setting Shade Mode value macro:
@param ep - endpoint where setting
@param mode_val - Shade Mode value
*/
#define ZB_ZCL_SHADE_SET_MODE(ep, mode_val) \
{ \
zb_uint8_t mode = (mode_val); \
ZB_ZCL_SET_ATTRIBUTE((ep), \
ZB_ZCL_CLUSTER_ID_SHADE_CONFIG, \
ZB_ZCL_ATTR_SHADE_CONFIG_MODE_ID, \
&mode, \
ZB_FALSE); \
}
/** @} */ /* Shade Configuration cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/** @name Shade Configuration cluster commands
@{
*/
/** @} */ /* Shade Configuration cluster commands */
/** @} */ /* ZCL Shade Configuration cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_shade_config_init_server(void);
void zb_zcl_shade_config_init_client(void);
#define ZB_ZCL_CLUSTER_ID_SHADE_CONFIG_SERVER_ROLE_INIT zb_zcl_shade_config_init_server
#define ZB_ZCL_CLUSTER_ID_SHADE_CONFIG_CLIENT_ROLE_INIT zb_zcl_shade_config_init_client
#endif /* ZB_ZCL_SHADE_CONFIG_H */

View File

@@ -0,0 +1,405 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Sub-GHz cluster definitions
*/
#ifndef ZB_ZCL_SUBGHZ_H
#define ZB_ZCL_SUBGHZ_H 1
#if defined ZB_ZCL_SUPPORT_CLUSTER_SUBGHZ || defined DOXYGEN
#include "zboss_api_core.h" /* ZBOSS core API types */
#include "zb_zcl_common.h"
/** @cond (DOXYGEN_ZCL_SECTION && DOXYGEN_SUBGHZ_FEATURE) */
/** @addtogroup ZB_ZCL_SUBGHZ
* @{
* @details This cluster provides attributes and commands specific to the use of Sub-GHz frequencies
* for a Smart Energy network.
*/
/** @defgroup ZB_ZCL_SUBGHZ_ATTRS Sub-GHz cluster attributes
* @{
*/
/** @brief Sub-GHz cluster's server-side attributes
* @see SE spec, subclause 14.2.2
*/
typedef enum zb_zcl_subghz_srv_attr_e
{
ZB_ZCL_ATTR_SUBGHZ_CHANNEL_CHANGE = 0x0000, /**< This is a 32-bit channel mask that defines
* the sub-GHz channel that the Coordinators
* Network Manager intends to move to.
* @par Value format
* bits 0..26 - channel number
* bits 27..31 - channel page number
*/
ZB_ZCL_ATTR_SUBGHZ_PAGE28_CHANNEL_MASK = 0x0001, /**< This is a 32-bit channel mask that defines
* the channels that are to be scanned when
* forming, joining or re-joining a network.
* Page 28 defines the first 27 channels within
* the 863-876MHz frequency band.
* @par Value format
* bits 0..26 - channel numbers bitmask
* bits 27..31 - page number (28 == 0b11100)
*/
ZB_ZCL_ATTR_SUBGHZ_PAGE29_CHANNEL_MASK = 0x0002, /**< This is a 32-bit channel mask that defines
* the channels that are to be scanned when
* forming, joining or re-joining a network.
* Page 29 defines channels 27 to 34 and channel
* 62 of the 863-876MHz frequency band.
* @par Value format
* bits 0..8 - channel numbers bitmask
* bits 9..26 - unused (set to 0)
* bits 27..31 - page number (29 == 0b11101)
*/
ZB_ZCL_ATTR_SUBGHZ_PAGE30_CHANNEL_MASK = 0x0003, /**< This is a 32-bit channel mask that defines
* the channels that are to be scanned when
* forming, joining or re-joining a network.
* Page 30 defines channels 35 to 61 of the
* 863-876MHz frequency band.
* @par Value format
* bits 0..26 - channel numbers bitmask
* bits 27..31 - page number (30 == 0b11110)
*/
ZB_ZCL_ATTR_SUBGHZ_PAGE31_CHANNEL_MASK = 0x0004 /**< This is a 32-bit channel mask that defines
* the channels that are to be scanned when
* forming, joining or re-joining a network.
* Page 31 defines the 27 channels within the
* 915-921MHz frequency band.
* @par Value format
* bits 0..26 - channel numbers bitmask
* bits 27..31 - page numbers (31 == 0b11111)
*/
} zb_zcl_subghz_svr_attr_t;
/** @brief Default value for Sub-GHz cluster revision global attribute (not defined anywhere) */
#define ZB_ZCL_SUBGHZ_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @cond internals_doc */
#ifndef ZB_ED_ROLE
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_SUBGHZ_CHANNEL_CHANGE(data_ptr) \
{ \
ZB_ZCL_ATTR_SUBGHZ_CHANNEL_CHANGE, \
ZB_ZCL_ATTR_TYPE_32BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_SUBGHZ_PAGE28_CHANNEL_MASK(data_ptr) \
{ \
ZB_ZCL_ATTR_SUBGHZ_PAGE28_CHANNEL_MASK, \
ZB_ZCL_ATTR_TYPE_32BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_SUBGHZ_PAGE29_CHANNEL_MASK(data_ptr) \
{ \
ZB_ZCL_ATTR_SUBGHZ_PAGE29_CHANNEL_MASK, \
ZB_ZCL_ATTR_TYPE_32BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_SUBGHZ_PAGE30_CHANNEL_MASK(data_ptr) \
{ \
ZB_ZCL_ATTR_SUBGHZ_PAGE30_CHANNEL_MASK, \
ZB_ZCL_ATTR_TYPE_32BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_SUBGHZ_PAGE31_CHANNEL_MASK(data_ptr) \
{ \
ZB_ZCL_ATTR_SUBGHZ_PAGE31_CHANNEL_MASK, \
ZB_ZCL_ATTR_TYPE_32BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @def ZB_ZCL_DECLARE_SUBGHZ_SRV_ATTR_LIST(attr_list, channel_change)
* @brief Declares mandatory attributes list for Sub-GHz cluster server
* @param[in] attr_list - attribute list name
* @param[in] channel_change - pointer to variable which will store ChannelChange attribute value
*/
#define ZB_ZCL_DECLARE_SUBGHZ_SRV_ATTR_LIST_PARTIAL(attr_list, channel_change) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_SUBGHZ) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_SUBGHZ_CHANNEL_CHANGE, (channel_change)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @def ZB_ZCL_DECLARE_SUBGHZ_SRV_ATTR_LIST_FULL(attr_list, channel_change, page28_channel_mask, page29_channel_mask, page30_channel_mask, page31_channel_mask)
* @brief Declares mandatory and all optional attributes list for Sub-GHz cluster server
* @param[in] attr_list - attribute list name
* @param[in] channel_change - pointer to variable which will store ChannelChange attribute value
* @param[in] page28_channel_mask - pointer to variable which will store Page28ChannelMask attribute value
* @param[in] page29_channel_mask - pointer to variable which will store Page29ChannelMask attribute value
* @param[in] page30_channel_mask - pointer to variable which will store Page30ChannelMask attribute value
* @param[in] page31_channel_mask - pointer to variable which will store Page31ChannelMask attribute value
*/
#define ZB_ZCL_DECLARE_SUBGHZ_SRV_ATTR_LIST_FULL(attr_list, channel_change, page28_channel_mask, page29_channel_mask, page30_channel_mask, page31_channel_mask) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_SUBGHZ) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_SUBGHZ_CHANNEL_CHANGE, (channel_change)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_SUBGHZ_PAGE28_CHANNEL_MASK, (page28_channel_mask)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_SUBGHZ_PAGE29_CHANNEL_MASK, (page29_channel_mask)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_SUBGHZ_PAGE30_CHANNEL_MASK, (page30_channel_mask)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_SUBGHZ_PAGE31_CHANNEL_MASK, (page31_channel_mask)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @endcond */ /* internals_doc */
/**
* @brief Sub GHz cluster attributes
*/
typedef struct zb_zcl_sub_ghz_attrs_s
{
/** @see ZB_ZCL_ATTR_SUBGHZ_CHANNEL_CHANGE
*/
zb_uint32_t channel_change;
/** @see ZB_ZCL_ATTR_SUBGHZ_PAGE28_CHANNEL_MASK
*/
zb_uint32_t page28_channel_mask;
/** @see ZB_ZCL_ATTR_SUBGHZ_PAGE29_CHANNEL_MASK
*/
zb_uint32_t page29_channel_mask;
/** @see ZB_ZCL_ATTR_SUBGHZ_PAGE30_CHANNEL_MASK
*/
zb_uint32_t page30_channel_mask;
/** @see ZB_ZCL_ATTR_SUBGHZ_PAGE31_CHANNEL_MASK
*/
zb_uint32_t page31_channel_mask;
}
zb_zcl_sub_ghz_attrs_t;
/** Declare attribute list for Sub-GHz cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - pointer to @ref zb_zcl_sub_ghz_attrs_s structure
*/
#define ZB_ZCL_DECLARE_SUBGHZ_SRV_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_SUBGHZ_SRV_ATTR_LIST_FULL(attr_list, &attrs.channel_change, &attrs.page28_channel_mask, &attrs.page29_channel_mask, &attrs.page30_channel_mask, &attrs.page31_channel_mask)
#endif /* !ZB_ED_ROLE */
/** @} */ /* ZB_ZCL_SUBGHZ_ATTRS */
/** @defgroup ZB_ZCL_SUBGHZ_COMMANDS Sub-GHz cluster commands
* @{
*/
/** @brief Sub-GHz cluster's server-side commands IDs
* @see SE spec, subclause 14.2.3
*/
typedef enum zb_zcl_subghz_srv_cmd_e
{
ZB_ZCL_SUBGHZ_SRV_CMD_SUSPEND_ZCL_MESSAGES = 0x00 /**< The @b SuspendZCLMessages command is sent to
* client device(s) by the server device when the
* server device has determined that the client
* device(s) shall suspend their ZCL communications
* to the server device for the period stated in
* the command. The command is also sent in response
* to a @b GetSuspendZCLMessagesStatus command.
* @note This command is sent automatically by SubGHz
* cluster and is not available in the application.
*/
} zb_zcl_subghz_srv_cmd_t;
/** @brief @ref ZB_ZCL_SUBGHZ_SRV_CMD_SUSPEND_ZCL_MESSAGES "SuspendZCLMessages" command payload
* @details An unsigned 8-bit integer indicating the period, in minutes, during which ZCL
* communications from the device shall be suspended. A value of zero shall indicate that ZCL
* communications are not currently suspended.
* @see SE spec, subclause 14.2.3.1
*/
typedef zb_uint8_t zb_zcl_subghz_suspend_zcl_msg_payload_t;
/** @brief Sub-GHz cluster's cliend-side commands IDs
* @see SE spec, subclause 14.3.3
*/
typedef enum zb_zcl_subghz_cli_cmd_e
{
ZB_ZCL_SUBGHZ_CLI_CMD_GET_SUSPEND_ZCL_MESSAGES_STATUS = 0x00 /**< The @b GetSuspendZCLMessagesStatus
* command allows a client device to
* request the current status of its
* ZCL communications with the server.
* @note This command is Mandatory for BOMDs.
*/
} zb_zcl_subghz_cli_cmd_t;
/* SUBGHZ cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_SUBGHZ_SERVER_ROLE_GENERATED_CMD_LIST ZB_ZCL_SUBGHZ_SRV_CMD_SUSPEND_ZCL_MESSAGES
#define ZB_ZCL_CLUSTER_ID_SUBGHZ_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_SUBGHZ_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_SUBGHZ_CLIENT_ROLE_GENERATED_CMD_LIST ZB_ZCL_SUBGHZ_CLI_CMD_GET_SUSPEND_ZCL_MESSAGES_STATUS
#define ZB_ZCL_CLUSTER_ID_SUBGHZ_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_SUBGHZ_CLIENT_ROLE_GENERATED_CMD_LIST
/** @cond internals_doc */
/** @brief Server-side Sub-GHz cluster context
*/
typedef struct zb_zcl_subghz_srv_ctx_s
{
/* FIXME: rewrite to exclude additional memory usage. */
zb_address_ieee_ref_t dev_list[ZB_NEIGHBOR_TABLE_SIZE]; /**< ref list to Sub-GHz devices in neighbor table */
zb_uint8_t mode; /**< MAC Duty Cycle Mode */
} zb_zcl_subghz_srv_ctx_t;
/** @brief Client-side Sub-GHz cluster context
*/
typedef struct zb_zcl_subghz_cli_ctx_s
{
zb_uint8_t zc_ep; /**< endpoint with Sub-GHz cluster on Coordinator */
zb_bool_t suspend_zcl_messages; /**< if TRUE, device is suspended by Coordinator */
} zb_zcl_subghz_cli_ctx_t;
/** @brief Sub-GHz cluster context
*/
typedef struct zb_zcl_subghz_ctx_s
{
#ifndef ZB_ED_ROLE
zb_zcl_subghz_srv_ctx_t srv; /**< server context */
#endif
zb_zcl_subghz_cli_ctx_t cli; /**< client context */
/* common fields */
zb_uint8_t ep; /**< endpoint of Sub-GHz cluster on this device */
} zb_zcl_subghz_ctx_t;
/** @fn void zb_subghz_cli_get_suspend_zcl_messages_status(zb_uint8_t param, zb_addr_u *dst_addr, zb_uint8_t dst_addr_mode, zb_uint8_t dst_ep, zb_uint8_t src_ep)
* @brief Sends @b GetSuspendZCLMessagesStatus client command
* @param[in] param - reference to the buffer to be used for outgoing packet
* @param[in] dst_addr - Coordinator's address (either short or long)
* @param[in] dst_addr_mode - address mode (see @ref aps_addr_mode)
* @param[in] dst_ep - endpoint address of Sub-GHz cluster on Coordinator
* @param[in] src_ep - endpoint address of Sub-GHz cluster on this device
*/
void zb_subghz_cli_get_suspend_zcl_messages_status(zb_uint8_t param,
zb_addr_u *dst_addr,
zb_uint8_t dst_addr_mode,
zb_uint8_t dst_ep,
zb_uint8_t src_ep);
/** @fn void zb_subghz_srv_suspend_zcl_messages(zb_uint8_t param, zb_addr_u *dst_addr, zb_uint8_t dst_addr_mode, zb_uint8_t dst_ep, zb_uint8_t src_ep, zb_zcl_subghz_suspend_zcl_msg_payload_t *payload)
* @brief Sends @b SuspendZCLMessages server command
*/
void zb_subghz_srv_suspend_zcl_messages(zb_uint8_t param,
zb_addr_u *dst_addr,
zb_uint8_t dst_addr_mode,
zb_uint8_t dst_ep,
zb_uint8_t src_ep,
zb_zcl_subghz_suspend_zcl_msg_payload_t *payload);
zb_bool_t zb_subghz_srv_device_suspended(zb_uint16_t addr);
/* TODO: Not implemented yet, disabling it for now to avoid MISRA violations */
#if 0
/** @fn zb_bool_t zb_zcl_process_subghz_specific_commands(zb_uint8_t param)
* @brief Internal handler for Sub-GHz specific commands
* @param[in] param - reference to the buffer containing incoming command
* @returns ZB_TRUE, if command was processed by Sub-GHz cluster, ZB_FALSE otherwise
*/
zb_bool_t zb_zcl_process_subghz_specific_commands(zb_uint8_t param);
#endif
/**
Start (or continue) polling ZC by Get Suspend ZCL Message Status
*/
void zb_subghz_start_suspend_status_poll(zb_uint8_t param);
zb_bool_t zb_subghz_catch_ota_image_block_req(zb_uint8_t *paramp);
#ifdef ZB_SUSPEND_APSDE_DATAREQ_BY_SUBGHZ_CLUSTER
/* Internal function for cancelling all APS outgoing transactions,
* called from zb_subghz_cli_suspend_zcl_messages when it receives a suspend command
*/
void zb_aps_cancel_outgoing_trans(zb_uint8_t param);
#endif /* ZB_SUSPEND_APSDE_DATAREQ_BY_SUBGHZ_CLUSTER */
#endif /* if defined ZB_ZCL_SUPPORT_CLUSTER_SUBGHZ || defined DOXYGEN */
/** @endcond */ /* internals_doc */
/** @} */ /* ZB_ZCL_SUBGHZ_COMMANDS */
/** @} */ /* ZB_ZCL_SUBGHZ */
/** @endcond */ /* DOXYGEN_ZCL_SECTION && DOXYGEN_SUBGHZ_FEATURE */
#ifdef ZB_ZCL_SUPPORT_CLUSTER_SUBGHZ
void zb_zcl_subghz_init_server(void);
void zb_zcl_subghz_init_client(void);
#define ZB_ZCL_CLUSTER_ID_SUB_GHZ_SERVER_ROLE_INIT zb_zcl_subghz_init_server
#define ZB_ZCL_CLUSTER_ID_SUB_GHZ_CLIENT_ROLE_INIT zb_zcl_subghz_init_client
#endif /* ZB_ZCL_SUPPORT_CLUSTER_SUBGHZ */
#ifdef ZB_ENABLE_SE
#define ZB_ZCL_SUBGHZ_CLUSTER_PROFILE_ID() (ZB_SE_MODE() ?\
ZB_AF_SE_PROFILE_ID : \
ZB_AF_HA_PROFILE_ID)
#else
#define ZB_ZCL_SUBGHZ_CLUSTER_PROFILE_ID() (ZB_AF_HA_PROFILE_ID)
#endif /* ZB_ENABLE_SE */
#endif /* ZB_ZCL_SUBGHZ_H */

View File

@@ -0,0 +1,210 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Temperature Measurement cluster definitions
*/
#ifndef ZB_ZCL_TEMP_MEASUREMENT_H
#define ZB_ZCL_TEMP_MEASUREMENT_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_TEMP_MEASUREMENT
* @{
* @details
* All commands in the cluster have only request form, and carry no payload.
*/
/* Cluster ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT */
/*! @name Temperature Measurement cluster attributes
@{
*/
/*! @brief Temperature Measurement cluster attribute identifiers
@see ZCL spec, Temperature Measurement Cluster 4.4.2.2.1
*/
enum zb_zcl_temp_measurement_attr_e
{
/*! @brief MeasuredValue, ZCL spec 4.4.2.2.1.1 */
ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID = 0x0000,
/*! @brief MinMeasuredValue, ZCL spec 4.4.2.2.1.2 */
ZB_ZCL_ATTR_TEMP_MEASUREMENT_MIN_VALUE_ID = 0x0001,
/*! @brief MaxMeasuredValue, ZCL spec 4.4.2.2.1.3 */
ZB_ZCL_ATTR_TEMP_MEASUREMENT_MAX_VALUE_ID = 0x0002,
/*! @brief Tolerance, ZCL spec 4.4.2.2.1.4 */
#ifndef ZB_DISABLE_TEMP_MEASUREMENT_TOLERANCE_ID
ZB_ZCL_ATTR_TEMP_MEASUREMENT_TOLERANCE_ID = 0x0003,
#else
ZB_ZCL_ATTR_TEMP_MEASUREMENT_TOLERANCE_ID = 0xF003,
#endif
};
/** @brief Default value for Temperature Measurement cluster revision global attribute */
#define ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0003u)
/** @brief MeasuredValue attribute unknown value */
#define ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_UNKNOWN ((zb_int16_t)0x8000)
/** @brief MinMeasuredValue attribute minimum value */
#define ZB_ZCL_ATTR_TEMP_MEASUREMENT_MIN_VALUE_MIN_VALUE ((zb_int16_t)0x954d)
/** @brief MinMeasuredValue attribute maximum value */
#define ZB_ZCL_ATTR_TEMP_MEASUREMENT_MIN_VALUE_MAX_VALUE 0x7ffe
/** @brief MinMeasuredValue attribute invalid value */
#define ZB_ZCL_ATTR_TEMP_MEASUREMENT_MIN_VALUE_INVALID ((zb_int16_t)0x8000)
/** @brief MaxMeasuredValue attribute minimum value */
#define ZB_ZCL_ATTR_TEMP_MEASUREMENT_MAX_VALUE_MIN_VALUE ((zb_int16_t)0x954e)
/** @brief MaxMeasuredValue attribute maximum value */
#define ZB_ZCL_ATTR_TEMP_MEASUREMENT_MAX_VALUE_MAX_VALUE 0x7fff
/** @brief MaxMeasuredValue attribute invalid value */
#define ZB_ZCL_ATTR_TEMP_MEASUREMENT_MAX_VALUE_INVALID ((zb_int16_t)0x8000)
/* (See: Table 4-13 Temperature Measurement Information Attribute Set) */
/** @brief Tolerance attribute minimum value */
#define ZB_ZCL_ATTR_TEMP_MEASUREMENT_TOLERANCE_MIN_VALUE 0x0000
/** @brief Tolerance attribute maximum value */
#define ZB_ZCL_ATTR_TEMP_MEASUREMENT_TOLERANCE_MAX_VALUE 0x0800
/** @brief Default value for Value attribute */
#define ZB_ZCL_TEMP_MEASUREMENT_VALUE_DEFAULT_VALUE ZB_ZCL_NON_VALUE_INT16
/** @brief Default value for MinValue attribute */
#define ZB_ZCL_TEMP_MEASUREMENT_MIN_VALUE_DEFAULT_VALUE ZB_ZCL_NON_VALUE_INT16
/** @brief Default value for MaxValue attribute */
#define ZB_ZCL_TEMP_MEASUREMENT_MAX_VALUE_DEFAULT_VALUE ZB_ZCL_NON_VALUE_INT16
/** @cond internals_doc */
/*! @internal @name Temperature Measurement cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TEMP_MEASUREMENT_MIN_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TEMP_MEASUREMENT_MIN_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TEMP_MEASUREMENT_MAX_VALUE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TEMP_MEASUREMENT_MAX_VALUE_ID, \
ZB_ZCL_ATTR_TYPE_S16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TEMP_MEASUREMENT_TOLERANCE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TEMP_MEASUREMENT_TOLERANCE_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in Temperature Measurement cluster */
#define ZB_ZCL_TEMP_MEASUREMENT_REPORT_ATTR_COUNT 1
/*! Write attribute hook is used to set min/max temperature values */
void zb_zcl_temp_measurement_write_attr_hook(
zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t *new_value);
/*! @} */ /* Temperature Measurement cluster internals */
/*! @}
* @endcond */ /* internals_doc */
/** @brief Declare attribute list for Temperature Measurement cluster - server side
@param attr_list - attribute list name
@param value - pointer to variable to store MeasuredValue attribute
@param min_value - pointer to variable to store MinMeasuredValue attribute
@param max_value - pointer to variable to store MAxMeasuredValue attribute
@param tolerance - pointer to variable to store Tolerance attribute
*/
#define ZB_ZCL_DECLARE_TEMP_MEASUREMENT_ATTRIB_LIST(attr_list, \
value, min_value, max_value, tolerance) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_TEMP_MEASUREMENT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, (value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TEMP_MEASUREMENT_MIN_VALUE_ID, (min_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TEMP_MEASUREMENT_MAX_VALUE_ID, (max_value)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TEMP_MEASUREMENT_TOLERANCE_ID, (tolerance)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Temperature Measurement cluster attributes */
/*! @name Temperature Measurement cluster commands
@{
*/
/*! @} */ /* Temperature Measurement cluster commands */
/*! @} */ /* ZCL Temperature Measurement cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_temp_measurement_init_server(void);
void zb_zcl_temp_measurement_init_client(void);
#define ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT_SERVER_ROLE_INIT zb_zcl_temp_measurement_init_server
#define ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT_CLIENT_ROLE_INIT zb_zcl_temp_measurement_init_client
#endif /* ZB_ZCL_TEMP_MEASUREMENT_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,175 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Thermostat UI Configuration cluster definitions
*/
#ifndef ZB_ZCL_THERMOSTAT_UI_CONFIG_H
#define ZB_ZCL_THERMOSTAT_UI_CONFIG_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/* Cluster ZB_ZCL_CLUSTER_ID_THERMOSTAT_UI_CONFIG */
/*! @addtogroup ZB_ZCL_THERMOSTAT_UI_CONFIG
@{
@name Thermostat UI Configuration cluster attributes
@{
*/
/*! @brief Thermostat UI Configuration cluster attribute identifiers
@see ZCL spec, subclause 6.6.2.2
*/
enum zb_zcl_thermostat_ui_config_attr_e
{
/** @brief Temperature Display Mode attribute */
ZB_ZCL_ATTR_THERMOSTAT_UI_CONFIG_TEMPERATURE_DISPLAY_MODE_ID = 0x0000,
/** @brief Keypad Lockout attribute */
ZB_ZCL_ATTR_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_ID = 0x0001,
/** The ScheduleProgrammingVisibility attribute is used to hide the weekly
* schedule programming functionality or menu on a thermostat from a user
* to prevent local user programming of the weekly schedule. */
ZB_ZCL_ATTR_THERMOSTAT_UI_CONFIG_SCHEDULE_PROGRAMMING_VISIBILITY_ID = 0x0002,
};
/*! @brief Values for Temperature Display Mode attribute,
@see ZCL spec, subclause 6.6.2.2.1 */
enum zb_zcl_thermostat_ui_config_temperature_display_mode_e
{
/*! Temperature in C value */
ZB_ZCL_THERMOSTAT_UI_CONFIG_TEMPERATURE_DISPLAY_MODE_IN_C = 0x00,
/*! Temperature in F value */
ZB_ZCL_THERMOSTAT_UI_CONFIG_TEMPERATURE_DISPLAY_MODE_IN_F = 0x01,
ZB_ZCL_THERMOSTAT_UI_CONFIG_TEMPERATURE_DISPLAY_MODE_RESERVED = 0x02
};
/*! @brief Values for Keypad Lockout attribute,
@see ZCL spec, subclause 6.6.2.2.2 */
enum zb_zcl_thermostat_ui_config_keypad_lockout_e
{
/*! No Lockout value */
ZB_ZCL_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_NO_LOCKOUT = 0x00,
/*! Level 1 Lockout value */
ZB_ZCL_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_LEVEL_1 = 0x01,
/*! Level 2 Lockout value */
ZB_ZCL_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_LEVEL_2 = 0x02,
/*! Level 3 Lockout value */
ZB_ZCL_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_LEVEL_3 = 0x03,
/*! Level 4 Lockout value */
ZB_ZCL_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_LEVEL_4 = 0x04,
/*! Level 5 Lockout value */
ZB_ZCL_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_LEVEL_5 = 0x05,
ZB_ZCL_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_RESERVED = 0x06
};
/** @brief Default value for Thermostat UI Configuration cluster revision global attribute */
#define ZB_ZCL_THERMOSTAT_UI_CONFIG_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0001u)
/** @brief Default value for Temperature Display Mode attribute */
#define ZB_ZCL_THERMOSTAT_UI_CONFIG_TEMPERATURE_DISPLAY_MODE_DEFAULT_VALUE 0x00
/** @brief Default value for Keypad Lockout attribute */
#define ZB_ZCL_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_DEFAULT_VALUE 0x00
/** @brief Default value for ScheduleProgrammingVisibility attribute */
#define ZB_ZCL_THERMOSTAT_UI_CONFIG_SCHEDULE_PROGRAMMING_VISIBILITY_DEFAULT_VALUE ((zb_uint8_t)0x00)
/** @brief Declare attribute list for Thermostat UI Configuration cluster
@param attr_list - attribute list name
@param temperature_display_mode - pointer to variable to store Temperature Display Mode attribute value
@param keypad_lockout - pointer to variable to store Keypad Lockout attribute value
*/
#define ZB_ZCL_DECLARE_THERMOSTAT_UI_CONFIG_ATTRIB_LIST(attr_list, temperature_display_mode, keypad_lockout) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_THERMOSTAT) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_THERMOSTAT_UI_CONFIG_TEMPERATURE_DISPLAY_MODE_ID, (temperature_display_mode)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_ID, (keypad_lockout)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/*! @} */ /* Thermostat UI Configuration cluster attributes */
/*! @name Thermostat UI Configuration cluster commands
@{
*/
/*! @} */ /* Thermostat UI Configuration cluster commands */
/*! @cond internals_doc
@internal @name Thermostat UI Configuration cluster internals
Internal structures for attribute representation in cluster definitions.
@{
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_THERMOSTAT_UI_CONFIG_TEMPERATURE_DISPLAY_MODE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_THERMOSTAT_UI_CONFIG_TEMPERATURE_DISPLAY_MODE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_THERMOSTAT_UI_CONFIG_KEYPAD_LOCKOUT_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in Thermostat UI Configuration cluster */
#define ZB_ZCL_THERMOSTAT_UI_CONFIG_REPORT_ATTR_COUNT 0
/*! @}
@endcond */ /* Thermostat UI Configuration cluster internals */
/*! @} */ /* ZCL HA Thermostat UI Configuration cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_thermostat_ui_config_init_server(void);
void zb_zcl_thermostat_ui_config_init_client(void);
#define ZB_ZCL_CLUSTER_ID_THERMOSTAT_UI_CONFIG_SERVER_ROLE_INIT zb_zcl_thermostat_ui_config_init_server
#define ZB_ZCL_CLUSTER_ID_THERMOSTAT_UI_CONFIG_CLIENT_ROLE_INIT zb_zcl_thermostat_ui_config_init_client
#endif /* ZB_ZCL_THERMOSTAT_UI_CONFIG_H */

View File

@@ -0,0 +1,491 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Time cluster definitions
*/
#ifndef ZB_ZCL_TIME_H
#define ZB_ZCL_TIME_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_TIME ZCL Time cluster
* @{
* @details
*/
/* Cluster ZB_ZCL_CLUSTER_ID_TIME */
/**
* @brief Set real time clock callback
* @param[in] time - UTC time at which real time clock will be set
* @return ZB_TRUE if real time clock was set to new value and ZB_FALSE otherwise
*
*/
typedef zb_bool_t (*zb_zcl_time_set_real_time_clock_t)(zb_uint32_t time);
/** @cond internals_doc */
/**
* @brief Set user's callback that will be initialize real time clock on device by
* specified value.
* @param[in] cb - Callback function
* @see zb_zcl_time_set_real_time_clock_t
*
*/
void zb_zcl_set_real_time_clock_callback(zb_zcl_time_set_real_time_clock_t cb);
/* typedef struct */
/** This enum defines possible authoritative levels of time server */
enum time_server_authoritative_level_e
{
ZB_ZCL_TIME_SERVER_NOT_CHOSEN = 0,
ZB_ZCL_TIME_HAS_SYNCHRONIZED_BIT,
ZB_ZCL_TIME_HAS_MASTER_BIT,
ZB_ZCL_TIME_HAS_MASTER_AND_SUPERSEDING_BITS,
ZB_ZCL_TIME_COORDINATOR_WITH_MASTER_AND_SUPERSEDING_BITS
};
/** Time synchronization payload */
typedef struct zb_zcl_time_sync_payload_s
{
/** Network time received from the most authoritative Time server */
zb_uint32_t time;
/** Source address of the most authoritative Time server */
zb_uint16_t addr;
/** Source endpoint of the most authoritative Time server */
zb_uint8_t endpoint;
/** Authoritative level of Time source server.
* @see @ref time_server_authoritative_level_e
*/
zb_uint8_t level;
} zb_zcl_time_sync_payload_t;
/** @endcond */ /* internals_doc */
/**
* @brief Set user's callback that will be initialize real time clock on device by
* specified value.
* "If the Master bit of the @ref ZB_ZCL_ATTR_TIME_TIME_STATUS_ID "TimeStatus" attribute has a value of 0,
* writing to @ref ZB_ZCL_ATTR_TIME_TIME_ID "Time" attribute SHALL set the real time clock to the written value,
* otherwise it cannot be written."
* @see ZCL spec, subclause 3.12.2.2.1
*
*/
#define ZB_ZCL_TIME_SET_REAL_TIME_CLOCK_CB(func_ptr) (zb_zcl_set_real_time_clock_callback((func_ptr)))
#define ZB_TIME_COMPARE_AUTH_LEVEL(new_level, new_short_addr, old_level, old_short_addr) \
(((new_level) > (old_level)) || \
(((old_level) > ZB_ZCL_TIME_SERVER_NOT_CHOSEN) && \
((new_level) == (old_level)) && \
((new_short_addr) < (old_short_addr))))
/**
* @brief Callback to call when new time server found during synchronization.
*/
typedef void (*zb_zcl_time_sync_time_server_found_cb_t)(zb_ret_t status, zb_uint32_t auth_level, zb_uint16_t short_addr,
zb_uint8_t ep, zb_uint32_t nw_time);
/**
* @brief Start time synchronization.
* @param endpoint endpoint for each time server synchronization shall be started.
* @param cb callback that will be called on each successful time server discovery.
* @details Start time synchronization process. If device doesn't have master bit set in Time Status attribute of Time Cluster
* then starts to search available time server in Zigbee network and tries to read status and time attributes.
* After time server successfully found and gathered attributes their values will be passed to application
* to take further actions.
*/
void zb_zcl_time_server_synchronize(zb_uint8_t endpoint, zb_zcl_time_sync_time_server_found_cb_t cb);
/**
* @brief Handle read attribute response for time cluster.
* @details Handles read attribute response while time synchronization process running.
* If time synchronization process is not started or finished there will be no processing.
*/
zb_bool_t zb_zcl_time_server_read_attr_handle(zb_uint8_t param);
/** @defgroup ZB_ZCL_TIME_ATTRS Time cluster attributes
@{
*/
/*! @brief Time cluster attribute identifiers
@see ZCL spec, subclause 3.12.2.2
*/
enum zb_zcl_time_attr_e
{
/*! @brief Time attribute */
ZB_ZCL_ATTR_TIME_TIME_ID = 0x0000,
/*! @brief Time Status attribute */
ZB_ZCL_ATTR_TIME_TIME_STATUS_ID = 0x0001,
/*! @brief Time Zone attribute */
ZB_ZCL_ATTR_TIME_TIME_ZONE_ID = 0x0002,
/*! @brief Dst Start attribute */
ZB_ZCL_ATTR_TIME_DST_START_ID = 0x0003,
/*! @brief Dst End attribute */
ZB_ZCL_ATTR_TIME_DST_END_ID = 0x0004,
/*! @brief Dst Shift attribute */
ZB_ZCL_ATTR_TIME_DST_SHIFT_ID = 0x0005,
/*! @brief Standard Time attribute */
ZB_ZCL_ATTR_TIME_STANDARD_TIME_ID = 0x0006,
/*! @brief Local Time attribute */
ZB_ZCL_ATTR_TIME_LOCAL_TIME_ID = 0x0007,
/*! @brief Last Set Time attribute */
ZB_ZCL_ATTR_TIME_LAST_SET_TIME_ID = 0x0008,
/*! @brief Valid Until Time attribute */
ZB_ZCL_ATTR_TIME_VALID_UNTIL_TIME_ID = 0x0009
};
/*! @brief Permissible values for Time Status attribute,
@see ZCL spec, subclause 3.12.2.2.2 */
enum zb_zcl_time_time_status_e
{
/*! Master value */
ZB_ZCL_TIME_MASTER = 0,
/*! Synchronized value */
ZB_ZCL_TIME_SYNCHRONIZED = 1,
/*! Master Zone Dst value */
ZB_ZCL_TIME_MASTER_ZONE_DST = 2,
/*! Superseding value */
ZB_ZCL_TIME_SUPERSEDING = 3
};
/** Check if @e Master bit of @ref zb_zcl_time_attr_e::ZB_ZCL_ATTR_TIME_TIME_STATUS_ID "TimeStatus" attribute is set.
* @param val - 8-bit that contains value of @e TimeStatus attribute
* @return zb_uint8_t value greater then 0 if @e Master bit is set, and return 0 otherwise.
* @see @ref zb_zcl_time_time_status_e
*/
#define ZB_ZCL_TIME_TIME_STATUS_MASTER_BIT_IS_SET(val) ((val) & (1 << ZB_ZCL_TIME_MASTER))
/** Check if @e Synchronized bit of @ref zb_zcl_time_attr_e::ZB_ZCL_ATTR_TIME_TIME_STATUS_ID "TimeStatus" attribute is set.
* @param val - 8-bit that contains value of @e TimeStatus attribute
* @return zb_uint8_t value greater then 0 if @e Synchronized bit is set, and return 0 otherwise.
* @see @ref zb_zcl_time_time_status_e
*/
#define ZB_ZCL_TIME_TIME_STATUS_SYNCHRONIZED_BIT_IS_SET(val) ((val) & (1 << ZB_ZCL_TIME_SYNCHRONIZED))
/** Check if MasterZoneDST bit of @ref zb_zcl_time_attr_e::ZB_ZCL_ATTR_TIME_TIME_STATUS_ID "TimeStatus" attribute is set.
* @param val - 8-bit that contains value of @e TimeStatus attribute
* @return zb_uint8_t value greater then 0 if @e MasterZoneDST bit is set, and return 0 otherwise.
* @see @ref zb_zcl_time_time_status_e
*/
#define ZB_ZCL_TIME_TIME_STATUS_MASTER_ZONE_DST_BIT_IS_SET(val) ((val) & (1 << ZB_ZCL_TIME_MASTER_ZONE_DST))
/** Check if Superseding bit of @ref zb_zcl_time_attr_e::ZB_ZCL_ATTR_TIME_TIME_STATUS_ID "TimeStatus" attribute is set.
* @param val - 8-bit that contains value of @e TimeStatus attribute
* @return zb_uint8_t value greater then 0 if @e Superseding bit is set, and return 0 otherwise.
* @see @ref zb_zcl_time_time_status_e
*/
#define ZB_ZCL_TIME_TIME_STATUS_SUPERSEDING_BIT_IS_SET(val) ((val) & (1 << ZB_ZCL_TIME_SUPERSEDING))
/** @brief Default value for Time cluster revision global attribute */
#define ZB_ZCL_TIME_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0002u)
/** @brief Invalid value of Time attribute */
#define ZB_ZCL_TIME_TIME_INVALID_VALUE ((zb_time_t)0xFFFFFFFF)
/** @brief Default value for Time attribute */
#define ZB_ZCL_TIME_TIME_DEFAULT_VALUE ZB_ZCL_TIME_TIME_INVALID_VALUE
/** @brief Minimum value for Time attribute */
#define ZB_ZCL_TIME_TIME_MIN_VALUE ((zb_time_t)0x0)
/** @brief Maximum value for Time attribute */
#define ZB_ZCL_TIME_TIME_MAX_VALUE ((zb_time_t)0xFFFFFFFE)
/** @brief Default value for Time Status attribute */
#define ZB_ZCL_TIME_TIME_STATUS_DEFAULT_VALUE 0x00
/** @brief Default value for Time Zone attribute */
#define ZB_ZCL_TIME_TIME_ZONE_DEFAULT_VALUE 0x00000000
/** @brief Default value for DstStart attribute */
#define ZB_ZCL_TIME_DST_START_DEFAULT_VALUE ((zb_uint32_t)0xFFFFFFFF)
/** @brief Default value for DstEnd attribute */
#define ZB_ZCL_TIME_DST_END_DEFAULT_VALUE ((zb_uint32_t)0xFFFFFFFF)
/** @brief Default value for Dst Shift attribute */
#define ZB_ZCL_TIME_DST_SHIFT_DEFAULT_VALUE 0x00000000
/** @brief Default value for StandardTime attribute */
#define ZB_ZCL_TIME_STANDARD_TIME_DEFAULT_VALUE ((zb_uint32_t)0xFFFFFFFF)
/** @brief Default value for LocalTime attribute */
#define ZB_ZCL_TIME_LOCAL_TIME_DEFAULT_VALUE ((zb_uint32_t)0xFFFFFFFF)
/** @brief Default value for Last Set Time attribute */
#define ZB_ZCL_TIME_LAST_SET_TIME_DEFAULT_VALUE 0xffffffff
/** @brief Default value for Valid Until Time attribute */
#define ZB_ZCL_TIME_VALID_UNTIL_TIME_DEFAULT_VALUE 0xffffffff
/** @brief Declare attribute list for Time cluster
@param attr_list - attribute list name
@param time - pointer to variable to store Time attribute value; write-optional acc.to ZCL8, be careful when redefining its handling
@param time_status - pointer to variable to store Time Status attribute value; write-optional acc.to ZCL8, be careful when redefining its handling
@param time_zone - pointer to variable to store Time Zone attribute value
@param dst_start - pointer to variable to store Dst Start attribute value
@param dst_end - pointer to variable to store Dst End attribute value
@param dst_shift - pointer to variable to store Dst Shift attribute value
@param standard_time - pointer to variable to store Standard Time attribute value
@param local_time - pointer to variable to store Local Time attribute value
@param last_set_time - pointer to variable to store Last Set Time attribute value
@param valid_until_time - pointer to variable to store Valid Until Time attribute value
Time and TimeStatus attributes are Read & Write-Optional acc. to ZCL8 spec.
Due to internal implementation specifics Read-Write access mode is used for
declaring the attributes, while optional writability is blocked by the stack
in runtime automatically according to conditions from ZCL8 spec sections 3.12.2.2.1-3.12.2.2.2.
*/
#define ZB_ZCL_DECLARE_TIME_ATTRIB_LIST(attr_list, time, time_status, time_zone, \
dst_start, dst_end, dst_shift, standard_time, local_time, last_set_time, valid_until_time) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_TIME) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_TIME_ID, (time)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_TIME_STATUS_ID, (time_status)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_TIME_ZONE_ID, (time_zone)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_DST_START_ID, (dst_start)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_DST_END_ID, (dst_end)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_DST_SHIFT_ID, (dst_shift)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_STANDARD_TIME_ID, (standard_time)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_LOCAL_TIME_ID, (local_time)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_LAST_SET_TIME_ID, (last_set_time)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_TIME_VALID_UNTIL_TIME_ID, (valid_until_time)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @} */ /* ZB_ZCL_TIME_ATTRS */
/** @defgroup ZB_ZCL_TIME_COMMANDS Time cluster commands
* @{
*/
/** @} */ /* ZB_ZCL_TIME_COMMANDS */
/** @cond internals_doc */
/** Acc. to ZCL8 Table 3-69 and section 3.12.2.2.1 "Time Attribute" Time attribute is write-optional.
* The corresponding conditions are checked in the stack, but be careful when redefining
* processing of the attribute in applications.
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_TIME_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_TIME_ID, \
ZB_ZCL_ATTR_TYPE_UTC_TIME, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** Acc. to ZCL8 Table 3-69 and section 3.12.2.2.2 "TimeStatus Attribute" TimeStatus attribute is write-optional.
* The corresponding conditions are checked in the stack, but be careful when redefining
* processing of the attribute in applications.
*/
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_TIME_STATUS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_TIME_STATUS_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_TIME_ZONE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_TIME_ZONE_ID, \
ZB_ZCL_ATTR_TYPE_S32, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_DST_START_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_DST_START_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_DST_END_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_DST_END_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_DST_SHIFT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_DST_SHIFT_ID, \
ZB_ZCL_ATTR_TYPE_S32, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_STANDARD_TIME_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_STANDARD_TIME_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_LOCAL_TIME_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_LOCAL_TIME_ID, \
ZB_ZCL_ATTR_TYPE_U32, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_LAST_SET_TIME_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_LAST_SET_TIME_ID, \
ZB_ZCL_ATTR_TYPE_UTC_TIME, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_TIME_VALID_UNTIL_TIME_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_TIME_VALID_UNTIL_TIME_ID, \
ZB_ZCL_ATTR_TYPE_UTC_TIME, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/*! @internal Number of attributes mandatory for reporting in Time cluster */
#define ZB_ZCL_TIME_REPORT_ATTR_COUNT 0
/** @endcond */ /* Time cluster internals */
/** @struct zb_zcl_time_attrs_s
* @brief Time cluster attributes
*/
typedef struct zb_zcl_time_attrs_s
{
/** @copydoc ZB_ZCL_ATTR_TIME_TIME_ID
* @see ZB_ZCL_ATTR_TIME_TIME_ID
*/
zb_uint32_t time;
/** @copydoc ZB_ZCL_ATTR_TIME_TIME_STATUS_ID
* @see ZB_ZCL_ATTR_TIME_TIME_STATUS_ID
*/
zb_uint8_t time_status;
/** @copydoc ZB_ZCL_ATTR_TIME_TIME_ZONE_ID
* @see ZB_ZCL_ATTR_TIME_TIME_ZONE_ID
*/
zb_int32_t time_zone;
/** @copydoc ZB_ZCL_ATTR_TIME_DST_START_ID
* @see ZB_ZCL_ATTR_TIME_DST_START_ID
*/
zb_uint32_t dst_start;
/** @copydoc ZB_ZCL_ATTR_TIME_DST_END_ID
* @see ZB_ZCL_ATTR_TIME_DST_END_ID
*/
zb_uint32_t dst_end;
/** @copydoc ZB_ZCL_ATTR_TIME_DST_SHIFT_ID
* @see ZB_ZCL_ATTR_TIME_DST_SHIFT_ID
*/
zb_uint32_t dst_shift;
/** @copydoc ZB_ZCL_ATTR_TIME_STANDARD_TIME_ID
* @see ZB_ZCL_ATTR_TIME_STANDARD_TIME_ID
*/
zb_uint32_t standard_time;
/** @copydoc ZB_ZCL_ATTR_TIME_LOCAL_TIME_ID
* @see ZB_ZCL_ATTR_TIME_LOCAL_TIME_ID
*/
zb_uint32_t local_time;
/** @copydoc ZB_ZCL_ATTR_TIME_LAST_SET_TIME_ID
* @see ZB_ZCL_ATTR_TIME_LAST_SET_TIME_ID
*/
zb_uint32_t last_set_time;
/** @copydoc ZB_ZCL_ATTR_TIME_VALID_UNTIL_TIME_ID
* @see ZB_ZCL_ATTR_TIME_VALID_UNTIL_TIME_ID
*/
zb_uint32_t valid_until_time;
} zb_zcl_time_attrs_t;
/** @brief Declare attribute list for Time cluster
* @param[in] attr_list - attribute list variable name
* @param[in] attrs - variable of @ref zb_zcl_time_attrs_s type (containing Time cluster attributes)
*/
#define ZB_ZCL_DECLARE_TIME_ATTR_LIST(attr_list, attrs) \
ZB_ZCL_DECLARE_TIME_ATTRIB_LIST(attr_list, \
&attrs.time, &attrs.time_status, &attrs.time_zone, \
&attrs.dst_start, &attrs.dst_end, &attrs.dst_shift, \
&attrs.standard_time, &attrs.local_time, \
&attrs.last_set_time, &attrs.valid_until_time )
/** @} */ /** ZB_ZCL_TIME */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_time_update_current_time(zb_uint8_t endpoint);
void zb_zcl_time_init_server(void);
void zb_zcl_time_init_client(void);
#define ZB_ZCL_CLUSTER_ID_TIME_SERVER_ROLE_INIT zb_zcl_time_init_server
#define ZB_ZCL_CLUSTER_ID_TIME_CLIENT_ROLE_INIT zb_zcl_time_init_client
#endif /* ZB_ZCL_TIME_H */

View File

@@ -0,0 +1,380 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: ZBOSS specific Tunnel cluster, purpose: general data tunneling.
*/
#ifndef ZB_ZCL_TUNNEL_H
#define ZB_ZCL_TUNNEL_H 1
/** @cond (DOXYGEN_ZCL_SECTION && DOXYGEN_CUSTOM_TUNNEL_CLUSTER) */
/** @addtogroup ZB_ZCL_TUNNEL
* @{
* @details
* Manufacture specific cluster for transmit custom data between peers
* Model: One (client) to More (servers)
* Usually a device has MIXED role
*/
/*! @name Tunnel cluster commands
@{
*/
/**
* @brief Tunnel cluster commands
*/
enum zb_zcl_tunnel_cmd_e
{
ZB_ZCL_CMD_TUNNEL_TRANSFER_DATA_REQ = 0x00, /**< Request to transfer data. */
ZB_ZCL_CMD_TUNNEL_TRANSFER_DATA_RESP = 0x01, /**< Response on received data */
};
/* Tunnel manufacturer specific cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_TUNNEL_FC00_SERVER_ROLE_GENERATED_CMD_LIST ZB_ZCL_CMD_TUNNEL_TRANSFER_DATA_RESP
#define ZB_ZCL_CLUSTER_ID_TUNNEL_FC00_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_TUNNEL_FC00_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_TUNNEL_FC00_CLIENT_ROLE_GENERATED_CMD_LIST ZB_ZCL_CMD_TUNNEL_TRANSFER_DATA_REQ
#define ZB_ZCL_CLUSTER_ID_TUNNEL_FC00_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_TUNNEL_FC00_CLIENT_ROLE_GENERATED_CMD_LIST
/** Tunnel status; range: 0x00 - 0x3F (6-bit value) */
typedef enum zb_zcl_tunnel_status_e
{
ZB_ZCL_TUNNEL_STATUS_OK = 0, /**< Data is sent or received. Use for inform User App about success current command */
ZB_ZCL_TUNNEL_STATUS_ERROR = 1, /**< General Error. Current operation has error: unexpected message etc. */
ZB_ZCL_TUNNEL_STATUS_ERROR_NO_MEMORY = 2, /**< No memory */
ZB_ZCL_TUNNEL_STATUS_ERROR_TIMEOUT = 3, /**< Timeout. Use for inform User App about when wait answer */
}
zb_zcl_tunnel_status_t;
/** Tunnel i/o operation type, range: 0x00 - 0x03 (2-bit value) */
enum zb_zcl_tunnel_operation_code_e
{
ZB_ZCL_TUNNEL_OPERATION_TX = 1 << 0, /**< Current command - send data */
ZB_ZCL_TUNNEL_OPERATION_RX = 1 << 1 /**< Current command - receive data */
};
/************* Tunnel cluster command structures **************/
/**
* @brief Tunnel Transfer Data Request command payload
*/
typedef ZB_PACKED_PRE struct zb_zcl_tunnel_transfer_data_req_s
{
zb_uint8_t tx_flag; /**< see @ref zb_zcl_tunnel_tx_flags_e */
/**< byte_num value:
- if ZB_ZCL_TUNNEL_TX_START is on => total data size to be sent is specified
- if ZB_ZCL_TUNNEL_TX_CONTINUE is on => current data offset is specified
*/
zb_uint16_t byte_num;
/**< length data - size of data */
zb_uint8_t data_size;
/**< data - part of transfer data */
}
ZB_PACKED_STRUCT
zb_zcl_tunnel_transfer_data_req_t;
/**
* @brief Tunnel Transfer Data Request command internal payload
*/
typedef ZB_PACKED_PRE struct zb_zcl_tunnel_transfer_data_req_internal_s
{
zb_zcl_tunnel_transfer_data_req_t req_header;
zb_uint8_t *tun_data;
}
ZB_PACKED_STRUCT
zb_zcl_tunnel_transfer_data_req_data_internal_t;
/**
* @brief Tunnel Transfer Data Request flags
*/
enum zb_zcl_tunnel_tx_flags_e
{
ZB_ZCL_TUNNEL_TX_START = 1 << 0, /**< first block - if set then contains total length of transferring data
else - contains current offset of transferring data */
};
/*! @brief Send Transfer Data command
@param _buffer - to put packet to
@param _addr - address to send packet to
@param _dst_addr_mode - addressing mode
@param _dst_ep - destination endpoint
@param _ep - sending endpoint
@param _prfl_id - profile identifier
@param _def_resp - enable or disable default response
@param _cb - callback for getting command send status
@param _manufacturer_id - Manufacturer code
@param _flag - command flag, see @ref zb_zcl_tunnel_tx_flags_e
@param _byte_num - all transfer length or current offset, see @ref zb_zcl_tunnel_transfer_data_req_t
@param _data_size - data size
@param _image_data - image data
*/
#define ZB_ZCL_TUNNEL_SEND_TRANSFER_REQ( \
_buffer, _addr, _dst_addr_mode, _dst_ep, _ep, _prfl_id, _def_resp, _cb, \
_manufacturer_id, _flag, _byte_num, _data_size, _image_data) \
{ \
zb_uint8_t* __ptr = ZB_ZCL_START_PACKET((_buffer)); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL_A(__ptr, \
ZB_ZCL_FRAME_DIRECTION_TO_SRV, ZB_ZCL_MANUFACTURER_SPECIFIC, (_def_resp));\
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(__ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_MANUFACTURER_SPECIFIC, (_manufacturer_id), \
ZB_ZCL_CMD_TUNNEL_TRANSFER_DATA_REQ); \
ZB_ZCL_PACKET_PUT_DATA8(__ptr, (_flag)); \
ZB_ZCL_PACKET_PUT_DATA16_VAL(__ptr, (_byte_num)); \
ZB_ZCL_PACKET_PUT_DATA8(__ptr, (_data_size)); \
if((_data_size)>0) \
{ \
ZB_ZCL_PACKET_PUT_DATA_N(__ptr, (_image_data), (_data_size)); \
} \
ZB_ZCL_FINISH_PACKET((_buffer), __ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(_buffer), (_addr), (_dst_addr_mode), (_dst_ep), (_ep), (_prfl_id), \
ZB_ZCL_CLUSTER_ID_TUNNEL, (_cb)); \
}
/** @brief Macro for getting Send Transfer Data command
* @attention Assumes that ZCL header already cut.
* @param _data_ptr - pointer to a variable of type @ref
* zb_zcl_tunnel_transfer_data_req_data_internal_t.
* @param _buffer containing the packet (by pointer).
* @param _status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*
* @note File data place is placed in buffer, payload saves pointer to data only!
*/
#define ZB_ZCL_TUNNEL_GET_TRANSFER_REQ(_data_ptr, _buffer, _status) \
{ \
zb_zcl_tunnel_transfer_data_req_t *src_ptr = \
(zb_zcl_tunnel_transfer_data_req_t*)zb_buf_begin((_buffer)); \
\
if (zb_buf_len((_buffer)) != sizeof(zb_zcl_tunnel_transfer_data_req_t) \
+ src_ptr->data_size * sizeof(zb_uint8_t) ) \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(_data_ptr)->req_header.tx_flag = src_ptr->tx_flag; \
ZB_HTOLE16(&((_data_ptr)->req_header.byte_num), &(src_ptr->byte_num)); \
(_data_ptr)->req_header.data_size = src_ptr->data_size; \
(_data_ptr)->tun_data = (zb_uint8_t*)(src_ptr+1); \
} \
}
/**
* @brief Tunnel Transfer Data Response command payload
*/
typedef ZB_PACKED_PRE struct zb_zcl_tunnel_transfer_data_resp_s
{
zb_uint8_t tun_status; /**< enum @ref zb_zcl_tunnel_status_e */
}
ZB_PACKED_STRUCT
zb_zcl_tunnel_transfer_data_resp_t;
/*! @brief Send Transfer Data response command
@param _buffer - to put packet to
@param _addr - address to send packet to
@param _dst_addr_mode - addressing mode
@param _dst_ep - destination endpoint
@param _ep - sending endpoint
@param _prfl_id - profile identifier
@param _seq - request sequence
@param _cb - callback for getting command send status
@param _manufacturer_id - Manufacturer code
@param _tun_status - command status, see @ref zb_zcl_tunnel_status_e
*/
#define ZB_ZCL_TUNNEL_SEND_TRANSFER_RESP( \
_buffer, _addr, _dst_addr_mode, _dst_ep, _ep, _prfl_id, _seq, _cb, \
_manufacturer_id, _tun_status) \
{ \
zb_uint8_t* __ptr = ZB_ZCL_START_PACKET((_buffer)); \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RESP_FRAME_CONTROL_A(__ptr, \
ZB_ZCL_FRAME_DIRECTION_TO_CLI, ZB_ZCL_MANUFACTURER_SPECIFIC); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(__ptr, (_seq), ZB_ZCL_MANUFACTURER_SPECIFIC,\
(_manufacturer_id), ZB_ZCL_CMD_TUNNEL_TRANSFER_DATA_RESP); \
ZB_ZCL_PACKET_PUT_DATA8(__ptr, (_tun_status)); \
ZB_ZCL_FINISH_PACKET((_buffer), __ptr) \
ZB_ZCL_SEND_COMMAND_SHORT( \
(_buffer), (_addr), (_dst_addr_mode), (_dst_ep), (_ep), (_prfl_id), \
ZB_ZCL_CLUSTER_ID_TUNNEL, (_cb)); \
}
/** @brief Macro for getting Send Transfer Data response command
* @attention Assumes that ZCL header already cut.
* @param _data_ptr - pointer to a variable of type @ref
* zb_zcl_tunnel_transfer_data_resp_t.
* @param _buffer containing the packet (by pointer).
* @param _status - variable to put parse status to (see @ref zb_zcl_parse_status_t).
*/
#define ZB_ZCL_TUNNEL_GET_TRANSFER_RESP(_data_ptr, _buffer, _status) \
{ \
zb_zcl_tunnel_transfer_data_resp_t *src_ptr = \
(zb_zcl_tunnel_transfer_data_resp_t*)zb_buf_begin((_buffer)); \
\
if (zb_buf_len((_buffer)) != sizeof(zb_zcl_tunnel_transfer_data_resp_t) ) \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
else \
{ \
(_status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
(_data_ptr)->tun_status = src_ptr->tun_status; \
} \
}
/*! @} */ /* Tunnel cluster commands */
/*********************** Tunnel API **************************/
/*! @name Tunnel cluster commands
@{
*/
/** Callback to inform user about tx operation status or rx data;
* @param param - param is reference to a buffer;
* zb_zcl_tunnel_io_param_t is stored as buffer parameter */
typedef void (ZB_CODE * zb_zcl_tunnel_cb_t)(zb_uint8_t param);
/** Tunnel operation status
*/
typedef ZB_PACKED_PRE struct zb_zcl_tunnel_op_status_s
{
zb_bitfield_t status :6; /**< zb_zcl_tunnel_status_e value */
zb_bitfield_t op_code :2; /**< zb_zcl_tunnel_operation_code_e value */
}
ZB_PACKED_STRUCT
zb_zcl_tunnel_op_status_t;
/** structure to pass parameters for data i/o
* Save in first of each buffer
* */
typedef ZB_PACKED_PRE struct zb_zcl_tunnel_io_param_s
{
zb_uint16_t length; /* total data size*/
zb_uint16_t peer_addr;
zb_uint8_t peer_ep;
zb_uint8_t src_ep;
zb_uint8_t next_buf; /* pointer to the next buf for fragmented data */
zb_zcl_tunnel_op_status_t op_status;
zb_uint8_t seq;
}
ZB_PACKED_STRUCT
zb_zcl_tunnel_io_param_t;
/** Init CTX data table
* @param manuf_id - manufacturer ID */
void zb_zcl_tunnel_init(zb_uint16_t manuf_id);
/** Register user callback */
void zb_zcl_tunnel_register_cb(zb_zcl_tunnel_cb_t tunnel_cb);
/** Start user data transmit. buf_param is a reference to a buffer;
* zb_zcl_tunnel_io_param_t is stored as a buffer parameter;
* data to be transmitted is stored as buffer data */
zb_ret_t zb_zcl_tunnel_transmit_data(zb_uint8_t buf_param);
/** Default user application
* Contain default handle (usually free buffer) for different Tunnel Status command */
void zb_zcl_tunnel_default_user_app(zb_uint8_t param);
/*! @} */ /* Tunnel cluster commands */
/**************************** Tunnel internal **********************************/
#define ZB_ZCL_TUNNEL_TIMEOUT (10*ZB_TIME_ONE_SECOND)
/** @brief Maximum slots for send/receive data */
#define ZB_ZCL_TUNNEL_MAX_IO_SLOT_NUMBER 16
/** @brief Not slots index*/
#define ZB_ZCL_TUNNEL_IO_SLOT_UNKNOWN 0xff
typedef ZB_PACKED_PRE struct zb_zcl_tunnel_io_slot_s
{
zb_zcl_tunnel_io_param_t io_param;
zb_uint16_t offset; /* length of current sent/received data */
zb_uint8_t seq;
}
ZB_PACKED_STRUCT
zb_zcl_tunnel_io_slot_t;
/** struct for next buffer in multi-buffer chain*/
typedef ZB_PACKED_PRE struct zb_zcl_tunnel_io_slot_continue_s
{
zb_uint8_t next_buf;
}
ZB_PACKED_STRUCT
zb_zcl_tunnel_io_slot_continue_t;
/* internal cluster data - context info */
typedef struct zb_zcl_tunnel_context_s
{
zb_uint16_t manufacturer_id; /* manufacturer ID - should be initialized */
zb_zcl_tunnel_cb_t tunnel_cb; /* user callback - should be registered */
/* store reference to i/o buffer: tx or rx;
* zb_zcl_tunnel_io_param_t is stored as buffer parameter to keep status info */
zb_uint8_t tunnel_io_slot[ZB_ZCL_TUNNEL_MAX_IO_SLOT_NUMBER];
}
zb_zcl_tunnel_context_t;
zb_ret_t zb_zcl_tunnel_transfer_data_req_handler(zb_uint8_t buf_param);
zb_ret_t zb_zcl_tunnel_transfer_data_resp_handler(zb_uint8_t buf_param);
void zb_zcl_tunnel_transfer_data_resp_send(zb_uint8_t param, zb_uint16_t endpoint16);
void zb_zcl_tunnel_send_fist_block(zb_uint8_t param, zb_uint16_t index16);
void zb_zcl_tunnel_timeout(zb_uint8_t index);
void zb_zcl_tunnel_invoke_user_app(zb_uint8_t param);
zb_ret_t zb_zcl_process_tunnel_default_response_commands(zb_uint8_t param);
zb_bool_t zb_zcl_process_tunnel_specific_commands(zb_uint8_t param);
/*! @} */ /* addtogroup */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_tunnel_init_server(void);
void zb_zcl_tunnel_init_client(void);
#define ZB_ZCL_CLUSTER_ID_TUNNEL_SERVER_ROLE_INIT zb_zcl_tunnel_init_server
#define ZB_ZCL_CLUSTER_ID_TUNNEL_CLIENT_ROLE_INIT zb_zcl_tunnel_init_client
#endif /* ZB_ZCL_TUNNEL_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,802 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: Window Covering cluster definitions
*/
#ifndef ZB_ZCL_WINDOW_COVERING_H
#define ZB_ZCL_WINDOW_COVERING_H 1
#include "zcl/zb_zcl_common.h"
#include "zcl/zb_zcl_commands.h"
/** @cond DOXYGEN_ZCL_SECTION */
/** @addtogroup ZB_ZCL_WINDOW_COVERING
* @{
* @details
* All commands in the cluster have request form only, and could be responded with Default
* Response command, if not disabled explicitly.
*
*/
/** @name Window Covering cluster attributes
@{
*/
/** @brief Window Covering Attribute Sets Identifiers
@see ZCL8 spec, Table 7-39
*/
enum zb_zcl_window_covering_attribute_sets_e
{
/** @brief Window Covering Information attribute set */
ZB_ZCL_WINDOW_COVERING_INFORMATION = 0x000,
/** @brief Window Covering Settings attribute set */
ZB_ZCL_WINDOW_COVERING_SETTINGS = 0x001
};
/** @brief Window Covering cluster information attribute set identifiers
@see ZCL8 spec, subclause 7.4.2.1.1
*/
enum zb_zcl_window_covering_info_attr_e
{
/** @brief Window Covering Type attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_WINDOW_COVERING_TYPE_ID = 0x0000,
/** @brief PhysicalClosedLimit Lift attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_PHYSICAL_CLOSED_LIMIT_LIFT_ID = 0x0001,
/** @brief PhysicalClosedLimit Tilt attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_PHY_CLOSED_LIMIT_TILT_ID = 0x0002,
/** @brief CurrentPosition Lift attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_ID = 0x0003,
/** @brief CurrentPosition Tilt attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_ID = 0x0004,
/** @brief Number of Actuations Lift attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_NUMBER_OF_ACTUATIONS_LIFT_ID = 0x0005,
/** @brief Number of Actuations Tilt attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_NUMBER_OF_ACTUATIONS_TILT_ID = 0x0006,
/** @brief Config/Status attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_STATUS_ID = 0x0007,
/** @brief Current Position Lift Percentage attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_ID = 0x0008,
/** @brief Current Position Tilt Percentage attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_ID = 0x0009
};
/** @brief Permissible values for Type attribute
* @see ZCL8 spec, subclause 7.4.2.1.2
*/
enum zb_zcl_window_covering_window_covering_type_e
{
/** Rollershade value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_ROLLERSHADE = 0x00,
/** Rollershade - 2 Motor value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_ROLLERSHADE_2_MOTOR = 0x01,
/** Rollershade - Exterior value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_ROLLERSHADE_EXTERIOR = 0x02,
/** Rollershade - Exterior - 2 Motor value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_ROLLERSHADE_EXTERIOR_2_MOTOR = 0x03,
/** Drapery value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_DRAPERY = 0x04,
/** Awning value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_AWNING = 0x05,
/** Shutter value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_SHUTTER = 0x06,
/** Tilt Blind - Tilt Only value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_TILT_BLIND_TILT_ONLY = 0x07,
/** Tilt Blind - Lift and Tilt value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_TILT_BLIND_LIFT_AND_TILT = 0x08,
/** Projector screen value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_PROJECTOR_SCREEN = 0x09
};
/** @brief Permissible values for Config/Status attribute
@see ZCL8 spec, subclause 7.4.2.1.2.7*/
enum zb_zcl_window_covering_config_status_e
{
/** Operational value */
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_OPERATIONAL = 0x01,
/** Online value */
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_ONLINE = 0x02,
/** Open/Up Commands have been reversed value */
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_REVERSE_COMMANDS = 0x04,
/** Lift control is Closed Loop value */
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_LIFT_CONTROL_IS_CLOSED_LOOP = 0x08,
/** Tilt control is Closed Loop value */
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_TILT_CONTROL_IS_CLOSED_LOOP = 0x10,
/** Lift Encoder Controlled value */
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_LIFT_ENCODER_CONTROLLED = 0x20,
/** Tilt Encoder Controlled value */
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_TILT_ENCODER_CONTROLLED = 0x40
};
/** @brief Window covering cluster settings attribute set identifiers
@see ZCL8 spec, subclause 7.4.2.1.3
*/
enum zb_zcl_window_covering_settings_attr_e
{
/** @brief InstalledOpenLimit - Lift attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_LIFT_ID = 0x0010,
/** @brief InstalledClosedLimit - Lift attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_LIFT_ID = 0x0011,
/** @brief InstalledOpenLimit - Tilt attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_TILT_ID = 0x0012,
/** @brief InstalledClosedLimit - Tilt attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_TILT_ID = 0x0013,
/** @brief Velocity - Lift attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_VELOCITY_ID = 0x0014,
/** @brief Acceleration Time - Lift attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_ACCELERATION_TIME_ID = 0x0015,
/** @brief Deceleration Time - Lift attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_DECELERATION_TIME_ID = 0x0016,
/** @brief Mode attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_MODE_ID = 0x0017,
/** @brief Intermediate Setpoints - Lift attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_INTERMEDIATE_SETPOINTS_LIFT_ID = 0x0018,
/** @brief Intermediate Setpoints - Tilt attribute */
ZB_ZCL_ATTR_WINDOW_COVERING_INTERMEDIATE_SETPOINTS_TILT_ID = 0x0019
};
/** @brief Permissible values for Mode attribute
@see ZCL8 spec, subclause 7.4.2.1.3.8*/
enum zb_zcl_window_covering_mode_e
{
/** Reversed motor direction value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_REVERSED_MOTOR_DIRECTION = 0x01,
/** Run in calibration mode value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_RUN_IN_CALIBRATION_MODE = 0x02,
/** Motor is running in maintenance mode value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_MOTOR_IS_RUNNING_IN_MAINTENANCE_MODE = 0x04,
/** LEDs will display feedback value */
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_LEDS_WILL_DISPLAY_FEEDBACK = 0x08
};
/** @brief Default value for Window Covering cluster revision global attribute */
#define ZB_ZCL_WINDOW_COVERING_CLUSTER_REVISION_DEFAULT ((zb_uint16_t)0x0003u)
/** @brief Default value for PhysicalClosedLimitLift attribute */
#define ZB_ZCL_WINDOW_COVERING_PHYSICAL_CLOSED_LIMIT_LIFT_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for PhyClosedLimitTilt attribute */
#define ZB_ZCL_WINDOW_COVERING_PHY_CLOSED_LIMIT_TILT_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for CurrentPositionLift attribute */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_LIFT_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for CurrentPositionTilt attribute */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_TILT_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for NumberOfActuationsLift attribute */
#define ZB_ZCL_WINDOW_COVERING_NUMBER_OF_ACTUATIONS_LIFT_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for NumberOfActuationsTilt attribute */
#define ZB_ZCL_WINDOW_COVERING_NUMBER_OF_ACTUATIONS_TILT_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Window covering type attribute default value */
#define ZB_ZCL_WINDOW_COVERING_WINDOW_COVERING_TYPE_DEFAULT_VALUE 0x00
/** @brief Config/status attribute default value */
#define ZB_ZCL_WINDOW_COVERING_CONFIG_STATUS_DEFAULT_VALUE \
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_OPERATIONAL \
| ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_ONLINE
/** @brief Current position lift attribute min value */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_LIFT_MIN_VALUE 0x0000
/** @brief Current position lift attribute max value */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_LIFT_MAX_VALUE 0xffff
/** @brief Current position tilt attribute min value */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_TILT_MIN_VALUE 0x0000
/** @brief Current position tilt attribute max value */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_LILT_MAX_VALUE 0xffff
/** @brief Current position lift percentage attribute default value */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_DEFAULT_VALUE 0xff
/** @brief Current position lift percentage attribute max value */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_MAX_VALUE 0x64
/** @brief Current position tilt percentage attribute default value */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_DEFAULT_VALUE 0xff
/** @brief Current position tilt percentage attribute max value */
#define ZB_ZCL_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_MAX_VALUE 0x64
/** @brief Installed open limit lift attribute default value */
#define ZB_ZCL_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_LIFT_DEFAULT_VALUE 0x0000
/** @brief Installed closed limit lift attribute default value */
#define ZB_ZCL_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_LIFT_DEFAULT_VALUE 0xffff
/** @brief Installed open limit tilt attribute default value */
#define ZB_ZCL_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_TILT_DEFAULT_VALUE 0x0000
/** @brief Installed closed limit tilt attribute default value */
#define ZB_ZCL_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_TILT_DEFAULT_VALUE 0xffff
/** @brief Default value for Velocity attribute */
#define ZB_ZCL_WINDOW_COVERING_VELOCITY_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for AccelerationTime attribute */
#define ZB_ZCL_WINDOW_COVERING_ACCELERATION_TIME_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Default value for DecelerationTime attribute */
#define ZB_ZCL_WINDOW_COVERING_DECELERATION_TIME_DEFAULT_VALUE ((zb_uint16_t)0x0000)
/** @brief Mode attribute default value */
#define ZB_ZCL_WINDOW_COVERING_MODE_DEFAULT_VALUE \
ZB_ZCL_ATTR_WINDOW_COVERING_TYPE_MOTOR_IS_RUNNING_IN_MAINTENANCE_MODE
/** @brief Default value for IntermediateSetpointsLift attribute */
#define ZB_ZCL_WINDOW_COVERING_INTERMEDIATE_SETPOINTS_LIFT_DEFAULT_VALUE {0x31, 0x2C, 0x30, 0x78, 0x30, 0x30, 0x30, 0x30, 0x00}
/** @brief Default value for IntermediateSetpointsTilt attribute */
#define ZB_ZCL_WINDOW_COVERING_INTERMEDIATE_SETPOINTS_TILT_DEFAULT_VALUE {0x31, 0x2C, 0x30, 0x78, 0x30, 0x30, 0x30, 0x30, 0x00}
/** @brief Declare attribute list for Window Covering cluster
@param attr_list - attribute list name
@param window_covering_type - pointer to variable to store Window Covering Type attribute value
@param config_status - pointer to variable to store Config/Status attribute value
@param current_position_lift_percentage - pointer to variable to store
Current Position Lift Percentage attribute value
@param current_position_tilt_percentage - pointer to variable to store
Current Position Tilt Percentage attribute value
@param installed_open_limit_lift - pointer to variable to store Installed Open Limit Lift
attribute value
@param installed_closed_limit_lift - pointer to variable to store Installed Closed Limit Lift
attribute value
@param installed_open_limit_tilt - pointer to variable to store Installed Open Limit Tilt
attribute value
@param installed_closed_limit_tilt - pointer to variable to store Installed Closed Limit Tilt
attribute value
@param mode - pointer to variable to store Mode attribute value
*/
#define ZB_ZCL_DECLARE_WINDOW_COVERING_CLUSTER_ATTRIB_LIST(attr_list, window_covering_type, \
config_status, current_position_lift_percentage, current_position_tilt_percentage, \
installed_open_limit_lift, installed_closed_limit_lift, installed_open_limit_tilt, \
installed_closed_limit_tilt, mode) \
ZB_ZCL_START_DECLARE_ATTRIB_LIST_CLUSTER_REVISION(attr_list, ZB_ZCL_WINDOW_COVERING) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_WINDOW_COVERING_WINDOW_COVERING_TYPE_ID, \
(window_covering_type)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_STATUS_ID, \
(config_status)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_ID, \
(current_position_lift_percentage)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_ID, \
(current_position_tilt_percentage)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_LIFT_ID, \
(installed_open_limit_lift)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_LIFT_ID, \
(installed_closed_limit_lift)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_TILT_ID, \
(installed_open_limit_tilt)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_TILT_ID, \
(installed_closed_limit_tilt)) \
ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_WINDOW_COVERING_MODE_ID, (mode)) \
ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
/** @} */ /* Window Covering cluster attributes */
/**
* @name Attribute value manipulation API
* @{
*/
/** @internal Set bits from conf_var variable to type_value */
#define ZB_ZCL_SET_BIT(conf_var, type_value) \
{ \
(conf_var) = (conf_var) | (type_value); \
}
/** @internal Get type_value bits from conf_var variable */
#define ZB_ZCL_GET_BIT(conf_var, type_value) ((conf_var) & (type_value))
/** @internal Clear type_value bits in conf_var variable */
#define ZB_ZCL_CLR_BIT(conf_var, type_value) \
{ \
(conf_var) = (conf_var) & ~(type_value); \
}
/**
* @brief Sets bits of Config/Status parameter.
* @param type_value - bit to set.
* @param conf_var - config variable.
* @hideinitializer
*/
#define ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_STATUS_SET(conf_var, type_value) \
ZB_ZCL_SET_BIT(conf_var, type_value)
/** @brief Gets bit value of Config/Status parameter
@param type_value - bit value to check
@param conf_var - config variable
* @hideinitializer
*/
#define ZB_ZCL_ATTR_WINDOW_COVERING_GET_CONFIG_STATUS_BIT_VAL(conf_var, type_value) \
ZB_ZCL_GET_BIT(conf_var, type_value)
/** @brief Clear bit of Config/Status parameter
@param type_value - bit to clear
@param conf_var - config variable
* @hideinitializer
*/
#define ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_STATUS_CLEAR(conf_var, type_value) \
ZB_ZCL_CLR_BIT(conf_var, type_value)
/** @brief Sets bits of Mode parameter
@param type_value - type which need to set
@param mode_var - mode variable
* @hideinitializer
*/
#define ZB_ZCL_ATTR_WINDOW_COVERING_MODE_SET(mode_var, type_value) \
ZB_ZCL_SET_BIT(mode_var, type_value)
/** @brief Gets bits of Mode parameter
@param type_value - type which need to set
@param mode_var - mode variable
* @hideinitializer
*/
#define ZB_ZCL_ATTR_WINDOW_COVERING_MODE_GET(mode_var, type_value) \
ZB_ZCL_GET_BIT(mode_var, type_value)
/** @brief Clear bytes of Mode parameter
@param type_value - type which need to set
@param mode_var - mode variable
*/
#define ZB_ZCL_ATTR_WINDOW_COVERING_MODE_CLEAR(mode_var, type_value) \
ZB_ZCL_CLR_BIT(mode_var, type_value)
/** @cond internals_doc */
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_WINDOW_COVERING_TYPE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_WINDOW_COVERING_TYPE_ID, \
ZB_ZCL_ATTR_TYPE_8BIT_ENUM, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_STATUS_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_CONFIG_STATUS_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_LIFT_PERCENTAGE_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_SCENE | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_CURRENT_POSITION_TILT_PERCENTAGE_ID, \
ZB_ZCL_ATTR_TYPE_U8, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY | ZB_ZCL_ATTR_ACCESS_SCENE | ZB_ZCL_ATTR_ACCESS_REPORTING, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_LIFT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_LIFT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_LIFT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_LIFT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_TILT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_OPEN_LIMIT_TILT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_TILT_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_INSTALLED_CLOSED_LIMIT_TILT_ID, \
ZB_ZCL_ATTR_TYPE_U16, \
ZB_ZCL_ATTR_ACCESS_READ_ONLY, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_WINDOW_COVERING_MODE_ID(data_ptr) \
{ \
ZB_ZCL_ATTR_WINDOW_COVERING_MODE_ID, \
ZB_ZCL_ATTR_TYPE_8BITMAP, \
ZB_ZCL_ATTR_ACCESS_READ_WRITE, \
(ZB_ZCL_NON_MANUFACTURER_SPECIFIC), \
(void*) data_ptr \
}
/** @internal Number of attributes mandatory for reporting in window covering cluster */
#define ZB_ZCL_WINDOW_COVERING_REPORT_ATTR_COUNT 2
/** @endcond */ /* internals_doc */
/** @} */ /* Attribute value manipulation API */
/** @name Window Covering cluster commands
@{
*/
/** @brief Window Covering cluster command identifiers
@see ZCL8 spec, subclause 7.4.2.2
*/
enum zb_zcl_window_covering_cmd_e
{
/** Up/Open command */
ZB_ZCL_CMD_WINDOW_COVERING_UP_OPEN = 0x00,
/** Down/Close command */
ZB_ZCL_CMD_WINDOW_COVERING_DOWN_CLOSE = 0x01,
/** Stop command */
ZB_ZCL_CMD_WINDOW_COVERING_STOP = 0x02,
/** Go to Lift Value command */
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_LIFT_VALUE = 0x04,
/** Go to Lift Percentage command */
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE = 0x05,
/** Go to Tilt Value command */
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_TILT_VALUE = 0x07,
/** Go to Tilt Percentage command */
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE = 0x08
};
/** @cond internals_doc */
/* Window covering cluster commands list : only for information - do not modify */
#define ZB_ZCL_CLUSTER_ID_WINDOW_COVERING_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_WINDOW_COVERING_CLIENT_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_WINDOW_COVERING_SERVER_ROLE_GENERATED_CMD_LIST
#define ZB_ZCL_CLUSTER_ID_WINDOW_COVERING_CLIENT_ROLE_GENERATED_CMD_LIST \
ZB_ZCL_CMD_WINDOW_COVERING_UP_OPEN, \
ZB_ZCL_CMD_WINDOW_COVERING_DOWN_CLOSE, \
ZB_ZCL_CMD_WINDOW_COVERING_STOP, \
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_LIFT_VALUE, \
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE, \
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_TILT_VALUE, \
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE
#define ZB_ZCL_CLUSTER_ID_WINDOW_COVERING_SERVER_ROLE_RECEIVED_CMD_LIST ZB_ZCL_CLUSTER_ID_WINDOW_COVERING_CLIENT_ROLE_GENERATED_CMD_LIST
/*! @}
* @endcond */ /* internals_doc */
/** Mandatory commands defines */
/** @brief Structured representation of GO_TO_LIFT_VALUE command payload */
typedef ZB_PACKED_PRE struct zb_zcl_go_to_lift_value_req_s
{
/** Lift Value */
zb_uint16_t lift_value;
} ZB_PACKED_STRUCT zb_zcl_go_to_lift_value_req_t;
/** @brief Structured representation of GO_TO_LIFT_PERCENTAGE command payload
@see ZCL8 spec, subclause 7.4.2.2.5.1*/
typedef ZB_PACKED_PRE struct zb_zcl_go_to_lift_percentage_req_s
{
/** Percentage Lift Value */
zb_uint8_t percentage_lift_value;
} ZB_PACKED_STRUCT zb_zcl_go_to_lift_percentage_req_t;
/** @brief Structured representation of GO_TO_TILT_VALUE command payload */
typedef ZB_PACKED_PRE struct zb_zcl_go_to_tilt_value_req_s
{
/** Tilt Value */
zb_uint16_t tilt_value;
} ZB_PACKED_STRUCT zb_zcl_go_to_tilt_value_req_t;
/** @brief Structured representation of GO_TO_TILT_PERCENTAGE command payload
@see ZCL8 spec, subclause 7.4.2.2.7.1*/
typedef ZB_PACKED_PRE struct zb_zcl_go_to_tilt_percentage_req_s
{
/** Percentage Tilt Value */
zb_uint8_t percentage_tilt_value;
} ZB_PACKED_STRUCT zb_zcl_go_to_tilt_percentage_req_t;
/** @brief Send Up/Open command
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
*/
#define ZB_ZCL_WINDOW_COVERING_SEND_UP_OPEN_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_WINDOW_COVERING_UP_OPEN); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, \
prfl_id, ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, cb); \
}
/** @brief Send Down/Close command
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
*/
#define ZB_ZCL_WINDOW_COVERING_SEND_DOWN_CLOSE_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_WINDOW_COVERING_DOWN_CLOSE); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, \
prfl_id, ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, cb); \
}
/** @brief Send Stop command
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
*/
#define ZB_ZCL_WINDOW_COVERING_SEND_STOP_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_WINDOW_COVERING_STOP); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, \
prfl_id, ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, cb); \
}
/** @brief Parses Get Go to Lift value command and fills data request
structure. If request contains invalid data, status parameter is ZB_FALSE
@param data_buf - pointer to zb_buf_t buffer containing command request data
@param lift_value_req - pointer to a variable to save command request to
@param status - return ZB_ZCL_PARSE_STATUS_SUCCESS if request contains valid data,
else ZB_ZCL_PARSE_STATUS_FAILURE
@note data_buf buffer should contain command request payload without ZCL header.
*/
#define ZB_ZCL_WINDOW_COVERING_GET_GO_TO_LIFT_VALUE_REQ( \
data_buf, lift_value_req, status) \
{ \
zb_zcl_go_to_lift_value_req_t *lift_value_req_ptr; \
(lift_value_req_ptr) = zb_buf_len(data_buf) >= \
sizeof(zb_zcl_go_to_lift_value_req_t) ? \
(zb_zcl_go_to_lift_value_req_t*)zb_buf_begin(data_buf) : NULL; \
if (lift_value_req_ptr != NULL) \
{ \
(lift_value_req)->lift_value = \
lift_value_req_ptr->lift_value; \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
else \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
}
/** @brief Send Go to Lift Percentage command
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param percentage_lift_value - Percentage Lift value
*/
#define ZB_ZCL_WINDOW_COVERING_SEND_GO_TO_LIFT_PERCENTAGE_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, percentage_lift_value) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, percentage_lift_value); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, \
prfl_id, ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, cb); \
}
/** @brief Parses Get Go to Lift Percentage command and fills data request
structure. If request contains invalid data, status parameter is ZB_FALSE
@param data_buf - pointer to zb_buf_t buffer containing command request data
@param lift_percentage_req - pointer to a variable to save command request to
@param status - return ZB_ZCL_PARSE_STATUS_SUCCESS if request contains valid data,
else ZB_ZCL_PARSE_STATUS_FAILURE
@note data_buf buffer should contain command request payload without ZCL header.
*/
#define ZB_ZCL_WINDOW_COVERING_GET_GO_TO_LIFT_PERCENTAGE_REQ( \
data_buf, lift_percentage_req, status) \
{ \
zb_zcl_go_to_lift_percentage_req_t *lift_percentage_req_ptr; \
(lift_percentage_req_ptr) = zb_buf_len(data_buf) >= \
sizeof(zb_zcl_go_to_lift_percentage_req_t) ? \
(zb_zcl_go_to_lift_percentage_req_t*)zb_buf_begin(data_buf) : NULL; \
if (lift_percentage_req_ptr != NULL) \
{ \
(lift_percentage_req)->percentage_lift_value = \
lift_percentage_req_ptr->percentage_lift_value; \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
else \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
}
/** @brief Parses Get Go to Tilt command and fills to data request
structure. If request contains invalid data, -1 is returned as Percentage Tilt Value
@param data_buf - pointer to zb_buf_t buffer containing command request data
@param tilt_value_req - variable to save command request
@param status - return ZB_ZCL_PARSE_STATUS_SUCCESS if request contains valid data,
else ZB_ZCL_PARSE_STATUS_FAILURE
@note data_buf buffer should contain command request payload without ZCL header.
*/
#define ZB_ZCL_WINDOW_COVERING_GET_GO_TO_TILT_VALUE_REQ( \
data_buf, tilt_value_req, status) \
{ \
zb_zcl_go_to_tilt_value_req_t *tilt_value_req_ptr; \
(tilt_value_req_ptr) = zb_buf_len(data_buf) >= \
sizeof(zb_zcl_go_to_tilt_value_req_t) ? \
(zb_zcl_go_to_tilt_value_req_t*)zb_buf_begin(data_buf) : NULL; \
if (tilt_value_req_ptr != NULL) \
{ \
(tilt_value_req)->tilt_value = \
tilt_value_req_ptr->tilt_value; \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
else \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
}
/** @brief Send Go to Tilt Percentage command
@param buffer - to put packet to
@param addr - address to send packet to
@param dst_addr_mode - addressing mode
@param dst_ep - destination endpoint
@param ep - sending endpoint
@param prfl_id - profile identifier
@param def_resp - enable/disable default response
@param cb - callback for getting command send status
@param percentage_tilt_value - Percentage Tilt value
*/
#define ZB_ZCL_WINDOW_COVERING_SEND_GO_TO_TILT_PERCENTAGE_REQ( \
buffer, addr, dst_addr_mode, dst_ep, ep, prfl_id, def_resp, cb, percentage_tilt_value) \
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, def_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), \
ZB_ZCL_CMD_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE); \
ZB_ZCL_PACKET_PUT_DATA8(ptr, percentage_tilt_value); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, \
prfl_id, ZB_ZCL_CLUSTER_ID_WINDOW_COVERING, cb); \
}
/** @brief Parses Get Go to Tilt Percentage command and fills to data request
structure. If request contains invalid data, -1 is returned as Percentage Tilt Value
@param data_buf - pointer to zb_buf_t buffer containing command request data
@param tilt_percentage_req - variable to save command request
@param status - return ZB_ZCL_PARSE_STATUS_SUCCESS if request contains valid data,
else ZB_ZCL_PARSE_STATUS_FAILURE
@note data_buf buffer should contain command request payload without ZCL header.
*/
#define ZB_ZCL_WINDOW_COVERING_GET_GO_TO_TILT_PERCENTAGE_REQ( \
data_buf, tilt_percentage_req, status) \
{ \
zb_zcl_go_to_tilt_percentage_req_t *tilt_percentage_req_ptr; \
(tilt_percentage_req_ptr) = zb_buf_len(data_buf) >= \
sizeof(zb_zcl_go_to_tilt_percentage_req_t) ? \
(zb_zcl_go_to_tilt_percentage_req_t*)zb_buf_begin(data_buf) : NULL; \
if (tilt_percentage_req_ptr != NULL) \
{ \
(tilt_percentage_req)->percentage_tilt_value = \
tilt_percentage_req_ptr->percentage_tilt_value; \
(status) = ZB_ZCL_PARSE_STATUS_SUCCESS; \
} \
else \
{ \
(status) = ZB_ZCL_PARSE_STATUS_FAILURE; \
} \
}
/** @} */ /* Window Covering cluster commands */
/** @} */ /* ZCL Window Covering cluster definitions */
/** @endcond */ /* DOXYGEN_ZCL_SECTION */
void zb_zcl_window_covering_init_server(void);
void zb_zcl_window_covering_init_client(void);
#define ZB_ZCL_CLUSTER_ID_WINDOW_COVERING_SERVER_ROLE_INIT zb_zcl_window_covering_init_server
#define ZB_ZCL_CLUSTER_ID_WINDOW_COVERING_CLIENT_ROLE_INIT zb_zcl_window_covering_init_client
#endif /* ZB_ZCL_WINDOW_COVERING_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: ZCL OTA Upgrade cluster specific command declarations
*/
#ifndef ZCL_OTA_UPGRADE_COMMANDS_H
#define ZCL_OTA_UPGRADE_COMMANDS_H 1
#endif /* ZCL_OTA_UPGRADE_COMMANDS_H */

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2012-2022 DSR Corporation, Denver CO, USA
* Copyright (c) 2021-2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
* integrated circuit in a product or a software update for such product,
* must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 4. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* PURPOSE: ZCL Shade Configuration cluster specific command declarations
*/
#ifndef ZCL_LEVEL_SHADE_CONFIG_COMMANDS_H
#define ZCL_LEVEL_SHADE_CONFIG_COMMANDS_H 1
void shade_normal_processing(zb_uint8_t ep_id, zb_uint16_t cluster_id, zb_uint8_t value);
void shade_config_processing(zb_uint8_t ep_id);
#endif /* ZCL_LEVEL_CONTROL_COMMANDS_H */