Skip to content

Commit 8e4c70d

Browse files
committed
Merge branch 'device/laundry_dryer' into 'main'
[Delegate needed] Add laundry dryer device type See merge request app-frameworks/esp-matter!688
2 parents 3ab972b + c00d022 commit 8e4c70d

12 files changed

+164
-1
lines changed

SUPPORTED_DEVICE_TYPES.md

+1
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ i. Appliance
7272
9. Energy Evse
7373
10. Microwave Oven
7474
11. Extractor Hood
75+
12. Laundry Dryer

components/esp_matter/esp_matter_attribute.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -2898,6 +2898,24 @@ attribute_t *create_supported_rinses(cluster_t *cluster, uint8_t *value, uint16_
28982898
} /* attribute */
28992899
} /* laundry_washer_controls */
29002900

2901+
namespace laundry_dryer_controls {
2902+
namespace attribute {
2903+
attribute_t *create_supported_dryness_levels(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
2904+
{
2905+
return esp_matter::attribute::create(cluster, LaundryDryerControls::Attributes::SupportedDrynessLevels::Id,
2906+
ATTRIBUTE_FLAG_NONE, esp_matter_array(value, length, count));
2907+
}
2908+
2909+
attribute_t *create_selected_dryness_level(cluster_t *cluster, nullable<uint8_t> value)
2910+
{
2911+
return esp_matter::attribute::create(cluster, LaundryDryerControls::Attributes::SelectedDrynessLevel::Id,
2912+
ATTRIBUTE_FLAG_NULLABLE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_nullable_uint8(value));
2913+
2914+
}
2915+
2916+
} /* attribute */
2917+
} /* laundry_dryer_controls */
2918+
29012919
namespace smoke_co_alarm {
29022920
namespace attribute {
29032921
attribute_t *create_expressed_state(cluster_t *cluster, uint8_t value)

components/esp_matter/esp_matter_attribute.h

+7
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,13 @@ attribute_t *create_supported_rinses(cluster_t *cluster, uint8_t *value, uint16_
703703
} /* attribute */
704704
} /* laundry_washer_controls */
705705

706+
namespace laundry_dryer_controls {
707+
namespace attribute {
708+
attribute_t *create_supported_dryness_levels(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
709+
attribute_t *create_selected_dryness_level(cluster_t *cluster, nullable<uint8_t> value);
710+
} /* attribute */
711+
} /* laundry_dryer_controls */
712+
706713
namespace smoke_co_alarm {
707714
namespace attribute {
708715
attribute_t *create_expressed_state(cluster_t *cluster, uint8_t value);

components/esp_matter/esp_matter_cluster.cpp

+46
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,52 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
23332333
}
23342334
} /* laundry_washer_controls */
23352335

2336+
namespace laundry_dryer_controls {
2337+
2338+
const function_generic_t function_list[] = {
2339+
(function_generic_t)MatterLaundryDryerControlsClusterServerPreAttributeChangedCallback,
2340+
};
2341+
const int function_flags = CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION;
2342+
2343+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
2344+
{
2345+
cluster_t *cluster = cluster::create(endpoint, LaundryDryerControls::Id, flags);
2346+
if (!cluster) {
2347+
ESP_LOGE(TAG, "Could not create cluster");
2348+
return NULL;
2349+
}
2350+
2351+
if (flags & CLUSTER_FLAG_SERVER) {
2352+
if (config -> delegate != nullptr) {
2353+
static const auto delegate_init_cb = LaundryDryerControlsDelegateInitCB;
2354+
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
2355+
}
2356+
add_function_list(cluster, function_list, function_flags);
2357+
}
2358+
if (flags & CLUSTER_FLAG_CLIENT) {
2359+
create_default_binding_cluster(endpoint);
2360+
}
2361+
2362+
if (flags & CLUSTER_FLAG_SERVER) {
2363+
/* Attributes managed internally */
2364+
global::attribute::create_feature_map(cluster, 0);
2365+
#if CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE
2366+
global::attribute::create_event_list(cluster, NULL, 0, 0);
2367+
#endif
2368+
attribute::create_supported_dryness_levels(cluster, NULL, 0, 0);
2369+
/* Attributes not managed internally */
2370+
if (config) {
2371+
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
2372+
attribute::create_selected_dryness_level(cluster, config->selected_dryness_level);
2373+
} else {
2374+
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
2375+
}
2376+
}
2377+
2378+
return cluster;
2379+
}
2380+
} /* laundry_dryer_controls */
2381+
23362382
namespace dish_washer_mode {
23372383
const function_generic_t *function_list = NULL;
23382384
const int function_flags = CLUSTER_FLAG_NONE;

components/esp_matter/esp_matter_cluster.h

+11
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,17 @@ typedef struct config {
565565
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
566566
} /* laundry_washer_controls */
567567

568+
namespace laundry_dryer_controls {
569+
typedef struct config {
570+
uint16_t cluster_revision;
571+
nullable<uint8_t> selected_dryness_level;
572+
void *delegate;
573+
config() : cluster_revision(1), selected_dryness_level(0), delegate(nullptr) {}
574+
} config_t;
575+
576+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
577+
} /* laundry_dryer_controls */
578+
568579
namespace dish_washer_mode {
569580
typedef struct config {
570581
uint16_t cluster_revision;

components/esp_matter/esp_matter_delegate_callbacks.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <app/clusters/operational-state-server/operational-state-server.h>
2323
#include <app/clusters/resource-monitoring-server/resource-monitoring-server.h>
2424
#include <app/clusters/fan-control-server/fan-control-server.h>
25+
#include <app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.h>
2526

2627
using namespace chip::app::Clusters;
2728
namespace esp_matter {
@@ -183,6 +184,16 @@ void ActivatedCarbonFilterMonitoringDelegateInitCB(void *delegate, uint16_t endp
183184
activatedCarbonFilterMonitoringInstance->Init();
184185
}
185186

187+
void LaundryDryerControlsDelegateInitCB(void *delegate, uint16_t endpoint_id)
188+
{
189+
if(delegate == nullptr)
190+
{
191+
return;
192+
}
193+
LaundryDryerControls::Delegate *laundry_dryer_controls_delegate = static_cast<LaundryDryerControls::Delegate*>(delegate);
194+
LaundryDryerControls::LaundryDryerControlsServer::SetDefaultDelegate(endpoint_id, laundry_dryer_controls_delegate);
195+
}
196+
186197
} // namespace delegate_cb
187198

188199
} // namespace cluster

components/esp_matter/esp_matter_delegate_callbacks.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void OperationalStateDelegateInitCB(void *delegate, uint16_t endpoint_id);
3030
void FanControlDelegateInitCB(void *delegate, uint16_t endpoint_id);
3131
void HepaFilterMonitoringDelegateInitCB(void *delegate, uint16_t endpoint_id);
3232
void ActivatedCarbonFilterMonitoringDelegateInitCB(void *delegate, uint16_t endpoint_id);
33+
void LaundryDryerControlsDelegateInitCB(void *delegate, uint16_t endpoint_id);
3334
} // namespace delegate_cb
3435

3536
} // namespace cluster

components/esp_matter/esp_matter_endpoint.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,43 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
816816
}
817817
} /* laundry_washer */
818818

819+
namespace laundry_dryer {
820+
uint32_t get_device_type_id()
821+
{
822+
return ESP_MATTER_LAUNDRY_DRYER_DEVICE_TYPE_ID;
823+
}
824+
825+
uint8_t get_device_type_version()
826+
{
827+
return ESP_MATTER_LAUNDRY_DRYER_DEVICE_TYPE_VERSION;
828+
}
829+
830+
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
831+
{
832+
endpoint_t *endpoint = endpoint::create(node, flags, priv_data);
833+
add(endpoint, config);
834+
return endpoint;
835+
}
836+
837+
esp_err_t add(endpoint_t *endpoint, config_t *config)
838+
{
839+
if (!endpoint) {
840+
ESP_LOGE(TAG, "Endpoint cannot be NULL");
841+
return ESP_ERR_INVALID_ARG;
842+
}
843+
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
844+
if (err != ESP_OK) {
845+
ESP_LOGE(TAG, "Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err);
846+
return err;
847+
}
848+
849+
descriptor::create(endpoint, &(config->descriptor), CLUSTER_FLAG_SERVER);
850+
operational_state::create(endpoint, &(config->operational_state), CLUSTER_FLAG_SERVER);
851+
852+
return ESP_OK;
853+
}
854+
} /* laundry_dryer */
855+
819856
namespace smoke_co_alarm {
820857
uint32_t get_device_type_id()
821858
{

components/esp_matter/esp_matter_endpoint.h

+13
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
#define ESP_MATTER_MICROWAVE_OVEN_DEVICE_TYPE_VERSION 1
8080
#define ESP_MATTER_SMOKE_CO_ALARM_DEVICE_TYPE_ID 0x0076
8181
#define ESP_MATTER_SMOKE_CO_ALARM_DEVICE_TYPE_VERSION 1
82+
#define ESP_MATTER_LAUNDRY_DRYER_DEVICE_TYPE_ID 0x007C
83+
#define ESP_MATTER_LAUNDRY_DRYER_DEVICE_TYPE_VERSION 1
8284

8385
#define ESP_MATTER_FAN_DEVICE_TYPE_ID 0x002B
8486
#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
388390
esp_err_t add(endpoint_t *endpoint, config_t *config);
389391
} /* laundry_washer */
390392

393+
namespace laundry_dryer {
394+
typedef struct config {
395+
cluster::descriptor::config_t descriptor;
396+
cluster::operational_state::config_t operational_state;
397+
} config_t;
398+
uint32_t get_device_type_id();
399+
uint8_t get_device_type_version();
400+
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data);
401+
esp_err_t add(endpoint_t *endpoint, config_t *config);
402+
} /* laundry_dryer */
403+
391404
namespace smoke_co_alarm {
392405
typedef struct config {
393406
cluster::descriptor::config_t descriptor;

docs/en/app_guide.rst

+11
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven.
101101

102102
`Resource Monitoring`_, `Resource Monitoring Delegate`_
103103

104+
9.1.2 Laundry Dryer Controls Cluster
105+
------------------------------------
106+
107+
.. csv-table:: Delegate and its impl
108+
:header: "Delegate Class", "Reference Implementation"
109+
110+
`Laundry Dryer Controls`_, `Laundry Dryer Controls Delegate`_
111+
112+
104113
.. note::
105114
Make sure that after implementing delegate class, you set the delegate class pointer at the time of creating cluster.
106115

@@ -126,3 +135,5 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven.
126135
.. _`Fan Control Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp
127136
.. _`Resource Monitoring`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/resource-monitoring-server/resource-monitoring-server.h
128137
.. _`Resource Monitoring Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/resource-monitoring-delegates.h
138+
.. _`Laundry Dryer Controls`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.h
139+
.. _`Laundry Dryer Controls Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/laundry-dryer-controls-delegate-impl.h

examples/all_device_types_app/main/device_types.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum device_type_enum {
4747
ESP_MATTER_ENERGY_EVSE,
4848
ESP_MATTER_MICROWAVE_OVEN,
4949
ESP_MATTER_EXTRACTOR_HOOD,
50+
ESP_MATTER_LAUNDRY_DRYER,
5051
ESP_MATTER_DEVICE_TYPE_MAX
5152
};
5253

@@ -99,6 +100,7 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
99100
{"cooktop", ESP_MATTER_COOKTOP},
100101
{"energy_evse", ESP_MATTER_ENERGY_EVSE},
101102
{"microwave_oven", ESP_MATTER_MICROWAVE_OVEN},
102-
{"extractor_hood", ESP_MATTER_EXTRACTOR_HOOD}
103+
{"extractor_hood", ESP_MATTER_EXTRACTOR_HOOD},
104+
{"laundry_dryer", ESP_MATTER_LAUNDRY_DRYER}
103105
};
104106
} /* namespace esp_matter */

examples/all_device_types_app/main/esp_matter_console_helpers.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ int create(uint8_t device_type_index)
429429
endpoint = esp_matter::endpoint::extractor_hood::create(node, &extractor_hood_config, ENDPOINT_FLAG_NONE, NULL);
430430
break;
431431
}
432+
case ESP_MATTER_LAUNDRY_DRYER: {
433+
esp_matter::endpoint::laundry_dryer::config_t laundry_dryer_config;
434+
endpoint = esp_matter::endpoint::laundry_dryer::create(node, &laundry_dryer_config, ENDPOINT_FLAG_NONE, NULL);
435+
break;
436+
}
432437
default: {
433438
ESP_LOGE(TAG, "Please input a valid device type");
434439
break;

0 commit comments

Comments
 (0)