Skip to content

Commit ab92285

Browse files
committedNov 13, 2024·
Merge branch 'cluster/wifi_net_management' into 'main'
components/esp-matter: Add Wifi Network Management and Thread Network Directory clusters See merge request app-frameworks/esp-matter!939
2 parents 82419a3 + 084f1cb commit ab92285

7 files changed

+217
-0
lines changed
 

‎components/esp_matter/esp_matter_attribute.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -4689,5 +4689,45 @@ attribute_t *create_pending_dataset_timestamp(cluster_t *cluster, nullable<uint6
46894689
} /* attribute */
46904690
} /* thread_border_router_management */
46914691

4692+
namespace wifi_network_management {
4693+
namespace attribute {
4694+
attribute_t *create_ssid(cluster_t *cluster, uint8_t *value, uint16_t length)
4695+
{
4696+
return esp_matter::attribute::create(cluster, WiFiNetworkManagement::Attributes::Ssid::Id,
4697+
ATTRIBUTE_FLAG_NULLABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_octet_str(value, length));
4698+
}
4699+
4700+
attribute_t *create_passphrase_surrogate(cluster_t *cluster, nullable<uint64_t> value)
4701+
{
4702+
return esp_matter::attribute::create(cluster, WiFiNetworkManagement::Attributes::PassphraseSurrogate::Id,
4703+
ATTRIBUTE_FLAG_NULLABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_nullable_uint64(value));
4704+
}
4705+
4706+
} /* attribute */
4707+
} /* wifi_network_management */
4708+
4709+
namespace thread_network_directory {
4710+
namespace attribute {
4711+
attribute_t *create_preferred_extended_pan_id(cluster_t *cluster, uint8_t *value, uint16_t length)
4712+
{
4713+
return esp_matter::attribute::create(cluster, ThreadNetworkDirectory::Attributes::PreferredExtendedPanID::Id,
4714+
ATTRIBUTE_FLAG_NULLABLE | ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_octet_str(value, length));
4715+
}
4716+
4717+
attribute_t *create_thread_networks(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
4718+
{
4719+
return esp_matter::attribute::create(cluster, ThreadNetworkDirectory::Attributes::ThreadNetworks::Id, ATTRIBUTE_FLAG_NONVOLATILE,
4720+
esp_matter_array(value, length, count));
4721+
}
4722+
4723+
attribute_t *create_thread_network_table_size(cluster_t *cluster, uint8_t value)
4724+
{
4725+
return esp_matter::attribute::create(cluster, ThreadNetworkDirectory::Attributes::ThreadNetworkTableSize::Id, ATTRIBUTE_FLAG_NONE,
4726+
esp_matter_uint8(value));
4727+
}
4728+
4729+
} /* attribute */
4730+
} /* thread_network_directory */
4731+
46924732
} /* cluster */
46934733
} /* esp_matter */

‎components/esp_matter/esp_matter_attribute.h

+15
Original file line numberDiff line numberDiff line change
@@ -1134,5 +1134,20 @@ attribute_t *create_pending_dataset_timestamp(cluster_t *cluster, nullable<uint6
11341134
} /* attribute */
11351135
} /* thread_border_router_management */
11361136

1137+
namespace wifi_network_management {
1138+
namespace attribute {
1139+
attribute_t *create_ssid(cluster_t *cluster, uint8_t *value, uint16_t length);
1140+
attribute_t *create_passphrase_surrogate(cluster_t *cluster, nullable<uint64_t> value);
1141+
} /* attribute */
1142+
} /* wifi_network_management */
1143+
1144+
namespace thread_network_directory {
1145+
namespace attribute {
1146+
attribute_t *create_preferred_extended_pan_id(cluster_t *cluster, uint8_t *value, uint16_t length);
1147+
attribute_t *create_thread_networks(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
1148+
attribute_t *create_thread_network_table_size(cluster_t *cluster, uint8_t value);
1149+
} /* attribute */
1150+
} /* thread_network_directory */
1151+
11371152
} /* cluster */
11381153
} /* esp_matter */

‎components/esp_matter/esp_matter_cluster.cpp

+61
Original file line numberDiff line numberDiff line change
@@ -3465,6 +3465,67 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
34653465

34663466
} /* thread_border_router_management */
34673467

