Skip to content

Commit

Permalink
Add supportedThreadFeatures, threadVersion and SupportedWiFiBands att…
Browse files Browse the repository at this point in the history
…ributes to some reference apps (#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
  • Loading branch information
jmartinez-silabs authored and pull[bot] committed Jan 20, 2024
1 parent a954b54 commit 1860930
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6873,6 +6873,9 @@ endpoint 0 {
ram attribute lastNetworkingStatus;
ram attribute lastNetworkID;
ram attribute lastConnectErrorValue;
callback attribute supportedWiFiBands;
callback attribute supportedThreadFeatures;
callback attribute threadVersion;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
Expand Down
48 changes: 48 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,54 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SupportedWiFiBands",
"code": 8,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SupportedThreadFeatures",
"code": 9,
"mfgCode": null,
"side": "server",
"type": "ThreadCapabilitiesBitmap",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ThreadVersion",
"code": 10,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6060,6 +6060,9 @@ endpoint 0 {
ram attribute lastNetworkingStatus;
ram attribute lastNetworkID;
ram attribute lastConnectErrorValue;
callback attribute supportedWiFiBands;
callback attribute supportedThreadFeatures;
callback attribute threadVersion;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2235,6 +2235,54 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SupportedWiFiBands",
"code": 8,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SupportedThreadFeatures",
"code": 9,
"mfgCode": null,
"side": "server",
"type": "ThreadCapabilitiesBitmap",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ThreadVersion",
"code": 10,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
Expand Down Expand Up @@ -6851,7 +6899,7 @@
"code": 0,
"mfgCode": null,
"side": "server",
"type": "int16s",
"type": "temperature",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
Expand Down Expand Up @@ -6899,7 +6947,7 @@
"code": 28,
"mfgCode": null,
"side": "server",
"type": "enum8",
"type": "SystemModeEnum",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,7 @@ endpoint 0 {
ram attribute lastNetworkingStatus;
ram attribute lastNetworkID;
ram attribute lastConnectErrorValue;
callback attribute supportedWiFiBands;
ram attribute featureMap default = 2;
ram attribute clusterRevision default = 1;

Expand Down
16 changes: 16 additions & 0 deletions examples/lighting-app/silabs/data_model/lighting-wifi-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,22 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SupportedWiFiBands",
"code": 8,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand Down
91 changes: 64 additions & 27 deletions src/app/clusters/network-commissioning/network-commissioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,39 +273,76 @@ CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValu
case Attributes::ClusterRevision::Id:
return aEncoder.Encode(kCurrentClusterRevision);

case Attributes::SupportedWiFiBands::Id:
#if (!CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION && !CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP)
return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute);
#else
VerifyOrReturnError(mFeatureFlags.Has(Feature::kWiFiNetworkInterface), CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));

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

// Extract every band from the bitmap of supported bands, starting positionally on the right.
for (uint32_t band_bit_pos = 0; band_bit_pos < std::numeric_limits<uint32_t>::digits; ++band_bit_pos)
{
uint32_t band_mask = static_cast<uint32_t>(1UL << band_bit_pos);
if ((bands & band_mask) != 0)
// Extract every band from the bitmap of supported bands, starting positionally on the right.
for (uint32_t band_bit_pos = 0; band_bit_pos < std::numeric_limits<uint32_t>::digits; ++band_bit_pos)
{
ReturnErrorOnFailure(encoder.Encode(static_cast<WiFiBandEnum>(band_bit_pos)));
uint32_t band_mask = static_cast<uint32_t>(1UL << band_bit_pos);
if ((bands & band_mask) != 0)
{
ReturnErrorOnFailure(encoder.Encode(static_cast<WiFiBandEnum>(band_bit_pos)));
}
}
}
return CHIP_NO_ERROR;
});
}
#endif
return aEncoder.EncodeList([](const auto & encoder) {
WiFiBandEnum bands = WiFiBandEnum::k2g4;
ReturnErrorOnFailure(encoder.Encode(bands));
return CHIP_NO_ERROR;
});
}
break;
case Attributes::SupportedThreadFeatures::Id: {
// TODO https://github.com/project-chip/connectedhomeip/issues/31431
BitMask<ThreadCapabilities> ThreadCapabilities = 0;
#if (CHIP_DEVICE_CONFIG_ENABLE_THREAD)
// This is a case of shared zap config where mandatory thread attributes are enabled for a wifi platform (e.g
// all-cluster-app). Real world product must only enable the attributes tied to the network technology supported by their
// product. Temporarily encode a value of 0 reflecting no thread capabilities hen CHIP_DEVICE_CONFIG_ENABLE_THREAD or
// ThreadNetworkInterface are not enabled until a solution is implemented with the attribute list.
// Final implementation will return UnsupportedAttribute if we get here without the needed thread support
// VerifyOrReturnError(mFeatureFlags.Has(Feature::kThreadNetworkInterface), CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
if (mFeatureFlags.Has(Feature::kThreadNetworkInterface))
{
ThreadCapabilities = mpDriver.Get<ThreadDriver *>()->GetSupportedThreadFeatures();
}
#endif
break;

case Attributes::SupportedThreadFeatures::Id:
VerifyOrReturnError(mFeatureFlags.Has(Feature::kThreadNetworkInterface), CHIP_NO_ERROR);
VerifyOrReturnError(mpDriver.Valid(), CHIP_NO_ERROR);
return aEncoder.Encode(mpDriver.Get<ThreadDriver *>()->GetSupportedThreadFeatures());

case Attributes::ThreadVersion::Id:
VerifyOrReturnError(mFeatureFlags.Has(Feature::kThreadNetworkInterface), CHIP_NO_ERROR);
VerifyOrReturnError(mpDriver.Valid(), CHIP_NO_ERROR);
return aEncoder.Encode(mpDriver.Get<ThreadDriver *>()->GetThreadVersion());

return aEncoder.Encode(ThreadCapabilities);
}
break;
case Attributes::ThreadVersion::Id: {
// TODO https://github.com/project-chip/connectedhomeip/issues/31431ß
uint16_t threadVersion = 0;
#if (CHIP_DEVICE_CONFIG_ENABLE_THREAD)
// This is a case of shared zap config where mandatory thread attributes are enabled for a wifi platform (e.g
// all-cluster-app) Real world product must only enable the attributes tied to the network technology supported by their
// product. Temporarily encode a value of 0 reflecting no thread version when CHIP_DEVICE_CONFIG_ENABLE_THREAD or
// ThreadNetworkInterface are not enabled until a solution is implemented with the attribute list.
// Final implementation will return UnsupportedAttribute if we get here without the needed thread support
// VerifyOrReturnError(mFeatureFlags.Has(Feature::kThreadNetworkInterface), CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
if (mFeatureFlags.Has(Feature::kThreadNetworkInterface))
{
threadVersion = mpDriver.Get<ThreadDriver *>()->GetThreadVersion();
}
#endif
return aEncoder.Encode(threadVersion);
}
break;
default:
return CHIP_NO_ERROR;
}
Expand Down

0 comments on commit 1860930

Please sign in to comment.