SimpleOTA client v1.0.1
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;
44
46typedef struct {
47 char *url;
48 size_t url_cap;
49 char checksum[SOTA_HASH_HEX_LEN + 1];
50 char deployment[64];
51 char version[SOTA_VERSION_MAX + 1];
52 char key_id[64];
53 uint32_t build;
54 uint32_t size;
57 uint8_t signature[64];
59
66
73 const char *version_label, char *out, size_t cap);
74
77bool sota_protocol_status_body(const char *device_id, const char *deployment,
78 const char *event, uint32_t build, const char *reason,
79 char *out, size_t cap);
80
88
91bool sota_protocol_check_status(const char *resp, char *out, size_t cap);
92
93#ifdef __cplusplus
94}
95#endif
96
97#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:61
@ SOTA_CHECK_MALFORMED
Offered, but url, checksum or build is unusable.
Definition sota_protocol.h:64
@ SOTA_CHECK_NO_UPDATE
update_available is false or missing.
Definition sota_protocol.h:62
@ SOTA_CHECK_OFFER
*offer holds an update.
Definition sota_protocol.h:63
sota_check_result_t sota_protocol_parse_check(const char *resp, sota_offer_t *offer)
Read a 2xx check response.
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
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:42
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:46
uint32_t size
0 when the server sent none.
Definition sota_protocol.h:54
bool signed_offer
security_mode is "signed".
Definition sota_protocol.h:55
uint32_t build
The build number SimpleOTA assigned.
Definition sota_protocol.h:53
char * url
Caller's buffer: pre-signed URLs run to 1.5 KB.
Definition sota_protocol.h:47
size_t url_cap
Size of the url buffer.
Definition sota_protocol.h:48
bool has_signature
signature decoded to 64 ed25519 bytes.
Definition sota_protocol.h:56