Microchip® Advanced Software Framework

timer_interface.h File Reference

Timer interface definition for MQTT client.

Defines an interface to timers that can be used by other system components. MQTT client requires timers to handle timeouts and MQTT keep alive. Starting point for porting the SDK to the timer hardware layer of a new platform.

Typedefs

typedef struct Timer Timer
 Timer Type. More...
 

Functions

void countdown (Timer *, unsigned int)
 Create a timer (seconds) More...
 
void countdown_ms (Timer *, unsigned int)
 Create a timer (milliseconds) More...
 
char expired (Timer *)
 Check if a timer is expired. More...
 
void InitTimer (Timer *)
 Initialize a timer. More...
 
int left_ms (Timer *)
 Check the time remaining on a give timer. More...
 

typedef struct Timer Timer

Timer Type.

Forward declaration of a timer struct. The definition of this struct is platform dependent. When porting to a new platform add this definition in "timer_<platform>.h" and include that file above.

void countdown ( Timer timer,
unsigned int  timeout 
)

Create a timer (seconds)

Sets the timer to expire in a specified number of seconds.

Parameters
Timer- pointer to the timer to be set to expire in seconds
unsignedint - set the timer to expire in this number of seconds

Create a timer (seconds)

Parameters
[in]timerTimer to be started.
[in]timeouttimeout in seconds.
Returns
None.

References Timer::end_time, getTimeInMillis(), and Timer::offset.

Referenced by addToAckWaitList(), cycle(), keepalive(), MQTTConnect(), and subscribeToShadowActionAcks().

void countdown_ms ( Timer timer,
unsigned int  timeout 
)

Create a timer (milliseconds)

Sets the timer to expire in a specified number of milliseconds.

Parameters
Timer- pointer to the timer to be set to expire in milliseconds
unsignedint - set the timer to expire in this number of milliseconds

Create a timer (milliseconds)

Parameters
[in]timerTimer to be started.
[in]timeouttimeout in milliseconds.
Returns
None.

References Timer::end_time, getTimeInMillis(), and Timer::offset.

Referenced by handleReconnect(), keepalive(), MQTTConnect(), MQTTDisconnect(), MQTTPublish(), MQTTResubscribe(), MQTTSubscribe(), MQTTUnsubscribe(), and MQTTYield().

char expired ( Timer timer)

Check if a timer is expired.

Call this function passing in a timer to check if that timer has expired.

Parameters
Timer- pointer to the timer to be checked for expiration
Returns
character - 1 = timer expired, 0 = timer not expired

Check if a timer is expired.

Parameters
[in]timerTimer to be checked.
Returns
time to expiry.

References Timer::end_time, getTimeInMillis(), and Timer::offset.

Referenced by HandleExpiredResponseCallbacks(), handleReconnect(), keepalive(), MQTTYield(), sendPacket(), subscribeToShadowActionAcks(), and waitfor().

void InitTimer ( Timer timer)

Initialize a timer.

Performs any initialization required to the timer passed in.

Parameters
Timer- pointer to the timer to be initialized

Initialize a timer.

Parameters
[in]timerTimer to be intialized.
Returns
None.

References Timer::end_time, and Timer::offset.

Referenced by addToAckWaitList(), keepalive(), MQTTClient(), MQTTConnect(), MQTTDisconnect(), MQTTPublish(), MQTTResubscribe(), MQTTSubscribe(), MQTTUnsubscribe(), MQTTYield(), and subscribeToShadowActionAcks().

int left_ms ( Timer timer)

Check the time remaining on a give timer.

Checks the input timer and returns the number of milliseconds remaining on the timer.

Parameters
Timer- pointer to the timer to be set to checked
Returns
int - milliseconds left on the countdown timer

Check the time remaining on a give timer.

Parameters
[in]timerTimer to be started.
Returns
Time for expiry in milliseconds.

References Timer::end_time, getTimeInMillis(), and Timer::offset.

Referenced by readPacket(), and sendPacket().