3468+
namespace wifi_network_management {
3469+
const function_generic_t *function_list = NULL;
3470+
const int function_flags = CLUSTER_FLAG_NONE;
3471+
3472+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features)
3473+
{
3474+
cluster_t *cluster = cluster::create(endpoint, WiFiNetworkManagement::Id, flags);
3475+
if (!cluster) {
3476+
ESP_LOGE(TAG, "Could not create cluster");
3477+
return NULL;
3478+
}
3479+
if (flags & CLUSTER_FLAG_SERVER) {
3480+
static const auto plugin_server_init_cb = CALL_ONCE(MatterWiFiNetworkManagementPluginServerInitCallback);
3481+
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
3482+
add_function_list(cluster, function_list, function_flags);
3483+
3484+
/* Attributes managed internally */
3485+
global::attribute::create_feature_map(cluster, 0);
3486+
attribute::create_ssid(cluster, nullptr, 0);
3487+
attribute::create_passphrase_surrogate(cluster, 0);
3488+
3489+
/** Attributes not managed internally **/
3490+
global::attribute::create_cluster_revision(cluster, cluster_revision);
3491+
}
3492+
3493+
return cluster;
3494+
}
3495+
3496+
} /* wifi_network_management */
3497+
3498+
namespace thread_network_directory {
3499+
const function_generic_t *function_list = NULL;
3500+
const int function_flags = CLUSTER_FLAG_NONE;
3501+
3502+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features)
3503+
{
3504+
cluster_t *cluster = cluster::create(endpoint, ThreadNetworkDirectory::Id, flags);
3505+
if (!cluster) {
3506+
ESP_LOGE(TAG, "Could not create cluster");
3507+
return NULL;
3508+
}
3509+
if (flags & CLUSTER_FLAG_SERVER) {
3510+
static const auto plugin_server_init_cb = CALL_ONCE(MatterThreadNetworkDirectoryPluginServerInitCallback);
3511+
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
3512+
add_function_list(cluster, function_list, function_flags);
3513+
3514+
/* Attributes managed internally */
3515+
global::attribute::create_feature_map(cluster, 0);
3516+
attribute::create_preferred_extended_pan_id(cluster, nullptr, 0);
3517+
attribute::create_thread_networks(cluster, nullptr, 0, 0);
3518+
attribute::create_thread_network_table_size(cluster, 0);
3519+
3520+
/** Attributes not managed internally **/
3521+
global::attribute::create_cluster_revision(cluster, cluster_revision);
3522+
}
3523+
3524+
return cluster;
3525+
}
3526+
3527+
} /* thread_network_directory */
3528+
34683529
// namespace binary_input_basic {
34693530
// // ToDo
34703531
// } /* binary_input_basic */

‎components/esp_matter/esp_matter_cluster.h

+10
Original file line numberDiff line numberDiff line change
@@ -887,5 +887,15 @@ typedef struct config {
887887
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features);
888888
} /* thread_border_router_management */
889889

890+
namespace wifi_network_management {
891+
using config_t = common::config_t;
892+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
893+
} /* wifi_network_management */
894+
895+
namespace thread_network_directory {
896+
using config_t = common::config_t;
897+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
898+
} /* thread_network_directory */
899+
890900
} /* cluster */
891901
} /* esp_matter */

‎components/esp_matter/esp_matter_command.cpp

+68
Original file line numberDiff line numberDiff line change
@@ -3161,6 +3161,72 @@ command_t *create_set_pending_dataset_request(cluster_t *cluster)
31613161
} /* command */
31623162
} /* thread_border_router_management */
31633163

