esp_matter: Change all IDs to their correct data types.

This commit is contained in:
Chirag Atal
2022-05-20 18:54:12 +05:30
committed by Shu Chen
parent 937bbd81fe
commit 28b385d228
32 changed files with 302 additions and 5899 deletions
@@ -46,7 +46,7 @@ app_zigbee_bridge_device_t *app_bridge_create_zigbee_device(node_t *node, uint8_
return new_dev;
}
uint16_t app_bridge_get_zigbee_shortaddr_by_matter_endpointid(int matter_endpointid)
uint16_t app_bridge_get_zigbee_shortaddr_by_matter_endpointid(uint16_t matter_endpointid)
{
app_zigbee_bridge_device_t *current_dev = device_list;
while (current_dev) {
@@ -58,7 +58,7 @@ uint16_t app_bridge_get_zigbee_shortaddr_by_matter_endpointid(int matter_endpoin
return 0xffff;
}
int app_bridge_get_matter_endpointid_by_zigbee_shortaddr(uint16_t zigbee_shortaddr)
uint16_t app_bridge_get_matter_endpointid_by_zigbee_shortaddr(uint16_t zigbee_shortaddr)
{
app_zigbee_bridge_device_t *current_dev = device_list;
while (current_dev) {
@@ -67,10 +67,10 @@ int app_bridge_get_matter_endpointid_by_zigbee_shortaddr(uint16_t zigbee_shortad
}
current_dev = current_dev->next;
}
return -1;
return 0xFFFF;
}
app_zigbee_bridge_device_t *app_bridge_get_zigbee_device_by_matter_endpointid(int matter_endpointid)
app_zigbee_bridge_device_t *app_bridge_get_zigbee_device_by_matter_endpointid(uint16_t matter_endpointid)
{
app_zigbee_bridge_device_t *current_dev = device_list;
while (current_dev) {
@@ -29,11 +29,11 @@ typedef struct app_zigbee_bridge_device {
app_zigbee_bridge_device_t *app_bridge_create_zigbee_device(node_t *node, uint8_t zigbee_endpointid,
uint16_t zigbee_shortaddr);
uint16_t app_bridge_get_zigbee_shortaddr_by_matter_endpointid(int matter_endpointid);
uint16_t app_bridge_get_zigbee_shortaddr_by_matter_endpointid(uint16_t matter_endpointid);
int app_bridge_get_matter_endpointid_by_zigbee_shortaddr(uint16_t zigbee_shortaddr);
uint16_t app_bridge_get_matter_endpointid_by_zigbee_shortaddr(uint16_t zigbee_shortaddr);
app_zigbee_bridge_device_t *app_bridge_get_zigbee_device_by_matter_endpointid(int matter_endpointid);
app_zigbee_bridge_device_t *app_bridge_get_zigbee_device_by_matter_endpointid(uint16_t matter_endpointid);
app_zigbee_bridge_device_t *app_bridge_get_zigbee_device_by_zigbee_shortaddr(uint16_t zigbee_shortaddr);
+9 -8
View File
@@ -20,7 +20,7 @@
using namespace esp_matter;
static const char *TAG = "app_driver";
extern int light_endpoint_id;
extern uint16_t light_endpoint_id;
/* Do any conversions/remapping for the actual value here */
static esp_err_t app_driver_light_set_power(esp_matter_attr_val_t *val)
@@ -49,9 +49,9 @@ static esp_err_t app_driver_light_set_saturation(esp_matter_attr_val_t *val)
static void app_driver_button_toggle_cb(void *arg)
{
ESP_LOGI(TAG, "Toggle button pressed");
int endpoint_id = light_endpoint_id;
int cluster_id = OnOff::Id;
int attribute_id = OnOff::Attributes::OnOff::Id;
uint16_t endpoint_id = light_endpoint_id;
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);
@@ -64,7 +64,8 @@ static void app_driver_button_toggle_cb(void *arg)
attribute::update(endpoint_id, cluster_id, attribute_id, &val);
}
esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val)
esp_err_t app_driver_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val)
{
esp_err_t err = ESP_OK;
if (endpoint_id == light_endpoint_id) {
@@ -94,13 +95,13 @@ static esp_err_t app_driver_attribute_set_defaults()
node_t *node = node::get();
endpoint_t *endpoint = endpoint::get_first(node);
while (endpoint) {
int endpoint_id = endpoint::get_id(endpoint);
uint16_t endpoint_id = endpoint::get_id(endpoint);
cluster_t *cluster = cluster::get_first(endpoint);
while (cluster) {
int cluster_id = cluster::get_id(cluster);
uint32_t cluster_id = cluster::get_id(cluster);
attribute_t *attribute = attribute::get_first(cluster);
while (attribute) {
int attribute_id = attribute::get_id(attribute);
uint32_t attribute_id = attribute::get_id(attribute);
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
err |= attribute::get_val(attribute, &val);
err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val);
+3 -3
View File
@@ -19,7 +19,7 @@
#include <app_qrcode.h>
static const char *TAG = "app_main";
int light_endpoint_id = 0;
uint16_t light_endpoint_id = 0;
using namespace esp_matter;
using namespace esp_matter::attribute;
@@ -36,8 +36,8 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT));
}
static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id,
esp_matter_attr_val_t *val, void *priv_data)
static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id,
uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data)
{
esp_err_t err = ESP_OK;
+2 -1
View File
@@ -49,4 +49,5 @@ esp_err_t app_driver_init(void);
* @return ESP_OK on success.
* @return error in case of failure.
*/
esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val);
esp_err_t app_driver_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val);
+9 -8
View File
@@ -20,7 +20,7 @@
using namespace esp_matter;
static const char *TAG = "app_driver";
extern int light_endpoint_id;
extern uint16_t light_endpoint_id;
/* Do any conversions/remapping for the actual value here */
static esp_err_t app_driver_light_set_power(esp_matter_attr_val_t *val)
@@ -49,9 +49,9 @@ static esp_err_t app_driver_light_set_saturation(esp_matter_attr_val_t *val)
static void app_driver_button_toggle_cb(void *arg)
{
ESP_LOGI(TAG, "Toggle button pressed");
int endpoint_id = light_endpoint_id;
int cluster_id = OnOff::Id;
int attribute_id = OnOff::Attributes::OnOff::Id;
uint16_t endpoint_id = light_endpoint_id;
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);
@@ -64,7 +64,8 @@ static void app_driver_button_toggle_cb(void *arg)
attribute::update(endpoint_id, cluster_id, attribute_id, &val);
}
esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val)
esp_err_t app_driver_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val)
{
esp_err_t err = ESP_OK;
if (endpoint_id == light_endpoint_id) {
@@ -94,13 +95,13 @@ static esp_err_t app_driver_attribute_set_defaults()
node_t *node = node::get();
endpoint_t *endpoint = endpoint::get_first(node);
while (endpoint) {
int endpoint_id = endpoint::get_id(endpoint);
uint16_t endpoint_id = endpoint::get_id(endpoint);
cluster_t *cluster = cluster::get_first(endpoint);
while (cluster) {
int cluster_id = cluster::get_id(cluster);
uint32_t cluster_id = cluster::get_id(cluster);
attribute_t *attribute = attribute::get_first(cluster);
while (attribute) {
int attribute_id = attribute::get_id(attribute);
uint32_t attribute_id = attribute::get_id(attribute);
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
err |= attribute::get_val(attribute, &val);
err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val);
+3 -3
View File
@@ -19,7 +19,7 @@
#include <app_rainmaker.h>
static const char *TAG = "app_main";
int light_endpoint_id = 0;
uint16_t light_endpoint_id = 0;
using namespace esp_matter;
using namespace esp_matter::attribute;
@@ -36,8 +36,8 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT));
}
static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id,
esp_matter_attr_val_t *val, void *priv_data)
static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id,
uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data)
{
esp_err_t err = ESP_OK;
+2 -1
View File
@@ -49,4 +49,5 @@ esp_err_t app_driver_init(void);
* @return ESP_OK on success.
* @return error in case of failure.
*/
esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val);
esp_err_t app_driver_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val);
+29 -25
View File
@@ -28,11 +28,12 @@
using namespace esp_matter;
static const char *TAG = "app_rainmaker";
extern int light_endpoint_id;
extern uint16_t light_endpoint_id;
#define DEFAULT_LIGHT_NAME "Light"
static esp_rmaker_param_val_t app_rainmaker_get_rmaker_val(esp_matter_attr_val_t *val, int cluster_id, int attribute_id)
static esp_rmaker_param_val_t app_rainmaker_get_rmaker_val(esp_matter_attr_val_t *val, uint32_t cluster_id,
uint32_t attribute_id)
{
/* Attributes which need to be remapped */
if (cluster_id == LevelControl::Id) {
@@ -69,7 +70,8 @@ static esp_rmaker_param_val_t app_rainmaker_get_rmaker_val(esp_matter_attr_val_t
return esp_rmaker_int(0);
}
static esp_matter_attr_val_t app_rainmaker_get_matter_val(esp_rmaker_param_val_t *val, int cluster_id, int attribute_id)
static esp_matter_attr_val_t app_rainmaker_get_matter_val(esp_rmaker_param_val_t *val, uint32_t cluster_id,
uint32_t attribute_id)
{
/* Attributes which need to be remapped */
if (cluster_id == LevelControl::Id) {
@@ -100,7 +102,7 @@ static esp_matter_attr_val_t app_rainmaker_get_matter_val(esp_rmaker_param_val_t
return esp_matter_int(0);
}
static const char *app_rainmaker_get_device_name_from_id(int endpoint_id)
static const char *app_rainmaker_get_device_name_from_id(uint32_t endpoint_id)
{
if (endpoint_id == light_endpoint_id) {
return DEFAULT_LIGHT_NAME;
@@ -108,7 +110,7 @@ static const char *app_rainmaker_get_device_name_from_id(int endpoint_id)
return NULL;
}
static const char *app_rainmaker_get_device_type_from_id(int device_type_id)
static const char *app_rainmaker_get_device_type_from_id(uint32_t device_type_id)
{
if (device_type_id == endpoint::color_dimmable_light::get_device_type_id()) {
return ESP_RMAKER_DEVICE_LIGHTBULB;
@@ -116,15 +118,15 @@ static const char *app_rainmaker_get_device_type_from_id(int device_type_id)
return NULL;
}
static int app_rainmaker_get_endpoint_id_from_name(const char *device_name)
static uint16_t app_rainmaker_get_endpoint_id_from_name(const char *device_name)
{
if (strcmp(device_name, DEFAULT_LIGHT_NAME) == 0) {
return light_endpoint_id;
}
return 0;
return 0xFFFF;
}
static const char *app_rainmaker_get_param_name_from_id(int cluster_id, int attribute_id)
static const char *app_rainmaker_get_param_name_from_id(uint32_t cluster_id, uint32_t attribute_id)
{
if (cluster_id == OnOff::Id) {
if (attribute_id == OnOff::Attributes::OnOff::Id) {
@@ -144,7 +146,7 @@ static const char *app_rainmaker_get_param_name_from_id(int cluster_id, int attr
return NULL;
}
static const char *app_rainmaker_get_param_type_from_id(int cluster_id, int attribute_id)
static const char *app_rainmaker_get_param_type_from_id(uint32_t cluster_id, uint32_t attribute_id)
{
if (cluster_id == OnOff::Id) {
if (attribute_id == OnOff::Attributes::OnOff::Id) {
@@ -164,7 +166,7 @@ static const char *app_rainmaker_get_param_type_from_id(int cluster_id, int attr
return NULL;
}
static const char *app_rainmaker_get_param_ui_type_from_id(int cluster_id, int attribute_id)
static const char *app_rainmaker_get_param_ui_type_from_id(uint32_t cluster_id, uint32_t attribute_id)
{
if (cluster_id == OnOff::Id) {
if (attribute_id == OnOff::Attributes::OnOff::Id) {
@@ -184,7 +186,8 @@ static const char *app_rainmaker_get_param_ui_type_from_id(int cluster_id, int a
return NULL;
}
static bool app_rainmaker_get_param_bounds_from_id(int cluster_id, int attribute_id, int *min, int *max, int *step)
static bool app_rainmaker_get_param_bounds_from_id(uint32_t cluster_id, uint32_t attribute_id, int *min, int *max,
int *step)
{
if (cluster_id == LevelControl::Id) {
if (attribute_id == LevelControl::Attributes::CurrentLevel::Id) {
@@ -211,8 +214,8 @@ static bool app_rainmaker_get_param_bounds_from_id(int cluster_id, int attribute
static esp_err_t app_rainmaker_param_add_ui_type(esp_rmaker_param_t *param, cluster_t *cluster, attribute_t *attribute)
{
int cluster_id = cluster::get_id(cluster);
int attribute_id = attribute::get_id(attribute);
uint32_t cluster_id = cluster::get_id(cluster);
uint32_t attribute_id = attribute::get_id(attribute);
const char *ui_type = app_rainmaker_get_param_ui_type_from_id(cluster_id, attribute_id);
if (!ui_type) {
return ESP_OK;
@@ -222,8 +225,8 @@ static esp_err_t app_rainmaker_param_add_ui_type(esp_rmaker_param_t *param, clus
static esp_err_t app_rainmaker_param_add_bounds(esp_rmaker_param_t *param, cluster_t *cluster, attribute_t *attribute)
{
int cluster_id = cluster::get_id(cluster);
int attribute_id = attribute::get_id(attribute);
uint32_t cluster_id = cluster::get_id(cluster);
uint32_t attribute_id = attribute::get_id(attribute);
esp_matter_attr_bounds_t *bounds = attribute::get_bounds(attribute);
if (bounds) {
esp_rmaker_param_val_t min_val = app_rainmaker_get_rmaker_val(&bounds->min, cluster_id, attribute_id);
@@ -245,7 +248,7 @@ static esp_err_t app_rainmaker_param_add_bounds(esp_rmaker_param_t *param, clust
return ESP_OK;
}
static int app_rainmaker_get_cluster_id_from_name(const char *param_name)
static uint32_t app_rainmaker_get_cluster_id_from_name(const char *param_name)
{
if (strcmp(param_name, ESP_RMAKER_DEF_POWER_NAME) == 0) {
return OnOff::Id;
@@ -259,7 +262,7 @@ static int app_rainmaker_get_cluster_id_from_name(const char *param_name)
return 0;
}
static int app_rainmaker_get_attribute_id_from_name(const char *param_name)
static uint32_t app_rainmaker_get_attribute_id_from_name(const char *param_name)
{
if (strcmp(param_name, ESP_RMAKER_DEF_POWER_NAME) == 0) {
return OnOff::Attributes::OnOff::Id;
@@ -273,7 +276,8 @@ static int app_rainmaker_get_attribute_id_from_name(const char *param_name)
return 0;
}
esp_err_t app_rainmaker_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val)
esp_err_t app_rainmaker_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val)
{
const char *device_name = app_rainmaker_get_device_name_from_id(endpoint_id);
const char *param_name = app_rainmaker_get_param_name_from_id(cluster_id, attribute_id);
@@ -305,9 +309,9 @@ static esp_err_t write_cb(const esp_rmaker_device_t *device, const esp_rmaker_pa
const char *device_name = esp_rmaker_device_get_name(device);
const char *param_name = esp_rmaker_param_get_name(param);
int endpoint_id = app_rainmaker_get_endpoint_id_from_name(device_name);
int cluster_id = app_rainmaker_get_cluster_id_from_name(param_name);
int attribute_id = app_rainmaker_get_attribute_id_from_name(param_name);
uint16_t endpoint_id = app_rainmaker_get_endpoint_id_from_name(device_name);
uint32_t cluster_id = app_rainmaker_get_cluster_id_from_name(param_name);
uint32_t attribute_id = app_rainmaker_get_attribute_id_from_name(param_name);
esp_matter_attr_val_t matter_val = app_rainmaker_get_matter_val((esp_rmaker_param_val_t *)&val, cluster_id,
attribute_id);
@@ -316,13 +320,13 @@ static esp_err_t write_cb(const esp_rmaker_device_t *device, const esp_rmaker_pa
static esp_rmaker_device_t *app_rainmaker_device_create(const esp_rmaker_node_t *node, endpoint_t *endpoint)
{
int endpoint_id = endpoint::get_id(endpoint);
uint16_t endpoint_id = endpoint::get_id(endpoint);
const char *device_name = app_rainmaker_get_device_name_from_id(endpoint_id);
if (!device_name) {
return NULL;
}
/* Add this device only if endpoint_id has been handled */
int device_type_id = endpoint::get_device_type_id(endpoint);
uint32_t device_type_id = endpoint::get_device_type_id(endpoint);
const char *device_type = app_rainmaker_get_device_type_from_id(device_type_id);
esp_rmaker_device_t *device = esp_rmaker_device_create(device_name, device_type, NULL);
if (!device) {
@@ -337,8 +341,8 @@ static esp_rmaker_device_t *app_rainmaker_device_create(const esp_rmaker_node_t
static esp_rmaker_param_t *app_rainmaker_param_create(esp_rmaker_device_t *device, cluster_t *cluster,
attribute_t *attribute)
{
int cluster_id = cluster::get_id(cluster);
int attribute_id = attribute::get_id(attribute);
uint32_t cluster_id = cluster::get_id(cluster);
uint32_t attribute_id = attribute::get_id(attribute);
const char *param_name = app_rainmaker_get_param_name_from_id(cluster_id, attribute_id);
if (!param_name) {
return NULL;
@@ -47,7 +47,8 @@ esp_err_t app_rainmaker_start(void);
* @return ESP_OK on success.
* @return error in case of failure.
*/
esp_err_t app_rainmaker_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val);
esp_err_t app_rainmaker_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val);
#ifdef __cplusplus
}
File diff suppressed because it is too large Load Diff
+21 -19
View File
@@ -25,9 +25,9 @@ using namespace esp_matter;
using namespace esp_matter::cluster;
static const char *TAG = "app_driver";
extern int switch_endpoint_id;
static int g_cluster_id = kInvalidClusterId;
static int g_command_id = kInvalidCommandId;
extern uint16_t switch_endpoint_id;
static uint32_t g_cluster_id = kInvalidClusterId;
static uint32_t g_command_id = kInvalidCommandId;
static esp_err_t app_driver_bound_console_handler(int argc, char **argv)
{
@@ -37,9 +37,9 @@ static esp_err_t app_driver_bound_console_handler(int argc, char **argv)
"\tinvoke: <endpoint_id> <cluster_id> <command_id>. "
"Example: matter esp bound invoke 0x0001 0x0006 0x0002.\n");
} else if (argc == 4 && strncmp(argv[0], "invoke", sizeof("invoke")) == 0) {
int endpoint_id = strtol((const char *)&argv[1][2], NULL, 16);
int cluster_id = strtol((const char *)&argv[2][2], NULL, 16);
int command_id = strtol((const char *)&argv[3][2], NULL, 16);
uint16_t endpoint_id = strtol((const char *)&argv[1][2], NULL, 16);
uint32_t cluster_id = strtol((const char *)&argv[2][2], NULL, 16);
uint32_t command_id = strtol((const char *)&argv[3][2], NULL, 16);
g_cluster_id = cluster_id;
g_command_id = command_id;
@@ -59,11 +59,11 @@ static esp_err_t app_driver_client_console_handler(int argc, char **argv)
"\tinvoke: <fabric_index> <remote_node_id> <remote_endpoint_id> <cluster_id> <command_id>. "
"Example: matter esp client invoke 0x0001 0xBC5C01 0x0001 0x0006 0x0002.\n");
} else if (argc == 6 && strncmp(argv[0], "invoke", sizeof("invoke")) == 0) {
int fabric_index = strtol((const char *)&argv[1][2], NULL, 16);
int node_id = strtol((const char *)&argv[2][2], NULL, 16);
int remote_endpoint_id = strtol((const char *)&argv[3][2], NULL, 16);
int cluster_id = strtol((const char *)&argv[4][2], NULL, 16);
int command_id = strtol((const char *)&argv[5][2], NULL, 16);
uint8_t fabric_index = strtol((const char *)&argv[1][2], NULL, 16);
uint64_t node_id = strtol((const char *)&argv[2][2], NULL, 16);
uint16_t remote_endpoint_id = strtol((const char *)&argv[3][2], NULL, 16);
uint32_t cluster_id = strtol((const char *)&argv[4][2], NULL, 16);
uint32_t command_id = strtol((const char *)&argv[5][2], NULL, 16);
g_cluster_id = cluster_id;
g_command_id = command_id;
@@ -98,7 +98,8 @@ static void app_driver_register_commands()
esp_matter_console_add_command(&client_command);
}
void app_driver_client_command_callback(client::peer_device_t *peer_device, int remote_endpoint_id, void *priv_data)
void app_driver_client_command_callback(client::peer_device_t *peer_device, uint16_t remote_endpoint_id,
void *priv_data)
{
/** TODO: Find a better way to get the cluster_id and command_id.
Once done, move the console commands to esp_matter_client. */
@@ -116,16 +117,17 @@ void app_driver_client_command_callback(client::peer_device_t *peer_device, int
static void app_driver_button_toggle_cb(void *arg)
{
ESP_LOGI(TAG, "Toggle button pressed");
int endpoint_id = switch_endpoint_id;
int cluster_id = OnOff::Id;
int command_id = OnOff::Commands::Toggle::Id;
uint16_t endpoint_id = switch_endpoint_id;
uint32_t cluster_id = OnOff::Id;
uint32_t command_id = OnOff::Commands::Toggle::Id;
g_cluster_id = cluster_id;
g_command_id = command_id;
client::cluster_update(endpoint_id, cluster_id);
}
esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val)
esp_err_t app_driver_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val)
{
/* Nothing to do here */
return ESP_OK;
@@ -138,13 +140,13 @@ static esp_err_t app_driver_attribute_set_defaults()
node_t *node = node::get();
endpoint_t *endpoint = endpoint::get_first(node);
while (endpoint) {
int endpoint_id = endpoint::get_id(endpoint);
uint16_t endpoint_id = endpoint::get_id(endpoint);
cluster_t *cluster = cluster::get_first(endpoint);
while (cluster) {
int cluster_id = cluster::get_id(cluster);
uint32_t cluster_id = cluster::get_id(cluster);
attribute_t *attribute = attribute::get_first(cluster);
while (attribute) {
int attribute_id = attribute::get_id(attribute);
uint32_t attribute_id = attribute::get_id(attribute);
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
err |= attribute::get_val(attribute, &val);
err |= app_driver_attribute_update(endpoint_id, cluster_id, attribute_id, &val);
+3 -3
View File
@@ -19,7 +19,7 @@
#include <app_qrcode.h>
static const char *TAG = "app_main";
int switch_endpoint_id = 0;
uint16_t switch_endpoint_id = 0;
using namespace esp_matter;
using namespace esp_matter::attribute;
@@ -36,8 +36,8 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT));
}
static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id,
esp_matter_attr_val_t *val, void *priv_data)
static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id,
uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data)
{
esp_err_t err = ESP_OK;
+2 -1
View File
@@ -33,4 +33,5 @@ esp_err_t app_driver_init(void);
* @return ESP_OK on success.
* @return error in case of failure.
*/
esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val);
esp_err_t app_driver_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val);
+9 -8
View File
@@ -20,7 +20,7 @@
using namespace esp_matter;
static const char *TAG = "app_driver";
extern int light_endpoint_id;
extern uint16_t light_endpoint_id;
/* Do any conversions/remapping for the actual value here */
static esp_err_t app_driver_light_set_power(esp_matter_attr_val_t *val)
@@ -49,9 +49,9 @@ static esp_err_t app_driver_light_set_saturation(esp_matter_attr_val_t *val)
static void app_driver_button_toggle_cb(void *arg)
{
ESP_LOGI(TAG, "Toggle button pressed");
int endpoint_id = light_endpoint_id;
int cluster_id = OnOff::Id;
int attribute_id = OnOff::Attributes::OnOff::Id;
uint16_t endpoint_id = light_endpoint_id;
uint32_t cluster_id = OnOff::Id;
uint32_t attribute_id = OnOff::Attributes::OnOff::Id;
uint8_t value;
attribute::get_val_raw(endpoint_id, cluster_id, attribute_id, &value, sizeof(uint8_t));
@@ -60,7 +60,8 @@ static void app_driver_button_toggle_cb(void *arg)
attribute::update(endpoint_id, cluster_id, attribute_id, &val);
}
esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val)
esp_err_t app_driver_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val)
{
esp_err_t err = ESP_OK;
if (endpoint_id == light_endpoint_id) {
@@ -90,9 +91,9 @@ esp_err_t app_driver_attribute_set_defaults()
/* Get the default value (current value) from matter submodule and update the app_driver */
esp_err_t err = ESP_OK;
uint8_t value;
int endpoint_id = 0;
int cluster_id = 0;
int attribute_id = 0;
uint16_t endpoint_id = 0;
uint32_t cluster_id = 0;
uint32_t attribute_id = 0;
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
endpoint_id = light_endpoint_id;
+3 -3
View File
@@ -21,7 +21,7 @@ using namespace esp_matter;
using namespace esp_matter::attribute;
static const char *TAG = "app_main";
int light_endpoint_id = 0;
uint16_t light_endpoint_id = 0;
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
{
@@ -34,8 +34,8 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT));
}
static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id,
esp_matter_attr_val_t *val, void *priv_data)
static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id,
uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data)
{
esp_err_t err = ESP_OK;
+2 -1
View File
@@ -43,7 +43,8 @@ esp_err_t app_driver_init(void);
* @return ESP_OK on success.
* @return error in case of failure.
*/
esp_err_t app_driver_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val);
esp_err_t app_driver_attribute_update(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
esp_matter_attr_val_t *val);
/** Set driver defaults
*
+2 -2
View File
@@ -34,8 +34,8 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT));
}
static esp_err_t app_attribute_update_cb(callback_type_t type, int endpoint_id, int cluster_id, int attribute_id,
esp_matter_attr_val_t *val, void *priv_data)
static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id,
uint32_t attribute_id, esp_matter_attr_val_t *val, void *priv_data)
{
esp_err_t err = ESP_OK;
@@ -120,7 +120,8 @@ void zigbee_bridge_send_off(zb_uint8_t buf, zb_uint16_t zigbee_shortaddr)
ZB_ZCL_CMD_ON_OFF_OFF_ID, NULL);
}
esp_err_t zigbee_bridge_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val)
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)
{
app_zigbee_bridge_device_t *zigbee_device = app_bridge_get_zigbee_device_by_matter_endpointid(endpoint_id);
if (zigbee_device && zigbee_device->dev && zigbee_device->dev->endpoint) {
+2 -1
View File
@@ -23,7 +23,8 @@ void zigbee_bridge_match_bridged_onoff_light(zb_bufid_t bufid);
void zigbee_bridge_match_bridged_onoff_light_timeout(zb_bufid_t bufid);
esp_err_t zigbee_bridge_attribute_update(int endpoint_id, int cluster_id, int attribute_id, esp_matter_attr_val_t *val);
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);
#ifdef __cplusplus
}