Skip to content

Commit fc3591d

Browse files
Add Wi-Fi Network Management Cluster and use correct NIM device type id (#33519)
* Add Wi-Fi Network Management Cluster and use correct NIM device type id * zap_regen_all * Change minimal CI job to build network-manager-app * Keep the minimal all-clusters-app build since it's required for merge * Cluster ID should be 0x0451 * zap_regen_all * Address review comments and other small tweaks - Factor out HaveNetworkCredentials() helper and use it consistently - Validate WPA credential in SetNetworkCredentials() - Don't emit an SSID change when only the passphrase changes - Use CHIPSafeCasts - Avoid std::bind (and we can't use std::bind_front yet) - Add a destructor that unregisters handlers * Address review comments - Rename Server -> WiFiNetworkManagementServer and move it up a namespace. - Move internal definitions into an anonymous namespace.
1 parent 8c8889b commit fc3591d

File tree

57 files changed

+4515
-15
lines changed

Some content is hidden

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

57 files changed

+4515
-15
lines changed

.github/workflows/minimal-build.yaml

+23-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ concurrency:
2626
cancel-in-progress: true
2727

2828
jobs:
29-
minimal:
29+
minimal-all-clusters:
3030
name: Linux / configure build of all-clusters-app
3131

3232
if: github.actor != 'restyled-io[bot]'
@@ -47,3 +47,25 @@ jobs:
4747
- name: Configure and build All Clusters App
4848
run: |
4949
CC=gcc CXX=g++ scripts/configure --project=examples/all-clusters-app/linux && ./ninja-build
50+
51+
minimal-network-manager:
52+
name: Linux / configure build of network-manager-app
53+
54+
if: github.actor != 'restyled-io[bot]'
55+
runs-on: ubuntu-latest
56+
57+
container:
58+
image: ghcr.io/project-chip/chip-build-minimal:50
59+
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
64+
- name: Checkout submodules # but don't bootstrap!
65+
uses: ./.github/actions/checkout-submodules
66+
with:
67+
platform: linux
68+
69+
- name: Configure and build Network Manager App
70+
run: |
71+
CC=gcc CXX=g++ scripts/configure --project=examples/network-manager-app/linux && ./ninja-build

.github/workflows/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ jobs:
189189
src/app/zap-templates/zcl/data-model/chip/wake-on-lan-cluster.xml \
190190
src/app/zap-templates/zcl/data-model/chip/washer-controls-cluster.xml \
191191
src/app/zap-templates/zcl/data-model/chip/wifi-network-diagnostics-cluster.xml \
192+
src/app/zap-templates/zcl/data-model/chip/wifi-network-management-cluster.xml \
192193
src/app/zap-templates/zcl/data-model/chip/window-covering.xml \
193194
src/app/zap-templates/zcl/data-model/chip/temperature-control-cluster.xml \
194195
src/app/zap-templates/zcl/data-model/chip/matter-devices.xml \

docs/zap_clusters.md

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Generally regenerate using one of:
112112
| 1069 | 0x42D | Pm10ConcentrationMeasurement |
113113
| 1070 | 0x42E | TotalVolatileOrganicCompoundsConcentrationMeasurement |
114114
| 1071 | 0x42F | RadonConcentrationMeasurement |
115+
| 1105 | 0x451 | WiFiNetworkManagement |
115116
| 1283 | 0x503 | WakeOnLan |
116117
| 1284 | 0x504 | Channel |
117118
| 1285 | 0x505 | TargetNavigator |

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

+12
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,32 @@
1616
*/
1717

1818
#include <AppMain.h>
19+
#include <app/clusters/wifi-network-management-server/wifi-network-management-server.h>
20+
#include <lib/core/CHIPSafeCasts.h>
21+
#include <lib/support/Span.h>
1922

2023
using namespace chip;
2124
using namespace chip::app;
25+
using namespace chip::app::Clusters;
2226

2327
void ApplicationInit() {}
2428
void ApplicationShutdown() {}
2529

30+
ByteSpan ByteSpanFromCharSpan(CharSpan span)
31+
{
32+
return ByteSpan(Uint8::from_const_char(span.data()), span.size());
33+
}
34+
2635
int main(int argc, char * argv[])
2736
{
2837
if (ChipLinuxAppInit(argc, argv) != 0)
2938
{
3039
return -1;
3140
}
3241

42+
WiFiNetworkManagementServer::Instance().SetNetworkCredentials(ByteSpanFromCharSpan("MatterAP"_span),
43+
ByteSpanFromCharSpan("Setec Astronomy"_span));
44+
3345
ChipLinuxAppMainLoop();
3446
return 0;
3547
}

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

+35-2
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,26 @@ cluster GroupKeyManagement = 63 {
11751175
fabric command access(invoke: administer) KeySetReadAllIndices(): KeySetReadAllIndicesResponse = 4;
11761176
}
11771177

1178+
/** Functionality to retrieve operational information about a managed Wi-Fi network. */
1179+
cluster WiFiNetworkManagement = 1105 {
1180+
revision 1;
1181+
1182+
readonly attribute nullable octet_string<32> ssid = 1;
1183+
readonly attribute command_id generatedCommandList[] = 65528;
1184+
readonly attribute command_id acceptedCommandList[] = 65529;
1185+
readonly attribute event_id eventList[] = 65530;
1186+
readonly attribute attrib_id attributeList[] = 65531;
1187+
readonly attribute bitmap32 featureMap = 65532;
1188+
readonly attribute int16u clusterRevision = 65533;
1189+
1190+
response struct NetworkPassphraseResponse = 1 {
1191+
octet_string<64> passphrase = 0;
1192+
}
1193+
1194+
/** Request the current WPA-Personal passphrase or PSK associated with the managed Wi-Fi network. */
1195+
command access(invoke: administer) NetworkPassphraseRequest(): NetworkPassphraseResponse = 0;
1196+
}
1197+
11781198
endpoint 0 {
11791199
device type ma_rootdevice = 22, version 1;
11801200

@@ -1280,7 +1300,7 @@ endpoint 0 {
12801300
callback attribute acceptedCommandList;
12811301
callback attribute attributeList;
12821302
callback attribute featureMap default = 0;
1283-
ram attribute clusterRevision default = 1;
1303+
callback attribute clusterRevision default = 0;
12841304
}
12851305

12861306
server cluster GeneralDiagnostics {
@@ -1425,7 +1445,7 @@ endpoint 0 {
14251445
}
14261446
}
14271447
endpoint 1 {
1428-
device type ma_network_infrastructure_manager = 4293984272, version 1;
1448+
device type ma_network_infrastructure_manager = 144, version 1;
14291449

14301450

14311451
server cluster Descriptor {
@@ -1440,6 +1460,19 @@ endpoint 1 {
14401460
callback attribute featureMap;
14411461
callback attribute clusterRevision;
14421462
}
1463+
1464+
server cluster WiFiNetworkManagement {
1465+
callback attribute ssid;
1466+
callback attribute generatedCommandList;
1467+
callback attribute acceptedCommandList;
1468+
callback attribute eventList;
1469+
callback attribute attributeList;
1470+
ram attribute featureMap default = 0;
1471+
ram attribute clusterRevision default = 1;
1472+
1473+
handle command NetworkPassphraseRequest;
1474+
handle command NetworkPassphraseResponse;
1475+
}
14431476
}
14441477

14451478

examples/network-manager-app/network-manager-common/network-manager-app.zap

+149-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"fileFormat": 2,
3-
"featureLevel": 100,
3+
"featureLevel": 102,
44
"creator": "zap",
55
"keyValuePairs": [
66
{
@@ -13,7 +13,7 @@
1313
},
1414
{
1515
"key": "manufacturerCodes",
16-
"value": "0x1002"
16+
"value": "0xFFF1"
1717
}
1818
],
1919
"package": [
@@ -29,6 +29,7 @@
2929
"pathRelativity": "relativeToZap",
3030
"path": "../../../src/app/zap-templates/app-templates.json",
3131
"type": "gen-templates-json",
32+
"category": "matter",
3233
"version": "chip-v1"
3334
}
3435
],
@@ -1352,10 +1353,10 @@
13521353
"side": "server",
13531354
"type": "int16u",
13541355
"included": 1,
1355-
"storageOption": "RAM",
1356+
"storageOption": "External",
13561357
"singleton": 0,
13571358
"bounded": 0,
1358-
"defaultValue": "1",
1359+
"defaultValue": "0",
13591360
"reportable": 1,
13601361
"minInterval": 0,
13611362
"maxInterval": 65344,
@@ -3016,14 +3017,14 @@
30163017
"id": 2,
30173018
"name": "Anonymous Endpoint Type",
30183019
"deviceTypeRef": {
3019-
"code": 4293984272,
3020+
"code": 144,
30203021
"profileId": 259,
30213022
"label": "MA-network-infrastructure-manager",
30223023
"name": "MA-network-infrastructure-manager"
30233024
},
30243025
"deviceTypes": [
30253026
{
3026-
"code": 4293984272,
3027+
"code": 144,
30273028
"profileId": 259,
30283029
"label": "MA-network-infrastructure-manager",
30293030
"name": "MA-network-infrastructure-manager"
@@ -3033,10 +3034,10 @@
30333034
1
30343035
],
30353036
"deviceIdentifiers": [
3036-
4293984272
3037+
144
30373038
],
30383039
"deviceTypeName": "MA-network-infrastructure-manager",
3039-
"deviceTypeCode": 4293984272,
3040+
"deviceTypeCode": 144,
30403041
"deviceTypeProfileId": 259,
30413042
"clusters": [
30423043
{
@@ -3208,6 +3209,146 @@
32083209
"reportableChange": 0
32093210
}
32103211
]
3212+
},
3213+
{
3214+
"name": "Wi-Fi Network Management",
3215+
"code": 1105,
3216+
"mfgCode": null,
3217+
"define": "WIFI_NETWORK_MANAGEMENT_CLUSTER",
3218+
"side": "server",
3219+
"enabled": 1,
3220+
"commands": [
3221+
{
3222+
"name": "NetworkPassphraseRequest",
3223+
"code": 0,
3224+
"mfgCode": null,
3225+
"source": "client",
3226+
"isIncoming": 1,
3227+
"isEnabled": 1
3228+
},
3229+
{
3230+
"name": "NetworkPassphraseResponse",
3231+
"code": 1,
3232+
"mfgCode": null,
3233+
"source": "server",
3234+
"isIncoming": 0,
3235+
"isEnabled": 1
3236+
}
3237+
],
3238+
"attributes": [
3239+
{
3240+
"name": "SSID",
3241+
"code": 1,
3242+
"mfgCode": null,
3243+
"side": "server",
3244+
"type": "octet_string",
3245+
"included": 1,
3246+
"storageOption": "External",
3247+
"singleton": 0,
3248+
"bounded": 0,
3249+
"defaultValue": null,
3250+
"reportable": 1,
3251+
"minInterval": 1,
3252+
"maxInterval": 65534,
3253+
"reportableChange": 0
3254+
},
3255+
{
3256+
"name": "GeneratedCommandList",
3257+
"code": 65528,
3258+
"mfgCode": null,
3259+
"side": "server",
3260+
"type": "array",
3261+
"included": 1,
3262+
"storageOption": "External",
3263+
"singleton": 0,
3264+
"bounded": 0,
3265+
"defaultValue": null,
3266+
"reportable": 1,
3267+
"minInterval": 1,
3268+
"maxInterval": 65534,
3269+
"reportableChange": 0
3270+
},
3271+
{
3272+
"name": "AcceptedCommandList",
3273+
"code": 65529,
3274+
"mfgCode": null,
3275+
"side": "server",
3276+
"type": "array",
3277+
"included": 1,
3278+
"storageOption": "External",
3279+
"singleton": 0,
3280+
"bounded": 0,
3281+
"defaultValue": null,
3282+
"reportable": 1,
3283+
"minInterval": 1,
3284+
"maxInterval": 65534,
3285+
"reportableChange": 0
3286+
},
3287+
{
3288+
"name": "EventList",
3289+
"code": 65530,
3290+
"mfgCode": null,
3291+
"side": "server",
3292+
"type": "array",
3293+
"included": 1,
3294+
"storageOption": "External",
3295+
"singleton": 0,
3296+
"bounded": 0,
3297+
"defaultValue": null,
3298+
"reportable": 1,
3299+
"minInterval": 1,
3300+
"maxInterval": 65534,
3301+
"reportableChange": 0
3302+
},
3303+
{
3304+
"name": "AttributeList",
3305+
"code": 65531,
3306+
"mfgCode": null,
3307+
"side": "server",
3308+
"type": "array",
3309+
"included": 1,
3310+
"storageOption": "External",
3311+
"singleton": 0,
3312+
"bounded": 0,
3313+
"defaultValue": null,
3314+
"reportable": 1,
3315+
"minInterval": 1,
3316+
"maxInterval": 65534,
3317+
"reportableChange": 0
3318+
},
3319+
{
3320+
"name": "FeatureMap",
3321+
"code": 65532,
3322+
"mfgCode": null,
3323+
"side": "server",
3324+
"type": "bitmap32",
3325+
"included": 1,
3326+
"storageOption": "RAM",
3327+
"singleton": 0,
3328+
"bounded": 0,
3329+
"defaultValue": "0",
3330+
"reportable": 1,
3331+
"minInterval": 1,
3332+
"maxInterval": 65534,
3333+
"reportableChange": 0
3334+
},
3335+
{
3336+
"name": "ClusterRevision",
3337+
"code": 65533,
3338+
"mfgCode": null,
3339+
"side": "server",
3340+
"type": "int16u",
3341+
"included": 1,
3342+
"storageOption": "RAM",
3343+
"singleton": 0,
3344+
"bounded": 0,
3345+
"defaultValue": "1",
3346+
"reportable": 1,
3347+
"minInterval": 1,
3348+
"maxInterval": 65534,
3349+
"reportableChange": 0
3350+
}
3351+
]
32113352
}
32123353
]
32133354
}

scripts/rules.matterlint

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ load "../src/app/zap-templates/zcl/data-model/chip/user-label-cluster.xml";
9797
load "../src/app/zap-templates/zcl/data-model/chip/wake-on-lan-cluster.xml";
9898
load "../src/app/zap-templates/zcl/data-model/chip/washer-controls-cluster.xml";
9999
load "../src/app/zap-templates/zcl/data-model/chip/wifi-network-diagnostics-cluster.xml";
100+
load "../src/app/zap-templates/zcl/data-model/chip/wifi-network-management-cluster.xml";
100101
load "../src/app/zap-templates/zcl/data-model/chip/window-covering.xml";
101102
load "../src/app/zap-templates/zcl/data-model/chip/temperature-control-cluster.xml";
102103
load "../src/app/zap-templates/zcl/data-model/chip/refrigerator-alarm.xml";

src/app/CommandHandlerInterface.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
#include <app/ConcreteCommandPath.h>
2424
#include <app/data-model/Decode.h>
2525
#include <app/data-model/List.h> // So we can encode lists
26+
#include <functional>
2627
#include <lib/core/DataModelTypes.h>
2728
#include <lib/support/Iterators.h>
29+
#include <type_traits>
2830

2931
namespace chip {
3032
namespace app {

0 commit comments

Comments
 (0)