Skip to content

Commit 55981f7

Browse files
committed
Merge branch 'device/mounted' into 'main'
components/esp-matter: Add Mounted On Off Control and Mounted Dimmable Load Control device types. See merge request app-frameworks/esp-matter!940
2 parents 65f1374 + b51fc3c commit 55981f7

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed

SUPPORTED_DEVICE_TYPES.md

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ c. Smart Plugs/Outlets
3434
2. Dimmable Plugin Unit
3535
3. Pump
3636
4. Water Valve
37+
5. Mounted On Off Control
38+
6. Mounted Dimmable Load Control
3739

3840
d. Generic
3941
1. Mode Select

components/esp_matter/esp_matter_endpoint.cpp

+71
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,77 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
19461946
}
19471947
} /* secondary_network_interface */
19481948

1949+
namespace mounted_on_off_control {
1950+
uint32_t get_device_type_id()
1951+
{
1952+
return ESP_MATTER_MOUNTED_ON_OFF_CONTROL_DEVICE_TYPE_ID;
1953+
}
1954+
1955+
uint8_t get_device_type_version()
1956+
{
1957+
return ESP_MATTER_MOUNTED_ON_OFF_CONTROL_DEVICE_TYPE_VERSION;
1958+
}
1959+
1960+
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
1961+
{
1962+
return common::create<config_t>(node, config, flags, priv_data, add);
1963+
}
1964+
1965+
esp_err_t add(endpoint_t *endpoint, config_t *config)
1966+
{
1967+
VerifyOrReturnError(endpoint != nullptr, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Endpoint cannot be NULL"));
1968+
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
1969+
if (err != ESP_OK) {
1970+
ESP_LOGE(TAG, "Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err);
1971+
return err;
1972+
}
1973+
1974+
cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER);
1975+
identify::command::create_trigger_effect(identify_cluster);
1976+
groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER);
1977+
on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id());
1978+
1979+
return ESP_OK;
1980+
}
1981+
1982+
} /* mounted_on_off_control */
1983+
1984+
namespace mounted_dimmable_load_control {
1985+
uint32_t get_device_type_id()
1986+
{
1987+
return ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL_DEVICE_TYPE_ID;
1988+
}
1989+
1990+
uint8_t get_device_type_version()
1991+
{
1992+
return ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL_DEVICE_TYPE_VERSION;
1993+
}
1994+
1995+
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
1996+
{
1997+
return common::create<config_t>(node, config, flags, priv_data, add);
1998+
}
1999+
2000+
esp_err_t add(endpoint_t *endpoint, config_t *config)
2001+
{
2002+
VerifyOrReturnError(endpoint != nullptr, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Endpoint cannot be NULL"));
2003+
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
2004+
if (err != ESP_OK) {
2005+
ESP_LOGE(TAG, "Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err);
2006+
return err;
2007+
}
2008+
2009+
cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER);
2010+
identify::command::create_trigger_effect(identify_cluster);
2011+
groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER);
2012+
on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id());
2013+
level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER,
2014+
level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id());
2015+
2016+
return ESP_OK;
2017+
}
2018+
} /* mounted_dimmable_load_control */
2019+
19492020
} /* endpoint */
19502021

19512022
namespace node {

components/esp_matter/esp_matter_endpoint.h

+22
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
#define ESP_MATTER_ON_OFF_PLUGIN_UNIT_DEVICE_TYPE_VERSION 3
5757
#define ESP_MATTER_DIMMABLE_PLUGIN_UNIT_DEVICE_TYPE_ID 0x010B
5858
#define ESP_MATTER_DIMMABLE_PLUGIN_UNIT_DEVICE_TYPE_VERSION 4
59+
#define ESP_MATTER_MOUNTED_ON_OFF_CONTROL_DEVICE_TYPE_ID 0x010F
60+
#define ESP_MATTER_MOUNTED_ON_OFF_CONTROL_DEVICE_TYPE_VERSION 1
61+
#define ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL_DEVICE_TYPE_ID 0x0110
62+
#define ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL_DEVICE_TYPE_VERSION 1
5963

6064
#define ESP_MATTER_TEMPERATURE_SENSOR_DEVICE_TYPE_ID 0x0302
6165
#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
806810
esp_err_t add(endpoint_t *endpoint, config_t *config);
807811
} /* secondary_network_interface */
808812

813+
namespace mounted_on_off_control {
814+
using config_t = on_off_config;
815+
816+
uint32_t get_device_type_id();
817+
uint8_t get_device_type_version();
818+
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data);
819+
esp_err_t add(endpoint_t *endpoint, config_t *config);
820+
} /** mounted_on_off_control **/
821+
822+
namespace mounted_dimmable_load_control {
823+
using config_t = dimmable_light::config_t;
824+
825+
uint32_t get_device_type_id();
826+
uint8_t get_device_type_version();
827+
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data);
828+
esp_err_t add(endpoint_t *endpoint, config_t *config);
829+
} /** mounted_dimmable_load_control **/
830+
809831
} /* endpoint */
810832

811833
namespace node {

examples/all_device_types_app/main/device_types.h

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ enum device_type_enum {
5353
ESP_MATTER_DEVICE_ENERGY_MANAGEMENT,
5454
ESP_MATTER_PUMP_CONTROLLER,
5555
ESP_MATTER_THREAD_BORDER_ROUTER,
56+
ESP_MATTER_MOUNTED_ON_OFF_CONTROL,
57+
ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL,
5658
ESP_MATTER_DEVICE_TYPE_MAX
5759
};
5860

@@ -112,5 +114,7 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
112114
{"device_energy_management", ESP_MATTER_DEVICE_ENERGY_MANAGEMENT},
113115
{"pump_controller", ESP_MATTER_PUMP_CONTROLLER},
114116
{"thread_border_router", ESP_MATTER_THREAD_BORDER_ROUTER},
117+
{"mounted_on_off_control", ESP_MATTER_MOUNTED_ON_OFF_CONTROL},
118+
{"mounted_dimmable_load_control", ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL},
115119
};
116120
} /* namespace esp_matter */

examples/all_device_types_app/main/esp_matter_console_helpers.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,16 @@ int create(uint8_t device_type_index)
519519
break;
520520
}
521521
#endif
522+
case ESP_MATTER_MOUNTED_ON_OFF_CONTROL: {
523+
esp_matter::endpoint::mounted_on_off_control::config_t mounted_on_off_control_config;
524+
endpoint = esp_matter::endpoint::mounted_on_off_control::create(node, &mounted_on_off_control_config, ENDPOINT_FLAG_NONE, NULL);
525+
break;
526+
}
527+
case ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL: {
528+
esp_matter::endpoint::mounted_dimmable_load_control::config_t mounted_dimmable_load_control_config;
529+
endpoint = esp_matter::endpoint::mounted_dimmable_load_control::create(node, &mounted_dimmable_load_control_config, ENDPOINT_FLAG_NONE, NULL);
530+
break;
531+
}
522532
default: {
523533
ESP_LOGE(TAG, "Please input a valid device type");
524534
break;

0 commit comments

Comments
 (0)