Skip to content

Commit

Permalink
Rename SystemLayer to Make abstraction of IP Lib (#17554)
Browse files Browse the repository at this point in the history
  • Loading branch information
jepenven-silabs authored and pull[bot] committed Jul 26, 2023
1 parent d9e2d5c commit 1952674
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_RunEventLoop(void)

// Call into the system layer to dispatch the callback functions for all timers
// that have expired.
err = static_cast<System::LayerImplLwIP &>(DeviceLayer::SystemLayer()).HandlePlatformTimer();
err = static_cast<System::LayerImplFreeRTOS &>(DeviceLayer::SystemLayer()).HandlePlatformTimer();
if (err != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Error handling CHIP timers: %s", ErrorStr(err));
Expand Down
4 changes: 2 additions & 2 deletions src/inet/TCPEndPointImplLwIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,8 @@ void TCPEndPointImplLwIP::LwIPHandleError(void * arg, err_t lwipErr)
{
if (arg != NULL)
{
TCPEndPointImplLwIP * ep = static_cast<TCPEndPointImplLwIP *>(arg);
System::LayerLwIP & lSystemLayer = static_cast<System::LayerLwIP &>(ep->GetSystemLayer());
TCPEndPointImplLwIP * ep = static_cast<TCPEndPointImplLwIP *>(arg);
System::LayerFreeRTOS & lSystemLayer = static_cast<System::LayerFreeRTOS &>(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
Expand Down
2 changes: 1 addition & 1 deletion src/platform/CYW30739/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void PlatformManagerImpl::SetEventFlags(uint32_t flags)

void PlatformManagerImpl::HandleTimerEvent(void)
{
const CHIP_ERROR err = static_cast<System::LayerImplLwIP &>(DeviceLayer::SystemLayer()).HandlePlatformTimer();
const CHIP_ERROR err = static_cast<System::LayerImplFreeRTOS &>(DeviceLayer::SystemLayer()).HandlePlatformTimer();
if (err != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "HandlePlatformTimer %ld", err.AsInteger());
Expand Down
4 changes: 2 additions & 2 deletions src/system/SystemLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
{
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@

/**
* @file
* This file implements LayerImplLwIP using LwIP.
* This file implements LayerImplFreeRTOS. Used by LwIP implementation and OpenThread
*/

#include <lib/support/CodeUtils.h>
#include <system/PlatformEventSupport.h>
#include <system/SystemFaultInjection.h>
#include <system/SystemLayer.h>
#include <system/SystemLayerImplLwIP.h>
#include <system/SystemLayerImplFreeRTOS.h>

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);

Expand All @@ -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);

Expand All @@ -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());

Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -58,7 +58,7 @@ class LayerImplLwIP : public LayerLwIP
ObjectLifeCycle mLayerState;
};

using LayerImpl = LayerImplLwIP;
using LayerImpl = LayerImplFreeRTOS;

} // namespace System
} // namespace chip
2 changes: 1 addition & 1 deletion src/system/system.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
4 changes: 2 additions & 2 deletions src/system/tests/TestSystemTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ class LayerEvents<LayerImpl, typename std::enable_if<std::is_base_of<LayerSocket
#if CHIP_SYSTEM_CONFIG_USE_LWIP

template <class LayerImpl>
class LayerEvents<LayerImpl, typename std::enable_if<std::is_base_of<LayerImplLwIP, LayerImpl>::value>::type>
class LayerEvents<LayerImpl, typename std::enable_if<std::is_base_of<LayerImplFreeRTOS, LayerImpl>::value>::type>
{
public:
static bool HasServiceEvents() { return true; }
static void ServiceEvents(Layer & aLayer)
{
LayerImplLwIP & layer = static_cast<LayerImplLwIP &>(aLayer);
LayerImplFreeRTOS & layer = static_cast<LayerImplFreeRTOS &>(aLayer);
if (layer.IsInitialized())
{
layer.HandlePlatformTimer();
Expand Down

0 comments on commit 1952674

Please sign in to comment.