diff --git a/CHANGES.md b/CHANGES.md index fe320b21e..9ef6e7f2e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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); ``` diff --git a/components/esp_matter_bridge/esp_matter_bridge.cpp b/components/esp_matter_bridge/esp_matter_bridge.cpp index 19330a0cb..1d19373b3 100644 --- a/components/esp_matter_bridge/esp_matter_bridge.cpp +++ b/components/esp_matter_bridge/esp_matter_bridge.cpp @@ -19,12 +19,12 @@ #include 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"); diff --git a/examples/bridge_zigbee/main/app_main.cpp b/examples/bridge_zigbee/main/app_main.cpp index 206686287..8d0c1f736 100644 --- a/examples/bridge_zigbee/main/app_main.cpp +++ b/examples/bridge_zigbee/main/app_main.cpp @@ -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"); } diff --git a/examples/bridge_zigbee/main/zigbee_bridge.cpp b/examples/bridge_zigbee/main/zigbee_bridge.cpp index bfc1fa428..9f9f79a66 100644 --- a/examples/bridge_zigbee/main/zigbee_bridge.cpp +++ b/examples/bridge_zigbee/main/zigbee_bridge.cpp @@ -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"); diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index 9824a98c1..bef70ebc6 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -19,13 +19,11 @@ #include #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"); } diff --git a/examples/rainmaker_light/main/app_main.cpp b/examples/rainmaker_light/main/app_main.cpp index 4aacbe746..ca6cbcdff 100644 --- a/examples/rainmaker_light/main/app_main.cpp +++ b/examples/rainmaker_light/main/app_main.cpp @@ -19,13 +19,11 @@ #include #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"); } diff --git a/examples/switch/main/app_main.cpp b/examples/switch/main/app_main.cpp index 109078a62..2468d7cbb 100644 --- a/examples/switch/main/app_main.cpp +++ b/examples/switch/main/app_main.cpp @@ -19,9 +19,6 @@ #include 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"); } diff --git a/examples/zap_light/main/zap-generated/endpoint_config.h b/examples/zap_light/main/zap-generated/endpoint_config.h index 6b3081934..61d85a247 100644 --- a/examples/zap_light/main/zap-generated/endpoint_config.h +++ b/examples/zap_light/main/zap-generated/endpoint_config.h @@ -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, \ diff --git a/examples/zap_light/main/zap-generated/light.zap b/examples/zap_light/main/zap-generated/light.zap index 53c0f4b02..f3921a520 100644 --- a/examples/zap_light/main/zap-generated/light.zap +++ b/examples/zap_light/main/zap-generated/light.zap @@ -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,