Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tizen] Implement GetThreadVersion() for Thread driver #34976

Merged
merged 5 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/include/platform/ThreadStackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ThreadStackManager
CHIP_ERROR GetAndLogThreadTopologyFull();
CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf);
CHIP_ERROR GetExternalIPv6Address(chip::Inet::IPAddress & addr);
CHIP_ERROR GetThreadVersion(uint16_t & version);
CHIP_ERROR GetPollPeriod(uint32_t & buf);

CHIP_ERROR SetThreadProvision(ByteSpan aDataset);
Expand Down Expand Up @@ -444,6 +445,11 @@ inline CHIP_ERROR ThreadStackManager::GetExternalIPv6Address(chip::Inet::IPAddre
return static_cast<ImplClass *>(this)->_GetExternalIPv6Address(addr);
}

inline CHIP_ERROR ThreadStackManager::GetThreadVersion(uint16_t & version)
{
return static_cast<ImplClass *>(this)->_GetThreadVersion(version);
}

inline CHIP_ERROR ThreadStackManager::GetPollPeriod(uint32_t & buf)
{
return static_cast<ImplClass *>(this)->_GetPollPeriod(buf);
Expand Down
6 changes: 3 additions & 3 deletions src/platform/Linux/NetworkCommissioningThreadDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ ThreadCapabilities LinuxThreadDriver::GetSupportedThreadFeatures()

uint16_t LinuxThreadDriver::GetThreadVersion()
{
// TODO https://github.com/project-chip/connectedhomeip/issues/30602
// Needs to be implemented with DBUS io.openthread.BorderRouter Thread API
return 0;
uint16_t version = 0;
ThreadStackMgrImpl().GetThreadVersion(version);
return version;
}

#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
Expand Down
7 changes: 7 additions & 0 deletions src/platform/Linux/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,13 @@ CHIP_ERROR ThreadStackManagerImpl::_GetExternalIPv6Address(chip::Inet::IPAddress
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::_GetThreadVersion(uint16_t & version)
{
// TODO https://github.com/project-chip/connectedhomeip/issues/30602
// Needs to be implemented with DBUS io.openthread.BorderRouter Thread API
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::_GetPollPeriod(uint32_t & buf)
{
// TODO: Remove Weave legacy APIs
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Linux/ThreadStackManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ThreadStackManagerImpl : public ThreadStackManager
CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf);

CHIP_ERROR _GetExternalIPv6Address(chip::Inet::IPAddress & addr);

CHIP_ERROR _GetThreadVersion(uint16_t & version);
CHIP_ERROR _GetPollPeriod(uint32_t & buf);

void _ResetThreadNetworkDiagnosticsCounts();
Expand Down
6 changes: 3 additions & 3 deletions src/platform/NuttX/NetworkCommissioningThreadDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ ThreadCapabilities LinuxThreadDriver::GetSupportedThreadFeatures()

uint16_t LinuxThreadDriver::GetThreadVersion()
{
// TODO https://github.com/project-chip/connectedhomeip/issues/30602
// Needs to be implemented with DBUS io.openthread.BorderRouter Thread API
return 0;
uint16_t version = 0;
ThreadStackMgrImpl().GetThreadVersion(version);
return version;
}

#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
Expand Down
7 changes: 7 additions & 0 deletions src/platform/NuttX/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ CHIP_ERROR ThreadStackManagerImpl::_GetExternalIPv6Address(chip::Inet::IPAddress
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::_GetThreadVersion(uint16_t & version)
{
// TODO https://github.com/project-chip/connectedhomeip/issues/30602
// Needs to be implemented with DBUS io.openthread.BorderRouter Thread API
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR ThreadStackManagerImpl::_GetPollPeriod(uint32_t & buf)
{
// TODO: Remove Weave legacy APIs
Expand Down
2 changes: 1 addition & 1 deletion src/platform/NuttX/ThreadStackManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ThreadStackManagerImpl : public ThreadStackManager
CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf);

CHIP_ERROR _GetExternalIPv6Address(chip::Inet::IPAddress & addr);

CHIP_ERROR _GetThreadVersion(uint16_t & version);
CHIP_ERROR _GetPollPeriod(uint32_t & buf);

CHIP_ERROR _JoinerStart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ ThreadCapabilities GenericThreadDriver::GetSupportedThreadFeatures()

uint16_t GenericThreadDriver::GetThreadVersion()
{
return otThreadGetVersion();
uint16_t version = 0;
ThreadStackMgrImpl().GetThreadVersion(version);
return version;
}

} // namespace NetworkCommissioning
Expand Down
41 changes: 21 additions & 20 deletions src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class GenericThreadStackManagerImpl_OpenThread

otInstance * OTInstance() const;
static void OnOpenThreadStateChange(uint32_t flags, void * context);
inline void OverrunErrorTally(void);
inline void OverrunErrorTally();
void
SetNetworkStatusChangeCallback(NetworkCommissioning::Internal::BaseDriver::NetworkStatusChangeCallback * statusChangeCallback)
{
Expand All @@ -80,21 +80,21 @@ class GenericThreadStackManagerImpl_OpenThread
protected:
// ===== Methods that implement the ThreadStackManager abstract interface.

void _ProcessThreadActivity(void);
void _ProcessThreadActivity();
bool _HaveRouteToAddress(const Inet::IPAddress & destAddr);
void _OnPlatformEvent(const ChipDeviceEvent * event);
bool _IsThreadEnabled(void);
bool _IsThreadEnabled();
CHIP_ERROR _SetThreadEnabled(bool val);

bool _IsThreadProvisioned(void);
bool _IsThreadAttached(void);
bool _IsThreadProvisioned();
bool _IsThreadAttached();
CHIP_ERROR _GetThreadProvision(Thread::OperationalDataset & dataset);
CHIP_ERROR _SetThreadProvision(ByteSpan netInfo);
CHIP_ERROR _AttachToThreadNetwork(const Thread::OperationalDataset & dataset,
NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback);
void _OnThreadAttachFinished(void);
void _ErasePersistentInfo(void);
ConnectivityManager::ThreadDeviceType _GetThreadDeviceType(void);
void _OnThreadAttachFinished();
void _ErasePersistentInfo();
ConnectivityManager::ThreadDeviceType _GetThreadDeviceType();
CHIP_ERROR _SetThreadDeviceType(ConnectivityManager::ThreadDeviceType deviceType);
CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback);
static void _OnNetworkScanFinished(otActiveScanResult * aResult, void * aContext);
Expand All @@ -105,16 +105,17 @@ class GenericThreadStackManagerImpl_OpenThread
CHIP_ERROR _SetPollingInterval(System::Clock::Milliseconds32 pollingInterval);
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

bool _HaveMeshConnectivity(void);
CHIP_ERROR _GetAndLogThreadStatsCounters(void);
CHIP_ERROR _GetAndLogThreadTopologyMinimal(void);
CHIP_ERROR _GetAndLogThreadTopologyFull(void);
bool _HaveMeshConnectivity();
CHIP_ERROR _GetAndLogThreadStatsCounters();
CHIP_ERROR _GetAndLogThreadTopologyMinimal();
CHIP_ERROR _GetAndLogThreadTopologyFull();
CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf);
CHIP_ERROR _GetExternalIPv6Address(chip::Inet::IPAddress & addr);
void _ResetThreadNetworkDiagnosticsCounts(void);
CHIP_ERROR _GetThreadVersion(uint16_t & version);
void _ResetThreadNetworkDiagnosticsCounts();
CHIP_ERROR _GetPollPeriod(uint32_t & buf);
void _OnWoBLEAdvertisingStart(void);
void _OnWoBLEAdvertisingStop(void);
void _OnWoBLEAdvertisingStart();
void _OnWoBLEAdvertisingStop();

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
CHIP_ERROR _AddSrpService(const char * aInstanceName, const char * aName, uint16_t aPort,
Expand Down Expand Up @@ -144,8 +145,8 @@ class GenericThreadStackManagerImpl_OpenThread

CHIP_ERROR ConfigureThreadStack(otInstance * otInst);
CHIP_ERROR DoInit(otInstance * otInst);
bool IsThreadAttachedNoLock(void);
bool IsThreadInterfaceUpNoLock(void);
bool IsThreadAttachedNoLock();
bool IsThreadInterfaceUpNoLock();

private:
// ===== Private members for use by this class only.
Expand Down Expand Up @@ -282,19 +283,19 @@ inline otInstance * GenericThreadStackManagerImpl_OpenThread<ImplClass>::OTInsta
}

template <class ImplClass>
inline void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OverrunErrorTally(void)
inline void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OverrunErrorTally()
{
mOverrunCount++;
}

template <class ImplClass>
inline void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnWoBLEAdvertisingStart(void)
inline void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnWoBLEAdvertisingStart()
{
// Do nothing by default.
}

template <class ImplClass>
inline void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnWoBLEAdvertisingStop(void)
inline void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnWoBLEAdvertisingStop()
{
// Do nothing by default.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define GENERIC_THREAD_STACK_MANAGER_IMPL_OPENTHREAD_IPP

#include <cassert>
#include <limits>

#include <openthread/cli.h>
#include <openthread/dataset.h>
Expand Down Expand Up @@ -59,7 +60,6 @@
#include <platform/ThreadStackManager.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <limits>
extern "C" void otSysProcessDrivers(otInstance * aInstance);

#if CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI
Expand All @@ -80,7 +80,7 @@ app::Clusters::NetworkCommissioning::Instance
sThreadNetworkCommissioningInstance(CHIP_DEVICE_CONFIG_THREAD_NETWORK_ENDPOINT_ID /* Endpoint Id */, &sGenericThreadDriver);
#endif

void initNetworkCommissioningThreadDriver(void)
void initNetworkCommissioningThreadDriver()
{
#ifndef _NO_GENERIC_THREAD_NETWORK_COMMISSIONING_DRIVER_
sThreadNetworkCommissioningInstance.Init();
Expand Down Expand Up @@ -143,7 +143,7 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnOpenThreadStateChang
}

template <class ImplClass>
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_ProcessThreadActivity(void)
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_ProcessThreadActivity()
{
otTaskletsProcess(mOTInst);
otSysProcessDrivers(mOTInst);
Expand Down Expand Up @@ -256,7 +256,7 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnPlatformEvent(const
}

template <class ImplClass>
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_IsThreadEnabled(void)
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_IsThreadEnabled()
{
VerifyOrReturnValue(mOTInst, false);
otDeviceRole curRole;
Expand Down Expand Up @@ -330,7 +330,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadProvis
}

template <class ImplClass>
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_IsThreadProvisioned(void)
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_IsThreadProvisioned()
{
VerifyOrReturnValue(mOTInst, false);
bool provisioned;
Expand Down Expand Up @@ -363,7 +363,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetThreadProvis
}

template <class ImplClass>
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_IsThreadAttached(void)
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_IsThreadAttached()
{
VerifyOrReturnValue(mOTInst, false);
otDeviceRole curRole;
Expand Down Expand Up @@ -525,7 +525,7 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnNetworkScanFinished
}

template <class ImplClass>
ConnectivityManager::ThreadDeviceType GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetThreadDeviceType(void)
ConnectivityManager::ThreadDeviceType GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetThreadDeviceType()
{
VerifyOrReturnValue(mOTInst, ConnectivityManager::kThreadDeviceType_NotSupported);
ConnectivityManager::ThreadDeviceType deviceType;
Expand Down Expand Up @@ -651,7 +651,7 @@ GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadDeviceType(Connec
}

template <class ImplClass>
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_HaveMeshConnectivity(void)
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_HaveMeshConnectivity()
{
VerifyOrReturnValue(mOTInst, false);
bool res;
Expand Down Expand Up @@ -700,7 +700,7 @@ bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::_HaveMeshConnectivity(
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetAndLogThreadStatsCounters(void)
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetAndLogThreadStatsCounters()
{
VerifyOrReturnError(mOTInst, CHIP_ERROR_INCORRECT_STATE);
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -795,7 +795,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetAndLogThread
}

template <class ImplClass>
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetAndLogThreadTopologyMinimal(void)
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetAndLogThreadTopologyMinimal()
{
VerifyOrReturnError(mOTInst, CHIP_ERROR_INCORRECT_STATE);
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -1072,7 +1072,14 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetExternalIPv6
}

template <class ImplClass>
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_ResetThreadNetworkDiagnosticsCounts(void)
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetThreadVersion(uint16_t & version)
{
version = otThreadGetVersion();
return CHIP_NO_ERROR;
}

template <class ImplClass>
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_ResetThreadNetworkDiagnosticsCounts()
{
// Based on the spec, only OverrunCount should be resetted.
mOverrunCount = 0;
Expand Down Expand Up @@ -1175,14 +1182,14 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::DoInit(otInstanc
}

template <class ImplClass>
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::IsThreadAttachedNoLock(void)
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::IsThreadAttachedNoLock()
{
otDeviceRole curRole = otThreadGetDeviceRole(mOTInst);
return (curRole != OT_DEVICE_ROLE_DISABLED && curRole != OT_DEVICE_ROLE_DETACHED);
}

template <class ImplClass>
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::IsThreadInterfaceUpNoLock(void)
bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::IsThreadInterfaceUpNoLock()
{
return otIp6IsEnabled(mOTInst);
}
Expand Down Expand Up @@ -1242,7 +1249,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetPollingInter
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

template <class ImplClass>
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_ErasePersistentInfo(void)
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_ErasePersistentInfo()
{
VerifyOrReturn(mOTInst);
ChipLogProgress(DeviceLayer, "Erasing Thread persistent info...");
Expand Down
2 changes: 1 addition & 1 deletion src/platform/OpenThread/OpenThreadUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ bool FormatOpenThreadError(char * buf, uint16_t bufSize, CHIP_ERROR err)
/**
* Register a text error formatter for OpenThread errors.
*/
void RegisterOpenThreadErrorFormatter(void)
void RegisterOpenThreadErrorFormatter()
{
static ErrorFormatter sOpenThreadErrorFormatter = { FormatOpenThreadError, NULL };

Expand Down
2 changes: 1 addition & 1 deletion src/platform/OpenThread/OpenThreadUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace Internal {
#endif // CHIP_CONFIG_OPENTHREAD_ERROR_MAX

extern CHIP_ERROR MapOpenThreadError(otError otErr);
extern void RegisterOpenThreadErrorFormatter(void);
extern void RegisterOpenThreadErrorFormatter();

/**
* Log information related to a state change in the OpenThread stack.
Expand Down
Loading
Loading