Skip to content

Commit

Permalink
WIP 202107291213
Browse files Browse the repository at this point in the history
#### Problem

XXX

#### Change overview

XXX

socket events in project-chip#6561

Split platform `#if` sections of `System::Layer` and `System::Timer`
into separate `WatchableEventManager` implementations.

`System::Timer` remains as an optional `Object`-pool implementation tool for the XXX

The intent is that the public `WatchableEventManager` interface will
become pure virtual methods of `System::Layer`, and the various versions
of `WatchableEventManager` will be its implementations.

- Make `Timer` list not LwIP-specific, mutex it, and use it in preference
  to iterating through the entire pool.
- Move `IsEarlier` from `Timer` to `Clock`.
- Fix dual definitions of `Clock::Platform` functions on Linux.

#### Testing
How was this tested? (at least one bullet point required)
* If unit tests were added, how do they cover this issue?
* If unit tests existed, how were they fixed/modified to prevent this in future?
* If new unit tests are not added, why not?
* If integration tests were added, how do they verify this change?
* If new integration tests are not added, why not?
* If manually tested, what platforms controller and device platforms were manually tested, and how?
* If no testing is required, why not?
  • Loading branch information
kpschoedel committed Aug 3, 2021
1 parent 3b9c48c commit 2fe3f89
Show file tree
Hide file tree
Showing 86 changed files with 1,321 additions and 1,221 deletions.
4 changes: 2 additions & 2 deletions examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState, CHIP_ERROR error

if (identifyTimerCount)
{
SystemLayer.StartTimer(kIdentifyTimerDelayMS, IdentifyTimerHandler, appState);
SystemLayer.StartFunctTimer(kIdentifyTimerDelayMS, IdentifyTimerHandler, appState);
// Decrement the timer count.
identifyTimerCount--;
}
Expand All @@ -223,7 +223,7 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI
identifyTimerCount = (*value) * 4;

SystemLayer.CancelTimer(IdentifyTimerHandler, this);
SystemLayer.StartTimer(kIdentifyTimerDelayMS, IdentifyTimerHandler, this);
SystemLayer.StartFunctTimer(kIdentifyTimerDelayMS, IdentifyTimerHandler, this);

exit:
return;
Expand Down
12 changes: 3 additions & 9 deletions examples/chip-tool/commands/common/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,16 +422,10 @@ static void OnResponseTimeout(chip::System::Layer *, void *, CHIP_ERROR)

