Skip to content

Commit

Permalink
[thread] Remove legacy APIs: joiner & ThreadMode (#32814)
Browse files Browse the repository at this point in the history
* [thread] Remove Thread Joiner functionality from platform layer

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.

* Remove unused ThreadMode setting
  • Loading branch information
Damian-Nordic authored Apr 3, 2024
1 parent 5fbe16d commit 0c0c6d6
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 201 deletions.
26 changes: 0 additions & 26 deletions src/include/platform/ConnectivityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ class ConnectivityManager
kWiFiAPMode_OnDemand_NoStationProvision = 5,
};

enum ThreadMode
{
kThreadMode_NotSupported = 0,
kThreadMode_ApplicationControlled = 1,
kThreadMode_Disabled = 2,
kThreadMode_Enabled = 3,
};

enum WiFiStationState
{
kWiFiStationState_NotConnected,
Expand Down Expand Up @@ -192,10 +184,7 @@ class ConnectivityManager
void SetWiFiAPIdleTimeout(System::Clock::Timeout val);

// Thread Methods
ThreadMode GetThreadMode();
CHIP_ERROR SetThreadMode(ThreadMode val);
bool IsThreadEnabled();
bool IsThreadApplicationControlled();
ThreadDeviceType GetThreadDeviceType();
CHIP_ERROR SetThreadDeviceType(ThreadDeviceType deviceType);
bool IsThreadAttached();
Expand Down Expand Up @@ -417,26 +406,11 @@ inline CHIP_ERROR ConnectivityManager::GetAndLogWiFiStatsCounters()
return static_cast<ImplClass *>(this)->_GetAndLogWiFiStatsCounters();
}

inline ConnectivityManager::ThreadMode ConnectivityManager::GetThreadMode()
{
return static_cast<ImplClass *>(this)->_GetThreadMode();
}

inline CHIP_ERROR ConnectivityManager::SetThreadMode(ThreadMode val)
{
return static_cast<ImplClass *>(this)->_SetThreadMode(val);
}

inline bool ConnectivityManager::IsThreadEnabled()
{
return static_cast<ImplClass *>(this)->_IsThreadEnabled();
}

inline bool ConnectivityManager::IsThreadApplicationControlled()
{
return static_cast<ImplClass *>(this)->_IsThreadApplicationControlled();
}

inline ConnectivityManager::ThreadDeviceType ConnectivityManager::GetThreadDeviceType()
{
return static_cast<ImplClass *>(this)->_GetThreadDeviceType();
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ class GenericConnectivityManagerImpl_NoThread
protected:
// ===== Methods that implement the ConnectivityManager abstract interface.

ConnectivityManager::ThreadMode _GetThreadMode(void);
CHIP_ERROR _SetThreadMode(ConnectivityManager::ThreadMode val);
bool _IsThreadEnabled(void);
bool _IsThreadApplicationControlled(void);
ConnectivityManager::ThreadDeviceType _GetThreadDeviceType(void);
CHIP_ERROR _SetThreadDeviceType(ConnectivityManager::ThreadDeviceType deviceType);
bool _IsThreadAttached(void);
Expand All @@ -57,30 +54,12 @@ class GenericConnectivityManagerImpl_NoThread
ImplClass * Impl() { return static_cast<ImplClass *>(this); }
};

template <class ImplClass>
inline ConnectivityManager::ThreadMode GenericConnectivityManagerImpl_NoThread<ImplClass>::_GetThreadMode(void)
{
return ConnectivityManager::kThreadMode_NotSupported;
}

template <class ImplClass>
inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread<ImplClass>::_SetThreadMode(ConnectivityManager::ThreadMode val)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

template <class ImplClass>
inline bool GenericConnectivityManagerImpl_NoThread<ImplClass>::_IsThreadEnabled(void)
{
return false;
}

template <class ImplClass>
inline bool GenericConnectivityManagerImpl_NoThread<ImplClass>::_IsThreadApplicationControlled(void)
{
return false;
}

template <class ImplClass>
inline bool GenericConnectivityManagerImpl_NoThread<ImplClass>::_IsThreadAttached(void)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ class GenericConnectivityManagerImpl_Thread

void _Init();
void _OnPlatformEvent(const ChipDeviceEvent * event);
ConnectivityManager::ThreadMode _GetThreadMode();
CHIP_ERROR _SetThreadMode(ConnectivityManager::ThreadMode val);
bool _IsThreadEnabled();
bool _IsThreadApplicationControlled();
ConnectivityManager::ThreadDeviceType _GetThreadDeviceType();
CHIP_ERROR _SetThreadDeviceType(ConnectivityManager::ThreadDeviceType deviceType);
#if CHIP_CONFIG_ENABLE_ICD_SERVER
Expand All @@ -82,7 +79,6 @@ class GenericConnectivityManagerImpl_Thread
enum class Flags : uint8_t
{
kHaveServiceConnectivity = 0x01,
kIsApplicationControlled = 0x02
};

BitFlags<Flags> mFlags;
Expand All @@ -102,12 +98,6 @@ inline bool GenericConnectivityManagerImpl_Thread<ImplClass>::_IsThreadEnabled()
return ThreadStackMgrImpl().IsThreadEnabled();
}

template <class ImplClass>
inline bool GenericConnectivityManagerImpl_Thread<ImplClass>::_IsThreadApplicationControlled()
{
return mFlags.Has(Flags::kIsApplicationControlled);
}

template <class ImplClass>
inline bool GenericConnectivityManagerImpl_Thread<ImplClass>::_IsThreadAttached()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,43 +56,6 @@ void GenericConnectivityManagerImpl_Thread<ImplClass>::_OnPlatformEvent(const Ch
}
}

template <class ImplClass>
ConnectivityManager::ThreadMode GenericConnectivityManagerImpl_Thread<ImplClass>::_GetThreadMode()
{
if (mFlags.Has(Flags::kIsApplicationControlled))
{
return ConnectivityManager::kThreadMode_ApplicationControlled;
}

return ThreadStackMgrImpl().IsThreadEnabled() ? ConnectivityManager::kThreadMode_Enabled
: ConnectivityManager::kThreadMode_Disabled;
}

template <class ImplClass>
CHIP_ERROR GenericConnectivityManagerImpl_Thread<ImplClass>::_SetThreadMode(ConnectivityManager::ThreadMode val)
{
CHIP_ERROR err = CHIP_NO_ERROR;

VerifyOrExit(val == ConnectivityManager::kThreadMode_Enabled || val == ConnectivityManager::kThreadMode_Disabled ||
val == ConnectivityManager::kThreadMode_ApplicationControlled,
err = CHIP_ERROR_INVALID_ARGUMENT);

if (val == ConnectivityManager::kThreadMode_ApplicationControlled)
{
mFlags.Set(Flags::kIsApplicationControlled);
}
else
{
mFlags.Clear(Flags::kIsApplicationControlled);

err = ThreadStackMgrImpl().SetThreadEnabled(val == ConnectivityManager::kThreadMode_Enabled);
SuccessOrExit(err);
}

exit:
return err;
}

template <class ImplClass>
void GenericConnectivityManagerImpl_Thread<ImplClass>::UpdateServiceConnectivity()
{
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 0c0c6d6

Please sign in to comment.