34
34
#include < lib/support/SortUtils.h>
35
35
#include < lib/support/ThreadOperationalDataset.h>
36
36
#include < platform/CHIPDeviceConfig.h>
37
+ #include < platform/ConnectivityManager.h>
37
38
#include < platform/DeviceControlServer.h>
38
39
#include < platform/PlatformManager.h>
39
40
#include < platform/internal/DeviceNetworkInfo.h>
@@ -135,6 +136,26 @@ void Instance::Shutdown()
135
136
mpBaseDriver->Shutdown ();
136
137
}
137
138
139
+ #if !CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
140
+ void Instance::SendNonConcurrentConnectNetworkResponse ()
141
+ {
142
+ auto commandHandleRef = std::move (mAsyncCommandHandle );
143
+ auto commandHandle = commandHandleRef.Get ();
144
+ if (commandHandle == nullptr )
145
+ {
146
+ return ;
147
+ }
148
+
149
+ #if CONFIG_NETWORK_LAYER_BLE
150
+ DeviceLayer::ConnectivityMgr ().GetBleLayer ()->IndicateBleClosing ();
151
+ #endif // CONFIG_NETWORK_LAYER_BLE
152
+ ChipLogProgress (NetworkProvisioning, " Non-concurrent mode. Send ConnectNetworkResponse(Success)" );
153
+ Commands::ConnectNetworkResponse::Type response;
154
+ response.networkingStatus = NetworkCommissioning::Status::kSuccess ;
155
+ commandHandle->AddResponse (mPath , response);
156
+ }
157
+ #endif // CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
158
+
138
159
void Instance::InvokeCommand (HandlerContext & ctxt)
139
160
{
140
161
if (mAsyncCommandHandle .Get () != nullptr )
@@ -177,12 +198,7 @@ void Instance::InvokeCommand(HandlerContext & ctxt)
177
198
178
199
case Commands::ConnectNetwork::Id: {
179
200
VerifyOrReturn (mFeatureFlags .Has (Feature::kWiFiNetworkInterface ) || mFeatureFlags .Has (Feature::kThreadNetworkInterface ));
180
- #if CONFIG_NETWORK_LAYER_BLE && !CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
181
- // If commissionee does not support Concurrent Connections, request the BLE to be stopped.
182
- // Start the ConnectNetwork, but this will not complete until the BLE is off.
183
- ChipLogProgress (NetworkProvisioning, " Closing BLE connections due to non-concurrent mode" );
184
- DeviceLayer::DeviceControlServer::DeviceControlSvr ().PostCloseAllBLEConnectionsToOperationalNetworkEvent ();
185
- #endif
201
+
186
202
HandleCommand<Commands::ConnectNetwork::DecodableType>(
187
203
ctxt, [this ](HandlerContext & ctx, const auto & req) { HandleConnectNetwork (ctx, req); });
188
204
return ;
@@ -708,18 +724,22 @@ void Instance::HandleConnectNetwork(HandlerContext & ctx, const Commands::Connec
708
724
mAsyncCommandHandle = CommandHandler::Handle (&ctx.mCommandHandler );
709
725
mCurrentOperationBreadcrumb = req.breadcrumb ;
710
726
711
- // In Non-concurrent mode postpone the final execution of ConnectNetwork until the operational
712
- // network has been fully brought up and kWiFiDeviceAvailable is delivered.
713
- // mConnectingNetworkIDLen and mConnectingNetworkID contains the received SSID
714
727
#if CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
715
728
mpWirelessDriver->ConnectNetwork (req.networkID , this );
729
+ #else
730
+ // In Non-concurrent mode postpone the final execution of ConnectNetwork until the operational
731
+ // network has been fully brought up and kOperationalNetworkStarted is delivered.
732
+ // mConnectingNetworkIDLen and mConnectingNetworkID contain the received SSID
733
+ // As per spec, send the ConnectNetworkResponse(Success) prior to releasing the commissioning channel
734
+ SendNonConcurrentConnectNetworkResponse ();
716
735
#endif
717
736
}
718
737
719
738
void Instance::HandleNonConcurrentConnectNetwork ()
720
739
{
721
740
ByteSpan nonConcurrentNetworkID = ByteSpan (mConnectingNetworkID , mConnectingNetworkIDLen );
722
- ChipLogProgress (NetworkProvisioning, " HandleNonConcurrentConnectNetwork() SSID=%s" , mConnectingNetworkID );
741
+ ChipLogProgress (NetworkProvisioning, " Non-concurrent mode, Connect to Network SSID=%.*s" , mConnectingNetworkIDLen ,
742
+ mConnectingNetworkID );
723
743
mpWirelessDriver->ConnectNetwork (nonConcurrentNetworkID, this );
724
744
}
725
745
@@ -826,13 +846,19 @@ void Instance::HandleQueryIdentity(HandlerContext & ctx, const Commands::QueryId
826
846
void Instance::OnResult (Status commissioningError, CharSpan debugText, int32_t interfaceStatus)
827
847
{
828
848
auto commandHandleRef = std::move (mAsyncCommandHandle );
829
- auto commandHandle = commandHandleRef.Get ();
849
+
850
+ // In Non-concurrent mode the commandHandle will be null here, the ConnectNetworkResponse
851
+ // has already been sent and the BLE will have been stopped, however the other functionality
852
+ // is still required
853
+ #if CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
854
+ auto commandHandle = commandHandleRef.Get ();
830
855
if (commandHandle == nullptr )
831
856
{
832
857
// When the platform shutted down, interaction model engine will invalidate all commandHandle to avoid dangling references.
833
858
// We may receive the callback after it and should make it noop.
834
859
return ;
835
860
}
861
+ #endif // CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
836
862
837
863
Commands::ConnectNetworkResponse::Type response;
838
864
response.networkingStatus = commissioningError;
@@ -856,13 +882,10 @@ void Instance::OnResult(Status commissioningError, CharSpan debugText, int32_t i
856
882
memcpy (mLastNetworkID , mConnectingNetworkID , mLastNetworkIDLen );
857
883
mLastNetworkingStatusValue .SetNonNull (commissioningError);
858
884
859
- #if CONFIG_NETWORK_LAYER_BLE && !CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
860
- ChipLogProgress (NetworkProvisioning, " Non-concurrent mode, ConnectNetworkResponse will NOT be sent" );
861
- // Do not send the ConnectNetworkResponse if in non-concurrent mode
862
- // Issue #30576 raised to modify CommandHandler to notify it if no response required
863
- #else
885
+ #if CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
864
886
commandHandle->AddResponse (mPath , response);
865
- #endif
887
+ #endif // CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
888
+
866
889
if (commissioningError == Status::kSuccess )
867
890
{
868
891
CommitSavedBreadcrumb ();
@@ -1063,8 +1086,11 @@ void Instance::OnPlatformEventHandler(const DeviceLayer::ChipDeviceEvent * event
1063
1086
{
1064
1087
this_->OnFailSafeTimerExpired ();
1065
1088
}
1066
- else if (event->Type == DeviceLayer::DeviceEventType::kWiFiDeviceAvailable )
1089
+ else if ((event->Type == DeviceLayer::DeviceEventType::kWiFiDeviceAvailable ) ||
1090
+ (event->Type == DeviceLayer::DeviceEventType::kOperationalNetworkStarted ))
1091
+
1067
1092
{
1093
+ // In Non-Concurrent mode connect the operational channel, as BLE has been stopped
1068
1094
this_->HandleNonConcurrentConnectNetwork ();
1069
1095
}
1070
1096
}
0 commit comments