Skip to content

Commit

Permalink
Use safe System::Clock types for system timers (#10779)
Browse files Browse the repository at this point in the history
#### Problem

Timer functions take plain integer arguments and rely on callers to
get the units correct.

Part of #10062 _Some operations on System::Clock types are not safe_

#### Change overview

Change `System::Layer` and `PlatformManager` timers to take
`System::Clock::Timeout` instead of plain integers.

This change primarily converts arguments at call sites by wrapping
with a `Clock::Milliseconds32()` constructor or similar operation.
Future changes will convert types further up the call stack.

#### Testing

CI; no change to functionality intended.
  • Loading branch information
kpschoedel authored Oct 21, 2021
1 parent 49727db commit ea1b443
Show file tree
Hide file tree
Showing 75 changed files with 219 additions and 231 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 @@ -217,7 +217,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState)

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

DeviceLayer::SystemLayer().CancelTimer(IdentifyTimerHandler, this);
DeviceLayer::SystemLayer().StartTimer(kIdentifyTimerDelayMS, IdentifyTimerHandler, this);
DeviceLayer::SystemLayer().StartTimer(Clock::Milliseconds32(kIdentifyTimerDelayMS), IdentifyTimerHandler, this);

exit:
return;
Expand Down
3 changes: 2 additions & 1 deletion examples/chip-tool/commands/common/CHIPCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ CHIP_ERROR CHIPCommand::StartWaiting(uint16_t seconds)
}
LogErrorOnFailure(chip::DeviceLayer::PlatformMgr().StopEventLoopTask());
#else
ReturnLogErrorOnFailure(chip::DeviceLayer::SystemLayer().StartTimer(seconds * 1000, OnResponseTimeout, this));
ReturnLogErrorOnFailure(
chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(seconds), OnResponseTimeout, this));
chip::DeviceLayer::PlatformMgr().RunEventLoop();
#endif // CONFIG_USE_SEPARATE_EVENTLOOP

Expand Down
2 changes: 1 addition & 1 deletion examples/chip-tool/commands/tests/TestCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void TestCommand::OnWaitForMsFn(chip::System::Layer * systemLayer, void * contex

CHIP_ERROR TestCommand::WaitForMs(uint32_t ms)
{
return chip::DeviceLayer::SystemLayer().StartTimer(ms, OnWaitForMsFn, this);
return chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(ms), OnWaitForMsFn, this);
}

CHIP_ERROR TestCommand::Log(const char * message)
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 @@ -374,7 +374,7 @@ void AppTask::StartTimer(uint32_t aTimeoutInMs)
{
CHIP_ERROR err;

err = SystemLayer().StartTimer(aTimeoutInMs, TimerEventHandler, this);
err = SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(aTimeoutInMs), TimerEventHandler, this);
SuccessOrExit(err);

mFunctionTimerActive = true;
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/esp32/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ void AppTask::AppTaskMain(void * pvParameter)
sLockLED.Animate();

Clock::MonotonicMicroseconds nowUS = SystemClock().GetMonotonicMicroseconds();
Clock::MonotonicMicroseconds nextChangeTimeUS = Clock::AddOffset(mLastChangeTimeUS, 5 * 1000 * 1000UL);
Clock::MonotonicMicroseconds nextChangeTimeUS = mLastChangeTimeUS + (5 * 1000 * 1000UL);

