Skip to content

Commit

Permalink
OpenThread: clear the previous srp host and services when connecting …
Browse files Browse the repository at this point in the history
…to a new network
  • Loading branch information
DejinChen committed Aug 19, 2024
1 parent b823a29 commit 3e9e9db
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,24 @@ void GenericThreadDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * c
status = Status::kUnknownError;
}

if (status == Status::kSuccess && ThreadStackMgrImpl().IsThreadAttached())
{
Thread::OperationalDataset currentDataset;
if (ThreadStackMgrImpl().GetThreadProvision(currentDataset) == CHIP_NO_ERROR)
{
// Clear the previous srp host and services
if (!currentDataset.AsByteSpan().data_equal(mStagingNetwork.AsByteSpan()) &&
ThreadStackMgrImpl().ClearAllSrpHostAndServices() != CHIP_NO_ERROR)
{
status = Status::kUnknownError;
}
}
else
{
status = Status::kUnknownError;
}
}

if (status == Status::kSuccess &&
DeviceLayer::ThreadStackMgrImpl().AttachToThreadNetwork(mStagingNetwork, callback) != CHIP_NO_ERROR)
{
Expand Down

0 comments on commit 3e9e9db

Please sign in to comment.