Skip to content

Commit c8d3a8f

Browse files
committed
Merge branch 'cluster/fabic_sync' into 'main'
components/esp-matter: Add Commissioner Control and Ecosystem Information clusters See merge request app-frameworks/esp-matter!949
2 parents 1bee314 + 86eaaed commit c8d3a8f

12 files changed

+211
-1
lines changed

components/esp_matter/esp_matter_attribute.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -4718,5 +4718,33 @@ attribute_t *create_current_low_power_mode_sensitivity(cluster_t *cluster, uint8
47184718
} /* attribute */
47194719
} /* energy_preference */
47204720

4721+
namespace commissioner_control {
4722+
namespace attribute {
4723+
attribute_t *create_supported_device_categories(cluster_t *cluster, uint32_t value)
4724+
{
4725+
return esp_matter::attribute::create(cluster, CommissionerControl::Attributes::SupportedDeviceCategories::Id,
4726+
ATTRIBUTE_FLAG_NONE, esp_matter_bitmap32(value));
4727+
}
4728+
4729+
} /* attribute */
4730+
} /* commissioner_control */
4731+
4732+
namespace ecosystem_information {
4733+
namespace attribute {
4734+
attribute_t *create_device_directory(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
4735+
{
4736+
return esp_matter::attribute::create(cluster, EcosystemInformation::Attributes::DeviceDirectory::Id, ATTRIBUTE_FLAG_NONVOLATILE,
4737+
esp_matter_array(value, length, count));
4738+
}
4739+
4740+
attribute_t *create_location_directory(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
4741+
{
4742+
return esp_matter::attribute::create(cluster, EcosystemInformation::Attributes::LocationDirectory::Id, ATTRIBUTE_FLAG_NONVOLATILE,
4743+
esp_matter_array(value, length, count));
4744+
}
4745+
4746+
} /* attribute */
4747+
} /* ecosystem_information */
4748+
47214749
} /* cluster */
47224750
} /* esp_matter */

components/esp_matter/esp_matter_attribute.h

+13
Original file line numberDiff line numberDiff line change
@@ -1181,5 +1181,18 @@ attribute_t *create_current_low_power_mode_sensitivity(cluster_t *cluster, uint8
11811181
} /* attribute */
11821182
} /* energy_preference */
11831183

1184+
namespace commissioner_control {
1185+
namespace attribute {
1186+
attribute_t *create_supported_device_categories(cluster_t *cluster, uint32_t value);
1187+
} /* attribute */
1188+
} /* commissioner_control */
1189+
1190+
namespace ecosystem_information {
1191+
namespace attribute {
1192+
attribute_t *create_device_directory(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
1193+
attribute_t *create_location_directory(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
1194+
} /* attribute */
1195+
} /* ecosystem_information */
1196+
11841197
} /* cluster */
11851198
} /* esp_matter */

components/esp_matter/esp_matter_cluster.cpp

+66
Original file line numberDiff line numberDiff line change
@@ -3451,6 +3451,72 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
34513451
}
34523452
} /* energy_preference */
34533453

3454+
namespace commissioner_control {
3455+
const function_generic_t *function_list = NULL;
3456+
const int function_flags = CLUSTER_FLAG_NONE;
3457+
3458+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features)
3459+
{
3460+
cluster_t *cluster = cluster::create(endpoint, CommissionerControl::Id, flags);
3461+
if (!cluster) {
3462+
ESP_LOGE(TAG, "Could not create cluster");
3463+
return NULL;
3464+
}
3465+
if (flags & CLUSTER_FLAG_SERVER) {
3466+
if (config -> delegate != nullptr) {
3467+
static const auto delegate_init_cb = CommissionerControlDelegateInitCB;
3468+
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
3469+
}
3470+
static const auto plugin_server_init_cb = CALL_ONCE(MatterCommissionerControlPluginServerInitCallback);
3471+
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
3472+
add_function_list(cluster, function_list, function_flags);
3473+
3474+
/* Attributes managed internally */
3475+
global::attribute::create_feature_map(cluster, 0);
3476+
3477+
/** Attributes not managed internally **/
3478+
global::attribute::create_cluster_revision(cluster, cluster_revision);
3479+
attribute::create_supported_device_categories(cluster, config->supported_device_categories);
3480+
}
3481+
3482+
if (flags & CLUSTER_FLAG_CLIENT) {
3483+
create_default_binding_cluster(endpoint);
3484+
}
3485+
3486+
event::create_commissioning_request_result(cluster);
3487+
return cluster;
3488+
}
3489+
} /* commissioner_control */
3490+
3491+
namespace ecosystem_information {
3492+
const function_generic_t *function_list = NULL;
3493+
const int function_flags = CLUSTER_FLAG_NONE;
3494+
3495+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features)
3496+
{
3497+
cluster_t *cluster = cluster::create(endpoint, EcosystemInformation::Id, flags);
3498+
if (!cluster) {
3499+
ESP_LOGE(TAG, "Could not create cluster");
3500+
return NULL;
3501+
}
3502+
if (flags & CLUSTER_FLAG_SERVER) {
3503+
static const auto plugin_server_init_cb = CALL_ONCE(MatterEcosystemInformationPluginServerInitCallback);
3504+
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
3505+
add_function_list(cluster, function_list, function_flags);
3506+
3507+
/* Attributes managed internally */
3508+
global::attribute::create_feature_map(cluster, 0);
3509+
attribute::create_device_directory(cluster, nullptr, 0, 0);
3510+
attribute::create_location_directory(cluster, nullptr, 0, 0);
3511+
3512+
/** Attributes not managed internally **/
3513+
global::attribute::create_cluster_revision(cluster, cluster_revision);
3514+
}
3515+
3516+
return cluster;
3517+
}
3518+
} /* ecosystem_information */
3519+
34543520
// namespace binary_input_basic {
34553521
// // ToDo
34563522
// } /* binary_input_basic */

