Merged
Changes from 1 commit
File filter
Filter by extension
Conversations
Failed to load comments.
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Failed to load files.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -20,6 +20,8 @@ bool ZigbeeAnalog::addAnalogInput() { | ||
"Analog Input"; | ||
uint32_t application_type = 0x00000000 | (ESP_ZB_ZCL_AI_GROUP_ID << 24); | ||
float resolution = 0.1; // Default resolution of 0.1 | ||
float min = -3.402823e+38; // Default min value for float | ||
float max = 3.402823e+38; // Default max value for float | ||
esp_err_t ret = esp_zb_analog_input_cluster_add_attr(esp_zb_analog_input_cluster, ESP_ZB_ZCL_ATTR_ANALOG_INPUT_DESCRIPTION_ID, (void *)default_description); | ||
if (ret != ESP_OK) { | ||
@@ -39,11 +41,24 @@ bool ZigbeeAnalog::addAnalogInput() { | ||
return false; | ||
} | ||
ret = esp_zb_analog_input_cluster_add_attr(esp_zb_analog_input_cluster, ESP_ZB_ZCL_ATTR_ANALOG_INPUT_MIN_PRESENT_VALUE_ID, (void *)&min); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to set min value: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
return false; | ||
} | ||
ret = esp_zb_analog_input_cluster_add_attr(esp_zb_analog_input_cluster, ESP_ZB_ZCL_ATTR_ANALOG_INPUT_MAX_PRESENT_VALUE_ID, (void *)&max); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to set max value: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
return false; | ||
} | ||
ret = esp_zb_cluster_list_add_analog_input_cluster(_cluster_list, esp_zb_analog_input_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to add Analog Input cluster: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
return false; | ||
} | ||
_analog_clusters |= ANALOG_INPUT; | ||
return true; | ||
} | ||
@@ -76,6 +91,8 @@ bool ZigbeeAnalog::addAnalogOutput() { | ||
"Analog Output"; | ||
uint32_t application_type = 0x00000000 | (ESP_ZB_ZCL_AO_GROUP_ID << 24); | ||
float resolution = 1; // Default resolution of 1 | ||
float min = -3.402823e+38; // Default min value for float | ||
float max = 3.402823e+38; // Default max value for float | ||
P-R-O-C-H-Y marked this conversation as resolved. Show resolved Hide resolvedUh oh!There was an error while loading. Please reload this page. | ||
esp_err_t ret = | ||
esp_zb_analog_output_cluster_add_attr(esp_zb_analog_output_cluster, ESP_ZB_ZCL_ATTR_ANALOG_OUTPUT_DESCRIPTION_ID, (void *)default_description); | ||
@@ -96,6 +113,19 @@ bool ZigbeeAnalog::addAnalogOutput() { | ||
return false; | ||
} | ||
ret = esp_zb_analog_output_cluster_add_attr(esp_zb_analog_output_cluster, ESP_ZB_ZCL_ATTR_ANALOG_OUTPUT_MIN_PRESENT_VALUE_ID, (void *)&min); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to set min value: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
return false; | ||
} | ||
ret = esp_zb_analog_output_cluster_add_attr(esp_zb_analog_output_cluster, ESP_ZB_ZCL_ATTR_ANALOG_OUTPUT_MAX_PRESENT_VALUE_ID, (void *)&max); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to set max value: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
return false; | ||
} | ||
ret = esp_zb_cluster_list_add_analog_output_cluster(_cluster_list, esp_zb_analog_output_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to add Analog Output cluster: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
@@ -376,4 +406,58 @@ bool ZigbeeAnalog::setAnalogOutputResolution(float resolution) { | ||
return true; | ||
} | ||
bool ZigbeeAnalog::setAnalogOutputMinMax(float min, float max) { | ||
if (!(_analog_clusters & ANALOG_OUTPUT)) { | ||
log_e("Analog Output cluster not added"); | ||
return false; | ||
} | ||
esp_zb_attribute_list_t *analog_output_cluster = | ||
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_ANALOG_OUTPUT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); | ||
if (analog_output_cluster == nullptr) { | ||
log_e("Failed to get analog output cluster"); | ||
return false; | ||
} | ||
esp_err_t ret = esp_zb_cluster_update_attr(analog_output_cluster, ESP_ZB_ZCL_ATTR_ANALOG_OUTPUT_MIN_PRESENT_VALUE_ID, (void *)&min); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to set min value: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
return false; | ||
} | ||
ret = esp_zb_cluster_update_attr(analog_output_cluster, ESP_ZB_ZCL_ATTR_ANALOG_OUTPUT_MAX_PRESENT_VALUE_ID, (void *)&max); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to set max value: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
return false; | ||
} | ||
return true; | ||
} | ||
bool ZigbeeAnalog::setAnalogInputMinMax(float min, float max) { | ||
if (!(_analog_clusters & ANALOG_INPUT)) { | ||
log_e("Analog Input cluster not added"); | ||
return false; | ||
} | ||
esp_zb_attribute_list_t *analog_input_cluster = | ||
esp_zb_cluster_list_get_cluster(_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_ANALOG_INPUT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); | ||
if (analog_input_cluster == nullptr) { | ||
log_e("Failed to get analog input cluster"); | ||
return false; | ||
} | ||
esp_err_t ret = esp_zb_cluster_update_attr(analog_input_cluster, ESP_ZB_ZCL_ATTR_ANALOG_INPUT_MIN_PRESENT_VALUE_ID, (void *)&min); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to set min value: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
return false; | ||
} | ||
ret = esp_zb_cluster_update_attr(analog_input_cluster, ESP_ZB_ZCL_ATTR_ANALOG_INPUT_MAX_PRESENT_VALUE_ID, (void *)&max); | ||
if (ret != ESP_OK) { | ||
log_e("Failed to set max value: 0x%x: %s", ret, esp_err_to_name(ret)); | ||
return false; | ||
} | ||
return true; | ||
} | ||
#endif // CONFIG_ZB_ENABLED |
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.