if (Clock::IsEarlier(nextChangeTimeUS, nowUS))
if (nextChangeTimeUS < nowUS)
{
mLastChangeTimeUS = nowUS;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/esp32/main/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ void LEDWidget::Animate()
{
chip::System::Clock::MonotonicMicroseconds nowUS = chip::System::SystemClock().GetMonotonicMicroseconds();
chip::System::Clock::MonotonicMicroseconds stateDurUS = ((mState) ? mBlinkOnTimeMS : mBlinkOffTimeMS) * 1000LL;
chip::System::Clock::MonotonicMicroseconds nextChangeTimeUS = chip::System::Clock::AddOffset(mLastChangeTimeUS, stateDurUS);
chip::System::Clock::MonotonicMicroseconds nextChangeTimeUS = mLastChangeTimeUS + stateDurUS;

if (chip::System::Clock::IsEarlier(nextChangeTimeUS, nowUS))
if (nextChangeTimeUS < nowUS)
{
DoSet(!mState);
mLastChangeTimeUS = nowUS;
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;

chip::DeviceLayer::SystemLayer().CancelTimer(TimerEventHandler, this);
err = chip::DeviceLayer::SystemLayer().StartTimer(aTimeoutInMs, TimerEventHandler, this);
err = chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(aTimeoutInMs), TimerEventHandler, this);
SuccessOrExit(err);

mFunctionTimerActive = true;
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/efr32/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void LEDWidget::Animate()
Clock::MonotonicMicroseconds stateDurUS = ((sl_led_get_state(mLed)) ? mBlinkOnTimeMS : mBlinkOffTimeMS) * 1000LL;
Clock::MonotonicMicroseconds nextChangeTimeUS = mLastChangeTimeUS + stateDurUS;

if (Clock::IsEarlier(nextChangeTimeUS, nowUS))
if (nextChangeTimeUS < nowUS)
{
Invert();
mLastChangeTimeUS = nowUS;
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/mbed/util/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void LEDWidget::Animate()
chip::System::Clock::MonotonicMilliseconds stateDurMS = (mLED == LED_ACTIVE_STATE) ? mBlinkOnTimeMS : mBlinkOffTimeMS;
chip::System::Clock::MonotonicMilliseconds nextChangeTimeMS = mLastChangeTimeMS + stateDurMS;

if (chip::System::Clock::IsEarlier(nextChangeTimeMS, nowMS))
if (nextChangeTimeMS < nowMS)
{
mLED = !mLED;
mLastChangeTimeMS = nowMS;
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/nxp/k32w/k32w0/util/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void LEDWidget::Animate()
chip::System::Clock::MonotonicMicroseconds stateDurUS = ((mState) ? mBlinkOnTimeMS : mBlinkOffTimeMS) * 1000LL;
chip::System::Clock::MonotonicMicroseconds nextChangeTimeUS = mLastChangeTimeUS + stateDurUS;

if (chip::System::Clock::IsEarlier(nextChangeTimeUS, nowUS))
if (nextChangeTimeUS < nowUS)
{
DoSet(!mState);
mLastChangeTimeUS = nowUS;
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/p6/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void LEDWidget::Animate()
chip::System::Clock::MonotonicMicroseconds stateDurUS = ((mState) ? mBlinkOnTimeMS : mBlinkOffTimeMS) * 1000LL;
chip::System::Clock::MonotonicMicroseconds nextChangeTimeUS = mLastChangeTimeUS + stateDurUS;

if (chip::System::Clock::IsEarlier(nextChangeTimeUS, nowUS))
if (nextChangeTimeUS < nowUS)
{
DoSet(!mState);
mLastChangeTimeUS = nowUS;
Expand Down
3 changes: 2 additions & 1 deletion examples/shell/shell_common/cmd_ping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ CHIP_ERROR SendEchoRequest(streamer_t * stream)
}

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

streamer_printf(stream, "\nSend echo request message with payload size: %d bytes to Node: %" PRIu64 "\n", payloadSize,
kTestDeviceNodeId);
Expand Down
2 changes: 1 addition & 1 deletion examples/tv-casting-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ int main(int argc, char * argv[])

// Give commissioners some time to respond and then ScheduleWork to initiate commissioning
DeviceLayer::SystemLayer().StartTimer(
kCommissionerDiscoveryTimeoutInMs,
chip::System::Clock::Milliseconds32(kCommissionerDiscoveryTimeoutInMs),
[](System::Layer *, void *) { chip::DeviceLayer::PlatformMgr().ScheduleWork(InitCommissioningFlow); }, nullptr);

// TBD: Content casting commands
Expand Down
2 changes: 1 addition & 1 deletion src/app/ReadClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ CHIP_ERROR ReadClient::RefreshLivenessCheckTimer()
CancelLivenessCheckTimer();
ChipLogProgress(DataManagement, "Refresh LivenessCheckTime with %d seconds", mMaxIntervalCeilingSeconds);
CHIP_ERROR err = InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->StartTimer(
mMaxIntervalCeilingSeconds * kMillisecondsPerSecond, OnLivenessTimeoutCallback, this);
System::Clock::Seconds16(mMaxIntervalCeilingSeconds), OnLivenessTimeoutCallback, this);

if (err != CHIP_NO_ERROR)
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ CHIP_ERROR ReadHandler::RefreshSubscribeSyncTimer()
OnRefreshSubscribeTimerSyncCallback, this);
mHoldReport = true;
return InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->StartTimer(
mMinIntervalFloorSeconds * kMillisecondsPerSecond, OnRefreshSubscribeTimerSyncCallback, this);
System::Clock::Seconds16(mMinIntervalFloorSeconds), OnRefreshSubscribeTimerSyncCallback, this);
}
} // namespace app
} // namespace chip
4 changes: 2 additions & 2 deletions src/app/clusters/identify-server/identify-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void MatterIdentifyClusterServerAttributeChangedCallback(const app::ConcreteAttr
/* finish identify process */
if (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT == identify->mCurrentEffectIdentifier && identifyTime > 0)
{
(void) chip::DeviceLayer::SystemLayer().StartTimer(MILLISECOND_TICKS_PER_SECOND, onIdentifyClusterTick,
(void) chip::DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(1), onIdentifyClusterTick,
identify);
return;
}
Expand All @@ -196,7 +196,7 @@ void MatterIdentifyClusterServerAttributeChangedCallback(const app::ConcreteAttr
/* we only start if both callbacks are set */
identify_activate(identify);

(void) chip::DeviceLayer::SystemLayer().StartTimer(MILLISECOND_TICKS_PER_SECOND, onIdentifyClusterTick, identify);
(void) chip::DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(1), onIdentifyClusterTick, identify);
return;
}
else
Expand Down
8 changes: 4 additions & 4 deletions src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ void CommissioningWindowManager::OnSessionEstablishmentError(CHIP_ERROR err)
void CommissioningWindowManager::OnSessionEstablishmentStarted()
{
// As per specifications, section 5.5: Commissioning Flows
constexpr uint16_t kPASESessionEstablishmentTimeoutSeconds = 60;
DeviceLayer::SystemLayer().StartTimer(kPASESessionEstablishmentTimeoutSeconds * 1000, HandleSessionEstablishmentTimeout, this);
constexpr System::Clock::Timeout kPASESessionEstablishmentTimeout = System::Clock::Seconds16(60);
DeviceLayer::SystemLayer().StartTimer(kPASESessionEstablishmentTimeout, HandleSessionEstablishmentTimeout, this);
}

