diff --git a/src/platform/Tizen/ThreadStackManagerImpl.cpp b/src/platform/Tizen/ThreadStackManagerImpl.cpp index 233f28b87b0293..91101346058d3c 100644 --- a/src/platform/Tizen/ThreadStackManagerImpl.cpp +++ b/src/platform/Tizen/ThreadStackManagerImpl.cpp @@ -53,6 +53,7 @@ #include #include +#include namespace chip { namespace DeviceLayer { @@ -309,9 +310,30 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadEnabled(bool val) if (val && !isEnabled) { threadErr = thread_network_attach(mThreadInstance); + DeviceLayer::SystemLayer().ScheduleLambda([&, threadErr]() { + if (this->mpConnectCallback != nullptr && threadErr != THREAD_ERROR_NONE) + { + this->mpConnectCallback->OnResult( + NetworkCommissioning::Status::kUnknownError, + CharSpan(), 0); + this->mpConnectCallback = nullptr; + } + }); + VerifyOrExit(threadErr == THREAD_ERROR_NONE, ChipLogError(DeviceLayer, "FAIL: attach thread network")); threadErr = thread_start(mThreadInstance); + DeviceLayer::SystemLayer().ScheduleLambda([&, threadErr]() { + if (this->mpConnectCallback != nullptr) + { + this->mpConnectCallback->OnResult( + threadErr == THREAD_ERROR_NONE ? + NetworkCommissioning::Status::kSuccess : + NetworkCommissioning::Status::kUnknownError, + CharSpan(), 0); + this->mpConnectCallback = nullptr; + } + }); VerifyOrExit(threadErr == THREAD_ERROR_NONE, ChipLogError(DeviceLayer, "FAIL: start thread network")); } else if (!val && isEnabled)