Thingstream Client Library  BLD4131-v2.13
Macros | Functions
Time utilities

Utilities related to time. More...

Collaboration diagram for Time utilities:

Macros

#define TIME_COMPARE(left, cmp, right)    (((int32_t)((left) - (right))) cmp 0)
 

Functions

uint32_t Thingstream_Util_runUntil (ThingstreamTransport *transport, uint32_t when)
 
uint32_t Thingstream_Util_run (ThingstreamTransport *transport, uint32_t delay)
 

Detailed Description

Utilities related to time.

Macro Definition Documentation

◆ TIME_COMPARE

#define TIME_COMPARE (   left,
  cmp,
  right 
)     (((int32_t)((left) - (right))) cmp 0)

A macro to compare two times, as returned from Thingstream_Platform_getTimeMillis(), and return TRUE if the given comparison holds. This macro handles zero-wrapping of either left or right values and provides a result assuming that the times are within 24 days of each other.

Parameters
leftthe left millisecond count
cmpthe comparison
rightthe right millisecond count
Returns
TRUE if (left cmp right) is true when treating left and right as reasonably close to each other.

Function Documentation

◆ Thingstream_Util_run()

uint32_t Thingstream_Util_run ( ThingstreamTransport transport,
uint32_t  delay 
)

Repeatedly invoke a transport run() function until the given interval has passed. This is a simple way to sleep for a fixed period. As a convenience to the caller, the value Thingstream_Platform_getTimeMillis() is returned (and may be ignored).

Parameters
transportthe transport instance
delaythe delay in milliseconds
Returns
transport current time

◆ Thingstream_Util_runUntil()

uint32_t Thingstream_Util_runUntil ( ThingstreamTransport transport,
uint32_t  when 
)

Repeatedly invoke a transport run() function until the given time limit is reached. As a convenience to the caller, the current time is returned, though it will usually be close to the 'when' parameter.

Parameters
transportthe transport instance
whenthe time limit, relative to Thingstream_Platform_getTimeMillis()
Returns
transport current time