Skip to content

Commit

Permalink
[nrf noup] Enhance/Optimize attach to thread network
Browse files Browse the repository at this point in the history
Enhance attaching to Thread by verifying if the
current dataset is the same as provided.
In current solution implementation will not
reset the Thread interface while the dataset
are equal to the active dataset.

Signed-off-by: Michał Szablowski <michal.szablowski@nordicsemi.no>
  • Loading branch information
doublemis1 committed Sep 11, 2023
1 parent 478ba85 commit 860dc14
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@ template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_AttachToThreadNetwork(
const Thread::OperationalDataset & dataset, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback)
{
Thread::OperationalDataset current_dataset;
// Validate the dataset change with the current state
ThreadStackMgrImpl().GetThreadProvision(current_dataset);
if (dataset.AsByteSpan().data_equal(current_dataset.AsByteSpan()) && callback == nullptr)
{
return CHIP_NO_ERROR;
}

// Reset the previously set callback since it will never be called in case incorrect dataset was supplied.
mpConnectCallback = nullptr;
ReturnErrorOnFailure(Impl()->SetThreadEnabled(false));
Expand Down

0 comments on commit 860dc14

Please sign in to comment.