22#define SOTA_REPORT_QUICK_RETRIES 3u
25#define SOTA_CONNECT_POLL_S 1u
30 return http_status > 0;
47 uint32_t report_failures,
49 uint32_t check_interval_s)
52 if (in_trial)
return quick_s;
54 return check_interval_s;
63#define SOTA_OUTBOX_VERSION 1u
64#define SOTA_OUTBOX_SLOTS 2u
84 size_t len = src ? strlen(src) : 0;
85 if (len >= cap)
return false;
86 if (len) memcpy(dst, src, len);
94 memset(box, 0,
sizeof(*box));
101 return memchr(field,
'\0', cap) != NULL;
109 for (uint8_t i = 0; i < box->
count; ++i) {
124 const char *reason,
const char *deployment,
128 memset(&r, 0,
sizeof(r));
129 if (!event || !event[0] || !deployment || !deployment[0] || build == 0)
return false;
148 if (box->
count == 0)
return;
static bool sota_field_terminated(const char *field, size_t cap)
True when field has a NUL within cap bytes.
Definition sota_report.h:99
static void sota_outbox_pop(sota_outbox_t *box)
Remove the report at the front.
Definition sota_report.h:146
static bool sota_outbox_valid(const sota_outbox_t *box)
True when a loaded blob has this layout, a count it can hold, and only reports that sota_outbox_push(...
Definition sota_report.h:106
static uint32_t sota_poll_interval_s(bool connected, bool in_trial, bool report_pending, uint32_t report_failures, uint32_t quick_s, uint32_t check_interval_s)
Seconds until the next check.
Definition sota_report.h:45
static bool sota_copy_field(char *dst, size_t cap, const char *src)
Copy src into a fixed field.
Definition sota_report.h:82
#define SOTA_OUTBOX_VERSION
Layout of the stored outbox blob.
Definition sota_report.h:63
static bool sota_report_delivered(int http_status)
A report is delivered once the server returns any HTTP response.
Definition sota_report.h:28
#define SOTA_REPORT_QUICK_RETRIES
Quick retries for a pending report before it waits for the check interval.
Definition sota_report.h:22
#define SOTA_OUTBOX_SLOTS
Reports the outbox holds.
Definition sota_report.h:64
#define SOTA_CONNECT_POLL_S
Seconds between is_connected() polls while the network is down.
Definition sota_report.h:25
static void sota_outbox_init(sota_outbox_t *box)
Empty the outbox.
Definition sota_report.h:92
static bool sota_outbox_push(sota_outbox_t *box, const char *event, const char *reason, const char *deployment, uint32_t build)
Add a report at the back.
Definition sota_report.h:123
The outbox, oldest report first.
Definition sota_report.h:75
sota_report_t reports[2u]
The reports, oldest first.
Definition sota_report.h:78
uint8_t count
Reports in use.
Definition sota_report.h:77
uint8_t version
SOTA_OUTBOX_VERSION.
Definition sota_report.h:76
One status report waiting to be sent.
Definition sota_report.h:67
char deployment[64]
The deployment the report is about.
Definition sota_report.h:70
uint32_t build
The build the report is about.
Definition sota_report.h:71
char event[12]
"confirmed" or "rolled_back".
Definition sota_report.h:68
char reason[24]
Empty when the event has none.
Definition sota_report.h:69