Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More revisions to System::Layer #8417

Merged
merged 1 commit into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void InitTestInetCommon()

void InitSystemLayer()
{
gSystemLayer.Init(nullptr);
gSystemLayer.Init();
}

void ShutdownSystemLayer()
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestCommandInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void InitializeChip(nlTestSuite * apSuite)
err = chip::Platform::MemoryInit();
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

chip::gSystemLayer.Init(nullptr);
chip::gSystemLayer.Init();

err = chip::gSessionManager.Init(chip::kTestDeviceNodeId, &chip::gSystemLayer, &chip::gTransportManager, &admins,
&chip::gMessageCounterManager);
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestEventLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void InitializeChip(nlTestSuite * apSuite)
err = chip::Platform::MemoryInit();
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

gSystemLayer.Init(nullptr);
gSystemLayer.Init();

err = gSessionManager.Init(kTestDeviceNodeId1, &gSystemLayer, &gTransportManager, &admins, &gMessageCounterManager);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestInteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void InitializeChip(nlTestSuite * apSuite)
err = chip::Platform::MemoryInit();
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

gSystemLayer.Init(nullptr);
gSystemLayer.Init();

err = gSessionManager.Init(chip::kTestDeviceNodeId, &gSystemLayer, &gTransportManager, &admins, &gMessageCounterManager);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestReadInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ void InitializeChip(nlTestSuite * apSuite)
err = chip::Platform::MemoryInit();
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

chip::gSystemLayer.Init(nullptr);
chip::gSystemLayer.Init();

err = chip::gSessionManager.Init(chip::kTestDeviceNodeId, &chip::gSystemLayer, &chip::gTransportManager, &admins,
&chip::gMessageCounterManager);
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestReportingEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void InitializeChip(nlTestSuite * apSuite)
err = chip::Platform::MemoryInit();
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

chip::gSystemLayer.Init(nullptr);
chip::gSystemLayer.Init();

err = chip::gSessionManager.Init(chip::kTestDeviceNodeId, &chip::gSystemLayer, &chip::gTransportManager, &admins,
&chip::gMessageCounterManager);
Expand Down
2 changes: 1 addition & 1 deletion src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ jint JNI_OnLoad(JavaVM * jvm, void * reserved)
ChipLogProgress(Controller, "Java class references loaded.");

// Initialize the CHIP System Layer.
err = sSystemLayer.Init(NULL);
err = sSystemLayer.Init();
SuccessOrExit(err);

// Initialize the CHIP Inet layer.
Expand Down
15 changes: 7 additions & 8 deletions src/include/platform/PlatformManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,13 @@ class PlatformManager
template <class>
friend class Internal::GenericConfigurationManagerImpl;
// Parentheses used to fix clang parsing issue with these declarations
friend ::CHIP_ERROR(::chip::System::Platform::EventSupport::PostEvent)(::chip::System::Layer & aLayer, void * aContext,
::chip::System::Object & aTarget,
::chip::System::EventType aType, uintptr_t aArgument);
friend ::CHIP_ERROR(::chip::System::Platform::EventSupport::DispatchEvents)(::chip::System::Layer & aLayer, void * aContext);
friend ::CHIP_ERROR(::chip::System::Platform::EventSupport::DispatchEvent)(::chip::System::Layer & aLayer, void * aContext,
::chip::System::Event aEvent);
friend ::CHIP_ERROR(::chip::System::Platform::EventSupport::StartTimer)(::chip::System::Layer & aLayer, void * aContext,
uint32_t aMilliseconds);
friend ::CHIP_ERROR(::chip::System::Platform::Eventing::PostEvent)(::chip::System::Layer & aLayer,
::chip::System::Object & aTarget,
::chip::System::EventType aType, uintptr_t aArgument);
friend ::CHIP_ERROR(::chip::System::Platform::Eventing::DispatchEvents)(::chip::System::Layer & aLayer);
friend ::CHIP_ERROR(::chip::System::Platform::Eventing::DispatchEvent)(::chip::System::Layer & aLayer,
::chip::System::Event aEvent);
friend ::CHIP_ERROR(::chip::System::Platform::Eventing::StartTimer)(::chip::System::Layer & aLayer, uint32_t aMilliseconds);

