mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
examples: simplified attribute retrieval api
This commit is contained in:
@@ -68,10 +68,7 @@ static void app_driver_button_toggle_cb(void *arg, void *data)
|
||||
uint32_t cluster_id = OnOff::Id;
|
||||
uint32_t attribute_id = OnOff::Attributes::OnOff::Id;
|
||||
|
||||
node_t *node = node::get();
|
||||
endpoint_t *endpoint = endpoint::get(node, endpoint_id);
|
||||
cluster_t *cluster = cluster::get(endpoint, cluster_id);
|
||||
attribute_t *attribute = attribute::get(cluster, attribute_id);
|
||||
attribute_t *attribute = attribute::get(endpoint_id, cluster_id, attribute_id);
|
||||
|
||||
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
|
||||
attribute::get_val(attribute, &val);
|
||||
@@ -86,9 +83,6 @@ esp_err_t app_driver_attribute_update(app_driver_handle_t driver_handle, uint16_
|
||||
char vcard_data[MAX_VCARD_ATTR][MAX_ATTR_SIZE];
|
||||
memset(vcard_data, '\0', sizeof(MAX_VCARD_ATTR * MAX_ATTR_SIZE));
|
||||
esp_matter_attr_val_t _val = esp_matter_invalid(NULL);
|
||||
node_t *node = node::get();
|
||||
endpoint_t *endpoint = endpoint::get(node, 0x0);
|
||||
cluster_t *cluster = cluster::get(endpoint, BADGE_CLUSTER_ID);
|
||||
attribute_t *attribute = NULL;
|
||||
|
||||
uint32_t _attribute_id = NAME_ATTRIBUTE_ID;
|
||||
@@ -100,7 +94,7 @@ esp_err_t app_driver_attribute_update(app_driver_handle_t driver_handle, uint16_
|
||||
_attribute_id++;
|
||||
continue;
|
||||
}
|
||||
attribute = attribute::get(cluster, _attribute_id);
|
||||
attribute = attribute::get(0x0, cluster_id, _attribute_id);
|
||||
attribute::get_val(attribute, &_val);
|
||||
memcpy(vcard_data[i], _val.val.a.b, _val.val.a.s);
|
||||
vcard_data[i][_val.val.a.s] = '\0';
|
||||
@@ -133,15 +127,10 @@ esp_err_t app_driver_light_set_defaults(uint16_t endpoint_id)
|
||||
esp_err_t err = ESP_OK;
|
||||
void *priv_data = endpoint::get_priv_data(endpoint_id);
|
||||
led_indicator_handle_t handle = (led_indicator_handle_t)priv_data;
|
||||
node_t *node = node::get();
|
||||
endpoint_t *endpoint = endpoint::get(node, endpoint_id);
|
||||
cluster_t *cluster = NULL;
|
||||
attribute_t *attribute = NULL;
|
||||
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
|
||||
|
||||
endpoint = endpoint::get(node, 0x0);
|
||||
cluster = cluster::get(endpoint, BADGE_CLUSTER_ID);
|
||||
attribute = attribute::get(cluster, NAME_ATTRIBUTE_ID);
|
||||
attribute = attribute::get(0x0, BADGE_CLUSTER_ID, NAME_ATTRIBUTE_ID);
|
||||
attribute::get_val(attribute, &val);
|
||||
if (val.val.a.b[NAME]) {
|
||||
char vcard_data[MAX_VCARD_ATTR][MAX_ATTR_SIZE];
|
||||
@@ -150,7 +139,7 @@ esp_err_t app_driver_light_set_defaults(uint16_t endpoint_id)
|
||||
uint32_t attribute_id = NAME_ATTRIBUTE_ID;
|
||||
do {
|
||||
esp_matter_attr_val_t _val = esp_matter_invalid(NULL);
|
||||
attribute = attribute::get(cluster, attribute_id);
|
||||
attribute = attribute::get(0x0, BADGE_CLUSTER_ID, attribute_id);
|
||||
attribute::get_val(attribute, &_val);
|
||||
memcpy(vcard_data[i], _val.val.a.b, _val.val.a.s);
|
||||
vcard_data[i][_val.val.a.s] = '\0';
|
||||
@@ -163,8 +152,7 @@ esp_err_t app_driver_light_set_defaults(uint16_t endpoint_id)
|
||||
}
|
||||
|
||||
/* If nodelabel value is set then display the nodelabel_input */
|
||||
cluster = cluster::get(endpoint, BasicInformation::Id);
|
||||
attribute = attribute::get(cluster, BasicInformation::Attributes::NodeLabel::Id);
|
||||
attribute = attribute::get(0x0, BasicInformation::Id, BasicInformation::Attributes::NodeLabel::Id);
|
||||
attribute::get_val(attribute, &val);
|
||||
if (val.val.a.s && !badge_cluster_input_exists) {
|
||||
set_badge_name(&val);
|
||||
@@ -173,8 +161,7 @@ esp_err_t app_driver_light_set_defaults(uint16_t endpoint_id)
|
||||
|
||||
/* Setting power */
|
||||
if (!nodelabel_input) {
|
||||
cluster = cluster::get(endpoint, OnOff::Id);
|
||||
attribute = attribute::get(cluster, OnOff::Attributes::OnOff::Id);
|
||||
attribute = attribute::get(0x0, OnOff::Id, OnOff::Attributes::OnOff::Id);
|
||||
attribute::get_val(attribute, &val);
|
||||
if (chip::Server::GetInstance().GetFabricTable().FabricCount())
|
||||
err |= app_driver_light_set_power(handle, &val);
|
||||
|
||||
Reference in New Issue
Block a user