SimpleOTA client v1.2.0
Shared core of the SimpleOTA Arduino and ESP-IDF clients
Loading...
Searching...
No Matches
sota_app.h File Reference

What the engine tells the application: events, log lines, and a wake-up when the confirm timeout fires. More...

Go to the source code of this file.

Data Structures

struct  sota_event_t
 One event, valid only during the sota_app_event() call. More...
 

Macros

#define SOTA_LOG_LEVEL   SOTA_LOG_DEBUG
 The most detailed level compiled in; lines above it are left out.
 
#define SOTA_LOG_AT(level, ...)    do { if (SOTA_LOG_LEVEL >= (level)) sota_app_log((level), __VA_ARGS__); } while (0)
 Log at level when SOTA_LOG_LEVEL includes it.
 
#define SOTA_LOGE(...)   SOTA_LOG_AT(SOTA_LOG_ERROR, __VA_ARGS__)
 Log an error.
 
#define SOTA_LOGW(...)   SOTA_LOG_AT(SOTA_LOG_WARN, __VA_ARGS__)
 Log a warning.
 
#define SOTA_LOGI(...)   SOTA_LOG_AT(SOTA_LOG_INFO, __VA_ARGS__)
 Log at info level.
 
#define SOTA_LOGD(...)   SOTA_LOG_AT(SOTA_LOG_DEBUG, __VA_ARGS__)
 Log at debug level.
 

Enumerations

enum  sota_event_id_t {
  SOTA_EVENT_CHECK_DONE , SOTA_EVENT_UPDATE_AVAILABLE , SOTA_EVENT_DOWNLOAD_PROGRESS , SOTA_EVENT_UPDATE_FAILED ,
  SOTA_EVENT_BEFORE_REBOOT , SOTA_EVENT_TRIAL_BOOT , SOTA_EVENT_CONFIRMED , SOTA_EVENT_ROLLING_BACK
}
 In the order of simpleota_event_id_t, so the API layer can pass them through. More...
 
enum  {
  SOTA_LOG_NONE , SOTA_LOG_ERROR , SOTA_LOG_WARN , SOTA_LOG_INFO ,
  SOTA_LOG_DEBUG
}
 Log levels, numbered as esp_log_level_t.
 

Functions

void sota_app_event (void *user, const sota_event_t *event)
 Deliver an event to the application, on the task doing the work.
 
bool sota_app_can_update (void *user)
 A managed step has an offer it is about to download: false puts it off until a later check offers it again.
 
void sota_app_wake (void *user)
 The confirm timeout fired, possibly in a timer task: arrange for sota_engine_service() to run soon on a task that may block.
 
void sota_app_log (int level, const char *fmt,...)
 Write one log line at level, printf-style, without a trailing newline.
 

Detailed Description

What the engine tells the application: events, log lines, and a wake-up when the confirm timeout fires.

Implemented by the public API layer (port/esp32/simpleota.c) and by the host tests' fake.

Macro Definition Documentation

◆ SOTA_LOG_LEVEL

#define SOTA_LOG_LEVEL   SOTA_LOG_DEBUG

The most detailed level compiled in; lines above it are left out.

The ESP-IDF component sets it to CONFIG_LOG_MAXIMUM_LEVEL.

Enumeration Type Documentation

◆ sota_event_id_t

In the order of simpleota_event_id_t, so the API layer can pass them through.

Enumerator
SOTA_EVENT_CHECK_DONE 

A check completed; no update offered.

SOTA_EVENT_UPDATE_AVAILABLE 

An update was offered.

SOTA_EVENT_DOWNLOAD_PROGRESS 

done / total advanced.

SOTA_EVENT_UPDATE_FAILED 

The update was dropped; reason says why.

SOTA_EVENT_BEFORE_REBOOT 

Flashed and verified; it runs from the next reboot.

SOTA_EVENT_TRIAL_BOOT 

Running an image that is not confirmed yet.

SOTA_EVENT_CONFIRMED 

The trial image's confirmed report was delivered.

SOTA_EVENT_ROLLING_BACK 

The trial failed; the previous image starts next.

Function Documentation

◆ sota_app_event()

void sota_app_event ( void *  user,
const sota_event_t *  event 
)

Deliver an event to the application, on the task doing the work.

user is sota_config_t::user.

◆ sota_app_log()

void sota_app_log ( int  level,
const char *  fmt,
  ... 
)

Write one log line at level, printf-style, without a trailing newline.

The core calls it through the SOTA_LOG* macros.