Add laundry dryer device type

This commit is contained in:
Rohit Jadhav
2024-04-04 12:42:48 +05:30
parent 3ab972b85a
commit 8692a149b8
9 changed files with 159 additions and 1 deletions
+1
View File
@@ -72,3 +72,4 @@ i. Appliance
9. Energy Evse
10. Microwave Oven
11. Extractor Hood
12. Laundry Dryer
@@ -2898,6 +2898,40 @@ attribute_t *create_supported_rinses(cluster_t *cluster, uint8_t *value, uint16_
} /* attribute */
} /* laundry_washer_controls */
namespace laundry_dryer_controls {
namespace attribute {
attribute_t *create_supported_dryness_levels(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, LaundryDryerControls::Attributes::SupportedDrynessLevels::Id,
ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count));
}
attribute_t *create_selected_dryness_level(cluster_t *cluster, nullable<uint8_t> value)
{
return esp_matter::attribute::create(cluster, LaundryDryerControls::Attributes::SelectedDrynessLevel::Id,
ATTRIBUTE_FLAG_NULLABLE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_nullable_uint8(value));
}
} /* attribute */
} /* laundry_dryer_controls */
namespace dish_washer_mode {
namespace attribute {
attribute_t *create_supported_modes(cluster_t *cluster, const uint8_t * value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, LaundryWasherMode::Attributes::SupportedModes::Id, ATTRIBUTE_FLAG_NONE, esp_matter_array((uint8_t*)value, length, count));
}
attribute_t *create_current_mode(cluster_t *cluster, uint8_t value)
{
return esp_matter::attribute::create(cluster, LaundryWasherMode::Attributes::CurrentMode::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint8(value));
}
} /* attribute */
} /* dish_washer_mode */
namespace smoke_co_alarm {
namespace attribute {
attribute_t *create_expressed_state(cluster_t *cluster, uint8_t value)
@@ -703,6 +703,20 @@ attribute_t *create_supported_rinses(cluster_t *cluster, uint8_t *value, uint16_
} /* attribute */
} /* laundry_washer_controls */
namespace laundry_dryer_controls {
namespace attribute {
attribute_t *create_supported_dryness_levels(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
attribute_t *create_selected_dryness_level(cluster_t *cluster, nullable<uint8_t> value);
} /* attribute */
} /* laundry_dryer_controls */
namespace dish_washer_mode {
namespace attribute {
attribute_t *create_supported_modes(cluster_t *cluster, const uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_current_mode(cluster_t *cluster, uint8_t value);
} /* attribute */
} /* dish_washer_mode */
namespace smoke_co_alarm {
namespace attribute {
attribute_t *create_expressed_state(cluster_t *cluster, uint8_t value);
@@ -2333,6 +2333,48 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}
} /* laundry_washer_controls */
namespace laundry_dryer_controls {
const function_generic_t function_list[] = {
(function_generic_t)MatterLaundryDryerControlsClusterServerPreAttributeChangedCallback,
};
const int function_flags = CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{
cluster_t *cluster = cluster::create(endpoint, LaundryDryerControls::Id, flags);
if (!cluster) {
ESP_LOGE(TAG, "Could not create cluster");
return NULL;
}
if (flags & CLUSTER_FLAG_SERVER) {
add_function_list(cluster, function_list, function_flags);
}
if (flags & CLUSTER_FLAG_CLIENT) {
create_default_binding_cluster(endpoint);
}
if (flags & CLUSTER_FLAG_SERVER) {
/* Attributes managed internally */
global::attribute::create_feature_map(cluster, 0);
#if CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE
global::attribute::create_event_list(cluster, NULL, 0, 0);
#endif
attribute::create_supported_dryness_levels(cluster, NULL, 0, 0);
/* Attributes not managed internally */
if (config) {
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
attribute::create_selected_dryness_level(cluster, config->selected_dryness_level);
} else {
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
}
}
return cluster;
}
} /* laundry_dryer_controls */
namespace dish_washer_mode {
const function_generic_t *function_list = NULL;
const int function_flags = CLUSTER_FLAG_NONE;
@@ -565,6 +565,16 @@ typedef struct config {
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* laundry_washer_controls */
namespace laundry_dryer_controls {
typedef struct config {
uint16_t cluster_revision;
nullable<uint8_t> selected_dryness_level;
config() : cluster_revision(1), selected_dryness_level(0) {}
} config_t;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* laundry_dryer_controls */
namespace dish_washer_mode {
typedef struct config {
uint16_t cluster_revision;
@@ -816,6 +816,43 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
}
} /* laundry_washer */
namespace laundry_dryer {
uint32_t get_device_type_id()
{
return ESP_MATTER_LAUNDRY_DRYER_DEVICE_TYPE_ID;
}
uint8_t get_device_type_version()
{
return ESP_MATTER_LAUNDRY_DRYER_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);
operational_state::create(endpoint, &(config->operational_state), CLUSTER_FLAG_SERVER);
return ESP_OK;
}
} /* laundry_dryer */
namespace smoke_co_alarm {
uint32_t get_device_type_id()
{
@@ -79,6 +79,8 @@
#define ESP_MATTER_MICROWAVE_OVEN_DEVICE_TYPE_VERSION 1
#define ESP_MATTER_SMOKE_CO_ALARM_DEVICE_TYPE_ID 0x0076
#define ESP_MATTER_SMOKE_CO_ALARM_DEVICE_TYPE_VERSION 1
#define ESP_MATTER_LAUNDRY_DRYER_DEVICE_TYPE_ID 0x007C
#define ESP_MATTER_LAUNDRY_DRYER_DEVICE_TYPE_VERSION 1
#define ESP_MATTER_FAN_DEVICE_TYPE_ID 0x002B
#define ESP_MATTER_FAN_DEVICE_TYPE_VERSION 1
@@ -388,6 +390,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);
} /* laundry_washer */
namespace laundry_dryer {
typedef struct config {
cluster::descriptor::config_t descriptor;
cluster::operational_state::config_t operational_state;
} 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);
} /* laundry_dryer */
namespace smoke_co_alarm {
typedef struct config {
cluster::descriptor::config_t descriptor;
@@ -47,6 +47,7 @@ enum device_type_enum {
ESP_MATTER_ENERGY_EVSE,
ESP_MATTER_MICROWAVE_OVEN,
ESP_MATTER_EXTRACTOR_HOOD,
ESP_MATTER_LAUNDRY_DRYER,
ESP_MATTER_DEVICE_TYPE_MAX
};
@@ -99,6 +100,7 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
{"cooktop", ESP_MATTER_COOKTOP},
{"energy_evse", ESP_MATTER_ENERGY_EVSE},
{"microwave_oven", ESP_MATTER_MICROWAVE_OVEN},
{"extractor_hood", ESP_MATTER_EXTRACTOR_HOOD}
{"extractor_hood", ESP_MATTER_EXTRACTOR_HOOD},
{"laundry_dryer", ESP_MATTER_LAUNDRY_DRYER}
};
} /* namespace esp_matter */
@@ -429,6 +429,11 @@ int create(uint8_t device_type_index)
endpoint = esp_matter::endpoint::extractor_hood::create(node, &extractor_hood_config, ENDPOINT_FLAG_NONE, NULL);
break;
}
case ESP_MATTER_LAUNDRY_DRYER: {
esp_matter::endpoint::laundry_dryer::config_t laundry_dryer_config;
endpoint = esp_matter::endpoint::laundry_dryer::create(node, &laundry_dryer_config, ENDPOINT_FLAG_NONE, NULL);
break;
}
default: {
ESP_LOGE(TAG, "Please input a valid device type");
break;