diff --git a/SUPPORTED_DEVICE_TYPES.md b/SUPPORTED_DEVICE_TYPES.md index 7032c860c..51ada4f0c 100644 --- a/SUPPORTED_DEVICE_TYPES.md +++ b/SUPPORTED_DEVICE_TYPES.md @@ -34,6 +34,8 @@ c. Smart Plugs/Outlets 2. Dimmable Plugin Unit 3. Pump 4. Water Valve +5. Mounted On Off Control +6. Mounted Dimmable Load Control d. Generic 1. Mode Select diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index df673963c..f1c6a6c9b 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -1946,6 +1946,77 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) } } /* secondary_network_interface */ +namespace mounted_on_off_control { +uint32_t get_device_type_id() +{ + return ESP_MATTER_MOUNTED_ON_OFF_CONTROL_DEVICE_TYPE_ID; +} + +uint8_t get_device_type_version() +{ + return ESP_MATTER_MOUNTED_ON_OFF_CONTROL_DEVICE_TYPE_VERSION; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) +{ + return common::create(node, config, flags, priv_data, add); +} + +esp_err_t add(endpoint_t *endpoint, config_t *config) +{ + VerifyOrReturnError(endpoint != nullptr, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Endpoint cannot be NULL")); + 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; + } + + cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + identify::command::create_trigger_effect(identify_cluster); + groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); + on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); + + return ESP_OK; +} + +} /* mounted_on_off_control */ + +namespace mounted_dimmable_load_control { +uint32_t get_device_type_id() +{ + return ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL_DEVICE_TYPE_ID; +} + +uint8_t get_device_type_version() +{ + return ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL_DEVICE_TYPE_VERSION; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) +{ + return common::create(node, config, flags, priv_data, add); +} + +esp_err_t add(endpoint_t *endpoint, config_t *config) +{ + VerifyOrReturnError(endpoint != nullptr, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Endpoint cannot be NULL")); + 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; + } + + cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + identify::command::create_trigger_effect(identify_cluster); + groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); + on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); + level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER, + level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()); + + return ESP_OK; +} +} /* mounted_dimmable_load_control */ + } /* endpoint */ namespace node { diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index 84a4c5ee3..58be8a9e8 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -56,6 +56,10 @@ #define ESP_MATTER_ON_OFF_PLUGIN_UNIT_DEVICE_TYPE_VERSION 3 #define ESP_MATTER_DIMMABLE_PLUGIN_UNIT_DEVICE_TYPE_ID 0x010B #define ESP_MATTER_DIMMABLE_PLUGIN_UNIT_DEVICE_TYPE_VERSION 4 +#define ESP_MATTER_MOUNTED_ON_OFF_CONTROL_DEVICE_TYPE_ID 0x010F +#define ESP_MATTER_MOUNTED_ON_OFF_CONTROL_DEVICE_TYPE_VERSION 1 +#define ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL_DEVICE_TYPE_ID 0x0110 +#define ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID 0x0302 #define ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_VERSION 2 @@ -806,6 +810,24 @@ 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); } /* secondary_network_interface */ +namespace mounted_on_off_control { +using config_t = on_off_config; + +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); +} /** mounted_on_off_control **/ + +namespace mounted_dimmable_load_control { +using config_t = dimmable_light::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); +} /** mounted_dimmable_load_control **/ + } /* endpoint */ namespace node { diff --git a/examples/all_device_types_app/main/device_types.h b/examples/all_device_types_app/main/device_types.h index e0493260c..48efb20be 100644 --- a/examples/all_device_types_app/main/device_types.h +++ b/examples/all_device_types_app/main/device_types.h @@ -53,6 +53,8 @@ enum device_type_enum { ESP_MATTER_DEVICE_ENERGY_MANAGEMENT, ESP_MATTER_PUMP_CONTROLLER, ESP_MATTER_THREAD_BORDER_ROUTER, + ESP_MATTER_MOUNTED_ON_OFF_CONTROL, + ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL, ESP_MATTER_DEVICE_TYPE_MAX }; @@ -112,5 +114,7 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = { {"device_energy_management", ESP_MATTER_DEVICE_ENERGY_MANAGEMENT}, {"pump_controller", ESP_MATTER_PUMP_CONTROLLER}, {"thread_border_router", ESP_MATTER_THREAD_BORDER_ROUTER}, + {"mounted_on_off_control", ESP_MATTER_MOUNTED_ON_OFF_CONTROL}, + {"mounted_dimmable_load_control", ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL}, }; } /* 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 4a25d333b..b7d13a8a1 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 @@ -519,6 +519,16 @@ int create(uint8_t device_type_index) break; } #endif + case ESP_MATTER_MOUNTED_ON_OFF_CONTROL: { + esp_matter::endpoint::mounted_on_off_control::config_t mounted_on_off_control_config; + endpoint = esp_matter::endpoint::mounted_on_off_control::create(node, &mounted_on_off_control_config, ENDPOINT_FLAG_NONE, NULL); + break; + } + case ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL: { + esp_matter::endpoint::mounted_dimmable_load_control::config_t mounted_dimmable_load_control_config; + endpoint = esp_matter::endpoint::mounted_dimmable_load_control::create(node, &mounted_dimmable_load_control_config, ENDPOINT_FLAG_NONE, NULL); + break; + } default: { ESP_LOGE(TAG, "Please input a valid device type"); break;