Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 143bab8

Browse files
committed
[Thread] Check DeviceType instead of device role
In ConnectivityManager, check DeviceType instead of device role to enable / disable thread routing.
1 parent a640fe8 commit 143bab8

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/adaptations/device-layer/include/Weave/DeviceLayer/internal/GenericConnectivityManagerImpl_Thread.ipp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
#include <Weave/DeviceLayer/internal/GenericConnectivityManagerImpl_Thread.h>
3030
#include <Warm/Warm.h>
3131

32-
#if WARM_CONFIG_SUPPORT_THREAD_ROUTING
33-
#include <openthread/thread.h>
34-
#endif // WARM_CONFIG_SUPPORT_THREAD_ROUTING
35-
3632
namespace nl {
3733
namespace Weave {
3834
namespace DeviceLayer {
@@ -72,14 +68,8 @@ void GenericConnectivityManagerImpl_Thread<ImplClass>::_OnPlatformEvent(const We
7268
event->ThreadStateChange.RoleChanged);
7369
if (threadRoleChanged)
7470
{
75-
otDeviceRole role;
76-
ThreadStackMgrImpl().LockThreadStack();
77-
role = otThreadGetDeviceRole(ThreadStackMgrImpl().OTInstance());
78-
ThreadStackMgrImpl().UnlockThreadStack();
79-
80-
bool isThreadRouter = (role == OT_DEVICE_ROLE_LEADER || role == OT_DEVICE_ROLE_ROUTER);
81-
82-
nl::Weave::Warm::InterfaceState interfaceState = isThreadRouter
71+
ConnectivityManager::ThreadDeviceType deviceType = ThreadStackMgr().GetThreadDeviceType();
72+
nl::Weave::Warm::InterfaceState interfaceState = (deviceType == ConnectivityManager::ThreadDeviceType::kThreadDeviceType_Router)
8373
? nl::Weave::Warm::kInterfaceStateUp
8474
: nl::Weave::Warm::kInterfaceStateDown;
8575
Warm::ThreadRoutingStateChange(interfaceState);

0 commit comments

Comments
 (0)