From 195267469baf8d320a5b5d58e19d6c7d4c0b49b4 Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Wed, 20 Apr 2022 11:43:39 -0400 Subject: [PATCH] Rename SystemLayer to Make abstraction of IP Lib (#17554) --- .../GenericPlatformManagerImpl_FreeRTOS.ipp | 2 +- src/inet/TCPEndPointImplLwIP.cpp | 4 ++-- src/platform/CYW30739/PlatformManagerImpl.cpp | 2 +- src/system/SystemLayer.h | 4 ++-- ...plLwIP.cpp => SystemLayerImplFreeRTOS.cpp} | 20 +++++++++---------- ...erImplLwIP.h => SystemLayerImplFreeRTOS.h} | 10 +++++----- src/system/system.gni | 2 +- src/system/tests/TestSystemTimer.cpp | 4 ++-- 8 files changed, 24 insertions(+), 24 deletions(-) rename src/system/{SystemLayerImplLwIP.cpp => SystemLayerImplFreeRTOS.cpp} (88%) rename src/system/{SystemLayerImplLwIP.h => SystemLayerImplFreeRTOS.h} (87%) diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp index 393d921110e09c..216665c08560de 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp +++ b/src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp @@ -175,7 +175,7 @@ void GenericPlatformManagerImpl_FreeRTOS::_RunEventLoop(void) // Call into the system layer to dispatch the callback functions for all timers // that have expired. - err = static_cast(DeviceLayer::SystemLayer()).HandlePlatformTimer(); + err = static_cast(DeviceLayer::SystemLayer()).HandlePlatformTimer(); if (err != CHIP_NO_ERROR) { ChipLogError(DeviceLayer, "Error handling CHIP timers: %s", ErrorStr(err)); diff --git a/src/inet/TCPEndPointImplLwIP.cpp b/src/inet/TCPEndPointImplLwIP.cpp index cc454552b3fb32..757b7d8d5c95de 100644 --- a/src/inet/TCPEndPointImplLwIP.cpp +++ b/src/inet/TCPEndPointImplLwIP.cpp @@ -991,8 +991,8 @@ void TCPEndPointImplLwIP::LwIPHandleError(void * arg, err_t lwipErr) { if (arg != NULL) { - TCPEndPointImplLwIP * ep = static_cast(arg); - System::LayerLwIP & lSystemLayer = static_cast(ep->GetSystemLayer()); + TCPEndPointImplLwIP * ep = static_cast(arg); + System::LayerFreeRTOS & lSystemLayer = static_cast(ep->GetSystemLayer()); // At this point LwIP has already freed the PCB. Since the thread that owns the TCPEndPoint may // try to use the PCB before it receives the TCPError event posted below, we set the PCB to NULL diff --git a/src/platform/CYW30739/PlatformManagerImpl.cpp b/src/platform/CYW30739/PlatformManagerImpl.cpp index 233e1b3fcc9f01..ff7cf1ca83e988 100644 --- a/src/platform/CYW30739/PlatformManagerImpl.cpp +++ b/src/platform/CYW30739/PlatformManagerImpl.cpp @@ -193,7 +193,7 @@ void PlatformManagerImpl::SetEventFlags(uint32_t flags) void PlatformManagerImpl::HandleTimerEvent(void) { - const CHIP_ERROR err = static_cast(DeviceLayer::SystemLayer()).HandlePlatformTimer(); + const CHIP_ERROR err = static_cast(DeviceLayer::SystemLayer()).HandlePlatformTimer(); if (err != CHIP_NO_ERROR) { ChipLogError(DeviceLayer, "HandlePlatformTimer %ld", err.AsInteger()); diff --git a/src/system/SystemLayer.h b/src/system/SystemLayer.h index 0d4554c3dc6124..ee0b72ddaac005 100644 --- a/src/system/SystemLayer.h +++ b/src/system/SystemLayer.h @@ -58,7 +58,7 @@ using TimerCompleteCallback = void (*)(Layer * aLayer, void * appState); * * The abstract class hierarchy is: * - Layer: Core timer methods. - * - LayerLwIP: Adds methods specific to CHIP_SYSTEM_CONFIG_USING_LWIP. + * - LayerFreeRTOS: Adds methods specific to CHIP_SYSTEM_CONFIG_USING_LWIP and CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT. * - LayerSockets: Adds I/O event methods specific to CHIP_SYSTEM_CONFIG_USING_SOCKETS. * - LayerSocketsLoop: Adds methods for event-loop-based implementations. * @@ -174,7 +174,7 @@ class DLL_EXPORT Layer #if CHIP_SYSTEM_CONFIG_USE_LWIP || CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT -class LayerLwIP : public Layer +class LayerFreeRTOS : public Layer { }; diff --git a/src/system/SystemLayerImplLwIP.cpp b/src/system/SystemLayerImplFreeRTOS.cpp similarity index 88% rename from src/system/SystemLayerImplLwIP.cpp rename to src/system/SystemLayerImplFreeRTOS.cpp index cac7b1faa4679c..b78e803a701c49 100644 --- a/src/system/SystemLayerImplLwIP.cpp +++ b/src/system/SystemLayerImplFreeRTOS.cpp @@ -18,21 +18,21 @@ /** * @file - * This file implements LayerImplLwIP using LwIP. + * This file implements LayerImplFreeRTOS. Used by LwIP implementation and OpenThread */ #include #include #include #include -#include +#include namespace chip { namespace System { -LayerImplLwIP::LayerImplLwIP() : mHandlingTimerComplete(false) {} +LayerImplFreeRTOS::LayerImplFreeRTOS() : mHandlingTimerComplete(false) {} -CHIP_ERROR LayerImplLwIP::Init() +CHIP_ERROR LayerImplFreeRTOS::Init() { VerifyOrReturnError(mLayerState.SetInitializing(), CHIP_ERROR_INCORRECT_STATE); @@ -44,13 +44,13 @@ CHIP_ERROR LayerImplLwIP::Init() return CHIP_NO_ERROR; } -CHIP_ERROR LayerImplLwIP::Shutdown() +CHIP_ERROR LayerImplFreeRTOS::Shutdown() { VerifyOrReturnError(mLayerState.ResetFromInitialized(), CHIP_ERROR_INCORRECT_STATE); return CHIP_NO_ERROR; } -CHIP_ERROR LayerImplLwIP::StartTimer(Clock::Timeout delay, TimerCompleteCallback onComplete, void * appState) +CHIP_ERROR LayerImplFreeRTOS::StartTimer(Clock::Timeout delay, TimerCompleteCallback onComplete, void * appState) { VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); @@ -74,7 +74,7 @@ CHIP_ERROR LayerImplLwIP::StartTimer(Clock::Timeout delay, TimerCompleteCallback return CHIP_NO_ERROR; } -void LayerImplLwIP::CancelTimer(TimerCompleteCallback onComplete, void * appState) +void LayerImplFreeRTOS::CancelTimer(TimerCompleteCallback onComplete, void * appState) { VerifyOrReturn(mLayerState.IsInitialized()); @@ -85,7 +85,7 @@ void LayerImplLwIP::CancelTimer(TimerCompleteCallback onComplete, void * appStat } } -CHIP_ERROR LayerImplLwIP::ScheduleWork(TimerCompleteCallback onComplete, void * appState) +CHIP_ERROR LayerImplFreeRTOS::ScheduleWork(TimerCompleteCallback onComplete, void * appState) { VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); @@ -98,7 +98,7 @@ CHIP_ERROR LayerImplLwIP::ScheduleWork(TimerCompleteCallback onComplete, void * /** * Start the platform timer with specified millsecond duration. */ -CHIP_ERROR LayerImplLwIP::StartPlatformTimer(System::Clock::Timeout aDelay) +CHIP_ERROR LayerImplFreeRTOS::StartPlatformTimer(System::Clock::Timeout aDelay) { VerifyOrReturnError(IsInitialized(), CHIP_ERROR_INCORRECT_STATE); CHIP_ERROR status = PlatformEventing::StartTimer(*this, aDelay); @@ -120,7 +120,7 @@ CHIP_ERROR LayerImplLwIP::StartPlatformTimer(System::Clock::Timeout aDelay) * @return CHIP_NO_ERROR on success, error code otherwise. * */ -CHIP_ERROR LayerImplLwIP::HandlePlatformTimer() +CHIP_ERROR LayerImplFreeRTOS::HandlePlatformTimer() { VerifyOrReturnError(IsInitialized(), CHIP_ERROR_INCORRECT_STATE); diff --git a/src/system/SystemLayerImplLwIP.h b/src/system/SystemLayerImplFreeRTOS.h similarity index 87% rename from src/system/SystemLayerImplLwIP.h rename to src/system/SystemLayerImplFreeRTOS.h index e59e45094fcf16..2220eb3faa85b7 100644 --- a/src/system/SystemLayerImplLwIP.h +++ b/src/system/SystemLayerImplFreeRTOS.h @@ -17,7 +17,7 @@ /** * @file - * This file declares an implementation of LayerImplLwIP using LwIP. + * This file declares an implementation of LayerImplFreeRTOS using LwIP. */ #pragma once @@ -29,11 +29,11 @@ namespace chip { namespace System { -class LayerImplLwIP : public LayerLwIP +class LayerImplFreeRTOS : public LayerFreeRTOS { public: - LayerImplLwIP(); - ~LayerImplLwIP() { VerifyOrDie(mLayerState.Destroy()); } + LayerImplFreeRTOS(); + ~LayerImplFreeRTOS() { VerifyOrDie(mLayerState.Destroy()); } // Layer overrides. CHIP_ERROR Init() override; @@ -58,7 +58,7 @@ class LayerImplLwIP : public LayerLwIP ObjectLifeCycle mLayerState; }; -using LayerImpl = LayerImplLwIP; +using LayerImpl = LayerImplFreeRTOS; } // namespace System } // namespace chip diff --git a/src/system/system.gni b/src/system/system.gni index 15aeead0a94c27..0a27615c40a577 100644 --- a/src/system/system.gni +++ b/src/system/system.gni @@ -46,7 +46,7 @@ declare_args() { # Event loop type. if (chip_system_config_use_lwip || chip_system_config_use_open_thread_inet_endpoints) { - chip_system_config_event_loop = "LwIP" + chip_system_config_event_loop = "FreeRTOS" } else { chip_system_config_event_loop = "Select" } diff --git a/src/system/tests/TestSystemTimer.cpp b/src/system/tests/TestSystemTimer.cpp index 59199db494605b..5deae61e81d28c 100644 --- a/src/system/tests/TestSystemTimer.cpp +++ b/src/system/tests/TestSystemTimer.cpp @@ -78,13 +78,13 @@ class LayerEvents -class LayerEvents::value>::type> +class LayerEvents::value>::type> { public: static bool HasServiceEvents() { return true; } static void ServiceEvents(Layer & aLayer) { - LayerImplLwIP & layer = static_cast(aLayer); + LayerImplFreeRTOS & layer = static_cast(aLayer); if (layer.IsInitialized()) { layer.HandlePlatformTimer();