void CommissioningWindowManager::OnSessionEstablished()
Expand Down Expand Up @@ -159,8 +159,8 @@ CHIP_ERROR CommissioningWindowManager::OpenCommissioningWindow()

if (mCommissioningTimeoutSeconds != kNoCommissioningTimeout)
{
ReturnErrorOnFailure(
DeviceLayer::SystemLayer().StartTimer(mCommissioningTimeoutSeconds * 1000, HandleCommissioningWindowTimeout, this));
ReturnErrorOnFailure(DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(mCommissioningTimeoutSeconds),
HandleCommissioningWindowTimeout, this));
}

ReturnErrorOnFailure(mServer->GetExchangeManager().RegisterUnsolicitedMessageHandlerForType(
Expand Down
4 changes: 2 additions & 2 deletions src/app/server/Dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ CHIP_ERROR DnssdServer::ScheduleDiscoveryExpiration()

mDiscoveryExpirationMs = mTimeSource.GetCurrentMonotonicTimeMs() + static_cast<uint64_t>(mDiscoveryTimeoutSecs) * 1000;

return DeviceLayer::SystemLayer().StartTimer(static_cast<uint32_t>(mDiscoveryTimeoutSecs) * 1000, HandleDiscoveryExpiration,
return DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(mDiscoveryTimeoutSecs), HandleDiscoveryExpiration,
nullptr);
}

Expand All @@ -231,7 +231,7 @@ CHIP_ERROR DnssdServer::ScheduleExtendedDiscoveryExpiration()
mExtendedDiscoveryExpirationMs =
mTimeSource.GetCurrentMonotonicTimeMs() + static_cast<uint64_t>(extendedDiscoveryTimeoutSecs) * 1000;

return DeviceLayer::SystemLayer().StartTimer(static_cast<uint32_t>(extendedDiscoveryTimeoutSecs) * 1000,
return DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(extendedDiscoveryTimeoutSecs),
HandleExtendedDiscoveryExpiration, nullptr);
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
Expand Down
3 changes: 2 additions & 1 deletion src/app/tests/TestCommissionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ void CheckCommissioningWindowManagerWindowTimeoutTask(intptr_t context)
CHIP_ERROR err = commissionMgr.OpenBasicCommissioningWindow(kTimeoutSeconds, CommissioningWindowAdvertisement::kDnssdOnly);
NL_TEST_ASSERT(suite, err == CHIP_NO_ERROR);
NL_TEST_ASSERT(suite, commissionMgr.IsCommissioningWindowOpen());
chip::DeviceLayer::SystemLayer().StartTimer(kTimeoutMs + kSleepPadding, CheckCommissioningWindowManagerWindowClosedTask, suite);
chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(kTimeoutMs + kSleepPadding),
CheckCommissioningWindowManagerWindowClosedTask, suite);
}

