Timeout manager

Timeout manager allows application to call specific function at desired time. It is used in middleware (and can be used by application too) to poll active connections.

Note

Callback function is called from processing thread. It is not allowed to call any blocking API function from it.

When application registers timeout, it needs to set timeout, callback function and optional user argument. When timeout elapses, ESP middleware will call timeout callback.

This feature can be considered as single-shot software timer.

group ESP_TIMEOUT

Timeout manager.

Typedefs

typedef void (*esp_timeout_fn)(void *arg)

Timeout callback function prototype.

Parameters
  • [in] arg: Custom user argument

Functions

espr_t esp_timeout_add(uint32_t time, esp_timeout_fn fn, void *arg)

Add new timeout to processing list.

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [in] time: Time in units of milliseconds for timeout execution

  • [in] fn: Callback function to call when timeout expires

  • [in] arg: Pointer to user specific argument to call when timeout callback function is executed

espr_t esp_timeout_remove(esp_timeout_fn fn)

Remove callback from timeout list.

Return

espOK on success, member of espr_t enumeration otherwise

Parameters
  • [in] fn: Callback function to identify timeout to remove

struct esp_timeout_t
#include <esp_typedefs.h>

Timeout structure.

Public Members

struct esp_timeout *next

Pointer to next timeout entry

uint32_t time

Time difference from previous entry

void *arg

Argument to pass to callback function

esp_timeout_fn fn

Callback function for timeout