SimpleOTA client main
Shared core of the SimpleOTA Arduino and ESP-IDF clients
Loading...
Searching...
No Matches
sota_protocol.h
Go to the documentation of this file.
1
14#ifndef SOTA_PROTOCOL_H
15#define SOTA_PROTOCOL_H
16
17#include <stdbool.h>
18#include <stddef.h>
19#include <stdint.h>
20
21#include "sota_state.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#define SOTA_PATH_CHECK "/api/v1/ota/check/"
28#define SOTA_PATH_STATUS "/api/v1/ota/status/"
32typedef struct {
33 const char *device_id;
34 const char *framework;
35 const char *chip_family;
36 const char *board_id;
37 const char *hardware_revision;
38 const char *partition_profile;
39 const char *channel;
40 const char *security_mode;
41 const char *labels_json;
47
49#define SOTA_KEY_ID_MAX 64u
50
52typedef struct {
53 char *url;
54 size_t url_cap;
55 char checksum[SOTA_HASH_HEX_LEN + 1];
56 char deployment[64];
57 char version[SOTA_VERSION_MAX + 1];
58 char key_id[SOTA_KEY_ID_MAX + 1];
59 uint32_t build;
60 uint32_t size;
63 uint8_t signature[64];
66 uint8_t manifest_sig[64];
68
75
82 const char *version_label, char *out, size_t cap);
83
86bool sota_protocol_status_body(const char *device_id, const char *deployment,
87 const char *event, uint32_t build, const char *reason,
88 char *out, size_t cap);
89
98
101bool sota_protocol_check_status(const char *resp, char *out, size_t cap);
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif /* SOTA_PROTOCOL_H */
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.
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_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.
sota_check_result_t
What a check response says.
Definition sota_protocol.h:70
@ SOTA_CHECK_MALFORMED
Offered, but url, checksum or build is unusable.
Definition sota_protocol.h:73
@ SOTA_CHECK_NO_UPDATE
update_available is false or missing.
Definition sota_protocol.h:71
@ SOTA_CHECK_OFFER
*offer holds an update.
Definition sota_protocol.h:72
sota_check_result_t sota_protocol_parse_check(const char *resp, sota_offer_t *offer)
Read a 2xx check response.
#define SOTA_KEY_ID_MAX
The longest signing key id: the server and CLI allow 1 to 64 ASCII characters.
Definition sota_protocol.h:49
Everything a client persists, and the order it is written.
#define SOTA_VERSION_MAX
Longest version label stored.
Definition sota_state.h:49
#define SOTA_HASH_HEX_LEN
sha256 in hex.
Definition sota_state.h:51
What the device says about itself on every check-in.
Definition sota_protocol.h:32
const char * partition_profile
Partition layout name.
Definition sota_protocol.h:38
const char * labels_json
A JSON object, embedded verbatim.
Definition sota_protocol.h:41
const char * security_mode
"basic" or "signed", or NULL to report none.
Definition sota_protocol.h:40
const char * hardware_revision
Board revision.
Definition sota_protocol.h:37
const char * framework
"arduino" or "esp_idf"
Definition sota_protocol.h:34
const char * board_id
Board model.
Definition sota_protocol.h:36
bool require_manifest
Only offers with a signed manifest are usable (sota_manifest.h); says so on check-ins.
Definition sota_protocol.h:42
const char * device_id
Stable per-unit identifier.
Definition sota_protocol.h:33
uint8_t nvs_schema_version
On-device data schema the firmware expects.
Definition sota_protocol.h:45
const char * channel
Release channel.
Definition sota_protocol.h:39
const char * chip_family
"esp32", "esp32s3", ...
Definition sota_protocol.h:35
What the device reports itself as running.
Definition sota_state.h:55
An update the server offered.
Definition sota_protocol.h:52
uint32_t size
0 when the server sent none.
Definition sota_protocol.h:60
bool signed_offer
security_mode is "signed".
Definition sota_protocol.h:61
uint32_t build
The build number SimpleOTA assigned.
Definition sota_protocol.h:59
char * url
Caller's buffer: pre-signed URLs run to 1.5 KB.
Definition sota_protocol.h:53
bool has_manifest
manifest_signature decoded, and its version is one this client checks.
Definition sota_protocol.h:64
size_t url_cap
Size of the url buffer.
Definition sota_protocol.h:54
bool has_signature
signature decoded to 64 ed25519 bytes.
Definition sota_protocol.h:62