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

The SimpleOTA HTTP API's request bodies and the check response. More...

Go to the source code of this file.

Data Structures

struct  sota_device_info_t
 What the device says about itself on every check-in. More...
 
struct  sota_offer_t
 An update the server offered. More...
 

Macros

#define SOTA_PATH_CHECK   "/api/v1/ota/check/"
 Check-in path, after the base URL.
 
#define SOTA_PATH_STATUS   "/api/v1/ota/status/"
 Status-event path, after the base URL.
 
#define SOTA_KEY_ID_MAX   64u
 The longest signing key id: the server and CLI allow 1 to 64 ASCII characters.
 

Enumerations

enum  sota_check_result_t { SOTA_CHECK_NO_UPDATE , SOTA_CHECK_OFFER , SOTA_CHECK_MALFORMED }
 What a check response says. More...
 

Functions

bool sota_protocol_check_body (const sota_device_info_t *dev, const sota_identity_t *live, const char *version_label, char *out, size_t cap)
 The check-in body.
 
bool sota_protocol_status_body (const char *device_id, const char *deployment, const char *event, uint32_t build, const char *reason, char *out, size_t cap)
 One status event's body.
 
sota_check_result_t sota_protocol_parse_check (const char *resp, sota_offer_t *offer)
 Read a 2xx check response.
 
bool sota_protocol_check_status (const char *resp, char *out, size_t cap)
 The server's "status" when no update is offered ("up_to_date", ...); false when absent.
 

Detailed Description

The SimpleOTA HTTP API's request bodies and the check response.

POST /api/v1/ota/check/ check-in; the response may offer an update POST /api/v1/ota/status/ one lifecycle event of a deployment

Request bodies are written into a caller's buffer, with every string value escaped, so a value from the server or the integrator can never break the JSON the server parses. Nothing here allocates.

Enumeration Type Documentation

◆ sota_check_result_t

What a check response says.

Enumerator
SOTA_CHECK_NO_UPDATE 

update_available is false or missing.

SOTA_CHECK_OFFER 

*offer holds an update.

SOTA_CHECK_MALFORMED 

Offered, but url, checksum or build is unusable.

Function Documentation

◆ sota_protocol_check_body()

bool sota_protocol_check_body ( const sota_device_info_t *  dev,
const sota_identity_t *  live,
const char *  version_label,
char *  out,
size_t  cap 
)

The check-in body.

version_label is the label to report (the configured one, else the stored one), NULL or empty to leave it out. Returns false when the body does not fit in cap bytes.

◆ sota_protocol_status_body()

bool sota_protocol_status_body ( const char *  device_id,
const char *  deployment,
const char *  event,
uint32_t  build,
const char *  reason,
char *  out,
size_t  cap 
)

One status event's body.

reason NULL leaves it out. False when it does not fit.

◆ sota_protocol_parse_check()

sota_check_result_t sota_protocol_parse_check ( const char *  resp,
sota_offer_t *  offer 
)

Read a 2xx check response.

offer->url and url_cap must be set; every other member is overwritten. A signature that is not base64 of 64 bytes, or names an algorithm other than ed25519, leaves has_signature false, so the signed-firmware gate fails closed when keys are pinned. The same goes for a manifest signature, and for a manifest_version other than 1.