mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
controller: Add support for clusters of occupancy_sensing, wind_covering, and thermost_userinterface_configuration
This commit is contained in:
@@ -1035,6 +1035,89 @@ esp_err_t send_remove_group(peer_device_t *remote_device, uint16_t remote_endpoi
|
||||
|
||||
} // namespace command
|
||||
} // namespace groups
|
||||
|
||||
namespace window_covering {
|
||||
namespace command {
|
||||
|
||||
esp_err_t send_up_or_open(peer_device_t *remote_device, uint16_t remote_endpoint_id)
|
||||
{
|
||||
WindowCovering::Commands::UpOrOpen::Type command_data;
|
||||
|
||||
chip::Controller::WindowCoveringCluster cluster(*remote_device->GetExchangeManager(),
|
||||
remote_device->GetSecureSession().Value(), remote_endpoint_id);
|
||||
cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t send_down_or_close(peer_device_t *remote_device, uint16_t remote_endpoint_id)
|
||||
{
|
||||
WindowCovering::Commands::DownOrClose::Type command_data;
|
||||
|
||||
chip::Controller::WindowCoveringCluster cluster(*remote_device->GetExchangeManager(),
|
||||
remote_device->GetSecureSession().Value(), remote_endpoint_id);
|
||||
cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t send_stop_motion(peer_device_t *remote_device, uint16_t remote_endpoint_id)
|
||||
{
|
||||
WindowCovering::Commands::StopMotion::Type command_data;
|
||||
|
||||
chip::Controller::WindowCoveringCluster cluster(*remote_device->GetExchangeManager(),
|
||||
remote_device->GetSecureSession().Value(), remote_endpoint_id);
|
||||
cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t send_go_to_lift_value(peer_device_t *remote_device, uint16_t remote_endpoint_id, uint16_t lift_value)
|
||||
{
|
||||
WindowCovering::Commands::GoToLiftValue::Type command_data;
|
||||
command_data.liftValue = lift_value;
|
||||
|
||||
chip::Controller::WindowCoveringCluster cluster(*remote_device->GetExchangeManager(),
|
||||
remote_device->GetSecureSession().Value(), remote_endpoint_id);
|
||||
cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t send_go_to_lift_percentage(peer_device_t *remote_device, uint16_t remote_endpoint_id,
|
||||
uint16_t lift_percent100ths_value)
|
||||
{
|
||||
WindowCovering::Commands::GoToLiftPercentage::Type command_data;
|
||||
command_data.liftPercent100thsValue = static_cast<chip::Percent100ths>(lift_percent100ths_value);
|
||||
|
||||
chip::Controller::WindowCoveringCluster cluster(*remote_device->GetExchangeManager(),
|
||||
remote_device->GetSecureSession().Value(), remote_endpoint_id);
|
||||
cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t send_go_to_tilt_value(peer_device_t *remote_device, uint16_t remote_endpoint_id, uint16_t tilt_value)
|
||||
{
|
||||
WindowCovering::Commands::GoToTiltValue::Type command_data;
|
||||
command_data.tiltValue = tilt_value;
|
||||
|
||||
chip::Controller::WindowCoveringCluster cluster(*remote_device->GetExchangeManager(),
|
||||
remote_device->GetSecureSession().Value(), remote_endpoint_id);
|
||||
cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t send_go_to_tilt_percentage(peer_device_t *remote_device, uint16_t remote_endpoint_id,
|
||||
uint16_t tilt_percent100ths_value)
|
||||
{
|
||||
WindowCovering::Commands::GoToTiltPercentage::Type command_data;
|
||||
command_data.tiltPercent100thsValue = static_cast<chip::Percent100ths>(tilt_percent100ths_value);
|
||||
|
||||
chip::Controller::WindowCoveringCluster cluster(*remote_device->GetExchangeManager(),
|
||||
remote_device->GetSecureSession().Value(), remote_endpoint_id);
|
||||
cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} // namespace command
|
||||
} // namespace window_covering
|
||||
|
||||
#endif // CONFIG_ESP_MATTER_ENABLE_DATA_MODEL
|
||||
|
||||
} // namespace cluster
|
||||
|
||||
@@ -193,5 +193,27 @@ esp_err_t send_remove_group(peer_device_t *remote_device, uint16_t remote_endpoi
|
||||
} // namespace command
|
||||
} // namespace groups
|
||||
|
||||
namespace window_covering {
|
||||
namespace command {
|
||||
|
||||
esp_err_t send_up_or_open(peer_device_t *remote_device, uint16_t remote_endpoint_id);
|
||||
|
||||
esp_err_t send_down_or_close(peer_device_t *remote_device, uint16_t remote_endpoint_id);
|
||||
|
||||
esp_err_t send_stop_motion(peer_device_t *remote_device, uint16_t remote_endpoint_id);
|
||||
|
||||
esp_err_t send_go_to_lift_value(peer_device_t *remote_device, uint16_t remote_endpoint_id, uint16_t lift_value);
|
||||
|
||||
esp_err_t send_go_to_lift_percentage(peer_device_t *remote_device, uint16_t remote_endpoint_id,
|
||||
uint16_t lift_percent100ths_value);
|
||||
|
||||
esp_err_t send_go_to_tilt_value(peer_device_t *remote_device, uint16_t remote_endpoint_id, uint16_t tilt_value);
|
||||
|
||||
esp_err_t send_go_to_tilt_percentage(peer_device_t *remote_device, uint16_t remote_endpoint_id,
|
||||
uint16_t tilt_percent100ths_value);
|
||||
|
||||
} // namespace command
|
||||
} // namespace window_covering
|
||||
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
@@ -369,6 +369,67 @@ static esp_err_t send_command(command_data_t *command_data, peer_device_t *remot
|
||||
|
||||
} // namespace groups
|
||||
|
||||
namespace window_covering {
|
||||
|
||||
static esp_err_t send_command(command_data_t *command_data, peer_device_t *remote_device, uint16_t remote_endpoint_id)
|
||||
{
|
||||
switch (command_data->command_id) {
|
||||
case WindowCovering::Commands::UpOrOpen::Id: {
|
||||
return esp_matter::cluster::window_covering::command::send_up_or_open(remote_device, remote_endpoint_id);
|
||||
break;
|
||||
}
|
||||
case WindowCovering::Commands::DownOrClose::Id: {
|
||||
return esp_matter::cluster::window_covering::command::send_down_or_close(remote_device, remote_endpoint_id);
|
||||
break;
|
||||
}
|
||||
case WindowCovering::Commands::StopMotion::Id: {
|
||||
return esp_matter::cluster::window_covering::command::send_stop_motion(remote_device, remote_endpoint_id);
|
||||
break;
|
||||
}
|
||||
case WindowCovering::Commands::GoToLiftValue::Id: {
|
||||
if (command_data->command_data_count != 1) {
|
||||
ESP_LOGE(TAG, "The command data should in following order: lift_value");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return esp_matter::cluster::window_covering::command::send_go_to_lift_value(
|
||||
remote_device, remote_endpoint_id, string_to_uint16(command_data->command_data_str[0]));
|
||||
break;
|
||||
}
|
||||
case WindowCovering::Commands::GoToLiftPercentage::Id: {
|
||||
if (command_data->command_data_count != 1) {
|
||||
ESP_LOGE(TAG, "The command data should in following order: lift_percentage");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return esp_matter::cluster::window_covering::command::send_go_to_lift_percentage(
|
||||
remote_device, remote_endpoint_id, string_to_uint16(command_data->command_data_str[0]));
|
||||
break;
|
||||
}
|
||||
case WindowCovering::Commands::GoToTiltValue::Id: {
|
||||
if (command_data->command_data_count != 1) {
|
||||
ESP_LOGE(TAG, "The command data should in following order: tilt_value");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return esp_matter::cluster::window_covering::command::send_go_to_tilt_value(
|
||||
remote_device, remote_endpoint_id, string_to_uint16(command_data->command_data_str[0]));
|
||||
break;
|
||||
}
|
||||
case WindowCovering::Commands::GoToTiltPercentage::Id: {
|
||||
if (command_data->command_data_count != 1) {
|
||||
ESP_LOGE(TAG, "The command data should in following order: tilt_percentage");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return esp_matter::cluster::window_covering::command::send_go_to_tilt_percentage(
|
||||
remote_device, remote_endpoint_id, string_to_uint16(command_data->command_data_str[0]));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
} // namespace window_covering
|
||||
|
||||
} // namespace clusters
|
||||
|
||||
void cluster_command::on_device_connected_fcn(void *context, ExchangeManager &exchangeMgr, const SessionHandle &sessionHandle)
|
||||
@@ -391,6 +452,9 @@ void cluster_command::on_device_connected_fcn(void *context, ExchangeManager &ex
|
||||
case Groups::Id:
|
||||
clusters::groups::send_command(cmd->m_command_data, &device_proxy, cmd->m_endpoint_id);
|
||||
break;
|
||||
case WindowCovering::Id:
|
||||
clusters::window_covering::send_command(cmd->m_command_data, &device_proxy, cmd->m_endpoint_id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -534,6 +534,86 @@ static esp_err_t write_attribute(uint64_t node_id, uint16_t endpoint_id, uint32_
|
||||
|
||||
} // namespace group_key_management
|
||||
|
||||
namespace occupancy_sensing {
|
||||
|
||||
static esp_err_t write_attribute(uint64_t node_id, uint16_t endpoint_id, uint32_t attribute_id, char *attribute_val_str)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
switch (attribute_id) {
|
||||
case OccupancySensing::Attributes::PIROccupiedToUnoccupiedDelay::Id:
|
||||
case OccupancySensing::Attributes::PIRUnoccupiedToOccupiedDelay::Id:
|
||||
case OccupancySensing::Attributes::UltrasonicOccupiedToUnoccupiedDelay::Id:
|
||||
case OccupancySensing::Attributes::UltrasonicUnoccupiedToOccupiedDelay::Id:
|
||||
case OccupancySensing::Attributes::PhysicalContactOccupiedToUnoccupiedDelay::Id:
|
||||
case OccupancySensing::Attributes::PhysicalContactUnoccupiedToOccupiedDelay::Id: {
|
||||
write_command<uint16_t> *cmd = New<write_command<uint16_t>>(node_id, endpoint_id, OccupancySensing::Id,
|
||||
attribute_id, string_to_uint16(attribute_val_str));
|
||||
ESP_RETURN_ON_FALSE(cmd, ESP_ERR_NO_MEM, TAG, "Failed to alloc memory for write_command");
|
||||
return cmd->send_command();
|
||||
break;
|
||||
}
|
||||
case OccupancySensing::Attributes::PIRUnoccupiedToOccupiedThreshold::Id:
|
||||
case OccupancySensing::Attributes::UltrasonicUnoccupiedToOccupiedThreshold::Id:
|
||||
case OccupancySensing::Attributes::PhysicalContactUnoccupiedToOccupiedThreshold::Id: {
|
||||
write_command<uint8_t> *cmd = New<write_command<uint8_t>>(node_id, endpoint_id, OccupancySensing::Id,
|
||||
attribute_id, string_to_uint8(attribute_val_str));
|
||||
ESP_RETURN_ON_FALSE(cmd, ESP_ERR_NO_MEM, TAG, "Failed to alloc memory for write_command");
|
||||
return cmd->send_command();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
err = ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
} // namespace occupancy_sensing
|
||||
|
||||
namespace window_covering {
|
||||
|
||||
static esp_err_t write_attribute(uint64_t node_id, uint16_t endpoint_id, uint32_t attribute_id, char *attribute_val_str)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
switch (attribute_id) {
|
||||
case WindowCovering::Attributes::Mode::Id: {
|
||||
write_command<uint8_t> *cmd = New<write_command<uint8_t>>(node_id, endpoint_id, WindowCovering::Id,
|
||||
attribute_id, string_to_uint8(attribute_val_str));
|
||||
ESP_RETURN_ON_FALSE(cmd, ESP_ERR_NO_MEM, TAG, "Failed to alloc memory for write_command");
|
||||
return cmd->send_command();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
err = ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
} // namespace window_covering
|
||||
|
||||
namespace thermostat_userinterface_configuration {
|
||||
|
||||
static esp_err_t write_attribute(uint64_t node_id, uint16_t endpoint_id, uint32_t attribute_id, char *attribute_val_str)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
switch (attribute_id) {
|
||||
case ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::Id:
|
||||
case ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::Id:
|
||||
case ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::Id: {
|
||||
write_command<uint8_t> *cmd =
|
||||
New<write_command<uint8_t>>(node_id, endpoint_id, ThermostatUserInterfaceConfiguration::Id, attribute_id,
|
||||
string_to_uint8(attribute_val_str));
|
||||
ESP_RETURN_ON_FALSE(cmd, ESP_ERR_NO_MEM, TAG, "Failed to alloc memory for write_command");
|
||||
return cmd->send_command();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
err = ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
} // namespace thermostat_userinterface_configuration
|
||||
|
||||
} // namespace clusters
|
||||
|
||||
esp_err_t send_write_attr_command(uint64_t node_id, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
|
||||
@@ -558,6 +638,16 @@ esp_err_t send_write_attr_command(uint64_t node_id, uint16_t endpoint_id, uint32
|
||||
case GroupKeyManagement::Id:
|
||||
return clusters::group_key_management::write_attribute(node_id, endpoint_id, attribute_id, attribute_val_str);
|
||||
break;
|
||||
case OccupancySensing::Id:
|
||||
return clusters::occupancy_sensing::write_attribute(node_id, endpoint_id, attribute_id, attribute_val_str);
|
||||
break;
|
||||
case WindowCovering::Id:
|
||||
return clusters::window_covering::write_attribute(node_id, endpoint_id, attribute_id, attribute_val_str);
|
||||
break;
|
||||
case ThermostatUserInterfaceConfiguration::Id:
|
||||
return clusters::thermostat_userinterface_configuration::write_attribute(node_id, endpoint_id, attribute_id,
|
||||
attribute_val_str);
|
||||
break;
|
||||
default:
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user