@@ -648,14 +648,15 @@ NetworkCommissioningCluster::HandleConnectNetwork(CommandHandler & handler, cons
648648
649649 mpWirelessDriver->ConnectNetwork (req.networkID , this );
650650#else
651+ mConnectNetworkResponseSentEarly = false ;
651652 // In Non-concurrent mode postpone the final execution of ConnectNetwork until the operational
652653 // network has been fully brought up and kOperationalNetworkStarted is delivered.
653- // mConnectingNetworkIDLen and mConnectingNetworkID contain the received SSID.
654- //
654+
655655 // For PASE/BLE requests, reply before tearing down the commissioning transport.
656656 // For CASE requests, keep the command open and reply from OnResult after attach finishes.
657657 if (IsConnectNetworkRequestOverPASE (handler))
658658 {
659+ mConnectNetworkResponseSentEarly = true ;
659660 SendNonConcurrentConnectNetworkResponse ();
660661 }
661662 else
@@ -827,7 +828,7 @@ void NetworkCommissioningCluster::DisconnectLingeringConnection()
827828void NetworkCommissioningCluster::OnResult (Status commissioningError, CharSpan debugText, int32_t interfaceStatus)
828829{
829830 auto commandHandleRef = std::move (mAsyncCommandHandle );
830-
831+ auto commandHandle = commandHandleRef. Get ();
831832 // In Non-concurrent mode the commandHandle will be null here, the ConnectNetworkResponse
832833 // has already been sent and the BLE will have been stopped, however the other functionality
833834 // is still required
@@ -862,14 +863,23 @@ void NetworkCommissioningCluster::OnResult(Status commissioningError, CharSpan d
862863 SetLastNetworkId (ByteSpan{ mConnectingNetworkID , mConnectingNetworkIDLen });
863864 SetLastNetworkingStatusValue (MakeNullable (commissioningError));
864865
866+ bool shouldSendConnectNetworkResponse = true ;
865867#if (CONFIG_NETWORK_LAYER_BLE || CHIP_DEVICE_CONFIG_ENABLE_THREAD_MESHCOP) && !CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
866- ChipLogProgress (NetworkProvisioning, " Non-concurrent mode, ConnectNetworkResponse will NOT be sent" );
867- // Do not send the ConnectNetworkResponse if in non-concurrent mode
868- // TODO(#30576) raised to modify CommandHandler to notify it if no response required
869- // -----> Is this required here: commandHandle->FinishCommand();
870- #else
868+ if (mConnectNetworkResponseSentEarly )
869+ {
870+ ChipLogProgress (NetworkProvisioning, " Non-concurrent mode, ConnectNetworkResponse was already sent" );
871+ shouldSendConnectNetworkResponse = false ;
872+ }
873+ #endif
874+
875+ if (shouldSendConnectNetworkResponse && commandHandle != nullptr )
876+ {
871877 commandHandle->AddResponse (mAsyncCommandPath , response);
872- #endif // CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
878+ }
879+
880+ #if !CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
881+ mConnectNetworkResponseSentEarly = false ;
882+ #endif
873883
874884 if (commissioningError == Status::kSuccess )
875885 {
@@ -969,6 +979,10 @@ void NetworkCommissioningCluster::OnFailSafeTimerExpired()
969979{
970980 VerifyOrReturn (mpWirelessDriver != nullptr );
971981
982+ #if !CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
983+ mConnectNetworkResponseSentEarly = false ;
984+ #endif
985+
972986 ChipLogDetail (Zcl, " Failsafe timeout, tell platform driver to revert network credentials." );
973987 TEMPORARY_RETURN_IGNORED mpWirelessDriver->RevertConfiguration ();
974988 mAsyncCommandHandle .Release ();
0 commit comments