From 2df2325158c65edcd868024bc864e5483cde939a Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Fri, 3 May 2024 12:28:39 +0530 Subject: [PATCH] Add Oven device type --- SUPPORTED_DEVICE_TYPES.md | 1 + components/esp_matter/esp_matter_endpoint.cpp | 38 +++++++++++++++++++ components/esp_matter/esp_matter_endpoint.h | 13 +++++++ .../all_device_types_app/main/device_types.h | 4 +- .../main/esp_matter_console_helpers.cpp | 17 +++++++++ 5 files changed, 72 insertions(+), 1 deletion(-) diff --git a/SUPPORTED_DEVICE_TYPES.md b/SUPPORTED_DEVICE_TYPES.md index 2839d1dd1..ab883a8e6 100644 --- a/SUPPORTED_DEVICE_TYPES.md +++ b/SUPPORTED_DEVICE_TYPES.md @@ -65,3 +65,4 @@ i. Appliance 3. Room Air Conditioner 4. Refrigerator 5. Temperature Controlled Cabinet +6. Oven diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index 88ad611dc..b2bb68ca5 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -1445,6 +1445,44 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) } } /** refrigerator **/ +namespace oven { + +uint32_t get_device_type_id() +{ + return ESP_MATTER_OVEN_DEVICE_TYPE_ID; +} + +uint8_t get_device_type_version() +{ + return ESP_MATTER_OVEN_DEVICE_TYPE_VERSION; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) +{ + endpoint_t *endpoint = endpoint::create(node, flags, priv_data); + add(endpoint, config); + return endpoint; +} + +esp_err_t add(endpoint_t *endpoint, config_t *config) +{ + if (!endpoint) { + ESP_LOGE(TAG, "Endpoint cannot be NULL"); + return ESP_ERR_INVALID_ARG; + } + esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version()); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err); + return err; + } + + descriptor::create(endpoint, &(config->descriptor), CLUSTER_FLAG_SERVER); + + return ESP_OK; +} + +} /** oven **/ + namespace robotic_vacuum_cleaner{ uint32_t get_device_type_id() diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index a5b1e3ee7..582ea2bbc 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -102,6 +102,8 @@ #define ESP_MATTER_RAIN_SENSOR_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_ELECTRICAL_SENSOR_DEVICE_TYPE_ID 0x0510 #define ESP_MATTER_ELECTRICAL_SENSOR_DEVICE_TYPE_VERSION 1 +#define ESP_MATTER_OVEN_DEVICE_TYPE_ID 0x007B +#define ESP_MATTER_OVEN_DEVICE_TYPE_VERSION 1 namespace esp_matter { @@ -598,6 +600,17 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat esp_err_t add(endpoint_t *endpoint, config_t *config); } /** refrigerator **/ +namespace oven { +typedef struct config { + cluster::descriptor::config_t descriptor; +} config_t; + +uint32_t get_device_type_id(); +uint8_t get_device_type_version(); +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data); +esp_err_t add(endpoint_t *endpoint, config_t *config); +} /** oven **/ + namespace robotic_vacuum_cleaner{ typedef struct config { cluster::descriptor::config_t descriptor; diff --git a/examples/all_device_types_app/main/device_types.h b/examples/all_device_types_app/main/device_types.h index 5d3a22b6e..6086442df 100644 --- a/examples/all_device_types_app/main/device_types.h +++ b/examples/all_device_types_app/main/device_types.h @@ -41,6 +41,7 @@ enum device_type_enum { ESP_MATTER_POWER_SOURCE, ESP_MATTER_RAIN_SENSOR, ESP_MATTER_ELECTRICAL_SENSOR, + ESP_MATTER_OVEN, ESP_MATTER_DEVICE_TYPE_MAX }; @@ -87,6 +88,7 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = { {"water_leak_detector", ESP_MATTER_WATER_LEAK_DETECTOR}, {"power_source", ESP_MATTER_POWER_SOURCE}, {"rain_sensor", ESP_MATTER_RAIN_SENSOR}, - {"electrical_sensor", ESP_MATTER_ELECTRICAL_SENSOR} + {"electrical_sensor", ESP_MATTER_ELECTRICAL_SENSOR}, + {"oven", ESP_MATTER_OVEN} }; } /* namespace esp_matter */ diff --git a/examples/all_device_types_app/main/esp_matter_console_helpers.cpp b/examples/all_device_types_app/main/esp_matter_console_helpers.cpp index d67ebc3e5..ea63015fc 100644 --- a/examples/all_device_types_app/main/esp_matter_console_helpers.cpp +++ b/examples/all_device_types_app/main/esp_matter_console_helpers.cpp @@ -315,6 +315,23 @@ int create(uint8_t device_type_index) cluster::temperature_control::feature::temperature_number::add(cluster, &temperature_number_config); break; } + case ESP_MATTER_OVEN: { + esp_matter::endpoint::oven::config_t oven_config; + endpoint = esp_matter::endpoint::oven::create(node, &oven_config, ENDPOINT_FLAG_NONE, NULL); + + esp_matter::endpoint::temperature_controlled_cabinet::config_t temperature_controlled_cabinet_config; + esp_matter::endpoint_t *tcc_endpoint = esp_matter::endpoint::temperature_controlled_cabinet::create(node, &temperature_controlled_cabinet_config, ENDPOINT_FLAG_NONE, NULL); + + if (!tcc_endpoint) { + ESP_LOGE(TAG, "Matter create endpoint failed"); + return 1; + } + + esp_matter::cluster_t *cluster = esp_matter::cluster::get(tcc_endpoint, chip::app::Clusters::TemperatureControl::Id); + cluster::temperature_control::feature::temperature_number::config_t temperature_number_config; + cluster::temperature_control::feature::temperature_number::add(cluster, &temperature_number_config); + break; + } case ESP_MATTER_AIR_PURIFIER: { esp_matter::endpoint::air_purifier::config_t air_purifier_config; endpoint = esp_matter::endpoint::air_purifier::create(node, &air_purifier_config, ENDPOINT_FLAG_NONE, NULL);