#ifndef ZIGBEE_ZCL_H
#define ZIGBEE_ZCL_H

#include <stdint.h>
#include <stdbool.h>

/**
 * @brief ZCL Thermostat cluster attributes
 */
typedef struct {
    int16_t local_temperature;     /**< Current temperature in 0.01°C units */
    uint8_t system_mode;           /**< System mode: 0=Off, 1=Auto, 3=Cool, 4=Heat */
    uint8_t control_sequence;      /**< HVAC operation sequence */
} zcl_thermostat_attrs_t;

/**
 * @brief Initialize Zigbee stack and ZCL Thermostat cluster
 * @return true if initialization successful, false otherwise
 */
bool zigbee_zcl_init(void);

/**
 * @brief Handle incoming Zigbee ZCL commands
 * @param endpoint Endpoint ID
 * @param cluster_id Cluster ID
 * @param command_id Command ID
 * @param payload Command payload
 * @param payload_length Length of payload
 * @return true if command processed successfully
 */
bool zigbee_zcl_handle_command(uint8_t endpoint, uint16_t cluster_id,
                              uint8_t command_id, const uint8_t* payload,
                              uint16_t payload_length);

/**
 * @brief Set local temperature attribute
 * @param temperature Temperature in 0.01°C units
 */
void zigbee_zcl_set_local_temperature(int16_t temperature);

/**
 * @brief Get local temperature attribute
 * @return Current temperature in 0.01°C units
 */
int16_t zigbee_zcl_get_local_temperature(void);

/**
 * @brief Set system mode attribute
 * @param mode System mode (0=Off, 1=Auto, 3=Cool, 4=Heat)
 */
void zigbee_zcl_set_system_mode(uint8_t mode);

/**
 * @brief Get system mode attribute
 * @return Current system mode
 */
uint8_t zigbee_zcl_get_system_mode(void);

/**
 * @brief Handle weekly schedule commands
 * @param command_id Schedule command ID
 * @param payload Schedule payload
 * @param payload_length Length of payload
 * @return true if command processed successfully
 */
bool zigbee_zcl_handle_schedule_command(uint8_t command_id,
                                       const uint8_t* payload,
                                       uint16_t payload_length);

#endif // ZIGBEE_ZCL_H