CHIP_ERROR Command::ScheduleWaitForResponse(uint16_t seconds)
{
chip::System::Timer * timer = nullptr;

CHIP_ERROR err = chip::DeviceLayer::SystemLayer.NewTimer(timer);
if (err == CHIP_NO_ERROR)
{
timer->Start(seconds * 1000, OnResponseTimeout, this);
}
else
CHIP_ERROR err = chip::DeviceLayer::SystemLayer.StartFunctTimer(seconds * 1000, OnResponseTimeout, this);
if (err != CHIP_NO_ERROR)
{
ChipLogError(chipTool, "Failed to allocate timer");
ChipLogError(chipTool, "Failed to allocate timer %" CHIP_ERROR_FORMAT, chip::ChipError::FormatError(err));
}
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/chip-tool/commands/common/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ CHIP_ERROR Commands::RunCommand(NodeId localId, NodeId remoteId, int argc, char
//
command->UpdateWaitForResponse(true);
#if CONFIG_USE_SEPARATE_EVENTLOOP
chip::DeviceLayer::PlatformMgr().ScheduleWork(RunQueuedCommand, reinterpret_cast<intptr_t>(command));
chip::DeviceLayer::PlatformMgr().PlatformScheduleWork(RunQueuedCommand, reinterpret_cast<intptr_t>(command));
command->WaitForResponse(command->GetWaitDurationInSeconds());
#else // CONFIG_USE_SEPARATE_EVENTLOOP
err = command->Run();
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void AppTask::StartTimer(uint32_t aTimeoutInMs)
CHIP_ERROR err;

SystemLayer.CancelTimer(TimerEventHandler, this);
err = SystemLayer.StartTimer(aTimeoutInMs, TimerEventHandler, this);
err = SystemLayer.StartFunctTimer(aTimeoutInMs, TimerEventHandler, this);
SuccessOrExit(err);

mFunctionTimerActive = true;
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/qpg/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void AppTask::StartTimer(uint32_t aTimeoutInMs)
CHIP_ERROR err;

SystemLayer.CancelTimer(TimerEventHandler, this);
err = SystemLayer.StartTimer(aTimeoutInMs, TimerEventHandler, this);
err = SystemLayer.StartFunctTimer(aTimeoutInMs, TimerEventHandler, this);
SuccessOrExit(err);

mFunctionTimerActive = true;
Expand Down
12 changes: 3 additions & 9 deletions examples/minimal-mdns/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,16 @@ int main(int argc, char ** args)

BroadcastPacket(&mdnsServer);

System::Timer * timer = nullptr;

if (DeviceLayer::SystemLayer.NewTimer(timer) == CHIP_NO_ERROR)
{
timer->Start(
CHIP_ERROR err = DeviceLayer::SystemLayer.StartFunctTimer(
gOptions.runtimeMs,
[](System::Layer *, void *, CHIP_ERROR err) {
DeviceLayer::PlatformMgr().StopEventLoopTask();
DeviceLayer::PlatformMgr().Shutdown();
},
nullptr);
}
else
if (err != CHIP_NO_ERROR)
{

printf("Failed to create the shutdown timer. Kill with ^C.\n");
printf("Failed to create the shutdown timer. Kill with ^C. %" CHIP_ERROR_FORMAT "\n", ChipError::FormatError(err));
}

DeviceLayer::PlatformMgr().RunEventLoop();
Expand Down
2 changes: 1 addition & 1 deletion examples/shell/shell_common/cmd_ping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ CHIP_ERROR SendEchoRequest(streamer_t * stream)
}

gPingArguments.SetLastEchoTime(System::Clock::GetMonotonicMilliseconds());
SuccessOrExit(chip::DeviceLayer::SystemLayer.StartTimer(gPingArguments.GetEchoInterval(), EchoTimerHandler, NULL));
SuccessOrExit(chip::DeviceLayer::SystemLayer.StartFunctTimer(gPingArguments.GetEchoInterval(), EchoTimerHandler, NULL));

streamer_printf(stream, "\nSend echo request message with payload size: %d bytes to Node: %" PRIu64 "\n", payloadSize,
kTestDeviceNodeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ EmberAfNodeOperationalCertStatus ConvertToNOCResponseStatus(CHIP_ERROR err)
bool emberAfOperationalCredentialsClusterRemoveAllFabricsCallback(chip::EndpointId endpoint, chip::app::CommandHandler * commandObj)
{
emberAfPrintln(EMBER_AF_PRINT_DEBUG, "OpCreds: Remove all Fabrics");
PlatformMgr().ScheduleWork(DoRemoveAllFabrics, 0);
PlatformMgr().PlatformScheduleWork(DoRemoveAllFabrics, 0);
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/reporting/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ CHIP_ERROR Engine::ScheduleRun()
{
if (InteractionModelEngine::GetInstance()->GetExchangeManager() != nullptr)
{
return InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionMgr()->SystemLayer()->ScheduleWork(Run, this);
return InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionMgr()->SystemLayer()->SystemScheduleWork(Run, this);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/tests/integration/MockEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ CHIP_ERROR MockEventGeneratorImpl::Init(chip::Messaging::ExchangeManager * apExc
mEventsLeft = mpEventGenerator->GetNumStates();

if (mTimeBetweenEvents != 0)
mpExchangeMgr->GetSessionMgr()->SystemLayer()->StartTimer(mTimeBetweenEvents, HandleNextEvent, this);
mpExchangeMgr->GetSessionMgr()->SystemLayer()->StartFunctTimer(mTimeBetweenEvents, HandleNextEvent, this);

return err;
}
Expand All @@ -174,7 +174,7 @@ void MockEventGeneratorImpl::HandleNextEvent(chip::System::Layer * apSystemLayer
generator->mEventsLeft--;
if ((generator->mEventWraparound) || (generator->mEventsLeft > 0))
{
apSystemLayer->StartTimer(generator->mTimeBetweenEvents, HandleNextEvent, generator);
apSystemLayer->StartFunctTimer(generator->mTimeBetweenEvents, HandleNextEvent, generator);
}
}
}
Expand All @@ -187,7 +187,7 @@ void MockEventGeneratorImpl::SetEventGeneratorStop()
// This helps quit the standalone app in an orderly way without
// spurious leaked timers.
if (mTimeBetweenEvents != 0)
mpExchangeMgr->GetSessionMgr()->SystemLayer()->StartTimer(0, HandleNextEvent, this);
mpExchangeMgr->GetSessionMgr()->SystemLayer()->StartFunctTimer(0, HandleNextEvent, this);
}

bool MockEventGeneratorImpl::IsEventGeneratorStopped()
Expand Down
14 changes: 7 additions & 7 deletions src/app/tests/integration/chip_im_initiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ void CommandRequestTimerHandler(chip::System::Layer * systemLayer, void * appSta
err = SendCommandRequest(commandSender);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to send command request with error: %s\n", chip::ErrorStr(err)));

err = chip::DeviceLayer::SystemLayer.StartTimer(gMessageIntervalSeconds * 1000, CommandRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer.StartFunctTimer(gMessageIntervalSeconds * 1000, CommandRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));
}
else
{
err = chip::DeviceLayer::SystemLayer.StartTimer(gMessageIntervalSeconds * 1000, BadCommandRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer.StartFunctTimer(gMessageIntervalSeconds * 1000, BadCommandRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));
}

Expand All @@ -343,7 +343,7 @@ void BadCommandRequestTimerHandler(chip::System::Layer * systemLayer, void * app
err = SendBadCommandRequest(commandSender);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to send bad command request with error: %s\n", chip::ErrorStr(err)));

err = chip::DeviceLayer::SystemLayer.StartTimer(gMessageIntervalSeconds * 1000, ReadRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer.StartFunctTimer(gMessageIntervalSeconds * 1000, ReadRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));

exit:
Expand All @@ -370,12 +370,12 @@ void ReadRequestTimerHandler(chip::System::Layer * systemLayer, void * appState,
err = SendReadRequest();
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to send read request with error: %s\n", chip::ErrorStr(err)));

err = chip::DeviceLayer::SystemLayer.StartTimer(gMessageIntervalSeconds * 1000, ReadRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer.StartFunctTimer(gMessageIntervalSeconds * 1000, ReadRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));
}
else
{
err = chip::DeviceLayer::SystemLayer.StartTimer(gMessageIntervalSeconds * 1000, WriteRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer.StartFunctTimer(gMessageIntervalSeconds * 1000, WriteRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));
}

Expand Down Expand Up @@ -407,7 +407,7 @@ void WriteRequestTimerHandler(chip::System::Layer * systemLayer, void * appState
err = SendWriteRequest(writeClient);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to send write request with error: %s\n", chip::ErrorStr(err)));

err = chip::DeviceLayer::SystemLayer.StartTimer(gMessageIntervalSeconds * 1000, WriteRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer.StartFunctTimer(gMessageIntervalSeconds * 1000, WriteRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));
}
else
Expand Down Expand Up @@ -590,7 +590,7 @@ int main(int argc, char * argv[])
err = EstablishSecureSession();
SuccessOrExit(err);

err = chip::DeviceLayer::SystemLayer.StartTimer(0, CommandRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer.StartFunctTimer(0, CommandRequestTimerHandler, NULL);
SuccessOrExit(err);

chip::DeviceLayer::PlatformMgr().RunEventLoop();
Expand Down
4 changes: 2 additions & 2 deletions src/app/util/af-event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ EmberStatus emberEventControlSetDelayMS(EmberEventControl * control, uint32_t de
{
control->status = EMBER_EVENT_MS_TIME;
#if !CHIP_DEVICE_LAYER_NONE
chip::DeviceLayer::SystemLayer.StartTimer(delayMs, EventControlHandler, control);
chip::DeviceLayer::SystemLayer.StartFunctTimer(delayMs, EventControlHandler, control);
#endif
}
else
Expand Down Expand Up @@ -179,7 +179,7 @@ void emberEventControlSetActive(EmberEventControl * control)
{
control->status = EMBER_EVENT_ZERO_DELAY;
#if !CHIP_DEVICE_LAYER_NONE
chip::DeviceLayer::SystemLayer.ScheduleWork(EventControlHandler, control);
chip::DeviceLayer::SystemLayer.SystemScheduleWork(EventControlHandler, control);
#endif
}

Expand Down
11 changes: 6 additions & 5 deletions src/ble/BLEEndPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ bool BLEEndPoint::SendIndication(PacketBufferHandle && buf)

CHIP_ERROR BLEEndPoint::StartConnectTimer()
{
const CHIP_ERROR timerErr = mBle->mSystemLayer->StartTimer(BLE_CONNECT_TIMEOUT_MS, HandleConnectTimeout, this);
const CHIP_ERROR timerErr = mBle->mSystemLayer->StartFunctTimer(BLE_CONNECT_TIMEOUT_MS, HandleConnectTimeout, this);
ReturnErrorOnFailure(timerErr);
mTimerStateFlags.Set(TimerStateFlag::kConnectTimerRunning);

Expand All @@ -1436,7 +1436,7 @@ CHIP_ERROR BLEEndPoint::StartConnectTimer()

CHIP_ERROR BLEEndPoint::StartReceiveConnectionTimer()
{
const CHIP_ERROR timerErr = mBle->mSystemLayer->StartTimer(BLE_CONNECT_TIMEOUT_MS, HandleReceiveConnectionTimeout, this);
const CHIP_ERROR timerErr = mBle->mSystemLayer->StartFunctTimer(BLE_CONNECT_TIMEOUT_MS, HandleReceiveConnectionTimeout, this);
ReturnErrorOnFailure(timerErr);
mTimerStateFlags.Set(TimerStateFlag::kReceiveConnectionTimerRunning);

Expand All @@ -1447,7 +1447,8 @@ CHIP_ERROR BLEEndPoint::StartAckReceivedTimer()
{
if (!mTimerStateFlags.Has(TimerStateFlag::kAckReceivedTimerRunning))
{
const CHIP_ERROR timerErr = mBle->mSystemLayer->StartTimer(BTP_ACK_RECEIVED_TIMEOUT_MS, HandleAckReceivedTimeout, this);
const CHIP_ERROR timerErr =
mBle->mSystemLayer->StartFunctTimer(BTP_ACK_RECEIVED_TIMEOUT_MS, HandleAckReceivedTimeout, this);
ReturnErrorOnFailure(timerErr);

mTimerStateFlags.Set(TimerStateFlag::kAckReceivedTimerRunning);
Expand All @@ -1472,7 +1473,7 @@ CHIP_ERROR BLEEndPoint::StartSendAckTimer()
if (!mTimerStateFlags.Has(TimerStateFlag::kSendAckTimerRunning))
{
ChipLogDebugBleEndPoint(Ble, "starting new SendAckTimer");
const CHIP_ERROR timerErr = mBle->mSystemLayer->StartTimer(BTP_ACK_SEND_TIMEOUT_MS, HandleSendAckTimeout, this);
const CHIP_ERROR timerErr = mBle->mSystemLayer->StartFunctTimer(BTP_ACK_SEND_TIMEOUT_MS, HandleSendAckTimeout, this);
ReturnErrorOnFailure(timerErr);

mTimerStateFlags.Set(TimerStateFlag::kSendAckTimerRunning);
Expand All @@ -1483,7 +1484,7 @@ CHIP_ERROR BLEEndPoint::StartSendAckTimer()

CHIP_ERROR BLEEndPoint::StartUnsubscribeTimer()
{
const CHIP_ERROR timerErr = mBle->mSystemLayer->StartTimer(BLE_UNSUBSCRIBE_TIMEOUT_MS, HandleUnsubscribeTimeout, this);
const CHIP_ERROR timerErr = mBle->mSystemLayer->StartFunctTimer(BLE_UNSUBSCRIBE_TIMEOUT_MS, HandleUnsubscribeTimeout, this);
ReturnErrorOnFailure(timerErr);
mTimerStateFlags.Set(TimerStateFlag::kUnsubscribeTimerRunning);

Expand Down
5 changes: 0 additions & 5 deletions src/ble/BleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ class DLL_EXPORT BleLayer
CHIP_ERROR CloseAllBleConnections();
CHIP_ERROR CloseBleConnection(BLE_CONNECTION_OBJECT connObj);

CHIP_ERROR ScheduleWork(chip::System::Layer::TimerCompleteFunct aComplete, void * aAppState)
{
return mSystemLayer->ScheduleWork(aComplete, aAppState);
}

/**< Platform interface functions:
* Calling conventions:
Expand Down
2 changes: 1 addition & 1 deletion src/channel/ChannelContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void ChannelContext::EnterAddressResolve()
if (mState == ChannelState::kPreparing && GetPrepareVars().mState == PrepareState::kAddressResolving)
{
System::Layer * layer = mExchangeManager->GetSessionMgr()->SystemLayer();
layer->StartTimer(CHIP_CONFIG_NODE_ADDRESS_RESOLVE_TIMEOUT_MSECS, AddressResolveTimeout, this);
layer->StartFunctTimer(CHIP_CONFIG_NODE_ADDRESS_RESOLVE_TIMEOUT_MSECS, AddressResolveTimeout, this);
Retain(); // Keep the pointer in the timer
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam

device->Init(GetControllerDeviceInitParams(), mListenPort, remoteDeviceId, peerAddress, fabric->GetFabricIndex());

mSystemLayer->StartTimer(kSessionEstablishmentTimeout, OnSessionEstablishmentTimeoutCallback, this);
mSystemLayer->StartFunctTimer(kSessionEstablishmentTimeout, OnSessionEstablishmentTimeoutCallback, this);
if (params.GetPeerAddress().GetTransportType() != Transport::Type::kBle)
{
device->SetAddress(params.GetPeerAddress().GetIPAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,6 @@ ChipError::StorageType pychip_DeviceController_PostTaskOnChipThread(ChipThreadTa
}
// This function is not called and should not be called on CHIP thread, thus we need to acquire a lock for posting tasks.
StackLock lock;
PlatformMgr().ScheduleWork(callback, reinterpret_cast<intptr_t>(pythonContext));
PlatformMgr().PlatformScheduleWork(callback, reinterpret_cast<intptr_t>(pythonContext));
return ChipError::AsInteger(CHIP_NO_ERROR);
}
2 changes: 1 addition & 1 deletion src/controller/python/chip/internal/ChipThreadWork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void ChipMainThreadScheduleAndWait(WorkCallback callback)
WorkData workdata;
workdata.callback = callback;

chip::DeviceLayer::PlatformMgr().ScheduleWork(PerformWork, reinterpret_cast<intptr_t>(&workdata));
chip::DeviceLayer::PlatformMgr().PlatformScheduleWork(PerformWork, reinterpret_cast<intptr_t>(&workdata));

workdata.Wait();
}
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@
"CHIP_DEVICE_LAYER_TARGET_NRF5=0",
"CHIP_DEVICE_LAYER_TARGET_EFR32=0",
"CHIP_SYSTEM_CONFIG_USE_SOCKETS=1",
"CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0",
"CHIP_SYSTEM_CONFIG_NO_LOCKING=1",
"$(inherited)",
);
HEADER_SEARCH_PATHS = (
Expand Down Expand Up @@ -738,6 +740,8 @@
"CHIP_DEVICE_LAYER_TARGET_NRF5=0",
"CHIP_DEVICE_LAYER_TARGET_EFR32=0",
"CHIP_SYSTEM_CONFIG_USE_SOCKETS=1",
"CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0",
"CHIP_SYSTEM_CONFIG_NO_LOCKING=1",
"$(inherited)",
);
HEADER_SEARCH_PATHS = (
Expand Down
15 changes: 5 additions & 10 deletions src/include/platform/PlatformManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <system/SystemLayer.h>

namespace chip {

namespace DeviceLayer {

class PlatformManagerImpl;
Expand All @@ -36,6 +37,7 @@ class ConfigurationManagerImpl;
class TraitManager;
class ThreadStackManagerImpl;
class TimeSyncManager;

namespace Internal {
class DeviceControlServer;
class FabricProvisioningServer;
Expand Down Expand Up @@ -87,7 +89,7 @@ class PlatformManager
* the work up but that work will NOT run until one of those functions is
* called.
*/
void ScheduleWork(AsyncWorkFunct workFunct, intptr_t arg = 0);
void PlatformScheduleWork(AsyncWorkFunct workFunct, intptr_t arg = 0);
/**
* Process work items until StopEventLoopTask is called. RunEventLoop will
* not return until work item processing is stopped. Once it returns it
Expand Down Expand Up @@ -169,14 +171,7 @@ class PlatformManager
friend class Internal::GenericThreadStackManagerImpl_OpenThread_LwIP;
template <class>
friend class Internal::GenericConfigurationManagerImpl;
// Parentheses used to fix clang parsing issue with these declarations
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);
friend class System::PlatformEventing;

void PostEvent(const ChipDeviceEvent * event);
void DispatchEvent(const ChipDeviceEvent * event);
Expand Down Expand Up @@ -274,7 +269,7 @@ inline void PlatformManager::RemoveEventHandler(EventHandlerFunct handler, intpt
static_cast<ImplClass *>(this)->_RemoveEventHandler(handler, arg);
}

inline void PlatformManager::ScheduleWork(AsyncWorkFunct workFunct, intptr_t arg)
inline void PlatformManager::PlatformScheduleWork(AsyncWorkFunct workFunct, intptr_t arg)
{
static_cast<ImplClass *>(this)->_ScheduleWork(workFunct, arg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void GenericPlatformManagerImpl<ImplClass>::DispatchEventToSystemLayer(const Chi
CHIP_ERROR err = CHIP_NO_ERROR;

// Invoke the System Layer's event handler function.
err = SystemLayer.HandleEvent(*event->ChipSystemLayerEvent.Target, event->ChipSystemLayerEvent.Type,
err = SystemLayer.WatchableEvents().LayerLwIPHandleEvent(*event->ChipSystemLayerEvent.Target, event->ChipSystemLayerEvent.Type,
event->ChipSystemLayerEvent.Argument);
if (err != CHIP_NO_ERROR)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_RunEventLoop(void)

// Call into the system layer to dispatch the callback functions for all timers
// that have expired.
err = SystemLayer.HandlePlatformTimer();
err = SystemLayer.WatchableEvents().LayerLwIPHandlePlatformTimer();
if (err != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Error handling CHIP timers: %s", ErrorStr(err));
Expand Down
Loading

0 comments on commit 2fe3f89

Please sign in to comment.