Skip to content

Commit 934beca

Browse files
committed
[Telink] modified non-concurrent commissioning path
Now it accomplishes all the steps of CNET 4.12.
1 parent 4ad5e95 commit 934beca

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

config/telink/chip-module/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,10 @@ endif
279279
config TFLM_FEATURE
280280
bool "Enable the TFLM micro speech feature"
281281
default n
282+
283+
config CHIP_TELINK_OPENTHREAD_NETWORK_SWITCH_PATH
284+
bool "Keep Thread enabled when switching between commissioned datasets"
285+
help
286+
Keep Thread enabled while switching between commissioned
287+
datasets to reduce detached window during fail-safe rollback/connect.
288+
default y

src/app/clusters/network-commissioning/NetworkCommissioningCluster.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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()
827828
void 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();

src/app/clusters/network-commissioning/NetworkCommissioningCluster.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ class NetworkCommissioningCluster : private NetworkCommissioningLogicListNode,
240240
uint8_t mLastNetworkIDLen = 0;
241241
Optional<uint64_t> mCurrentOperationBreadcrumb;
242242
bool mScanningWasDirected = false;
243+
#if !CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
244+
bool mConnectNetworkResponseSentEarly = false;
245+
#endif
243246
Context mClusterContext;
244247

245248
void SetLastNetworkingStatusValue(NetworkCommissioning::Attributes::LastNetworkingStatus::TypeInfo::Type networkingStatusValue);

src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,17 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_AttachToThreadN
391391

392392
// Reset the previously set callback since it will never be called in case incorrect dataset was supplied.
393393
mpConnectCallback = nullptr;
394+
395+
#if CONFIG_CHIP_TELINK_OPENTHREAD_NETWORK_SWITCH_PATH
396+
if (callback == nullptr && dataset.IsCommissioned() && current_dataset.IsCommissioned() &&
397+
!dataset.AsByteSpan().data_equal(current_dataset.AsByteSpan()) && Impl()->IsThreadEnabled())
398+
{
399+
ReturnErrorOnFailure(Impl()->SetThreadProvision(dataset.AsByteSpan()));
400+
mpConnectCallback = callback;
401+
return CHIP_NO_ERROR;
402+
}
403+
#endif
404+
394405
ReturnErrorOnFailure(Impl()->SetThreadEnabled(false));
395406
ReturnErrorOnFailure(Impl()->SetThreadProvision(dataset.AsByteSpan()));
396407

0 commit comments

Comments
 (0)