AWS IoT Device SDK C: Platform
Platform portability layer
Return to main page ↑
IotClock_TimerArm

Arm a timer to expire at the given relative timeout.

uint32_t relativeTimeoutMs,
uint32_t periodMs );

This function arms a timer to run its expiration routine at the given time.

If periodMs is nonzero, the timer should expire periodically at intervals such as:

  • relativeTimeoutMs
  • relativeTimeoutMs + periodMs
  • relativeTimeoutMs + 2 * periodMs
  • Etc. (subject to some jitter).

Setting periodMs to 0 arms a one-shot, non-periodic timer.

Parameters
[in]pTimerThe timer to arm.
[in]relativeTimeoutMsWhen the timer should expire, relative to the time this function is called.
[in]periodMsHow often the timer should expire again after relativeTimerMs.
Returns
true if the timer was successfully armed; false otherwise.
See also
IotClock_TimerCreate, IotClock_TimerDestroy

Example

void timerExpirationRoutine( void * pArgument );
void timerExample( void )
{
IotTimer_t timer;
if( IotClock_TimerCreate( &timer, timerExpirationRoutine, NULL ) == true )
{
// Set the timer to periodically expire every 10 seconds.
if( IotClock_TimerArm( &timer, 10000, 10000 ) == true )
{
// Wait for timer to expire.
}
}
}