Skip to content

File espos_ota_manifest.h

File List > espos_ota > include > espos_ota_manifest.h

Go to the documentation of this file

/*
 * SPDX-FileCopyrightText: 2026 Dirk Wahrheit
 * SPDX-License-Identifier: Apache-2.0
 *
 * Version manifest (docs/ota.md) — pure C, host-tested.
 */
#pragma once

#include <stdbool.h>
#include <stddef.h>

#include "esp_err.h"

#ifdef __cplusplus
extern "C" {
#endif

#define ESPOS_OTA_VERSION_MAX 32
#define ESPOS_OTA_URL_MAX     256
#define ESPOS_OTA_NOTES_MAX   128

/* Largest "size" a manifest may claim, 256 MB. Not a policy limit -- it is
 * far past any ESP32 flash part -- but a bound that keeps the double-to-
 * size_t conversion defined: JSON numbers are doubles, a manifest can say
 * 1e999, and that parses as infinity. Anything above this (or NaN, or
 * negative) reads as 0, which already means "unknown". */
#define ESPOS_OTA_SIZE_MAX (256u * 1024u * 1024u)

typedef struct {
    char version[ESPOS_OTA_VERSION_MAX];
    char url[ESPOS_OTA_URL_MAX];      /* absolute; relative manifest URLs are resolved */
    char sha256[65];                  /* hex or "" */
    char notes[ESPOS_OTA_NOTES_MAX];
    size_t size;                      /* 0 = unknown */
    bool newer;                       /* strictly newer than the running version */
} espos_ota_build_t;

int espos_ota_version_cmp(const char *a, const char *b);

esp_err_t espos_ota_manifest_pick(const char *json, size_t len, const char *manifest_url,
                                  const char *app, const char *target, const char *channel,
                                  const char *running_version, espos_ota_build_t *out);

bool espos_ota_resolve_url(const char *base, const char *rel, char *out, size_t out_size);

#ifdef __cplusplus
}
#endif