Skip to content

Commit 1424442

Browse files
jepenven-silabspull[bot]
authored andcommitted
Update EFR32 Thread Stack Manager Impl (#17111)
1 parent 6cd501f commit 1424442

11 files changed

+55
-29
lines changed

src/platform/EFR32/CHIPDevicePlatformConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
#if defined(EFR32MG21)
8383
#define CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE (2 * 1024)
8484
#else
85-
#define CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE (4 * 1024)
85+
#define CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE (8 * 1024)
8686
#endif
8787
#endif // CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE
8888

src/platform/EFR32/ConnectivityManagerImpl.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
#include <platform/ConnectivityManager.h>
2424
#include <platform/internal/BLEManager.h>
2525

26-
#include <lwip/dns.h>
27-
#include <lwip/ip_addr.h>
28-
#include <lwip/nd6.h>
29-
#include <lwip/netif.h>
30-
3126
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
3227
#include <platform/internal/GenericConnectivityManagerImpl_BLE.ipp>
3328
#endif

src/platform/EFR32/DiagnosticDataProviderImpl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
2929
#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h>
3030
#endif
31-
#include <lwip/tcpip.h>
3231

3332
#include "AppConfig.h"
3433
#include "FreeRTOS.h"

src/platform/EFR32/Logging.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@
5757
#define LOG_WARN "<warn > "
5858
#define LOG_INFO "<info > "
5959
#define LOG_DETAIL "<detail> "
60+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
6061
#define LOG_LWIP "<lwip > "
62+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
6163
#define LOG_EFR32 "<efr32 > "
6264
// If a new category string LOG_* is created, add it in the MaxStringLength arguments below
65+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
6366
static constexpr size_t kMaxCategoryStrLen = chip::MaxStringLength(LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DETAIL, LOG_LWIP, LOG_EFR32);
67+
#else
68+
static constexpr size_t kMaxCategoryStrLen = chip::MaxStringLength(LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DETAIL, LOG_EFR32);
69+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
6470

6571
#if EFR32_LOG_ENABLED
6672
static bool sLogInitialized = false;
@@ -218,6 +224,8 @@ void LogV(const char * module, uint8_t category, const char * aFormat, va_list v
218224
} // namespace Logging
219225
} // namespace chip
220226

227+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
228+
221229
/**
222230
* LwIP log output function.
223231
*/
@@ -251,7 +259,7 @@ extern "C" void LwIPLog(const char * aFormat, ...)
251259
#endif // EFR32_LOG_ENABLED
252260
va_end(v);
253261
}
254-
262+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
255263
/**
256264
* Platform logging function for OpenThread
257265
*/

src/platform/EFR32/PlatformManagerImpl.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
#include <platform/PlatformManager.h>
3131
#include <platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp>
3232

33+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
3334
#include <lwip/tcpip.h>
35+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
3436

3537
#include "AppConfig.h"
3638
#include "FreeRTOS.h"
@@ -51,8 +53,10 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
5153
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
5254
SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance());
5355

56+
#if CHIP_SYSTEM_CONFIG_USE_LWIP
5457
// Initialize LwIP.
5558
tcpip_init(NULL, NULL);
59+
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
5660

5761
ReturnErrorOnFailure(System::Clock::InitClock_RealTime());
5862

src/platform/EFR32/SystemPlatformConfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct ChipDeviceEvent;
3636
// ==================== Platform Adaptations ====================
3737
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1
3838
#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *
39+
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8
3940

4041
// ========== Platform-specific Configuration Overrides =========
4142

src/platform/EFR32/ThreadStackManagerImpl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <platform/internal/CHIPDeviceLayerInternal.h>
2828

2929
#include <platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.cpp>
30-
#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp>
30+
#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp>
3131
#include <platform/OpenThread/OpenThreadUtils.h>
3232
#include <platform/ThreadStackManager.h>
3333

@@ -54,7 +54,7 @@ CHIP_ERROR ThreadStackManagerImpl::InitThreadStack(otInstance * otInst)
5454
// Initialize the generic implementation base classes.
5555
err = GenericThreadStackManagerImpl_FreeRTOS<ThreadStackManagerImpl>::DoInit();
5656
SuccessOrExit(err);
57-
err = GenericThreadStackManagerImpl_OpenThread_LwIP<ThreadStackManagerImpl>::DoInit(otInst);
57+
err = GenericThreadStackManagerImpl_OpenThread<ThreadStackManagerImpl>::DoInit(otInst);
5858
SuccessOrExit(err);
5959

6060
exit:

src/platform/EFR32/ThreadStackManagerImpl.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#pragma once
2727

2828
#include <platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.h>
29-
#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.h>
29+
#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h>
3030

