mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
[blemesh & zigbee bridge] Adds support to reduce complexity of bridged_device search using priv_data instead of using endpoint
Fixes and closes https://github.com/espressif/esp-matter/issues/60
This commit is contained in:
@@ -66,9 +66,8 @@ static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint
|
||||
uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
if (type == PRE_UPDATE) {
|
||||
err = blemesh_bridge_attribute_update(endpoint_id, cluster_id, attribute_id, val);
|
||||
err = blemesh_bridge_attribute_update(endpoint_id, cluster_id, attribute_id, val, (app_bridged_device_t *)priv_data);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#include <esp_matter_core.h>
|
||||
#include <esp_matter_bridge.h>
|
||||
|
||||
#include <app_bridged_device.h>
|
||||
#include <blemesh_bridge.h>
|
||||
#include <app_blemesh.h>
|
||||
#include <app_bridged_device.h>
|
||||
|
||||
static const char *TAG = "blemesh_bridge";
|
||||
|
||||
@@ -69,9 +69,8 @@ esp_err_t blemesh_bridge_match_bridged_onoff_light(uint8_t *composition_data, ui
|
||||
}
|
||||
|
||||
esp_err_t blemesh_bridge_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
|
||||
esp_matter_attr_val_t *val)
|
||||
esp_matter_attr_val_t *val, app_bridged_device_t *bridged_device)
|
||||
{
|
||||
app_bridged_device_t *bridged_device = app_bridge_get_device_by_matter_endpointid(endpoint_id);
|
||||
if (bridged_device && bridged_device->dev && bridged_device->dev->endpoint) {
|
||||
if (cluster_id == OnOff::Id) {
|
||||
if (attribute_id == OnOff::Attributes::OnOff::Id) {
|
||||
@@ -80,6 +79,9 @@ esp_err_t blemesh_bridge_attribute_update(uint16_t endpoint_id, uint32_t cluster
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
ESP_LOGE(TAG, "Unable to Update Bridge Device, ep: %d, cluster: %d, att: %d", endpoint_id, cluster_id, attribute_id);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ extern "C" {
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <esp_matter_attribute_utils.h>
|
||||
#include <app_bridged_device.h>
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@@ -30,7 +31,7 @@ extern "C" {
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t blemesh_bridge_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
|
||||
esp_matter_attr_val_t *val);
|
||||
esp_matter_attr_val_t *val, app_bridged_device_t *bridged_device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ app_bridged_device_t *app_bridge_create_bridged_device(node_t *node, uint16_t pa
|
||||
return NULL;
|
||||
}
|
||||
app_bridged_device_t *new_dev = (app_bridged_device_t *)calloc(1, sizeof(app_bridged_device_t));
|
||||
new_dev->dev = esp_matter_bridge::create_device(node, parent_endpoint_id, matter_device_type_id);
|
||||
new_dev->dev = esp_matter_bridge::create_device(node, parent_endpoint_id, matter_device_type_id, new_dev);
|
||||
if (!(new_dev->dev)) {
|
||||
ESP_LOGE(TAG, "Failed to create the bridged device");
|
||||
free(new_dev);
|
||||
@@ -175,7 +175,7 @@ esp_err_t app_bridge_initialize(node_t *node)
|
||||
ESP_LOGE(TAG, "Failed to alloc memory for the resumed bridged device");
|
||||
continue;
|
||||
}
|
||||
new_dev->dev = esp_matter_bridge::resume_device(node, matter_endpoint_id_array[idx]);
|
||||
new_dev->dev = esp_matter_bridge::resume_device(node, matter_endpoint_id_array[idx], new_dev);
|
||||
if (!(new_dev->dev)) {
|
||||
ESP_LOGE(TAG, "Failed to resume the bridged device");
|
||||
free(new_dev);
|
||||
@@ -230,18 +230,6 @@ esp_err_t app_bridge_remove_device(app_bridged_device_t *bridged_device)
|
||||
}
|
||||
|
||||
/** ZigBee Device APIs */
|
||||
app_bridged_device_t *app_bridge_get_device_by_matter_endpointid(uint16_t matter_endpointid)
|
||||
{
|
||||
app_bridged_device_t *current_dev = g_bridged_device_list;
|
||||
while (current_dev) {
|
||||
if (current_dev->dev && (esp_matter::endpoint::get_id(current_dev->dev->endpoint) == matter_endpointid)) {
|
||||
return current_dev;
|
||||
}
|
||||
current_dev = current_dev->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
app_bridged_device_t *app_bridge_get_device_by_zigbee_shortaddr(uint16_t zigbee_shortaddr)
|
||||
{
|
||||
app_bridged_device_t *current_dev = g_bridged_device_list;
|
||||
|
||||
@@ -67,8 +67,6 @@ esp_err_t app_bridge_initialize(node_t *node);
|
||||
|
||||
esp_err_t app_bridge_remove_device(app_bridged_device_t *bridged_device);
|
||||
|
||||
app_bridged_device_t *app_bridge_get_device_by_matter_endpointid(uint16_t matter_endpointid);
|
||||
|
||||
/** ZigBee Device APIs */
|
||||
app_bridged_device_t *app_bridge_get_device_by_zigbee_shortaddr(uint16_t zigbee_shortaddr);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
if (type == PRE_UPDATE) {
|
||||
err = zigbee_bridge_attribute_update(endpoint_id, cluster_id, attribute_id, val);
|
||||
err = zigbee_bridge_attribute_update(endpoint_id, cluster_id, attribute_id, val, (app_bridged_device_t *)priv_data);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -50,9 +50,8 @@ void zigbee_bridge_find_bridged_on_off_light_cb(zb_uint8_t zdo_status, zb_uint16
|
||||
}
|
||||
|
||||
esp_err_t zigbee_bridge_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
|
||||
esp_matter_attr_val_t *val)
|
||||
esp_matter_attr_val_t *val, app_bridged_device_t *zigbee_device)
|
||||
{
|
||||
app_bridged_device_t *zigbee_device = app_bridge_get_device_by_matter_endpointid(endpoint_id);
|
||||
if (zigbee_device && zigbee_device->dev && zigbee_device->dev->endpoint) {
|
||||
if (cluster_id == OnOff::Id) {
|
||||
if (attribute_id == OnOff::Attributes::OnOff::Id) {
|
||||
@@ -68,5 +67,8 @@ esp_err_t zigbee_bridge_attribute_update(uint16_t endpoint_id, uint32_t cluster_
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
ESP_LOGE(TAG, "Unable to Update Bridge Device, ep: %d, cluster: %d, att: %d", endpoint_id, cluster_id, attribute_id);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
#include <esp_matter_attribute_utils.h>
|
||||
#include <esp_zigbee_api_HA_standard.h>
|
||||
#include <esp_zigbee_api_core.h>
|
||||
#include <app_bridged_device.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void zigbee_bridge_find_bridged_on_off_light_cb(zb_uint8_t zdo_status, zb_uint16_t addr, zb_uint8_t endpoint);
|
||||
|
||||
esp_err_t zigbee_bridge_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
|
||||
esp_matter_attr_val_t *val);
|
||||
esp_matter_attr_val_t *val, app_bridged_device_t *zigbee_device);
|
||||
|
||||
Reference in New Issue
Block a user