diff --git a/src/app_cfg.h b/src/app_cfg.h index b40a144..b6b22a9 100644 --- a/src/app_cfg.h +++ b/src/app_cfg.h @@ -154,6 +154,7 @@ extern "C" { //#define ZCL_IAS_ZONE_SUPPORT 1 #define ZCL_TEMPERATURE_MEASUREMENT_SUPPORT 1 #define ZCL_RELATIVE_HUMIDITY_SUPPORT 1 +#define ZCL_THERMOSTAT_UI_CFG_SUPPORT 1 //#define ZCL_POLL_CTRL_SUPPORT 1 #define ZCL_OTA_SUPPORT 1 @@ -163,6 +164,10 @@ extern "C" { #define ZCL_RELATIVE_HUMIDITY #define ZCL_RELATIVE_HUMIDITY_MEASUREMENT #endif +#if ZCL_THERMOSTAT_UI_CFG_SUPPORT +#define ZCL_THERMOSTAT_UI_CFG +#endif + #define DEFAULT_POLL_RATE (10 * (4 * POLL_RATE_QUARTERSECONDS)) diff --git a/src/custom_zcl/zcl_thermostat_ui_cfg.c b/src/custom_zcl/zcl_thermostat_ui_cfg.c new file mode 100644 index 0000000..cb2826a --- /dev/null +++ b/src/custom_zcl/zcl_thermostat_ui_cfg.c @@ -0,0 +1,34 @@ + +/********************************************************************** + * INCLUDES + */ +#include "zcl_include.h" + + +#ifdef ZCL_THERMOSTAT_UI_CFG +/********************************************************************** + * LOCAL CONSTANTS + */ + + +/********************************************************************** + * LOCAL TYPES + */ + + +/********************************************************************** + * LOCAL VARIABLES + */ + + +/********************************************************************** + * LOCAL FUNCTIONS + */ + +_CODE_ZCL_ status_t zcl_thermostat_ui_cfg_register(u8 endpoint, u16 manuCode, u8 attrNum, const zclAttrInfo_t attrTbl[], cluster_forAppCb_t cb) +{ + return zcl_registerCluster(endpoint, ZCL_CLUSTER_HAVC_USER_INTERFACE_CONFIG, manuCode, attrNum, attrTbl, NULL, cb); +} + +#endif /* ZCL_THERMOSTAT_UI */ + diff --git a/src/custom_zcl/zcl_thermostat_ui_cfg.h b/src/custom_zcl/zcl_thermostat_ui_cfg.h new file mode 100644 index 0000000..a338f11 --- /dev/null +++ b/src/custom_zcl/zcl_thermostat_ui_cfg.h @@ -0,0 +1,18 @@ + +#ifndef ZCL_THERMOSTAT_UI_CFG_H +#define ZCL_THERMOSTAT_UI_CFG_H + +/********************************************************************* + * CONSTANTS + */ + +/** + * @brief thermostatu UI configuration cluster Attribute IDs + */ +#define ZCL_THERMOSTAT_UI_CFG_ATTRID_TEMPERATUREDISPLAYMODE 0x0000 +#define ZCL_THERMOSTAT_UI_CFG_ATTRID_KEYPADLOCKOUT 0x0001 +#define ZCL_THERMOSTAT_UI_CFG_ATTRID_SCHEDULEPROGRAMMINGVISIBILITY 0x0002 + +status_t zcl_thermostat_ui_cfg_register(u8 endpoint, u16 manuCode, u8 attrNum, const zclAttrInfo_t attrTbl[], cluster_forAppCb_t cb); + +#endif /* ZCL_THERMOSTAT_UI_CFG_H */ diff --git a/src/device.c b/src/device.c index 7a0e3b3..cb342d2 100644 --- a/src/device.c +++ b/src/device.c @@ -201,9 +201,17 @@ void read_sensor_and_save() { g_zcl_powerAttrs.batteryVoltage = converted_voltage; g_zcl_powerAttrs.batteryPercentage = percentage2; + s16 displayTemperature = g_zcl_temperatureAttrs.measuredValue / 10; + u8 tempSymbol = 1; + + if (g_zcl_thermostatUICfgAttrs.displayMode == 1) { + displayTemperature = (s16)(((s32)g_zcl_temperatureAttrs.measuredValue * 9) / (5*10) + 320); + tempSymbol = 2; + } + // update lcd - show_temp_symbol(1); - show_big_number(g_zcl_temperatureAttrs.measuredValue / 10, 1); + show_temp_symbol(tempSymbol); + show_big_number(displayTemperature, 1); show_small_number(g_zcl_relHumidityAttrs.measuredValue / 100, 1); #if defined(SHOW_SMILEY) show_smiley( diff --git a/src/device.h b/src/device.h index bd0310e..81e8090 100644 --- a/src/device.h +++ b/src/device.h @@ -90,6 +90,13 @@ typedef struct { u16 tolerance; }zcl_relHumidityAttr_t; +/** + * @brief Defined for thermostat UI config cluster attributes + */ +typedef struct { + u8 displayMode; +}zcl_thermostatUICfgAttr_t; + /** * @brief Defined for poll control cluster attributes @@ -126,6 +133,7 @@ extern const af_simple_descriptor_t sensorDevice_simpleDesc; extern zcl_basicAttr_t g_zcl_basicAttrs; extern zcl_identifyAttr_t g_zcl_identifyAttrs; extern zcl_powerAttr_t g_zcl_powerAttrs; +extern zcl_thermostatUICfgAttr_t g_zcl_thermostatUICfgAttrs; extern zcl_temperatureAttr_t g_zcl_temperatureAttrs; extern zcl_relHumidityAttr_t g_zcl_relHumidityAttrs; // extern zcl_iasZoneAttr_t g_zcl_iasZoneAttrs; diff --git a/src/sensorEpCfg.c b/src/sensorEpCfg.c index 9bbb788..0af8530 100644 --- a/src/sensorEpCfg.c +++ b/src/sensorEpCfg.c @@ -4,6 +4,7 @@ #include "tl_common.h" #include "zcl_include.h" #include "zcl_relative_humidity.h" +#include "zcl_thermostat_ui_cfg.h" #include "device.h" /********************************************************************** @@ -243,6 +244,22 @@ const zclAttrInfo_t relative_humdity_attrTbl[] = #define ZCL_RELATIVE_HUMIDITY_ATTR_NUM sizeof(relative_humdity_attrTbl) / sizeof(zclAttrInfo_t) #endif +#ifdef ZCL_THERMOSTAT_UI_CFG +zcl_thermostatUICfgAttr_t g_zcl_thermostatUICfgAttrs = +{ + .displayMode = 0x0000, +}; + +const zclAttrInfo_t thermostat_ui_cfg_attrTbl[] = +{ + { ZCL_THERMOSTAT_UI_CFG_ATTRID_TEMPERATUREDISPLAYMODE, ZCL_DATA_TYPE_ENUM8, ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE, (u8*)&g_zcl_thermostatUICfgAttrs.displayMode }, + + { ZCL_ATTRID_GLOBAL_CLUSTER_REVISION, ZCL_DATA_TYPE_UINT16, ACCESS_CONTROL_READ, (u8*)&zcl_attr_global_clusterRevision}, +}; + +#define ZCL_THERMOSTAT_UI_CFG_ATTR_NUM sizeof(thermostat_ui_cfg_attrTbl) / sizeof(zclAttrInfo_t) +#endif + #ifdef ZCL_POLL_CTRL /* Poll Control */ @@ -288,7 +305,11 @@ const zcl_specClusterInfo_t g_sensorDeviceClusterList[] = {ZCL_CLUSTER_MS_TEMPERATURE_MEASUREMENT, MANUFACTURER_CODE_NONE, ZCL_TEMPERATURE_MEASUREMENT_ATTR_NUM, temperature_measurement_attrTbl, zcl_temperature_measurement_register, NULL}, #endif #ifdef ZCL_RELATIVE_HUMIDITY - {ZCL_CLUSTER_MS_RELATIVE_HUMIDITY, MANUFACTURER_CODE_NONE, ZCL_RELATIVE_HUMIDITY_ATTR_NUM, relative_humdity_attrTbl, zcl_relative_humidity_register, NULL}, + {ZCL_CLUSTER_MS_RELATIVE_HUMIDITY, MANUFACTURER_CODE_NONE, ZCL_RELATIVE_HUMIDITY_ATTR_NUM, relative_humdity_attrTbl, zcl_relative_humidity_register, NULL}, +#endif +#ifdef ZCL_THERMOSTAT_UI_CFG + // typo in SDK + {ZCL_CLUSTER_HAVC_USER_INTERFACE_CONFIG, MANUFACTURER_CODE_NONE, ZCL_THERMOSTAT_UI_CFG_ATTR_NUM, thermostat_ui_cfg_attrTbl, zcl_thermostat_ui_cfg_register, NULL}, #endif #ifdef ZCL_POLL_CTRL {ZCL_CLUSTER_GEN_POLL_CONTROL, MANUFACTURER_CODE_NONE, ZCL_POLLCTRL_ATTR_NUM, pollCtrl_attrTbl, zcl_pollCtrl_register, sensorDevice_pollCtrlCb},