Skip to content

Commit 2997377

Browse files
Damian-Nordicpull[bot]
authored andcommitted
[OpenThread] Clean the code for older API versions (#28058)
All platform should already switch to something newer than OPENTHREAD_API_REVISION 219 from a year ago.
1 parent 3231894 commit 2997377

File tree

2 files changed

+2
-47
lines changed

2 files changed

+2
-47
lines changed

src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp

+2-36
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ namespace chip {
7878
namespace DeviceLayer {
7979
namespace Internal {
8080

81+
static_assert(OPENTHREAD_API_VERSION >= 219, "OpenThread version too old");
82+
8183
// Network commissioning
8284
namespace {
8385
#ifndef _NO_NETWORK_COMMISSIONING_DRIVER_
@@ -189,17 +191,6 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnPlatformEvent(const
189191
{
190192
if (event->Type == DeviceEventType::kThreadStateChange)
191193
{
192-
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT && (OPENTHREAD_API_VERSION < 218)
193-
if (event->ThreadStateChange.AddressChanged)
194-
{
195-
const otSrpClientHostInfo * hostInfo = otSrpClientGetHostInfo(Impl()->OTInstance());
196-
if (hostInfo && hostInfo->mName)
197-
{
198-
Impl()->_SetupSrpHost(hostInfo->mName);
199-
}
200-
}
201-
#endif
202-
203194
bool isThreadAttached = Impl()->_IsThreadAttached();
204195
// Avoid sending muliple events if the attachement state didn't change (Child->router or disable->Detached)
205196
if (event->ThreadStateChange.RoleChanged && (isThreadAttached != mIsAttached))
@@ -1568,12 +1559,8 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
15681559
otOperationalDataset activeDataset;
15691560
otError otErr = otDatasetGetActive(mOTInst, &activeDataset);
15701561
VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr));
1571-
#if OPENTHREAD_API_VERSION >= 219
15721562
uint64_t activeTimestamp = (activeDataset.mActiveTimestamp.mSeconds << 16) | (activeDataset.mActiveTimestamp.mTicks << 1) |
15731563
activeDataset.mActiveTimestamp.mAuthoritative;
1574-
#else
1575-
uint64_t activeTimestamp = activeDataset.mActiveTimestamp;
1576-
#endif
15771564
err = encoder.Encode(activeTimestamp);
15781565
}
15791566
break;
@@ -1582,12 +1569,8 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
15821569
otOperationalDataset activeDataset;
15831570
otError otErr = otDatasetGetActive(mOTInst, &activeDataset);
15841571
VerifyOrReturnError(otErr == OT_ERROR_NONE, MapOpenThreadError(otErr));
1585-
#if OPENTHREAD_API_VERSION >= 219
15861572
uint64_t pendingTimestamp = (activeDataset.mPendingTimestamp.mSeconds << 16) |
15871573
(activeDataset.mPendingTimestamp.mTicks << 1) | activeDataset.mPendingTimestamp.mAuthoritative;
1588-
#else
1589-
uint64_t pendingTimestamp = activeDataset.mPendingTimestamp;
1590-
#endif
15911574
err = encoder.Encode(pendingTimestamp);
15921575
}
15931576
break;
@@ -2118,8 +2101,6 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_UpdateNetworkStatus()
21182101

21192102
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
21202103

2121-
static_assert(OPENTHREAD_API_VERSION >= 156, "SRP Client requires a more recent OpenThread version");
2122-
21232104
template <class ImplClass>
21242105
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnSrpClientNotification(otError aError,
21252106
const otSrpClientHostInfo * aHostInfo,
@@ -2459,9 +2440,6 @@ template <class ImplClass>
24592440
CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetupSrpHost(const char * aHostName)
24602441
{
24612442
CHIP_ERROR error = CHIP_NO_ERROR;
2462-
#if OPENTHREAD_API_VERSION < 218
2463-
Inet::IPAddress hostAddress;
2464-
#endif
24652443

24662444
VerifyOrReturnError(mSrpClient.mIsInitialized, CHIP_ERROR_WELL_UNINITIALIZED);
24672445

@@ -2477,21 +2455,9 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetupSrpHost(co
24772455
error = MapOpenThreadError(otSrpClientSetHostName(mOTInst, mSrpClient.mHostName));
24782456
SuccessOrExit(error);
24792457

2480-
#if OPENTHREAD_API_VERSION >= 218
24812458
error = MapOpenThreadError(otSrpClientEnableAutoHostAddress(mOTInst));
2482-
#endif
24832459
}
24842460

2485-
#if OPENTHREAD_API_VERSION < 218
2486-
// Check if device has any external IPv6 assigned. If not, host will be set without IPv6 addresses
2487-
// and updated later on.
2488-
if (ThreadStackMgr().GetExternalIPv6Address(hostAddress) == CHIP_NO_ERROR)
2489-
{
2490-
memcpy(&mSrpClient.mHostAddress.mFields.m32, hostAddress.Addr, sizeof(hostAddress.Addr));
2491-
error = MapOpenThreadError(otSrpClientSetHostAddresses(mOTInst, &mSrpClient.mHostAddress, 1));
2492-
}
2493-
#endif
2494-
24952461
exit:
24962462
Impl()->UnlockThreadStack();
24972463

src/platform/OpenThread/OpenThreadUtils.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,8 @@ void LogOpenThreadStateChange(otInstance * otInst, uint32_t flags)
9696
{
9797
#if CHIP_DETAIL_LOGGING
9898

99-
#if OPENTHREAD_API_VERSION >= 126
10099
const uint32_t kParamsChanged = (OT_CHANGED_THREAD_NETWORK_NAME | OT_CHANGED_THREAD_PANID | OT_CHANGED_THREAD_EXT_PANID |
101100
OT_CHANGED_THREAD_CHANNEL | OT_CHANGED_NETWORK_KEY | OT_CHANGED_PSKC);
102-
#else
103-
const uint32_t kParamsChanged = (OT_CHANGED_THREAD_NETWORK_NAME | OT_CHANGED_THREAD_PANID | OT_CHANGED_THREAD_EXT_PANID |
104-
OT_CHANGED_THREAD_CHANNEL | OT_CHANGED_MASTER_KEY | OT_CHANGED_PSKC);
105-
#endif
106-
107101
static char strBuf[64];
108102

109103
ChipLogDetail(DeviceLayer, "OpenThread State Changed (Flags: 0x%08" PRIx32 ")", flags);
@@ -132,13 +126,8 @@ void LogOpenThreadStateChange(otInstance * otInst, uint32_t flags)
132126
}
133127
#if CHIP_CONFIG_SECURITY_TEST_MODE
134128
{
135-
#if OPENTHREAD_API_VERSION >= 126
136129
const otNetworkKey * otKey = otThreadGetNetworkKey(otInst);
137130
for (int i = 0; i < OT_NETWORK_KEY_SIZE; i++)
138-
#else
139-
const otMasterKey * otKey = otThreadGetMasterKey(otInst);
140-
for (int i = 0; i < OT_MASTER_KEY_SIZE; i++)
141-
#endif
142131
snprintf(&strBuf[i * 2], 3, "%02X", otKey->m8[i]);
143132
ChipLogDetail(DeviceLayer, " Network Key: %s", strBuf);
144133
}

0 commit comments

Comments
 (0)