3131
#include <openthread/tasklet.h>
3232
#include <openthread/thread.h>
@@ -47,7 +47,7 @@ extern int GetEntropy_EFR32(uint8_t * buf, size_t bufSize);
4747
* using the Silicon Labs SDK and the OpenThread stack.
4848
*/
4949
class ThreadStackManagerImpl final : public ThreadStackManager,
50-
public Internal::GenericThreadStackManagerImpl_OpenThread_LwIP<ThreadStackManagerImpl>,
50+
public Internal::GenericThreadStackManagerImpl_OpenThread<ThreadStackManagerImpl>,
5151
public Internal::GenericThreadStackManagerImpl_FreeRTOS<ThreadStackManagerImpl>
5252
{
5353
// Allow the ThreadStackManager interface class to delegate method calls to
@@ -58,7 +58,7 @@ class ThreadStackManagerImpl final : public ThreadStackManager,
5858
// this class.
5959
#ifndef DOXYGEN_SHOULD_SKIP_THIS
6060
friend Internal::GenericThreadStackManagerImpl_OpenThread<ThreadStackManagerImpl>;
61-
friend Internal::GenericThreadStackManagerImpl_OpenThread_LwIP<ThreadStackManagerImpl>;
61+
friend Internal::GenericThreadStackManagerImpl_OpenThread<ThreadStackManagerImpl>;
6262
friend Internal::GenericThreadStackManagerImpl_FreeRTOS<ThreadStackManagerImpl>;
6363
#endif
6464

src/platform/EFR32/args.gni

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ mbedtls_target = "${efr32_sdk_build_root}:efr32_sdk"
2626
openthread_external_mbedtls = mbedtls_target
2727

2828
chip_device_platform = "efr32"
29-
chip_mdns = "platform"
3029

30+
#Net work configuration OpenThread
3131
lwip_platform = "efr32"
32-
32+
chip_mdns = "platform"
3333
chip_inet_config_enable_ipv4 = false
34-
3534
chip_inet_config_enable_tcp_endpoint = false
3635
chip_system_config_use_open_thread_inet_endpoints = true
3736

src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp

+29-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565
#include <app/data-model/Encode.h>
6666

6767
#include <limits>
68-
68+
#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
69+
#include <app/server/Server.h>
70+
#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
6971
extern "C" void otSysProcessDrivers(otInstance * aInstance);
7072

7173
#if CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI
@@ -215,6 +217,32 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnPlatformEvent(const
215217

216218
#endif // CHIP_DETAIL_LOGGING
217219

220+
#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
221+
if (event->ThreadStateChange.RoleChanged || event->ThreadStateChange.AddressChanged)
222+
{
223+
bool isInterfaceUp;
224+
isInterfaceUp = GenericThreadStackManagerImpl_OpenThread<ImplClass>::IsThreadInterfaceUpNoLock();
225+
// Post an event signaling the change in Thread interface connectivity state.
226+
{
227+
ChipDeviceEvent event;
228+
event.Clear();
229+
event.Type = DeviceEventType::kThreadConnectivityChange;
230+
event.ThreadConnectivityChange.Result = (isInterfaceUp) ? kConnectivity_Established : kConnectivity_Lost;
231+
CHIP_ERROR status = PlatformMgr().PostEvent(&event);
232+
if (status != CHIP_NO_ERROR)
233+
{
234+
ChipLogError(DeviceLayer, "Failed to post Thread connectivity change: %" CHIP_ERROR_FORMAT, status.Format());
235+
}
236+
}
237+
238+
// Refresh Multicast listening
239+
if (GenericThreadStackManagerImpl_OpenThread<ImplClass>::IsThreadAttachedNoLock())
240+
{
241+
ChipLogDetail(DeviceLayer, "Thread Attached updating Multicast address");
242+
Server::GetInstance().RejoinExistingMulticastGroups();
243+
}
244+
}
245+
#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
218246
Impl()->UnlockThreadStack();
219247
}
220248
}

src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp

+4-12
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@
3838

3939
#include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp>
4040

41-
#include <app/server/Server.h>
4241
#include <transport/raw/PeerAddress.h>
4342

43+
#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
44+
#error "When using OpenThread Endpoints, one should also use GenericThreadStackManagerImpl_OpenThread"
45+
#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
46+
4447
namespace chip {
4548
namespace DeviceLayer {
4649
namespace Internal {
@@ -230,17 +233,6 @@ void GenericThreadStackManagerImpl_OpenThread_LwIP<ImplClass>::UpdateThreadInter
230233
addrAssigned[addrIdx] = true;
231234
}
232235
}
233-
234-
// Multicast won't work with LWIP on top of OT
235-
// Duplication of listeners, unecessary timers, buffer duplication, hardfault etc...
236-
#if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
237-
// Refresh Multicast listening
238-
if (GenericThreadStackManagerImpl_OpenThread<ImplClass>::IsThreadAttachedNoLock())
239-
{
240-
ChipLogDetail(DeviceLayer, "Thread Attached updating Multicast address");
241-
Server::GetInstance().RejoinExistingMulticastGroups();
242-
}
243-
#endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
244236
}
245237

246238
ChipLogDetail(DeviceLayer, "LwIP Thread interface addresses %s", isInterfaceUp ? "updated" : "cleared");

0 commit comments

Comments
 (0)