Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e0d1a3b

Browse files
ksperling-applebzbarsky-applekiel-apple
authored andcommittedJul 31, 2024
Implement Thread Network Directory server (project-chip#34343)
* Update Thread Network Directory cluster definition - Use octstr[8] for ExtendedPanID fields - Add ActiveTimestamp to ThreadNetworkStruct - Remove NetworkChanged event PreferredExtendedPanID is nullable, so the uint64 representation is not suitable because the value 0xFFF... is disallowed as a null marker. Change all related attributes / fields to octstr[8] to be consistent. Also add the cluster to the relevant meta-data files. See CHIP-Specifications/connectedhomeip-spec#10019 * zap_regen_all * Implement Thread Network Directory server Also add it to the network-manager example app. * Apply suggestions from code review Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> Co-authored-by: Kiel Oleson <kielo@apple.com> * Apply suggestions from code review Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Remove stale zap generated files * Address review comments Remove DefaultInstance() and weak cluster init function and instead provide a DefaultThreadNetworkDirectoryServer sub-class that's easy to instantiate with the default storage implementation. Roll back in-memory state on persistent storage failure and add tests for this. Add documentation about ByteSpan lifetimes in OperationalDataset class. Add comments to MTRDemuxingStorage.mm * Use emberAf...ClusterInitCallback (not ...Server) * Address review comments * Avoid conversion warning --------- Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> Co-authored-by: Kiel Oleson <kielo@apple.com>
1 parent ef1dbcb commit e0d1a3b

File tree

70 files changed

+1788
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1788
-721
lines changed
 

‎examples/network-manager-app/linux/main.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
*/
1717

1818
#include <AppMain.h>
19+
#include <app/clusters/thread-network-directory-server/thread-network-directory-server.h>
1920
#include <app/clusters/wifi-network-management-server/wifi-network-management-server.h>
2021
#include <lib/core/CHIPSafeCasts.h>
22+
#include <lib/support/CodeUtils.h>
2123
#include <lib/support/Span.h>
2224

25+
#include <optional>
26+
2327
using namespace chip;
2428
using namespace chip::app;
2529
using namespace chip::app::Clusters;
@@ -32,6 +36,13 @@ ByteSpan ByteSpanFromCharSpan(CharSpan span)
3236
return ByteSpan(Uint8::from_const_char(span.data()), span.size());
3337
}
3438

39+
std::optional<DefaultThreadNetworkDirectoryServer> gThreadNetworkDirectoryServer;
40+
void emberAfThreadNetworkDirectoryClusterInitCallback(chip::EndpointId endpoint)
41+
{
42+
VerifyOrDie(!gThreadNetworkDirectoryServer);
43+
gThreadNetworkDirectoryServer.emplace(endpoint).Init();
44+
}
45+
3546
int main(int argc, char * argv[])
3647
{
3748
if (ChipLinuxAppInit(argc, argv) != 0)

‎examples/network-manager-app/network-manager-common/network-manager-app.matter

+62
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,51 @@ cluster WiFiNetworkManagement = 1105 {
11951195
command access(invoke: administer) NetworkPassphraseRequest(): NetworkPassphraseResponse = 0;
11961196
}
11971197

1198+
/** Manages the names and credentials of Thread networks visible to the user. */
1199+
cluster ThreadNetworkDirectory = 1107 {
1200+
revision 1;
1201+
1202+
struct ThreadNetworkStruct {
1203+
octet_string<8> extendedPanID = 0;
1204+
char_string<16> networkName = 1;
1205+
int16u channel = 2;
1206+
int64u activeTimestamp = 3;
1207+
}
1208+
1209+
attribute access(read: manage, write: manage) nullable octet_string<8> preferredExtendedPanID = 0;
1210+
readonly attribute access(read: operate) ThreadNetworkStruct threadNetworks[] = 1;
1211+
readonly attribute int8u threadNetworkTableSize = 2;
1212+
readonly attribute command_id generatedCommandList[] = 65528;
1213+
readonly attribute command_id acceptedCommandList[] = 65529;
1214+
readonly attribute event_id eventList[] = 65530;
1215+
readonly attribute attrib_id attributeList[] = 65531;
1216+
readonly attribute bitmap32 featureMap = 65532;
1217+
readonly attribute int16u clusterRevision = 65533;
1218+
1219+
request struct AddNetworkRequest {
1220+
octet_string<254> operationalDataset = 0;
1221+
}
1222+
1223+
request struct RemoveNetworkRequest {
1224+
octet_string<8> extendedPanID = 0;
1225+
}
1226+
1227+
request struct GetOperationalDatasetRequest {
1228+
octet_string<8> extendedPanID = 0;
1229+
}
1230+
1231+
response struct OperationalDatasetResponse = 3 {
1232+
octet_string<254> operationalDataset = 0;
1233+
}
1234+
1235+
/** Adds an entry to the ThreadNetworks list. */
1236+
timed command access(invoke: manage) AddNetwork(AddNetworkRequest): DefaultSuccess = 0;
1237+
/** Removes an entry from the ThreadNetworks list. */
1238+
timed command access(invoke: manage) RemoveNetwork(RemoveNetworkRequest): DefaultSuccess = 1;
1239+
/** Retrieves a Thread Operational Dataset from the ThreadNetworks list. */
1240+
timed command GetOperationalDataset(GetOperationalDatasetRequest): OperationalDatasetResponse = 2;
1241+
}
1242+
11981243
endpoint 0 {
11991244
device type ma_rootdevice = 22, version 1;
12001245

@@ -1473,6 +1518,23 @@ endpoint 1 {
14731518
handle command NetworkPassphraseRequest;
14741519
handle command NetworkPassphraseResponse;
14751520
}
1521+
1522+
server cluster ThreadNetworkDirectory {
1523+
callback attribute preferredExtendedPanID;
1524+
callback attribute threadNetworks;
1525+
callback attribute threadNetworkTableSize;
1526+
callback attribute generatedCommandList;
1527+
callback attribute acceptedCommandList;
1528+
callback attribute eventList;
1529+
callback attribute attributeList;
1530+
ram attribute featureMap default = 0;
1531+
ram attribute clusterRevision default = 1;
1532+
1533+
handle command AddNetwork;
1534+
handle command RemoveNetwork;
1535+
handle command GetOperationalDataset;
1536+
handle command OperationalDatasetResponse;
1537+
}
14761538
}
14771539

14781540

0 commit comments

Comments
 (0)