Skip to content

Commit

Permalink
Fix NetworkCommissioning post-review from project-chip#32156
Browse files Browse the repository at this point in the history
- Found a regression on Thread scanning.
- Changed some ConstraintError to InvalidCommand where
  more applicable.
- Removed an update of cluster state on fail safe expiry.

Testing done:

- Retested on Wi-Fi
- Testing on Thread as well
  • Loading branch information
tcarmelveilleux committed Feb 16, 2024
1 parent 1dd67c3 commit b9d5e21
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/app/clusters/network-commissioning/network-commissioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetw
}
if (ssid.size() > DeviceLayer::Internal::kMaxWiFiSSIDLength)
{
// This should not happen, it means it's a broken driver.
// Clients should never use too large a SSID.
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::ConstraintError);
SetLastNetworkingStatusValue(MakeNullable(Status::kUnknownError));
return;
Expand All @@ -491,10 +491,10 @@ void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetw
}
else if (mFeatureFlags.Has(Feature::kThreadNetworkInterface))
{
// Not allowed to populate SSID for Thread.
if (!req.ssid.HasValue())
// SSID present on Thread violates the `[WI]` conformance.
if (req.ssid.HasValue())
{
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::ConstraintError);
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::InvalidCommand);
return;
}

Expand Down Expand Up @@ -559,7 +559,7 @@ void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands
return;
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::ConstraintError);
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::InvalidCommand);
return;
}

Expand Down Expand Up @@ -1202,11 +1202,8 @@ void Instance::OnFailSafeTimerExpired()
mpWirelessDriver->RevertConfiguration();
mAsyncCommandHandle.Release();

// Reset state on failsafe expiry.
// Mark the network list changed since `mpWirelessDriver->RevertConfiguration()` may have updated it.
ReportNetworksListChanged();
SetLastNetworkId(ByteSpan{});
SetLastConnectErrorValue(NullNullable);
SetLastNetworkingStatusValue(NullNullable);
}

CHIP_ERROR Instance::EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context)
Expand Down

0 comments on commit b9d5e21

Please sign in to comment.