Skip to content

Commit

Permalink
[thread] Remove Thread Joiner functionality from platform layer
Browse files Browse the repository at this point in the history
Thread Joiner role is not used by Matter so this should
not be a part of Thread interface in Matter SDK. It is
a leftover from Weave.
  • Loading branch information
Damian-Nordic committed Apr 2, 2024
1 parent d3e3d97 commit 8049ff6
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 107 deletions.
6 changes: 0 additions & 6 deletions src/include/platform/ThreadStackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class ThreadStackManager
CHIP_ERROR GetExternalIPv6Address(chip::Inet::IPAddress & addr);
CHIP_ERROR GetPollPeriod(uint32_t & buf);

CHIP_ERROR JoinerStart();
CHIP_ERROR SetThreadProvision(ByteSpan aDataset);
CHIP_ERROR SetThreadEnabled(bool val);
CHIP_ERROR AttachToThreadNetwork(const Thread::OperationalDataset & dataset,
Expand Down Expand Up @@ -451,11 +450,6 @@ inline CHIP_ERROR ThreadStackManager::GetPollPeriod(uint32_t & buf)
return static_cast<ImplClass *>(this)->_GetPollPeriod(buf);
}

inline CHIP_ERROR ThreadStackManager::JoinerStart()
{
return static_cast<ImplClass *>(this)->_JoinerStart();
}

inline void ThreadStackManager::ResetThreadNetworkDiagnosticsCounts()
{
static_cast<ImplClass *>(this)->_ResetThreadNetworkDiagnosticsCounts();
Expand Down
6 changes: 0 additions & 6 deletions src/platform/Linux/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,6 @@ CHIP_ERROR ThreadStackManagerImpl::_GetPollPeriod(uint32_t & buf)
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::_JoinerStart()
{
// TODO: Remove Weave legacy APIs
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::GLibMatterContextCallScan(ThreadStackManagerImpl * self)
{
VerifyOrDie(g_main_context_get_thread_default() != nullptr);
Expand Down
2 changes: 0 additions & 2 deletions src/platform/Linux/ThreadStackManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ class ThreadStackManagerImpl : public ThreadStackManager

CHIP_ERROR _GetPollPeriod(uint32_t & buf);

CHIP_ERROR _JoinerStart();

void _ResetThreadNetworkDiagnosticsCounts();

CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ class GenericThreadStackManagerImpl_OpenThread
bool IsThreadAttachedNoLock(void);
bool IsThreadInterfaceUpNoLock(void);

CHIP_ERROR _JoinerStart(void);

private:
// ===== Private members for use by this class only.

Expand Down Expand Up @@ -264,9 +262,6 @@ class GenericThreadStackManagerImpl_OpenThread
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT

static void OnJoinerComplete(otError aError, void * aContext);
void OnJoinerComplete(otError aError);

inline ImplClass * Impl() { return static_cast<ImplClass *>(this); }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1199,78 +1199,6 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_ErasePersistentInfo(v
Impl()->UnlockThreadStack();
}

template <class ImplClass>
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnJoinerComplete(otError aError, void * aContext)
{
static_cast<GenericThreadStackManagerImpl_OpenThread *>(aContext)->OnJoinerComplete(aError);
}

template <class ImplClass>
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnJoinerComplete(otError aError)
{
#if CHIP_PROGRESS_LOGGING

ChipLogProgress(DeviceLayer, "Join Thread network: %s", otThreadErrorToString(aError));

if (aError == OT_ERROR_NONE)
{
otError error = otThreadSetEnabled(mOTInst, true);

ChipLogProgress(DeviceLayer, "Start Thread network: %s", otThreadErrorToString(error));
}
#endif // CHIP_PROGRESS_LOGGING
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_JoinerStart(void)
{
VerifyOrReturnError(mOTInst, CHIP_ERROR_INCORRECT_STATE);
CHIP_ERROR error = CHIP_NO_ERROR;

Impl()->LockThreadStack();
VerifyOrExit(!otDatasetIsCommissioned(mOTInst) && otThreadGetDeviceRole(mOTInst) == OT_DEVICE_ROLE_DISABLED,
error = MapOpenThreadError(OT_ERROR_INVALID_STATE));
VerifyOrExit(otJoinerGetState(mOTInst) == OT_JOINER_STATE_IDLE, error = MapOpenThreadError(OT_ERROR_BUSY));

if (!otIp6IsEnabled(mOTInst))
{
SuccessOrExit(error = MapOpenThreadError(otIp6SetEnabled(mOTInst, true)));
}

{
otJoinerDiscerner discerner;
// This is dead code to remove, so the placeholder value is OK.
// See ThreadStackManagerImpl.
uint16_t discriminator = 3840;

discerner.mLength = 12;
discerner.mValue = discriminator;

ChipLogProgress(DeviceLayer, "Joiner Discerner: %u", discriminator);
otJoinerSetDiscerner(mOTInst, &discerner);
}

{
otJoinerPskd pskd;
// This is dead code to remove, so the placeholder value is OK.d
// See ThreadStackManagerImpl.
uint32_t pincode = 20202021;

snprintf(pskd.m8, sizeof(pskd.m8) - 1, "%09" PRIu32, pincode);

ChipLogProgress(DeviceLayer, "Joiner PSKd: %s", pskd.m8);
error = MapOpenThreadError(otJoinerStart(mOTInst, pskd.m8, NULL, NULL, NULL, NULL, NULL,
&GenericThreadStackManagerImpl_OpenThread::OnJoinerComplete, this));
}

exit:
Impl()->UnlockThreadStack();

ChipLogProgress(DeviceLayer, "Joiner start: %s", chip::ErrorStr(error));

return error;
}

template <class ImplClass>
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_UpdateNetworkStatus()
{
Expand Down
6 changes: 0 additions & 6 deletions src/platform/Tizen/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,6 @@ CHIP_ERROR ThreadStackManagerImpl::_GetPollPeriod(uint32_t & buf)
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::_JoinerStart()
{
ChipLogError(DeviceLayer, "Not implemented");
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::_StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback)
{
ChipLogError(DeviceLayer, "Not implemented");
Expand Down
2 changes: 0 additions & 2 deletions src/platform/Tizen/ThreadStackManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ class ThreadStackManagerImpl : public ThreadStackManager

CHIP_ERROR _GetPollPeriod(uint32_t & buf);

CHIP_ERROR _JoinerStart();

void _ResetThreadNetworkDiagnosticsCounts();

CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback);
Expand Down
6 changes: 0 additions & 6 deletions src/platform/webos/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,6 @@ CHIP_ERROR ThreadStackManagerImpl::_GetPollPeriod(uint32_t & buf)
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::_JoinerStart()
{
// TODO: Remove Weave legacy APIs
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::_StartThreadScan(ThreadDriver::ScanCallback * callback)
{
// There is another ongoing scan request, reject the new one.
Expand Down
2 changes: 0 additions & 2 deletions src/platform/webos/ThreadStackManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ class ThreadStackManagerImpl : public ThreadStackManager

CHIP_ERROR _GetPollPeriod(uint32_t & buf);

CHIP_ERROR _JoinerStart();

void _ResetThreadNetworkDiagnosticsCounts();

CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback);
Expand Down

0 comments on commit 8049ff6

Please sign in to comment.