Skip to content

Commit b9f116b

Browse files
jmartinez-silabslpbeliveau-silabs
authored andcommitted
Add supportedThreadFeatures, threadVersion and SupportedWiFiBands attributes to some reference apps (project-chip#31328)
* Update zap file of some reference apps to enable supportedThreadFeatures, threadVersion and SupportedWiFiBands attributes of the network commissioning cluster * regen all * Revert change to examples other than all-clusters apps * Gate the encoding base on the Network type define enablement define. Return UnsupportedAttribute otherwise. * fix conflicts * fixup * Rework condition logic to fix CI issue with linux all-cluster-app * Fix Clang-tidy validation
1 parent 8371dc9 commit b9f116b

File tree

7 files changed

+185
-29
lines changed

7 files changed

+185
-29
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+3
Original file line numberDiff line numberDiff line change
@@ -6829,6 +6829,9 @@ endpoint 0 {
68296829
ram attribute lastNetworkingStatus;
68306830
ram attribute lastNetworkID;
68316831
ram attribute lastConnectErrorValue;
6832+
callback attribute supportedWiFiBands;
6833+
callback attribute supportedThreadFeatures;
6834+
callback attribute threadVersion;
68326835
callback attribute generatedCommandList;
68336836
callback attribute acceptedCommandList;
68346837
callback attribute eventList;

examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

+48
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,54 @@
25622562
"maxInterval": 65534,
25632563
"reportableChange": 0
25642564
},
2565+
{
2566+
"name": "SupportedWiFiBands",
2567+
"code": 8,
2568+
"mfgCode": null,
2569+
"side": "server",
2570+
"type": "array",
2571+
"included": 1,
2572+
"storageOption": "External",
2573+
"singleton": 0,
2574+
"bounded": 0,
2575+
"defaultValue": "",
2576+
"reportable": 1,
2577+
"minInterval": 1,
2578+
"maxInterval": 65534,
2579+
"reportableChange": 0
2580+
},
2581+
{
2582+
"name": "SupportedThreadFeatures",
2583+
"code": 9,
2584+
"mfgCode": null,
2585+
"side": "server",
2586+
"type": "ThreadCapabilitiesBitmap",
2587+
"included": 1,
2588+
"storageOption": "External",
2589+
"singleton": 0,
2590+
"bounded": 0,
2591+
"defaultValue": "",
2592+
"reportable": 1,
2593+
"minInterval": 1,
2594+
"maxInterval": 65534,
2595+
"reportableChange": 0
2596+
},
2597+
{
2598+
"name": "ThreadVersion",
2599+
"code": 10,
2600+
"mfgCode": null,
2601+
"side": "server",
2602+
"type": "int16u",
2603+
"included": 1,
2604+
"storageOption": "External",
2605+
"singleton": 0,
2606+
"bounded": 0,
2607+
"defaultValue": "",
2608+
"reportable": 1,
2609+
"minInterval": 1,
2610+
"maxInterval": 65534,
2611+
"reportableChange": 0
2612+
},
25652613
{
25662614
"name": "GeneratedCommandList",
25672615
"code": 65528,

examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter

+3
Original file line numberDiff line numberDiff line change
@@ -6016,6 +6016,9 @@ endpoint 0 {
60166016
ram attribute lastNetworkingStatus;
60176017
ram attribute lastNetworkID;
60186018
ram attribute lastConnectErrorValue;
6019+
callback attribute supportedWiFiBands;
6020+
callback attribute supportedThreadFeatures;
6021+
callback attribute threadVersion;
60196022
callback attribute generatedCommandList;
60206023
callback attribute acceptedCommandList;
60216024
callback attribute eventList;

examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap

+50-2
Original file line numberDiff line numberDiff line change
@@ -2235,6 +2235,54 @@
22352235
"maxInterval": 65534,
22362236
"reportableChange": 0
22372237
},
2238+
{
2239+
"name": "SupportedWiFiBands",
2240+
"code": 8,
2241+
"mfgCode": null,
2242+
"side": "server",
2243+
"type": "array",
2244+
"included": 1,
2245+
"storageOption": "External",
2246+
"singleton": 0,
2247+
"bounded": 0,
2248+
"defaultValue": "",
2249+
"reportable": 1,
2250+
"minInterval": 1,
2251+
"maxInterval": 65534,
2252+
"reportableChange": 0
2253+
},
2254+
{
2255+
"name": "SupportedThreadFeatures",
2256+
"code": 9,
2257+
"mfgCode": null,
2258+
"side": "server",
2259+
"type": "ThreadCapabilitiesBitmap",
2260+
"included": 1,
2261+
"storageOption": "External",
2262+
"singleton": 0,
2263+
"bounded": 0,
2264+
"defaultValue": "",
2265+
"reportable": 1,
2266+
"minInterval": 1,
2267+
"maxInterval": 65534,
2268+
"reportableChange": 0
2269+
},
2270+
{
2271+
"name": "ThreadVersion",
2272+
"code": 10,
2273+
"mfgCode": null,
2274+
"side": "server",
2275+
"type": "int16u",
2276+
"included": 1,
2277+
"storageOption": "External",
2278+
"singleton": 0,
2279+
"bounded": 0,
2280+
"defaultValue": "",
2281+
"reportable": 1,
2282+
"minInterval": 1,
2283+
"maxInterval": 65534,
2284+
"reportableChange": 0
2285+
},
22382286
{
22392287
"name": "GeneratedCommandList",
22402288
"code": 65528,
@@ -6835,7 +6883,7 @@
68356883
"code": 0,
68366884
"mfgCode": null,
68376885
"side": "server",
6838-
"type": "int16s",
6886+
"type": "temperature",
68396887
"included": 1,
68406888
"storageOption": "RAM",
68416889
"singleton": 0,
@@ -6883,7 +6931,7 @@
68836931
"code": 28,
68846932
"mfgCode": null,
68856933
"side": "server",
6886-
"type": "enum8",
6934+
"type": "SystemModeEnum",
68876935
"included": 1,
68886936
"storageOption": "RAM",
68896937
"singleton": 0,

examples/lighting-app/silabs/data_model/lighting-wifi-app.matter

+1
Original file line numberDiff line numberDiff line change
@@ -2394,6 +2394,7 @@ endpoint 0 {
23942394
ram attribute lastNetworkingStatus;
23952395
ram attribute lastNetworkID;
23962396
ram attribute lastConnectErrorValue;
2397+
callback attribute supportedWiFiBands;
23972398
ram attribute featureMap default = 2;
23982399
ram attribute clusterRevision default = 1;
23992400

examples/lighting-app/silabs/data_model/lighting-wifi-app.zap

+16
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,22 @@
14281428
"maxInterval": 65534,
14291429
"reportableChange": 0
14301430
},
1431+
{
1432+
"name": "SupportedWiFiBands",
1433+
"code": 8,
1434+
"mfgCode": null,
1435+
"side": "server",
1436+
"type": "array",
1437+
"included": 1,
1438+
"storageOption": "External",
1439+
"singleton": 0,
1440+
"bounded": 0,
1441+
"defaultValue": "",
1442+
"reportable": 1,
1443+
"minInterval": 1,
1444+
"maxInterval": 65534,
1445+
"reportableChange": 0
1446+
},
14311447
{
14321448
"name": "FeatureMap",
14331449
"code": 65532,

src/app/clusters/network-commissioning/network-commissioning.cpp

+64-27
Original file line numberDiff line numberDiff line change
@@ -273,39 +273,76 @@ CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValu
273273
case Attributes::ClusterRevision::Id:
274274
return aEncoder.Encode(kCurrentClusterRevision);
275275

276-
case Attributes::SupportedWiFiBands::Id:
277-
#if (!CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION && !CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP)
278-
return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute);
279-
#else
280-
VerifyOrReturnError(mFeatureFlags.Has(Feature::kWiFiNetworkInterface), CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
281-
282-
return aEncoder.EncodeList([this](const auto & encoder) {
283-
uint32_t bands = mpDriver.Get<WiFiDriver *>()->GetSupportedWiFiBandsMask();
276+
case Attributes::SupportedWiFiBands::Id: {
277+
#if (CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP)
278+
// TODO https://github.com/project-chip/connectedhomeip/issues/31431
279+
// This is a case of shared zap config where mandatory wifi attributes are enabled for a thread platform (e.g
280+
// all-cluster-app). Real world product must only enable the attributes tied to the network technology supported by their
281+
// product. Temporarily return an list of 1 element of value 0 when wifi is not supported or WiFiNetworkInterface is not
282+
// enabled until a solution is implemented with the attribute list.
283+
// Final implementation will return UnsupportedAttribute if we get here without the needed WiFi support .
284+
// VerifyOrReturnError(mFeatureFlags.Has(Feature::kWiFiNetworkInterface), CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
285+
if (mFeatureFlags.Has(Feature::kWiFiNetworkInterface))
286+
{
287+
return aEncoder.EncodeList([this](const auto & encoder) {
288+
uint32_t bands = mpDriver.Get<WiFiDriver *>()->GetSupportedWiFiBandsMask();
284289

285-
// Extract every band from the bitmap of supported bands, starting positionally on the right.
286-
for (uint32_t band_bit_pos = 0; band_bit_pos < std::numeric_limits<uint32_t>::digits; ++band_bit_pos)
287-
{
288-
uint32_t band_mask = static_cast<uint32_t>(1UL << band_bit_pos);
289-
if ((bands & band_mask) != 0)
290+
// Extract every band from the bitmap of supported bands, starting positionally on the right.
291+
for (uint32_t band_bit_pos = 0; band_bit_pos < std::numeric_limits<uint32_t>::digits; ++band_bit_pos)
290292
{
291-
ReturnErrorOnFailure(encoder.Encode(static_cast<WiFiBandEnum>(band_bit_pos)));
293+
uint32_t band_mask = static_cast<uint32_t>(1UL << band_bit_pos);
294+
if ((bands & band_mask) != 0)
295+
{
296+
ReturnErrorOnFailure(encoder.Encode(static_cast<WiFiBandEnum>(band_bit_pos)));
297+
}
292298
}
293-
}
299+
return CHIP_NO_ERROR;
300+
});
301+
}
302+
#endif
303+
return aEncoder.EncodeList([](const auto & encoder) {
304+
WiFiBandEnum bands = WiFiBandEnum::k2g4;
305+
ReturnErrorOnFailure(encoder.Encode(bands));
294306
return CHIP_NO_ERROR;
295307
});
308+
}
309+
break;
310+
case Attributes::SupportedThreadFeatures::Id: {
311+
// TODO https://github.com/project-chip/connectedhomeip/issues/31431
312+
BitMask<ThreadCapabilities> ThreadCapabilities = 0;
313+
#if (CHIP_DEVICE_CONFIG_ENABLE_THREAD)
314+
// This is a case of shared zap config where mandatory thread attributes are enabled for a wifi platform (e.g
315+
// all-cluster-app). Real world product must only enable the attributes tied to the network technology supported by their
316+
// product. Temporarily encode a value of 0 reflecting no thread capabilities hen CHIP_DEVICE_CONFIG_ENABLE_THREAD or
317+
// ThreadNetworkInterface are not enabled until a solution is implemented with the attribute list.
318+
// Final implementation will return UnsupportedAttribute if we get here without the needed thread support
319+
// VerifyOrReturnError(mFeatureFlags.Has(Feature::kThreadNetworkInterface), CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
320+
if (mFeatureFlags.Has(Feature::kThreadNetworkInterface))
321+
{
322+
ThreadCapabilities = mpDriver.Get<ThreadDriver *>()->GetSupportedThreadFeatures();
323+
}
296324
#endif
297-
break;
298-
299-
case Attributes::SupportedThreadFeatures::Id:
300-
VerifyOrReturnError(mFeatureFlags.Has(Feature::kThreadNetworkInterface), CHIP_NO_ERROR);
301-
VerifyOrReturnError(mpDriver.Valid(), CHIP_NO_ERROR);
302-
return aEncoder.Encode(mpDriver.Get<ThreadDriver *>()->GetSupportedThreadFeatures());
303-
304-
case Attributes::ThreadVersion::Id:
305-
VerifyOrReturnError(mFeatureFlags.Has(Feature::kThreadNetworkInterface), CHIP_NO_ERROR);
306-
VerifyOrReturnError(mpDriver.Valid(), CHIP_NO_ERROR);
307-
return aEncoder.Encode(mpDriver.Get<ThreadDriver *>()->GetThreadVersion());
308-
325+
return aEncoder.Encode(ThreadCapabilities);
326+
}
327+
break;
328+
case Attributes::ThreadVersion::Id: {
329+
// TODO https://github.com/project-chip/connectedhomeip/issues/31431ß
330+
uint16_t threadVersion = 0;
331+
#if (CHIP_DEVICE_CONFIG_ENABLE_THREAD)
332+
// This is a case of shared zap config where mandatory thread attributes are enabled for a wifi platform (e.g
333+
// all-cluster-app) Real world product must only enable the attributes tied to the network technology supported by their
334+
// product. Temporarily encode a value of 0 reflecting no thread version when CHIP_DEVICE_CONFIG_ENABLE_THREAD or
335+
// ThreadNetworkInterface are not enabled until a solution is implemented with the attribute list.
336+
// Final implementation will return UnsupportedAttribute if we get here without the needed thread support
337+
// VerifyOrReturnError(mFeatureFlags.Has(Feature::kThreadNetworkInterface), CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
338+
if (mFeatureFlags.Has(Feature::kThreadNetworkInterface))
339+
{
340+
threadVersion = mpDriver.Get<ThreadDriver *>()->GetThreadVersion();
341+
}
342+
#endif
343+
return aEncoder.Encode(threadVersion);
344+
}
345+
break;
309346
default:
310347
return CHIP_NO_ERROR;
311348
}

0 commit comments

Comments
 (0)