Skip to content

Commit

Permalink
feat(Zigbee): Update Zigbee Dimmable light example config/define names
Browse files Browse the repository at this point in the history
  • Loading branch information
FaBjE committed Dec 13, 2024
1 parent 538c57a commit a0d57bb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 49 deletions.
4 changes: 2 additions & 2 deletions libraries/Zigbee/src/ep/ZigbeeDimmableLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ZigbeeDimmableLight::ZigbeeDimmableLight(uint8_t endpoint) : ZigbeeEP(endpoint)
{
_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);

_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};
Expand Down Expand Up @@ -98,7 +98,7 @@ void ZigbeeDimmableLight::setLightLevel(uint8_t 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_identify_cluster = esp_zb_identify_cluster_create(&light_cfg->identify_cfg);
Expand Down
88 changes: 41 additions & 47 deletions libraries/Zigbee/src/ep/ZigbeeDimmableLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,79 +15,73 @@
*
*
*/
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_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_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_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.
* Added here as not supported by ESP Zigbee library.
*
*/
#define ESP_ZB_DEFAULT_DIMMABLE_LIGHT_CONFIG() \
{ \
.basic_cfg = \
{ \
.zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \
.power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \
}, \
.identify_cfg = \
{ \
.identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \
}, \
.groups_cfg = \
{ \
.groups_name_support_id = ESP_ZB_ZCL_GROUPS_NAME_SUPPORT_DEFAULT_VALUE, \
}, \
.scenes_cfg = \
{ \
.scenes_count = ESP_ZB_ZCL_SCENES_SCENE_COUNT_DEFAULT_VALUE, \
.current_scene = ESP_ZB_ZCL_SCENES_CURRENT_SCENE_DEFAULT_VALUE, \
.current_group = ESP_ZB_ZCL_SCENES_CURRENT_GROUP_DEFAULT_VALUE, \
.scene_valid = ESP_ZB_ZCL_SCENES_SCENE_VALID_DEFAULT_VALUE, \
.name_support = ESP_ZB_ZCL_SCENES_NAME_SUPPORT_DEFAULT_VALUE, \
}, \
.on_off_cfg = \
{ \
.on_off = ESP_ZB_ZCL_ON_OFF_ON_OFF_DEFAULT_VALUE, \
}, \
.level_cfg = \
{ \
.current_level = ESP_ZB_ZCL_LEVEL_CONTROL_CURRENT_LEVEL_DEFAULT_VALUE, \
}, \
#define ZIGBEE_DEFAULT_DIMMABLE_LIGHT_CONFIG() \
{ \
.basic_cfg = \
{ \
.zcl_version = ESP_ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE, \
.power_source = ESP_ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE, \
}, \
.identify_cfg = \
{ \
.identify_time = ESP_ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE, \
}, \
.groups_cfg = \
{ \
.groups_name_support_id = ESP_ZB_ZCL_GROUPS_NAME_SUPPORT_DEFAULT_VALUE, \
}, \
.scenes_cfg = \
{ \
.scenes_count = ESP_ZB_ZCL_SCENES_SCENE_COUNT_DEFAULT_VALUE, \
.current_scene = ESP_ZB_ZCL_SCENES_CURRENT_SCENE_DEFAULT_VALUE, \
.current_group = ESP_ZB_ZCL_SCENES_CURRENT_GROUP_DEFAULT_VALUE, \
.scene_valid = ESP_ZB_ZCL_SCENES_SCENE_VALID_DEFAULT_VALUE, \
.name_support = ESP_ZB_ZCL_SCENES_NAME_SUPPORT_DEFAULT_VALUE, \
}, \
.on_off_cfg = \
{ \
.on_off = ESP_ZB_ZCL_ON_OFF_ON_OFF_DEFAULT_VALUE, \
}, \
.level_cfg = \
{ \
.current_level = ESP_ZB_ZCL_LEVEL_CONTROL_CURRENT_LEVEL_DEFAULT_VALUE, \
}, \
}

class ZigbeeDimmableLight : public ZigbeeEP
{
class ZigbeeDimmableLight : public ZigbeeEP {
public:
ZigbeeDimmableLight(uint8_t endpoint);
~ZigbeeDimmableLight();

void onLightChange(void (*callback)(bool, uint8_t))
{
void onLightChange(void (*callback)(bool, uint8_t)) {
_on_light_change = callback;
}
void restoreLight()
{
void restoreLight() {
lightChanged();
}

void setLightState(bool state);
void setLightLevel(uint8_t level);
void setLight(bool state, uint8_t level);

bool getLightState()
{
bool getLightState() {
return _current_state;
}
uint8_t getLightLevel()
{
uint8_t getLightLevel() {
return _current_level;
}

Expand All @@ -103,15 +97,15 @@ class ZigbeeDimmableLight : public ZigbeeEP
* Added here as not supported by ESP Zigbee library.
*
* @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
*
*/
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;
uint8_t _current_level;
};

#endif // SOC_IEEE802154_SUPPORTED
#endif // SOC_IEEE802154_SUPPORTED

0 comments on commit a0d57bb

Please sign in to comment.