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

Commit 2a3eeea

Browse files
committed
Populate 802.15.4 MAC address on Thread-enabled platforms
On platforms that enable Thread, populate 802.15.4 extended address. This address may be a meaningless set of numbers -- there is no guarantee that the address populated will be the same as the address used in joining (or re-attaching) to any particular Thread network or that it will correspond to the factory provisioned EUI64.
1 parent 104666b commit 2a3eeea

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

src/adaptations/device-layer/include/Weave/DeviceLayer/OpenThread/GenericThreadStackManagerImpl_OpenThread.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class GenericThreadStackManagerImpl_OpenThread
7777
WEAVE_ERROR _GetAndLogThreadStatsCounters(void);
7878
WEAVE_ERROR _GetAndLogThreadTopologyMinimal(void);
7979
WEAVE_ERROR _GetAndLogThreadTopologyFull(void);
80+
WEAVE_ERROR _GetPrimary802154MACAddress(uint8_t *buf);
8081

8182
// ===== Members available to the implementation subclass.
8283

src/adaptations/device-layer/include/Weave/DeviceLayer/OpenThread/GenericThreadStackManagerImpl_OpenThread.ipp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,14 @@ exit:
806806
return err;
807807
}
808808

809+
template<class ImplClass>
810+
WEAVE_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_GetPrimary802154MACAddress(uint8_t *buf)
811+
{
812+
const otExtAddress *extendedAddr = otLinkGetExtendedAddress(mOTInst);
813+
memcpy(buf, extendedAddr, sizeof(otExtAddress));
814+
return WEAVE_NO_ERROR;
815+
};
816+
809817
template<class ImplClass>
810818
WEAVE_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::DoInit(otInstance * otInst)
811819
{
@@ -871,7 +879,6 @@ bool GenericThreadStackManagerImpl_OpenThread<ImplClass>::IsThreadAttachedNoLock
871879
return (curRole != OT_DEVICE_ROLE_DISABLED && curRole != OT_DEVICE_ROLE_DETACHED);
872880
}
873881

874-
875882
} // namespace Internal
876883
} // namespace DeviceLayer
877884
} // namespace Weave

src/adaptations/device-layer/include/Weave/DeviceLayer/ThreadStackManager.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class ThreadStackManager
6666
WEAVE_ERROR GetAndLogThreadStatsCounters(void);
6767
WEAVE_ERROR GetAndLogThreadTopologyMinimal(void);
6868
WEAVE_ERROR GetAndLogThreadTopologyFull(void);
69+
WEAVE_ERROR GetPrimary802154MACAddress(uint8_t *buf);
6970

7071
private:
7172

@@ -75,6 +76,7 @@ class ThreadStackManager
7576
friend class ConfigurationManagerImpl;
7677
friend class Internal::DeviceControlServer;
7778
template<class> friend class Internal::GenericPlatformManagerImpl;
79+
template<class> friend class Internal::GenericConfigurationManagerImpl;
7880
template<class> friend class Internal::GenericPlatformManagerImpl_FreeRTOS;
7981
template<class> friend class Internal::GenericConnectivityManagerImpl_Thread;
8082
template<class> friend class Internal::GenericThreadStackManagerImpl_OpenThread;
@@ -236,6 +238,11 @@ inline WEAVE_ERROR ThreadStackManager::GetAndLogThreadTopologyFull(void)
236238
return static_cast<ImplClass*>(this)->_GetAndLogThreadTopologyFull();
237239
}
238240

241+
inline WEAVE_ERROR ThreadStackManager::GetPrimary802154MACAddress(uint8_t * buf)
242+
{
243+
return static_cast<ImplClass*>(this)->_GetPrimary802154MACAddress(buf);
244+
}
245+
239246
} // namespace DeviceLayer
240247
} // namespace Weave
241248
} // namespace nl

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#include <Weave/DeviceLayer/internal/WeaveDeviceLayerInternal.h>
2929
#include <Weave/DeviceLayer/internal/GenericConfigurationManagerImpl.h>
3030

31+
#if WEAVE_DEVICE_CONFIG_ENABLE_THREAD
32+
#include <Weave/DeviceLayer/ThreadStackManager.h>
33+
#endif
3134

3235
namespace nl {
3336
namespace Weave {
@@ -194,7 +197,11 @@ WEAVE_ERROR GenericConfigurationManagerImpl<ImplClass>::_StorePrimaryWiFiMACAddr
194197
template<class ImplClass>
195198
WEAVE_ERROR GenericConfigurationManagerImpl<ImplClass>::_GetPrimary802154MACAddress(uint8_t * buf)
196199
{
200+
#if WEAVE_DEVICE_CONFIG_ENABLE_THREAD
201+
return ThreadStackManager().GetPrimary802154MACAddress(buf);
202+
#else
197203
return WEAVE_DEVICE_ERROR_CONFIG_NOT_FOUND;
204+
#endif // WEAVE_DEVICE_CONFIG_ENABLE_THREAD
198205
}
199206

200207
template<class ImplClass>

0 commit comments

Comments
 (0)