Skip to content

Commit d989f15

Browse files
[thread] Enhance/Optimize attach to thread network (project-chip#33191)
Enhance attaching to Thread network by verifying if the current dataset is the same as provided. In the current solution implementation will not reset the Thread interface while the dataset are equal to the active dataset.
1 parent 13ab158 commit d989f15

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,14 @@ template <class ImplClass>
373373
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_AttachToThreadNetwork(
374374
const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback)
375375
{
376+
Thread::OperationalDataset current_dataset;
377+
// Validate the dataset change with the current state
378+
ThreadStackMgrImpl().GetThreadProvision(current_dataset);
379+
if (dataset.AsByteSpan().data_equal(current_dataset.AsByteSpan()) && callback == nullptr)
380+
{
381+
return CHIP_NO_ERROR;
382+
}
383+
376384
// Reset the previously set callback since it will never be called in case incorrect dataset was supplied.
377385
mpConnectCallback = nullptr;
378386
ReturnErrorOnFailure(Impl()->SetThreadEnabled(false));

0 commit comments

Comments
 (0)