@@ -266,7 +266,9 @@ void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetw
266
266
}
267
267
if (ssid.size () > DeviceLayer::Internal::kMaxWiFiSSIDLength )
268
268
{
269
- ctx.mCommandHandler .AddStatus (ctx.mRequestPath , Protocols::InteractionModel::Status::InvalidCommand);
269
+ // Clients should never use too large a SSID.
270
+ ctx.mCommandHandler .AddStatus (ctx.mRequestPath , Protocols::InteractionModel::Status::ConstraintError);
271
+ SetLastNetworkingStatusValue (MakeNullable (Status::kUnknownError ));
270
272
return ;
271
273
}
272
274
mCurrentOperationBreadcrumb = req.breadcrumb ;
@@ -276,6 +278,13 @@ void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetw
276
278
}
277
279
else if (mFeatureFlags .Has (NetworkCommissioningFeature::kThreadNetworkInterface ))
278
280
{
281
+ // SSID present on Thread violates the `[WI]` conformance.
282
+ if (req.ssid .HasValue ())
283
+ {
284
+ ctx.mCommandHandler .AddStatus (ctx.mRequestPath , Protocols::InteractionModel::Status::InvalidCommand);
285
+ return ;
286
+ }
287
+
279
288
mCurrentOperationBreadcrumb = req.breadcrumb ;
280
289
mAsyncCommandHandle = CommandHandler::Handle (&ctx.mCommandHandler );
281
290
ctx.mCommandHandler .FlushAcksRightAwayOnSlowCommand ();
@@ -322,6 +331,26 @@ void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands
322
331
323
332
VerifyOrReturn (CheckFailSafeArmed (ctx));
324
333
334
+ if (req.ssid .empty () || req.ssid .size () > DeviceLayer::Internal::kMaxWiFiSSIDLength )
335
+ {
336
+ ctx.mCommandHandler .AddStatus (ctx.mRequestPath , Protocols::InteractionModel::Status::ConstraintError, " ssid" );
337
+ return ;
338
+ }
339
+
340
+ // Presence of a Network Identity indicates we're configuring for Per-Device Credentials
341
+ if (req.networkIdentity .HasValue ())
342
+ {
343
+ #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC
344
+ if (mFeatureFlags .Has (Feature::kWiFiNetworkInterface ))
345
+ {
346
+ HandleAddOrUpdateWiFiNetworkWithPDC (ctx, req);
347
+ return ;
348
+ }
349
+ #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_PDC
350
+ ctx.mCommandHandler .AddStatus (ctx.mRequestPath , Protocols::InteractionModel::Status::InvalidCommand);
351
+ return ;
352
+ }
353
+
325
354
// Spec 11.8.8.4
326
355
// Valid Credentials length are:
327
356
// - 0 bytes: Unsecured (open) connection
@@ -671,6 +700,17 @@ void Instance::OnFailSafeTimerExpired()
671
700
ChipLogDetail (Zcl, " Failsafe timeout, tell platform driver to revert network credentials." );
672
701
mpWirelessDriver->RevertConfiguration ();
673
702
mAsyncCommandHandle .Release ();
703
+
704
+ // Mark the network list changed since `mpWirelessDriver->RevertConfiguration()` may have updated it.
705
+ ReportNetworksListChanged ();
706
+
707
+ // If no networks are left, clear-out errors;
708
+ if (mpBaseDriver && (CountAndRelease (mpBaseDriver->GetNetworks ()) == 0 ))
709
+ {
710
+ SetLastNetworkId (ByteSpan{});
711
+ SetLastConnectErrorValue (NullNullable);
712
+ SetLastNetworkingStatusValue (NullNullable);
713
+ }
674
714
}
675
715
676
716
CHIP_ERROR Instance::EnumerateAcceptedCommands (const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context)
0 commit comments