void PostEvent(const ChipDeviceEvent * event);
void DispatchEvent(const ChipDeviceEvent * event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ CHIP_ERROR GenericPlatformManagerImpl<ImplClass>::_InitChipStack()

// Initialize the CHIP system layer.
new (&SystemLayer) System::Layer();
err = SystemLayer.Init(nullptr);
err = SystemLayer.Init();
if (err != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "SystemLayer initialization failed: %s", ErrorStr(err));
Expand Down
6 changes: 2 additions & 4 deletions src/inet/tests/TestInetCommonPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ void InitSystemLayer()
{
#if CHIP_SYSTEM_CONFIG_USE_LWIP
AcquireLwIP();

gSystemLayer.Init(sLwIPEventQueue);
#else // !CHIP_SYSTEM_CONFIG_USE_LWIP
gSystemLayer.Init(nullptr);
#endif // !CHIP_SYSTEM_CONFIG_USE_LWIP

gSystemLayer.Init();
}

void ShutdownSystemLayer()
Expand Down
26 changes: 13 additions & 13 deletions src/messaging/tests/TestReliableMessageProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void CheckFailRetrans(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

MockAppDelegate mockAppDelegate;
ExchangeContext * exchange = ctx.NewExchangeToPeer(&mockAppDelegate);
Expand All @@ -240,7 +240,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -305,7 +305,7 @@ void CheckCloseExchangeAndResendApplicationMessage(nlTestSuite * inSuite, void *
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -370,7 +370,7 @@ void CheckFailedMessageRetainOnSend(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -425,7 +425,7 @@ void CheckResendApplicationMessageWithPeerExchange(nlTestSuite * inSuite, void *
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -492,7 +492,7 @@ void CheckDuplicateMessageClosedExchange(nlTestSuite * inSuite, void * inContext
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -574,7 +574,7 @@ void CheckResendSessionEstablishmentMessageWithPeerExchange(nlTestSuite * inSuit
ctx.SetPeerKeyId(0);
ctx.SetAdminId(kUndefinedAdminId);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -652,7 +652,7 @@ void CheckDuplicateMessage(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -726,7 +726,7 @@ void CheckReceiveAfterStandaloneAck(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -820,7 +820,7 @@ void CheckNoPiggybackAfterPiggyback(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -957,7 +957,7 @@ void CheckSendUnsolicitedStandaloneAckMessage(nlTestSuite * inSuite, void * inCo
*/
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData("", 0);
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down Expand Up @@ -999,7 +999,7 @@ void CheckSendStandaloneAckMessage(nlTestSuite * inSuite, void * inContext)
{
TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

MockAppDelegate mockAppDelegate;
ExchangeContext * exchange = ctx.NewExchangeToPeer(&mockAppDelegate);
Expand Down Expand Up @@ -1033,7 +1033,7 @@ void CheckMessageAfterClosed(nlTestSuite * inSuite, void * inContext)

TestContext & ctx = *reinterpret_cast<TestContext *>(inContext);

ctx.GetInetLayer().SystemLayer()->Init(nullptr);
ctx.GetInetLayer().SystemLayer()->Init();

chip::System::PacketBufferHandle buffer = chip::MessagePacketBuffer::NewWithData(PAYLOAD, sizeof(PAYLOAD));
NL_TEST_ASSERT(inSuite, !buffer.IsNull());
Expand Down
11 changes: 5 additions & 6 deletions src/platform/SystemEventSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
namespace chip {
namespace System {
namespace Platform {
namespace EventSupport {
namespace Eventing {

using namespace ::chip::DeviceLayer;

CHIP_ERROR PostEvent(System::Layer & aLayer, void * aContext, System::Object & aTarget, System::EventType aType,
uintptr_t aArgument)
CHIP_ERROR PostEvent(System::Layer & aLayer, System::Object & aTarget, System::EventType aType, uintptr_t aArgument)
{
ChipDeviceEvent event;
event.Type = DeviceEventType::kChipSystemLayerEvent;
Expand All @@ -48,21 +47,21 @@ CHIP_ERROR PostEvent(System::Layer & aLayer, void * aContext, System::Object & a
return CHIP_NO_ERROR;
}

CHIP_ERROR DispatchEvents(System::Layer & aLayer, void * aContext)
CHIP_ERROR DispatchEvents(System::Layer & aLayer)
{
PlatformMgr().RunEventLoop();

return CHIP_NO_ERROR;
}

CHIP_ERROR DispatchEvent(System::Layer & aLayer, void * aContext, const ChipDeviceEvent * aEvent)
CHIP_ERROR DispatchEvent(System::Layer & aLayer, const ChipDeviceEvent * aEvent)
{
PlatformMgr().DispatchEvent(aEvent);

return CHIP_NO_ERROR;
}

} // namespace EventSupport
} // namespace Eventing
} // namespace Platform
} // namespace System
} // namespace chip
6 changes: 3 additions & 3 deletions src/platform/SystemTimerSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
namespace chip {
namespace System {
namespace Platform {
namespace EventSupport {
namespace Eventing {

using namespace ::chip::DeviceLayer;

CHIP_ERROR StartTimer(System::Layer & aLayer, void * aContext, uint32_t aMilliseconds)
CHIP_ERROR StartTimer(System::Layer & aLayer, uint32_t aMilliseconds)
{
return PlatformMgr().StartChipTimer(aMilliseconds);
}

} // namespace EventSupport
} // namespace Eventing
} // namespace Platform
} // namespace System
} // namespace chip
15 changes: 0 additions & 15 deletions src/system/SystemConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,21 +428,6 @@ struct LwIPEvent;

#endif /* CHIP_SYSTEM_CONFIG_USE_LWIP */


/**
* @def CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_XTOR_FUNCTIONS
*
* @brief
* This defines whether (1) or not (0) your platform will provide the following platform-specific functions:
* - chip::System::Platform::WillInit
* - chip::System::Platform::WillShutdown
* - chip::System::Platform::DidInit
* - chip::System::Platform::DidShutdown
*/
#ifndef CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_XTOR_FUNCTIONS
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_XTOR_FUNCTIONS 0
#endif /* CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_XTOR_FUNCTIONS */

/**
* @def CHIP_SYSTEM_CONFIG_NUM_TIMERS
*
Expand Down
Loading