#ifndef MEASUREMENT_DEVICE_H
#define MEASUREMENT_DEVICE_H

/* Temperature sensor device version */
#define ZB_HA_DEVICE_VER_TEMPERATURE_SENSOR     0

// Basic, Identify, Temperature, Illuminance, Humidity, Pressure, CO2, PM25
#define ZB_HA_MEASUREMENT_DEVICE_IN_CLUSTER_NUM			8
// Identify
#define ZB_HA_MEASUREMENT_DEVICE_OUT_CLUSTER_NUM		1

// Temperature, Illuminance, Humidity, Pressure, CO2, PM25
#define ZB_HA_MEASUREMENT_DEVICE_REPORT_ATTR_COUNT		6


#define ZB_HA_DECLARE_MEASUREMENT_DEVICE_CLUSTER_LIST(						\
		cluster_list_name,								\
		basic_attr_list,								\
		identify_attr_list,								\
		temperature_measurement_attr_list,				\
		illuminance_attr_list,							\
		humidity_measurement_attr_list,					\
		pressure_measurement_attr_list,					\
		co2_measurement_attr_list,					\
		pm25_measurement_attr_list					\
		)										\
	zb_zcl_cluster_desc_t cluster_list_name[] =						\
	{											\
		ZB_ZCL_CLUSTER_DESC(								\
			ZB_ZCL_CLUSTER_ID_BASIC,						\
			ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t),			\
			(basic_attr_list),							\
			ZB_ZCL_CLUSTER_SERVER_ROLE,						\
			ZB_ZCL_MANUF_CODE_INVALID						\
			),									\
		ZB_ZCL_CLUSTER_DESC(								\
			ZB_ZCL_CLUSTER_ID_IDENTIFY,						\
			ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t),		\
			(identify_attr_list),						\
			ZB_ZCL_CLUSTER_SERVER_ROLE,						\
			ZB_ZCL_MANUF_CODE_INVALID						\
			),									\
		ZB_ZCL_CLUSTER_DESC(								\
			ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT,					\
			ZB_ZCL_ARRAY_SIZE(temperature_measurement_attr_list, zb_zcl_attr_t),	\
			(temperature_measurement_attr_list),					\
			ZB_ZCL_CLUSTER_SERVER_ROLE,						\
			ZB_ZCL_MANUF_CODE_INVALID						\
			),									\
		ZB_ZCL_CLUSTER_DESC(								\
			ZB_ZCL_CLUSTER_ID_ILLUMINANCE_MEASUREMENT,				\
			ZB_ZCL_ARRAY_SIZE(illuminance_attr_list, zb_zcl_attr_t),	\
			(illuminance_attr_list),					\
			ZB_ZCL_CLUSTER_SERVER_ROLE,						\
			ZB_ZCL_MANUF_CODE_INVALID						\
			),									\
		ZB_ZCL_CLUSTER_DESC(								\
			ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT,				\
			ZB_ZCL_ARRAY_SIZE(humidity_measurement_attr_list, zb_zcl_attr_t),	\
			(humidity_measurement_attr_list),					\
			ZB_ZCL_CLUSTER_SERVER_ROLE,						\
			ZB_ZCL_MANUF_CODE_INVALID						\
			),									\
		ZB_ZCL_CLUSTER_DESC(								\
			ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT,					\
			ZB_ZCL_ARRAY_SIZE(pressure_measurement_attr_list, zb_zcl_attr_t),	\
			(pressure_measurement_attr_list),					\
			ZB_ZCL_CLUSTER_SERVER_ROLE,						\
			ZB_ZCL_MANUF_CODE_INVALID						\
			),									\
		ZB_ZCL_CLUSTER_DESC(								\
			ZB_ZCL_CLUSTER_ID_CO2_MEASUREMENT,					\
			ZB_ZCL_ARRAY_SIZE(co2_measurement_attr_list, zb_zcl_attr_t),	\
			(co2_measurement_attr_list),					\
			ZB_ZCL_CLUSTER_SERVER_ROLE,						\
			ZB_ZCL_MANUF_CODE_INVALID						\
			),									\
		ZB_ZCL_CLUSTER_DESC(								\
			ZB_ZCL_CLUSTER_ID_PM25_MEASUREMENT,					\
			ZB_ZCL_ARRAY_SIZE(pm25_measurement_attr_list, zb_zcl_attr_t),	\
			(pm25_measurement_attr_list),					\
			ZB_ZCL_CLUSTER_SERVER_ROLE,						\
			ZB_ZCL_MANUF_CODE_INVALID						\
			),									\
		ZB_ZCL_CLUSTER_DESC(                                        \
          ZB_ZCL_CLUSTER_ID_IDENTIFY,                               \
          0,                                                        \
          NULL,                                                     \
          ZB_ZCL_CLUSTER_CLIENT_ROLE,                               \
          ZB_ZCL_MANUF_CODE_INVALID                                 \
        ),                                                           \
	}

#define ZB_ZCL_DECLARE_MEASUREMENT_DEVICE_DESC(						\
		ep_name,								\
		ep_id,									\
		in_clust_num,								\
		out_clust_num)								\
	ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num);				\
	ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name =	\
	{										\
		ep_id,									\
		ZB_AF_HA_PROFILE_ID,							\
		ZB_HA_TEMPERATURE_SENSOR_DEVICE_ID,					\
		ZB_HA_DEVICE_VER_TEMPERATURE_SENSOR,					\
		0,									\
		in_clust_num,								\
		out_clust_num,								\
		{									\
			ZB_ZCL_CLUSTER_ID_BASIC,					\
			ZB_ZCL_CLUSTER_ID_IDENTIFY,					\
			ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT,				\
			ZB_ZCL_CLUSTER_ID_ILLUMINANCE_MEASUREMENT,				\
			ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT,			\
			ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT,				\
			ZB_ZCL_CLUSTER_ID_CO2_MEASUREMENT,				\
			ZB_ZCL_CLUSTER_ID_PM25_MEASUREMENT,				\
			ZB_ZCL_CLUSTER_ID_IDENTIFY,					\
		}									\
	}

#define ZB_HA_DECLARE_MEASUREMENT_DEVICE_EP(ep_name, ep_id, cluster_list)				\
	ZB_ZCL_DECLARE_MEASUREMENT_DEVICE_DESC(							\
		ep_name,									\
		ep_id,										\
		ZB_HA_MEASUREMENT_DEVICE_IN_CLUSTER_NUM,						\
		ZB_HA_MEASUREMENT_DEVICE_OUT_CLUSTER_NUM);						\
	ZBOSS_DEVICE_DECLARE_REPORTING_CTX(							\
		reporting_info##ep_name,							\
		ZB_HA_MEASUREMENT_DEVICE_REPORT_ATTR_COUNT);					\
	ZB_AF_DECLARE_ENDPOINT_DESC(								\
		ep_name,									\
		ep_id,										\
		ZB_AF_HA_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,				\
		ZB_HA_MEASUREMENT_DEVICE_REPORT_ATTR_COUNT, reporting_info##ep_name, 0, NULL)

#endif /* MEASUREMENT_DEVICE_H */