Skip to content

Commit

Permalink
Align handling of missing SSID in ScanNetworks with spec changes. (#1…
Browse files Browse the repository at this point in the history
…7925)

Spec has made SSID optional for wifi ScanNetworks, with missing value
treated as null.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed May 7, 2022
1 parent b59a5d3 commit 6e7939c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/app/clusters/network-commissioning/network-commissioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,24 +247,22 @@ void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetw
MATTER_TRACE_EVENT_SCOPE("HandleScanNetwork", "NetworkCommissioning");
if (mFeatureFlags.Has(NetworkCommissioningFeature::kWiFiNetworkInterface))
{
if (!req.ssid.HasValue())
{
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::InvalidCommand);
return;
}
const auto nullableSSID = req.ssid.Value();
ByteSpan ssid;
if (!nullableSSID.IsNull())
if (req.ssid.HasValue())
{
ssid = nullableSSID.Value();
if (ssid.empty())
const auto & nullableSSID = req.ssid.Value();
if (!nullableSSID.IsNull())
{
// Normalize the zero value to null ByteSpan.
// Spec 7.17.1. Empty string is an equivalent of null.
ssid = ByteSpan();
ssid = nullableSSID.Value();
if (ssid.empty())
{
// Normalize empty span value to null ByteSpan.
// Spec 7.17.1. Empty string is an equivalent of null.
ssid = ByteSpan();
}
}
}
if (!(ssid.size() <= DeviceLayer::Internal::kMaxWiFiSSIDLength))
if (ssid.size() > DeviceLayer::Internal::kMaxWiFiSSIDLength)
{
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::InvalidCommand);
return;
Expand Down

0 comments on commit 6e7939c

Please sign in to comment.