libcoap 4.3.2rc2

Macros | Typedefs | Functions
Clock Handling
Application API

API for internal clock assess. More...

## Macros
#define | COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))
| Use ms resolution on POSIX systems. More...

## Typedefs
typedef uint64_t | coap_tick_t
| This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution. More...
typedef time_t | coap_time_t
| CoAP time in seconds since epoch. More...
typedef int64_t | coap_tick_diff_t
| This data type is used to represent the difference between two clock_tick_t values. More...

## Functions
void | coap_clock_init (void)
| Initializes the internal clock. More...
void | coap_ticks (coap_tick_t *t)
| Sets `t` to the internal time with COAP_TICKS_PER_SECOND resolution. More...
coap_time_t | coap_ticks_to_rt (coap_tick_t t)
| Helper function that converts coap ticks to wallclock time. More...
uint64_t | coap_ticks_to_rt_us (coap_tick_t t)
| Helper function that converts coap ticks to POSIX wallclock time in us. More...
coap_tick_t | coap_ticks_from_rt_us (uint64_t t)
| Helper function that converts POSIX wallclock time in us to coap ticks. More...
COAP_STATIC_INLINE int | coap_time_lt (coap_tick_t a, coap_tick_t b)
| Returns `1` if and only if `a` is less than `b` where less is defined on a signed data type. More...
COAP_STATIC_INLINE int | coap_time_le (coap_tick_t a, coap_tick_t b)
| Returns `1` if and only if `a` is less than or equal `b` where less is defined on a signed data type. More...

## Detailed Description

API for internal clock assess.

## Macro Definition Documentation

## ◆ COAP_TICKS_PER_SECOND

#define COAP_TICKS_PER_SECOND ((coap_tick_t)(1000U))

Use ms resolution on POSIX systems.

Definition at line 159 of file coap_time.h.

## Typedef Documentation

## ◆ coap_tick_diff_t

typedef int64_t coap_tick_diff_t

This data type is used to represent the difference between two clock_tick_t values.

This data type must have the same size in memory as coap_tick_t to allow wrapping.

Definition at line 156 of file coap_time.h.

## ◆ coap_tick_t

typedef uint64_t coap_tick_t

This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.

Definition at line 144 of file coap_time.h.

## ◆ coap_time_t

typedef time_t coap_time_t

CoAP time in seconds since epoch.

Definition at line 149 of file coap_time.h.

## Function Documentation

## ◆ coap_clock_init()

void coap_clock_init | ( | void |  | ) |

Initializes the internal clock.

## ◆ coap_ticks()

void coap_ticks | ( | coap_tick_t * | t | ) |

Sets `t` to the internal time with COAP_TICKS_PER_SECOND resolution.

## ◆ coap_ticks_from_rt_us()

coap_tick_t coap_ticks_from_rt_us | ( | uint64_t | t | ) |

Helper function that converts POSIX wallclock time in us to coap ticks.

Parameters

  t | POSIX time is us

Returns
  coap ticks

## ◆ coap_ticks_to_rt()

coap_time_t coap_ticks_to_rt | ( | coap_tick_t | t | ) |

Helper function that converts coap ticks to wallclock time.

On POSIX, this function returns the number of seconds since the epoch. On other systems, it may be the calculated number of seconds since last reboot or so.

Parameters

  t | Internal system ticks.

Returns
  The number of seconds that has passed since a specific reference point (seconds since epoch on POSIX).

## ◆ coap_ticks_to_rt_us()

uint64_t coap_ticks_to_rt_us | ( | coap_tick_t | t | ) |

Helper function that converts coap ticks to POSIX wallclock time in us.

Parameters

  t | Internal system ticks.

Returns
  The number of seconds that has passed since a specific reference point (seconds since epoch on POSIX).

## ◆ coap_time_le()

COAP_STATIC_INLINE int coap_time_le | ( | coap_tick_t | a,
|  | coap_tick_t | b
| ) |  |

Returns `1` if and only if `a` is less than or equal `b` where less is defined on a signed data type.

Definition at line 217 of file coap_time.h.

## ◆ coap_time_lt()

COAP_STATIC_INLINE int coap_time_lt | ( | coap_tick_t | a,
|  | coap_tick_t | b
| ) |  |

Returns `1` if and only if `a` is less than `b` where less is defined on a signed data type.

Definition at line 208 of file coap_time.h.