SimpleOTA client main
Shared core of the SimpleOTA Arduino and ESP-IDF clients
Loading...
Searching...
No Matches
sota_app.h
Go to the documentation of this file.
1
8#ifndef SOTA_APP_H
9#define SOTA_APP_H
10
11#include <stddef.h>
12#include <stdint.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
30
32typedef struct {
34 const char *reason;
35 uint32_t build;
36 size_t done;
37 size_t total;
40
43void sota_app_event(void *user, const sota_event_t *event);
44
47bool sota_app_can_update(void *user);
48
51void sota_app_wake(void *user);
52
54enum { SOTA_LOG_NONE, SOTA_LOG_ERROR, SOTA_LOG_WARN, SOTA_LOG_INFO, SOTA_LOG_DEBUG };
55
58void sota_app_log(int level, const char *fmt, ...)
59#ifdef __GNUC__
60 __attribute__((format(printf, 2, 3)))
61#endif
62 ;
63
64#ifndef SOTA_LOG_LEVEL
67#define SOTA_LOG_LEVEL SOTA_LOG_DEBUG
68#endif
69
71#define SOTA_LOG_AT(level, ...) \
72 do { if (SOTA_LOG_LEVEL >= (level)) sota_app_log((level), __VA_ARGS__); } while (0)
73#define SOTA_LOGE(...) SOTA_LOG_AT(SOTA_LOG_ERROR, __VA_ARGS__)
74#define SOTA_LOGW(...) SOTA_LOG_AT(SOTA_LOG_WARN, __VA_ARGS__)
75#define SOTA_LOGI(...) SOTA_LOG_AT(SOTA_LOG_INFO, __VA_ARGS__)
76#define SOTA_LOGD(...) SOTA_LOG_AT(SOTA_LOG_DEBUG, __VA_ARGS__)
78#ifdef __cplusplus
79}
80#endif
81
82#endif /* SOTA_APP_H */
void sota_app_wake(void *user)
The confirm timeout fired, possibly in a timer task: arrange for sota_engine_service() to run soon on...
void sota_app_event(void *user, const sota_event_t *event)
Deliver an event to the application, on the task doing the work.
void sota_app_log(int level, const char *fmt,...)
Write one log line at level, printf-style, without a trailing newline.
sota_event_id_t
In the order of simpleota_event_id_t, so the API layer can pass them through.
Definition sota_app.h:20
@ SOTA_EVENT_BEFORE_REBOOT
Flashed and verified; it runs from the next reboot.
Definition sota_app.h:25
@ SOTA_EVENT_ROLLING_BACK
The trial failed; the previous image starts next.
Definition sota_app.h:28
@ SOTA_EVENT_DOWNLOAD_PROGRESS
done / total advanced.
Definition sota_app.h:23
@ SOTA_EVENT_CONFIRMED
The trial image's confirmed report was delivered.
Definition sota_app.h:27
@ SOTA_EVENT_CHECK_DONE
A check completed; no update offered.
Definition sota_app.h:21
@ SOTA_EVENT_UPDATE_AVAILABLE
An update was offered.
Definition sota_app.h:22
@ SOTA_EVENT_UPDATE_FAILED
The update was dropped; reason says why.
Definition sota_app.h:24
@ SOTA_EVENT_TRIAL_BOOT
Running an image that is not confirmed yet.
Definition sota_app.h:26
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 ...
One event, valid only during the sota_app_event() call.
Definition sota_app.h:32
size_t done
DOWNLOAD_PROGRESS: bytes written.
Definition sota_app.h:36
uint32_t build
The build the event is about, 0 when none.
Definition sota_app.h:35
size_t total
DOWNLOAD_PROGRESS: bytes expected, 0 when unknown.
Definition sota_app.h:37
const char * reason
A reason token or server status, or NULL.
Definition sota_app.h:34
sota_event_id_t id
What happened.
Definition sota_app.h:33