Skip to content

Commit

Permalink
[Tizen] Add missing thread network connected callback (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ravinder-01 committed Jul 3, 2023
1 parent 21cc4be commit dba6a86
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/platform/Tizen/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <platform/PlatformManager.h>

#include <platform/Tizen/ThreadStackManagerImpl.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>

namespace chip {
namespace DeviceLayer {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dba6a86

Please sign in to comment.