@@ -29,17 +29,25 @@ static esp_err_t app_attribute_update_cb(
2929 uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data)
3030{
3131 esp_err_t err = ESP_OK;
32- if (type == PRE_UPDATE) { /* * Callback before updating the value in the database */
33- MatterEndPoint *ep = (MatterEndPoint *) priv_data; // end point pointer
34- if (ep != NULL ) {
35- err = ep->attributeChangeCB (endpoint_id, cluster_id, attribute_id, val) ? ESP_OK : ESP_FAIL;
36- }
37- }
38- if (type == POST_UPDATE) { /* * Callback after updating the value in the database */
39- }
40- if (type == READ) { /* * Callback for reading the attribute value. This is used when the `ATTRIBUTE_FLAG_OVERRIDE` is set. */
41- }
42- if (type == WRITE) { /* * Callback for writing the attribute value. This is used when the `ATTRIBUTE_FLAG_OVERRIDE` is set. */
32+ switch (type) {
33+ case PRE_UPDATE: // Callback before updating the value in the database
34+ log_i (" Attribute update callback: PRE_UPDATE" );
35+ MatterEndPoint *ep = (MatterEndPoint *) priv_data; // endpoint pointer to base class
36+ if (ep != NULL ) {
37+ err = ep->attributeChangeCB (endpoint_id, cluster_id, attribute_id, val) ? ESP_OK : ESP_FAIL;
38+ }
39+ break ;
40+ case POST_UPDATE: // Callback after updating the value in the database
41+ log_i (" Attribute update callback: POST_UPDATE" );
42+ break ;
43+ case READ: // Callback for reading the attribute value. This is used when the `ATTRIBUTE_FLAG_OVERRIDE` is set.
44+ log_i (" Attribute update callback: READ" );
45+ break ;
46+ case WRITE: // Callback for writing the attribute value. This is used when the `ATTRIBUTE_FLAG_OVERRIDE` is set.
47+ log_i (" Attribute update callback: WRITE" );
48+ break ;
49+ default :
50+ log_i (" Attribute update callback: Unknown type %d" , type);
4351 }
4452 return err;
4553}
0 commit comments