Skip to content

Commit

Permalink
Merge branch 'device/mounted' into 'main'
Browse files Browse the repository at this point in the history
components/esp-matter: Add Mounted On Off Control and Mounted Dimmable Load Control device types.

See merge request app-frameworks/esp-matter!940
  • Loading branch information
dhrishi committed Nov 15, 2024
2 parents 65f1374 + b51fc3c commit 55981f7
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
2 changes: 2 additions & 0 deletions SUPPORTED_DEVICE_TYPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
71 changes: 71 additions & 0 deletions components/esp_matter/esp_matter_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<config_t>(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<config_t>(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 {
Expand Down
22 changes: 22 additions & 0 deletions components/esp_matter/esp_matter_endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions examples/all_device_types_app/main/device_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -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 */
10 changes: 10 additions & 0 deletions examples/all_device_types_app/main/esp_matter_console_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 55981f7

Please sign in to comment.