void CheckCommissioningWindowManagerWindowTimeout(nlTestSuite * suite, void *)
Expand Down
8 changes: 5 additions & 3 deletions src/app/tests/integration/MockEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ CHIP_ERROR MockEventGeneratorImpl::Init(chip::Messaging::ExchangeManager * apExc
mEventsLeft = mpEventGenerator->GetNumStates();

if (mTimeBetweenEvents != 0)
mpExchangeMgr->GetSessionManager()->SystemLayer()->StartTimer(mTimeBetweenEvents, HandleNextEvent, this);
mpExchangeMgr->GetSessionManager()->SystemLayer()->StartTimer(chip::System::Clock::Milliseconds32(mTimeBetweenEvents),
HandleNextEvent, this);

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

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

err = chip::DeviceLayer::SystemLayer().StartTimer(gMessageIntervalMsec, CommandRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(gMessageIntervalMsec),
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(gMessageIntervalMsec, BadCommandRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(gMessageIntervalMsec),
BadCommandRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));
}

Expand All @@ -489,7 +491,8 @@ void BadCommandRequestTimerHandler(chip::System::Layer * systemLayer, void * app
err = SendBadCommandRequest(std::move(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(gMessageIntervalMsec, ReadRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(gMessageIntervalMsec),
ReadRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));

exit:
Expand All @@ -516,12 +519,14 @@ 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(gMessageIntervalMsec, ReadRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(gMessageIntervalMsec),
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(gMessageIntervalMsec, WriteRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(gMessageIntervalMsec),
WriteRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));
}

Expand Down Expand Up @@ -553,12 +558,14 @@ 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(gMessageIntervalMsec, WriteRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(gMessageIntervalMsec),
WriteRequestTimerHandler, 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, SubscribeRequestTimerHandler, NULL);
err = chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(gMessageIntervalSeconds * 1000),
SubscribeRequestTimerHandler, NULL);
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to schedule timer with error: %s\n", chip::ErrorStr(err)));
}

Expand Down Expand Up @@ -586,7 +593,7 @@ void SubscribeRequestTimerHandler(chip::System::Layer * systemLayer, void * appS
err = SendSubscribeRequest();
VerifyOrExit(err == CHIP_NO_ERROR, printf("Failed to send write request with error: %s\n", chip::ErrorStr(err)));

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

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

chip::DeviceLayer::PlatformMgr().RunEventLoop();
Expand Down
Loading

0 comments on commit ea1b443

Please sign in to comment.