3164+
namespace wifi_network_management {
3165+
namespace command {
3166+
3167+
constexpr const command_entry_t accepted_command_list[] = {
3168+
{WiFiNetworkManagement::Commands::NetworkPassphraseRequest::Id, COMMAND_FLAG_ACCEPTED, NULL},
3169+
};
3170+
3171+
constexpr const command_entry_t generated_command_list[] = {
3172+
{WiFiNetworkManagement::Commands::NetworkPassphraseResponse::Id, COMMAND_FLAG_GENERATED, NULL},
3173+
};
3174+
3175+
command_t *create_network_passphrase_request(cluster_t *cluster)
3176+
{
3177+
return esp_matter::command::create(cluster, WiFiNetworkManagement::Commands::NetworkPassphraseRequest::Id,
3178+
COMMAND_FLAG_ACCEPTED, NULL);
3179+
}
3180+
3181+
command_t *create_network_passphrase_response(cluster_t *cluster)
3182+
{
3183+
return esp_matter::command::create(cluster, WiFiNetworkManagement::Commands::NetworkPassphraseResponse::Id,
3184+
COMMAND_FLAG_GENERATED, NULL);
3185+
}
3186+
3187+
} /* command */
3188+
} /* wifi_network_management */
3189+
3190+
namespace thread_network_directory {
3191+
namespace command {
3192+
3193+
constexpr const command_entry_t accepted_command_list[] = {
3194+
{ThreadNetworkDirectory::Commands::AddNetwork::Id, COMMAND_FLAG_ACCEPTED, NULL},
3195+
{ThreadNetworkDirectory::Commands::RemoveNetwork::Id, COMMAND_FLAG_ACCEPTED, NULL},
3196+
{ThreadNetworkDirectory::Commands::GetOperationalDataset::Id, COMMAND_FLAG_ACCEPTED, NULL},
3197+
};
3198+
3199+
constexpr const command_entry_t generated_command_list[] = {
3200+
{ThreadNetworkDirectory::Commands::OperationalDatasetResponse::Id, COMMAND_FLAG_GENERATED, NULL},
3201+
};
3202+
3203+
command_t *create_add_network(cluster_t *cluster)
3204+
{
3205+
return esp_matter::command::create(cluster, ThreadNetworkDirectory::Commands::AddNetwork::Id,
3206+
COMMAND_FLAG_ACCEPTED, NULL);
3207+
}
3208+
3209+
command_t *create_remove_network(cluster_t *cluster)
3210+
{
3211+
return esp_matter::command::create(cluster, ThreadNetworkDirectory::Commands::RemoveNetwork::Id,
3212+
COMMAND_FLAG_ACCEPTED, NULL);
3213+
}
3214+
3215+
command_t *create_get_operational_dataset(cluster_t *cluster)
3216+
{
3217+
return esp_matter::command::create(cluster, ThreadNetworkDirectory::Commands::GetOperationalDataset::Id,
3218+
COMMAND_FLAG_ACCEPTED, NULL);
3219+
}
3220+
3221+
command_t *create_operational_dataset_response(cluster_t *cluster)
3222+
{
3223+
return esp_matter::command::create(cluster, ThreadNetworkDirectory::Commands::OperationalDatasetResponse::Id,
3224+
COMMAND_FLAG_GENERATED, NULL);
3225+
}
3226+
3227+
} /* command */
3228+
} /* thread_network_directory */
3229+
31643230
} /* cluster */
31653231
} /* esp_matter */
31663232

@@ -3205,6 +3271,8 @@ constexpr const cluster_command_t cluster_command_table[] = {
32053271
{EnergyEvse::Id, GET_COMMAND_COUNT_LIST(cluster::energy_evse)},
32063272
{ValveConfigurationAndControl::Id, GET_COMMAND_COUNT_LIST(cluster::valve_configuration_and_control)},
32073273
{ThreadBorderRouterManagement::Id, GET_COMMAND_COUNT_LIST(cluster::thread_border_router_management)},
3274+
{WiFiNetworkManagement::Id, GET_COMMAND_COUNT_LIST(cluster::wifi_network_management)},
3275+
{ThreadNetworkDirectory::Id, GET_COMMAND_COUNT_LIST(cluster::thread_network_directory)},
32083276
};
32093277

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

‎components/esp_matter/esp_matter_command.h

+16
Original file line numberDiff line numberDiff line change
@@ -441,5 +441,21 @@ command_t *create_set_pending_dataset_request(cluster_t *cluster);
441441
} /* command */
442442
} /* thread_border_router_management */
443443

444+
namespace wifi_network_management {
445+
namespace command {
446+
command_t *create_network_passphrase_request(cluster_t *cluster);
447+
command_t *create_network_passphrase_response(cluster_t *cluster);
448+
} /* command */
449+
} /* wifi_network_management */
450+
451+
namespace thread_network_directory {
452+
namespace command {
453+
command_t *create_add_network(cluster_t *cluster);
454+
command_t *create_remove_network(cluster_t *cluster);
455+
command_t *create_get_operational_dataset(cluster_t *cluster);
456+
command_t *create_operational_dataset_response(cluster_t *cluster);
457+
} /* command */
458+
} /* thread_network_directory */
459+
444460
} /* cluster */
445461
} /* esp_matter */

‎components/esp_matter/private/esp_matter_cluster_revisions.h

+7
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,13 @@ namespace thread_border_router_management {
371371
constexpr uint16_t cluster_revision = 1;
372372
} // namespace thread_border_router_management
373373

374+
namespace wifi_network_management {
375+
constexpr uint16_t cluster_revision = 1;
376+
} // namespace wifi_network_management
377+
378+
namespace thread_network_directory {
379+
constexpr uint16_t cluster_revision = 1;
380+
} // namespace thread_network_directory
374381

375382
} // namespace cluster
376383
} // namespace esp_matter

0 commit comments

Comments
 (0)
Please sign in to comment.