cleanup, make it less talkative
This commit is contained in:
@@ -12,6 +12,9 @@ static char manufacturer[] = "\x05""Drath";
|
||||
static char model[] = "\x15""Dimmable Zigbee Light";
|
||||
static const uint8_t endpoint_no = 1;
|
||||
|
||||
static const uint16_t transition_on_off_ms = 500;
|
||||
static const uint16_t transition_level_ms = 100;
|
||||
|
||||
static esp_err_t deferred_driver_init(void) {
|
||||
static bool is_inited = false;
|
||||
if (!is_inited) {
|
||||
@@ -44,10 +47,8 @@ esp_err_t zigbee_utility_add_ep_basic_manufacturer_info(esp_zb_ep_list_t *ep_lis
|
||||
static esp_err_t zigbee_attribute_handler(const esp_zb_zcl_set_attr_value_message_t* message) {
|
||||
ESP_RETURN_ON_FALSE(message, ESP_FAIL, TAG, "Empty message");
|
||||
ESP_RETURN_ON_FALSE(message->info.status == ESP_ZB_ZCL_STATUS_SUCCESS, ESP_ERR_INVALID_ARG, TAG, "Received message: error status(%d)", message->info.status);
|
||||
ESP_LOGI(TAG, "Received message: endpoint(%d), cluster(0x%x), attribute(0x%x), data size(%d)", message->info.dst_endpoint, message->info.cluster, message->attribute.id, message->attribute.data.size);
|
||||
|
||||
if (message->info.dst_endpoint == endpoint_no) {
|
||||
const uint16_t transition = 200; // default 200ms transition
|
||||
switch (message->info.cluster) {
|
||||
|
||||
case ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY:
|
||||
@@ -59,24 +60,21 @@ static esp_err_t zigbee_attribute_handler(const esp_zb_zcl_set_attr_value_messag
|
||||
bool light_state = false;
|
||||
light_state = message->attribute.data.value ? *(bool*)message->attribute.data.value : light_state;
|
||||
ESP_LOGI(TAG, "Light sets to %s", light_state ? "On" : "Off");
|
||||
light_driver_set_power(light_state, transition);
|
||||
light_driver_set_power(light_state, transition_on_off_ms);
|
||||
}
|
||||
else { ESP_LOGW(TAG, "On/Off cluster data: attribute(0x%x), type(0x%x)", message->attribute.id, message->attribute.data.type); }
|
||||
break;
|
||||
|
||||
case ESP_ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL:
|
||||
if (message->attribute.id == ESP_ZB_ZCL_ATTR_LEVEL_CONTROL_CURRENT_LEVEL_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_U8) {
|
||||
uint8_t light_level = 0;
|
||||
light_level = message->attribute.data.value ? *(uint8_t*)message->attribute.data.value : light_level;
|
||||
light_driver_set_level(light_level, transition);
|
||||
light_driver_set_level(light_level, transition_level_ms);
|
||||
ESP_LOGI(TAG, "Light level changes to %d", light_level);
|
||||
}
|
||||
else
|
||||
ESP_LOGW(TAG, "Level Control cluster data: attribute(0x%x), type(0x%x)", message->attribute.id, message->attribute.data.type);
|
||||
break;
|
||||
|
||||
default:
|
||||
ESP_LOGI(TAG, "Message data: cluster(0x%x), attribute(0x%x) ", message->info.cluster, message->attribute.id);
|
||||
ESP_LOGW(TAG, "Unhandled zigbee message, data: cluster(0x%x), attribute(0x%x) ", message->info.cluster, message->attribute.id);
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
Reference in New Issue
Block a user