feat(Zigbee): Update Zigbee Dimmable light example config/define names

This commit is contained in:
FaBjE 2024-12-13 19:16:06 +01:00
parent 538c57a994
commit a0d57bb6d0
2 changed files with 43 additions and 49 deletions

View file

@ -8,7 +8,7 @@ ZigbeeDimmableLight::ZigbeeDimmableLight(uint8_t endpoint) : ZigbeeEP(endpoint)
{ {
_device_id = ESP_ZB_HA_DIMMABLE_LIGHT_DEVICE_ID; _device_id = ESP_ZB_HA_DIMMABLE_LIGHT_DEVICE_ID;
esp_zb_dimmable_light_cfg_t light_cfg = ESP_ZB_DEFAULT_DIMMABLE_LIGHT_CONFIG(); zigbee_dimmable_light_cfg_t light_cfg = ZIGBEE_DEFAULT_DIMMABLE_LIGHT_CONFIG();
_cluster_list = esp_zb_dimmable_light_clusters_create(&light_cfg); _cluster_list = esp_zb_dimmable_light_clusters_create(&light_cfg);
_ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_DIMMABLE_LIGHT_DEVICE_ID, .app_device_version = 0}; _ep_config = {.endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_DIMMABLE_LIGHT_DEVICE_ID, .app_device_version = 0};
@ -98,7 +98,7 @@ void ZigbeeDimmableLight::setLightLevel(uint8_t level)
setLight(_current_state, level); setLight(_current_state, level);
} }
esp_zb_cluster_list_t *ZigbeeDimmableLight::esp_zb_dimmable_light_clusters_create(esp_zb_dimmable_light_cfg_t *light_cfg) esp_zb_cluster_list_t *ZigbeeDimmableLight::esp_zb_dimmable_light_clusters_create(zigbee_dimmable_light_cfg_t *light_cfg)
{ {
esp_zb_attribute_list_t *esp_zb_basic_cluster = esp_zb_basic_cluster_create(&light_cfg->basic_cfg); esp_zb_attribute_list_t *esp_zb_basic_cluster = esp_zb_basic_cluster_create(&light_cfg->basic_cfg);
esp_zb_attribute_list_t *esp_zb_identify_cluster = esp_zb_identify_cluster_create(&light_cfg->identify_cfg); esp_zb_attribute_list_t *esp_zb_identify_cluster = esp_zb_identify_cluster_create(&light_cfg->identify_cfg);

View file

@ -15,22 +15,21 @@
* *
* *
*/ */
typedef struct esp_zb_dimmable_light_cfg_s typedef struct zigbee_dimmable_light_cfg_s {
{
esp_zb_basic_cluster_cfg_t basic_cfg; /*!< Basic cluster configuration, @ref esp_zb_basic_cluster_cfg_s */ esp_zb_basic_cluster_cfg_t basic_cfg; /*!< Basic cluster configuration, @ref esp_zb_basic_cluster_cfg_s */
esp_zb_identify_cluster_cfg_t identify_cfg; /*!< Identify cluster configuration, @ref esp_zb_identify_cluster_cfg_s */ esp_zb_identify_cluster_cfg_t identify_cfg; /*!< Identify cluster configuration, @ref esp_zb_identify_cluster_cfg_s */
esp_zb_groups_cluster_cfg_t groups_cfg; /*!< Groups cluster configuration, @ref esp_zb_groups_cluster_cfg_s */ esp_zb_groups_cluster_cfg_t groups_cfg; /*!< Groups cluster configuration, @ref esp_zb_groups_cluster_cfg_s */
esp_zb_scenes_cluster_cfg_t scenes_cfg; /*!< Scenes cluster configuration, @ref esp_zb_scenes_cluster_cfg_s */ esp_zb_scenes_cluster_cfg_t scenes_cfg; /*!< Scenes cluster configuration, @ref esp_zb_scenes_cluster_cfg_s */
esp_zb_on_off_cluster_cfg_t on_off_cfg; /*!< On off cluster configuration, @ref esp_zb_on_off_cluster_cfg_s */ esp_zb_on_off_cluster_cfg_t on_off_cfg; /*!< On off cluster configuration, @ref esp_zb_on_off_cluster_cfg_s */
esp_zb_level_cluster_cfg_t level_cfg; /*!< Level cluster configuration, @ref esp_zb_level_cluster_cfg_s */ esp_zb_level_cluster_cfg_t level_cfg; /*!< Level cluster configuration, @ref esp_zb_level_cluster_cfg_s */
} esp_zb_dimmable_light_cfg_t; } zigbee_dimmable_light_cfg_t;
/** /**
* @brief Zigbee HA standard dimmable light device default config value. * @brief Zigbee HA standard dimmable light device default config value.
* Added here as not supported by ESP Zigbee library. * Added here as not supported by ESP Zigbee library.
* *
*/ */
#define ESP_ZB_DEFAULT_DIMMABLE_LIGHT_CONFIG() \ #define ZIGBEE_DEFAULT_DIMMABLE_LIGHT_CONFIG() \
{ \ { \
.basic_cfg = \ .basic_cfg = \
{ \ { \
@ -63,18 +62,15 @@ typedef struct esp_zb_dimmable_light_cfg_s
}, \ }, \
} }
class ZigbeeDimmableLight : public ZigbeeEP class ZigbeeDimmableLight : public ZigbeeEP {
{
public: public:
ZigbeeDimmableLight(uint8_t endpoint); ZigbeeDimmableLight(uint8_t endpoint);
~ZigbeeDimmableLight(); ~ZigbeeDimmableLight();
void onLightChange(void (*callback)(bool, uint8_t)) void onLightChange(void (*callback)(bool, uint8_t)) {
{
_on_light_change = callback; _on_light_change = callback;
} }
void restoreLight() void restoreLight() {
{
lightChanged(); lightChanged();
} }
@ -82,12 +78,10 @@ public:
void setLightLevel(uint8_t level); void setLightLevel(uint8_t level);
void setLight(bool state, uint8_t level); void setLight(bool state, uint8_t level);
bool getLightState() bool getLightState() {
{
return _current_state; return _current_state;
} }
uint8_t getLightLevel() uint8_t getLightLevel() {
{
return _current_level; return _current_level;
} }
@ -103,12 +97,12 @@ private:
* Added here as not supported by ESP Zigbee library. * Added here as not supported by ESP Zigbee library.
* *
* @note This contains basic, identify, groups, scenes, on-off, level, as server side. * @note This contains basic, identify, groups, scenes, on-off, level, as server side.
* @param[in] light_cfg Configuration parameters for this cluster lists defined by @ref esp_zb_dimmable_light_cfg_t * @param[in] light_cfg Configuration parameters for this cluster lists defined by @ref zigbee_dimmable_light_cfg_t
* *
* @return Pointer to cluster list @ref esp_zb_cluster_list_s * @return Pointer to cluster list @ref esp_zb_cluster_list_s
* *
*/ */
esp_zb_cluster_list_t *esp_zb_dimmable_light_clusters_create(esp_zb_dimmable_light_cfg_t *light_cfg); esp_zb_cluster_list_t *esp_zb_dimmable_light_clusters_create(zigbee_dimmable_light_cfg_t *light_cfg);
bool _current_state; bool _current_state;
uint8_t _current_level; uint8_t _current_level;