mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
examples/app_main: Making the endpoint_configs local instead of global
The attributes values are now allocated and copied internally. So not using the endpoint_config as the storage for the attributes. app_main: Adding default for hue. Also adding defaults for zap_light.
This commit is contained in:
+3
-3
@@ -7,10 +7,10 @@ The examples create the ESP Matter data model using the new APIs and default con
|
||||
These APIs add the mandatory clusters and the corresponding attributes and commands for the
|
||||
device type (endpoint) created.
|
||||
```
|
||||
static esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
static esp_matter_endpoint_color_dimmable_light_config_t light_config = ENDPOINT_CONFIG_COLOR_DIMMABLE_LIGHT_DEFAULT();
|
||||
|
||||
esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
esp_matter_node_t *node = esp_matter_node_create(&node_config, app_attribute_update_cb, NULL);
|
||||
|
||||
esp_matter_endpoint_color_dimmable_light_config_t light_config = ENDPOINT_CONFIG_COLOR_DIMMABLE_LIGHT_DEFAULT();
|
||||
esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_color_dimmable_light(node, &light_config, ESP_MATTER_ENDPOINT_FLAG_NONE);
|
||||
```
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#include <esp_matter_bridge.h>
|
||||
|
||||
static const char *TAG = "esp_matter_bridge";
|
||||
esp_matter_endpoint_bridged_node_config_t bridged_node_config = ENDPOINT_CONFIG_BRIDGED_NODE_DEFAULT();
|
||||
|
||||
esp_matter_bridge_device_t *esp_matter_bridge_create_device(esp_matter_node_t *node)
|
||||
{
|
||||
esp_matter_bridge_device_t *dev = (esp_matter_bridge_device_t *)calloc(1, sizeof(esp_matter_bridge_device_t));
|
||||
dev->node = node;
|
||||
esp_matter_endpoint_bridged_node_config_t bridged_node_config = ENDPOINT_CONFIG_BRIDGED_NODE_DEFAULT();
|
||||
dev->endpoint = esp_matter_endpoint_create_bridged_node(node, &bridged_node_config, ESP_MATTER_ENDPOINT_FLAG_DELETABLE);
|
||||
if (!(dev->endpoint)) {
|
||||
ESP_LOGE(TAG, "Could not create esp_matter endpoint for bridged device");
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "zigbee_bridge.h"
|
||||
static const char *TAG = "app_main";
|
||||
|
||||
static esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
|
||||
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
|
||||
{
|
||||
if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) {
|
||||
@@ -52,11 +50,10 @@ extern "C" void app_main()
|
||||
nvs_flash_init();
|
||||
|
||||
/* Create matter device */
|
||||
esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
esp_matter_node_t *node = esp_matter_node_create(&node_config, app_attribute_update_cb, NULL);
|
||||
|
||||
/**
|
||||
These node and endpoint handles can be used to create and add other endpoints and other clusters to the endpoints.
|
||||
*/
|
||||
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
|
||||
if (!node) {
|
||||
ESP_LOGE(TAG, "Matter device creation failed");
|
||||
}
|
||||
|
||||
@@ -20,14 +20,13 @@
|
||||
|
||||
static const char *TAG = "zigbee_bridge";
|
||||
|
||||
static esp_matter_cluster_on_off_config_t on_off_config = CLUSTER_CONFIG_ON_OFF_DEFAULT();
|
||||
|
||||
static esp_err_t init_bridged_onoff_light(esp_matter_bridge_device_t *dev)
|
||||
{
|
||||
if (!dev) {
|
||||
ESP_LOGE(TAG, "Invalid bridge device to be initialized");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
esp_matter_cluster_on_off_config_t on_off_config = CLUSTER_CONFIG_ON_OFF_DEFAULT();
|
||||
esp_matter_cluster_create_on_off(dev->endpoint, &on_off_config, CLUSTER_MASK_SERVER);
|
||||
if (esp_matter_endpoint_enable(dev->endpoint) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "ESP Matter enable dynamic endpoint failed");
|
||||
|
||||
@@ -19,13 +19,11 @@
|
||||
#include <app_qrcode.h>
|
||||
|
||||
#define DEFAULT_POWER true
|
||||
#define DEFAULT_BRIGHTNESS 254
|
||||
#define DEFAULT_BRIGHTNESS 64
|
||||
#define DEFAULT_HUE 127
|
||||
#define DEFAULT_SATURATION 254
|
||||
|
||||
static const char *TAG = "app_main";
|
||||
|
||||
static esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
static esp_matter_endpoint_color_dimmable_light_config_t light_config = ENDPOINT_CONFIG_COLOR_DIMMABLE_LIGHT_DEFAULT();
|
||||
int light_endpoint_id = 0;
|
||||
|
||||
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
|
||||
@@ -62,16 +60,19 @@ extern "C" void app_main()
|
||||
nvs_flash_init();
|
||||
|
||||
/* Create matter device */
|
||||
esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
esp_matter_node_t *node = esp_matter_node_create(&node_config, app_attribute_update_cb, NULL);
|
||||
|
||||
esp_matter_endpoint_color_dimmable_light_config_t light_config = ENDPOINT_CONFIG_COLOR_DIMMABLE_LIGHT_DEFAULT();
|
||||
light_config.on_off.on_off = DEFAULT_POWER;
|
||||
light_config.level_control.current_level = DEFAULT_BRIGHTNESS;
|
||||
light_config.color_control.current_hue = DEFAULT_HUE;
|
||||
light_config.color_control.current_saturation = DEFAULT_SATURATION;
|
||||
esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_color_dimmable_light(node, &light_config,
|
||||
ESP_MATTER_ENDPOINT_FLAG_NONE);
|
||||
light_endpoint_id = esp_matter_endpoint_get_id(endpoint);
|
||||
/**
|
||||
These node and endpoint handles can be used to create and add other endpoints and other clusters to the endpoints.
|
||||
*/
|
||||
|
||||
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
|
||||
if (!node || !endpoint) {
|
||||
ESP_LOGE(TAG, "Matter device creation failed");
|
||||
}
|
||||
|
||||
@@ -19,13 +19,11 @@
|
||||
#include <app_rainmaker.h>
|
||||
|
||||
#define DEFAULT_POWER true
|
||||
#define DEFAULT_BRIGHTNESS 254
|
||||
#define DEFAULT_BRIGHTNESS 64
|
||||
#define DEFAULT_HUE 127
|
||||
#define DEFAULT_SATURATION 254
|
||||
|
||||
static const char *TAG = "app_main";
|
||||
|
||||
static esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
static esp_matter_endpoint_color_dimmable_light_config_t light_config = ENDPOINT_CONFIG_COLOR_DIMMABLE_LIGHT_DEFAULT();
|
||||
int light_endpoint_id = 0;
|
||||
|
||||
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
|
||||
@@ -71,16 +69,19 @@ extern "C" void app_main()
|
||||
nvs_flash_init();
|
||||
|
||||
/* Create matter device */
|
||||
esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
esp_matter_node_t *node = esp_matter_node_create(&node_config, app_attribute_update_cb, NULL);
|
||||
|
||||
esp_matter_endpoint_color_dimmable_light_config_t light_config = ENDPOINT_CONFIG_COLOR_DIMMABLE_LIGHT_DEFAULT();
|
||||
light_config.on_off.on_off = DEFAULT_POWER;
|
||||
light_config.level_control.current_level = DEFAULT_BRIGHTNESS;
|
||||
light_config.color_control.current_hue = DEFAULT_HUE;
|
||||
light_config.color_control.current_saturation = DEFAULT_SATURATION;
|
||||
esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_color_dimmable_light(node, &light_config,
|
||||
ESP_MATTER_ENDPOINT_FLAG_NONE);
|
||||
light_endpoint_id = esp_matter_endpoint_get_id(endpoint);
|
||||
/**
|
||||
These node and endpoint handles can be used to create and add other endpoints and other clusters to the endpoints.
|
||||
*/
|
||||
|
||||
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
|
||||
if (!node || !endpoint) {
|
||||
ESP_LOGE(TAG, "Matter device creation failed");
|
||||
}
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
#include <app_qrcode.h>
|
||||
|
||||
static const char *TAG = "app_main";
|
||||
|
||||
static esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
static esp_matter_endpoint_on_off_switch_config_t switch_config = ENDPOINT_CONFIG_ON_OFF_SWITCH_DEFAULT();
|
||||
int switch_endpoint_id = 0;
|
||||
|
||||
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
|
||||
@@ -58,13 +55,15 @@ extern "C" void app_main()
|
||||
nvs_flash_init();
|
||||
|
||||
/* Create matter device */
|
||||
esp_matter_node_config_t node_config = NODE_CONFIG_DEFAULT();
|
||||
esp_matter_node_t *node = esp_matter_node_create(&node_config, app_attribute_update_cb, NULL);
|
||||
|
||||
esp_matter_endpoint_on_off_switch_config_t switch_config = ENDPOINT_CONFIG_ON_OFF_SWITCH_DEFAULT();
|
||||
esp_matter_endpoint_t *endpoint = esp_matter_endpoint_create_on_off_switch(node, &switch_config,
|
||||
ESP_MATTER_ENDPOINT_FLAG_NONE);
|
||||
switch_endpoint_id = esp_matter_endpoint_get_id(endpoint);
|
||||
/**
|
||||
These node and endpoint handles can be used to create and add other endpoints and other clusters to the endpoints.
|
||||
*/
|
||||
|
||||
/* These node and endpoint handles can be used to create/add other endpoints and clusters. */
|
||||
if (!node || !endpoint) {
|
||||
ESP_LOGE(TAG, "Matter device creation failed");
|
||||
}
|
||||
|
||||
@@ -306,13 +306,13 @@
|
||||
\
|
||||
/* Endpoint: 1, Cluster: On/Off (server) */ \
|
||||
{0x00000000, ZAP_TYPE(BOOLEAN), 1, 0, \
|
||||
ZAP_SIMPLE_DEFAULT(0)}, /* OnOff */ \
|
||||
ZAP_SIMPLE_DEFAULT(1)}, /* OnOff */ \
|
||||
{0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, \
|
||||
ZAP_SIMPLE_DEFAULT(4)}, /* ClusterRevision */ \
|
||||
\
|
||||
/* Endpoint: 1, Cluster: Level Control (server) */ \
|
||||
{0x00000000, ZAP_TYPE(INT8U), 1, 0, \
|
||||
ZAP_SIMPLE_DEFAULT(0x00)}, /* current level */ \
|
||||
ZAP_SIMPLE_DEFAULT(0x40)}, /* current level */ \
|
||||
{0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, \
|
||||
ZAP_SIMPLE_DEFAULT(5)}, /* ClusterRevision */ \
|
||||
\
|
||||
@@ -346,9 +346,9 @@
|
||||
\
|
||||
/* Endpoint: 1, Cluster: Color Control (server) */ \
|
||||
{0x00000000, ZAP_TYPE(INT8U), 1, 0, \
|
||||
ZAP_SIMPLE_DEFAULT(0x00)}, /* current hue */ \
|
||||
ZAP_SIMPLE_DEFAULT(0x7F)}, /* current hue */ \
|
||||
{0x00000001, ZAP_TYPE(INT8U), 1, 0, \
|
||||
ZAP_SIMPLE_DEFAULT(0x00)}, /* current saturation */ \
|
||||
ZAP_SIMPLE_DEFAULT(0xFE)}, /* current saturation */ \
|
||||
{0x00000003, ZAP_TYPE(INT16U), 2, 0, \
|
||||
ZAP_SIMPLE_DEFAULT(0x616B)}, /* current x */ \
|
||||
{0x00000004, ZAP_TYPE(INT16U), 2, 0, \
|
||||
|
||||
@@ -3639,7 +3639,7 @@
|
||||
"storageOption": "RAM",
|
||||
"singleton": 0,
|
||||
"bounded": 0,
|
||||
"defaultValue": "0",
|
||||
"defaultValue": "1",
|
||||
"reportable": 1,
|
||||
"minInterval": 1,
|
||||
"maxInterval": 65534,
|
||||
@@ -3906,7 +3906,7 @@
|
||||
"storageOption": "RAM",
|
||||
"singleton": 0,
|
||||
"bounded": 0,
|
||||
"defaultValue": "0x00",
|
||||
"defaultValue": "0x40",
|
||||
"reportable": 1,
|
||||
"minInterval": 1,
|
||||
"maxInterval": 65534,
|
||||
@@ -4736,7 +4736,7 @@
|
||||
"storageOption": "RAM",
|
||||
"singleton": 0,
|
||||
"bounded": 0,
|
||||
"defaultValue": "0x00",
|
||||
"defaultValue": "0x7F",
|
||||
"reportable": 1,
|
||||
"minInterval": 1,
|
||||
"maxInterval": 65534,
|
||||
@@ -4751,7 +4751,7 @@
|
||||
"storageOption": "RAM",
|
||||
"singleton": 0,
|
||||
"bounded": 0,
|
||||
"defaultValue": "0x00",
|
||||
"defaultValue": "0xFE",
|
||||
"reportable": 1,
|
||||
"minInterval": 1,
|
||||
"maxInterval": 65534,
|
||||
|
||||
Reference in New Issue
Block a user