components/esp_matter/esp_matter_cluster.h

+15
Original file line numberDiff line numberDiff line change
@@ -941,5 +941,20 @@ typedef struct config {
941941
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features);
942942
} /* energy_preference */
943943

944+
namespace commissioner_control {
945+
typedef struct config {
946+
uint32_t supported_device_categories;
947+
void *delegate;
948+
config() : supported_device_categories(0), delegate(nullptr) {}
949+
} config_t;
950+
951+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
952+
} /* commissioner_control */
953+
954+
namespace ecosystem_information {
955+
using config_t = common::config_t;
956+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
957+
} /* ecosystem_information */
958+
944959
} /* cluster */
945960
} /* esp_matter */

components/esp_matter/esp_matter_command.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -3280,6 +3280,38 @@ command_t *create_cancel_boost(cluster_t *cluster)
32803280
} /* command */
32813281
} /* water_heater_management */
32823282

3283+
namespace commissioner_control {
3284+
namespace command {
3285+
constexpr const command_entry_t accepted_command_list[] = {
3286+
{CommissionerControl::Commands::RequestCommissioningApproval::Id, COMMAND_FLAG_ACCEPTED, NULL},
3287+
{CommissionerControl::Commands::CommissionNode::Id, COMMAND_FLAG_ACCEPTED, NULL},
3288+
};
3289+
3290+
constexpr const command_entry_t generated_command_list[] = {
3291+
{CommissionerControl::Commands::ReverseOpenCommissioningWindow::Id, COMMAND_FLAG_GENERATED, NULL},
3292+
};
3293+
3294+
command_t *create_request_commissioning_approval(cluster_t *cluster)
3295+
{
3296+
return esp_matter::command::create(cluster, CommissionerControl::Commands::RequestCommissioningApproval::Id,
3297+
COMMAND_FLAG_ACCEPTED, NULL);
3298+
}
3299+
3300+
command_t *create_commission_node(cluster_t *cluster)
3301+
{
3302+
return esp_matter::command::create(cluster, CommissionerControl::Commands::CommissionNode::Id,
3303+
COMMAND_FLAG_ACCEPTED, NULL);
3304+
}
3305+
3306+
command_t *create_reverse_open_commissioning_window(cluster_t *cluster)
3307+
{
3308+
return esp_matter::command::create(cluster, CommissionerControl::Commands::ReverseOpenCommissioningWindow::Id,
3309+
COMMAND_FLAG_ACCEPTED, NULL);
3310+
}
3311+
3312+
} /* command */
3313+
} /* commissioner_control */
3314+
32833315
} /* cluster */
32843316
} /* esp_matter */
32853317

@@ -3327,6 +3359,7 @@ constexpr const cluster_command_t cluster_command_table[] = {
33273359
{WiFiNetworkManagement::Id, GET_COMMAND_COUNT_LIST(cluster::wifi_network_management)},
33283360
{ThreadNetworkDirectory::Id, GET_COMMAND_COUNT_LIST(cluster::thread_network_directory)},
33293361
{WaterHeaterManagement::Id, GET_COMMAND_COUNT_LIST(cluster::water_heater_management)},
3362+
{CommissionerControl::Id, GET_COMMAND_COUNT_LIST(cluster::commissioner_control)},
33303363
};
33313364

33323365
#if defined(CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER) && defined(CONFIG_ESP_MATTER_ENABLE_DATA_MODEL)

components/esp_matter/esp_matter_command.h

+8
Original file line numberDiff line numberDiff line change
@@ -473,5 +473,13 @@ command_t *create_cancel_boost(cluster_t *cluster);
473473
} /* command */
474474
} /* water_heater_management */
475475

476+
namespace commissioner_control {
477+
namespace command {
478+
command_t *create_request_commissioning_approval(cluster_t *cluster);
479+
command_t *create_commission_node(cluster_t *cluster);
480+
command_t *create_reverse_open_commissioning_window(cluster_t *cluster);
481+
} /* command */
482+
} /* commissioner_control */
483+
476484
} /* cluster */
477485
} /* esp_matter */

