#pragma once

#include "wifi_provisioning.h"

/**
 * If server_version is non-empty and differs from the running firmware's
 * embedded version (esp_app_desc), streams the server's uploaded image
 * (GET /frame/firmware) into the idle OTA slot via esp_https_ota and
 * restarts into it -- so this only returns when there's nothing to do or
 * the update failed (logged, retried on a later wake). Plain string
 * inequality, deliberately: uploading an older image downgrades, which
 * is a feature.
 *
 * Rollback safety is handled elsewhere: the freshly-booted image is
 * marked valid in frame_client_run() only after a full successful
 * fetch/display cycle (CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE) -- until
 * then, any reboot reverts to the previous slot.
 */
void ota_update_if_available(const frame_config_t *cfg, const char *server_version);