components/esp_matter/esp_matter_delegate_callbacks.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <app/clusters/thread-border-router-management-server/thread-border-router-management-server.h>
4141
#include <app/clusters/water-heater-management-server/water-heater-management-server.h>
4242
#include <app/clusters/energy-preference-server/energy-preference-server.h>
43+
#include <app/clusters/commissioner-control-server/commissioner-control-server.h>
4344

4445
using namespace chip::app::Clusters;
4546
namespace esp_matter {
@@ -347,6 +348,16 @@ void EnergyPreferenceDelegateInitCB(void *delegate, uint16_t endpoint_id)
347348
EnergyPreference::SetDelegate(energy_preference_delegate);
348349
}
349350

351+
void CommissionerControlDelegateInitCB(void *delegate, uint16_t endpoint_id)
352+
{
353+
if(delegate == nullptr)
354+
{
355+
return;
356+
}
357+
CommissionerControl::Delegate *commissioner_control_delegate = static_cast<CommissionerControl::Delegate*>(delegate);
358+
CommissionerControl::CommissionerControlServer::Instance().Init(*commissioner_control_delegate);
359+
}
360+
350361
} // namespace delegate_cb
351362

352363
} // namespace cluster

components/esp_matter/esp_matter_delegate_callbacks.h

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void ThreadBorderRouterManagementDelegateInitCB(void *delegate, uint16_t endpoin
5050
void ServiceAreaDelegateInitCB(void *delegate, uint16_t endpoint_id);
5151
void WaterHeaterManagementDelegateInitCB(void *delegate, uint16_t endpoint_id);
5252
void EnergyPreferenceDelegateInitCB(void *delegate, uint16_t endpoint_id);
53+
void CommissionerControlDelegateInitCB(void *delegate, uint16_t endpoint_id);
5354
} // namespace delegate_cb
5455

5556
} // namespace cluster

components/esp_matter/esp_matter_event.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -759,5 +759,15 @@ event_t *create_boost_ended(cluster_t *cluster)
759759
} // namespace event
760760
} // namespace water_heater_management
761761

762+
namespace commissioner_control {
763+
namespace event {
764+
event_t *create_commissioning_request_result(cluster_t *cluster)
765+
{
766+
return esp_matter::event::create(cluster, CommissionerControl::Events::CommissioningRequestResult::Id);
767+
}
768+
769+
} // namespace event
770+
} // namespace commissioner_control
771+
762772
} // namespace cluster
763773
} // namespace esp_matter

components/esp_matter/esp_matter_event.h

+6
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,11 @@ event_t *create_boost_ended(cluster_t *cluster);
230230
} // namespace event
231231
} // namespace water_heater_management
232232

233+
namespace commissioner_control {
234+
namespace event {
235+
event_t *create_commissioning_request_result(cluster_t *cluster);
236+
} // namespace event
237+
} // namespace commissioner_control
238+
233239
} // namespace cluster
234240
} // namespace esp_matter

components/esp_matter/private/esp_matter_cluster_revisions.h

+8
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,14 @@ namespace energy_preference {
395395
constexpr uint16_t cluster_revision = 1;
396396
} // namespace energy_preference
397397

398+
namespace commissioner_control {
399+
constexpr uint16_t cluster_revision = 1;
400+
} // namespace commissioner_control
401+
402+
namespace ecosystem_information {
403+
constexpr uint16_t cluster_revision = 1;
404+
} // namespace ecosystem_information
405+
398406
} // namespace cluster
399407
} // namespace esp_matter
400408

docs/en/app_guide.rst

+12-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ List of clusters with delegate:
4747
- Mode Select Cluster.
4848
- Water Heater Management Cluster.
4949
- Energy Preference Cluster.
50+
- Commissioner Control Cluster.
5051

5152
9.1.1 Mode Base Cluster
5253
-----------------------
@@ -227,14 +228,22 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven.
227228

228229
`Water Heater Management`_, `Water Heater Management Delegate`_
229230

230-
9.1.21 Energy Preference Cluster
231+
9.1.22 Energy Preference Cluster
231232
--------------------------------
232233

233234
.. csv-table::
234235
:header: "Delegate Class", "Reference Implementation"
235236

236237
`Energy Preference`_, `Energy Preference Delegate`_
237238

239+
9.1.23 Commissioner Control Cluster
240+
-----------------------------------
241+
242+
.. csv-table::
243+
:header: "Delegate Class", "Reference Implementation"
244+
245+
`Commissioner Control`_, `Commissioner Control Delegate`_
246+
238247

239248
.. note::
240249
Make sure that after implementing delegate class, you set the delegate class pointer at the time of creating cluster.
@@ -293,3 +302,5 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven.
293302
.. _`Water Heater Management Delegate`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/examples/energy-management-app/energy-management-common/water-heater/include/WhmDelegate.h
294303
.. _`Energy Preference`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/src/app/clusters/energy-preference-server/energy-preference-server.h
295304
.. _`Energy Preference Delegate`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp
305+
.. _`Commissioner Control`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/src/app/clusters/commissioner-control-server/commissioner-control-server.h
306+
.. _`Commissioner Control Delegate`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/examples/fabric-bridge-app/linux/include/CommissionerControl.h

0 commit comments

Comments
 (0)