SolarEnergy/esp32_device/main/ota.c

39 lines
1.2 KiB
C
Raw Normal View History

2024-10-05 18:39:05 +00:00
#include "esp_log.h"
#include "esp_partition.h"
#include "esp_ota_ops.h"
2024-10-05 18:28:55 +00:00
#include "ota.h"
2024-10-12 14:10:07 +00:00
#include "storage.h"
#include <string.h>
2024-10-05 18:28:55 +00:00
2024-10-05 18:39:05 +00:00
const char *TAG = "ota";
2024-10-05 18:28:55 +00:00
bool ota_perform_update(const char *version)
{
2024-10-05 18:39:05 +00:00
const esp_partition_t *configured = esp_ota_get_boot_partition();
const esp_partition_t *running = esp_ota_get_running_partition();
if (configured != running)
{
ESP_LOGW(TAG, "Configured OTA boot partition at offset 0x%08" PRIx32 ", but running from offset 0x%08" PRIx32,
configured->address, running->address);
ESP_LOGW(TAG, "(This can happen if either the OTA boot data or preferred boot image become corrupted somehow.)");
}
ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08" PRIx32 ")",
running->type, running->subtype, running->address);
2024-10-12 14:10:07 +00:00
// Determine firmware download URL
char *secure_url = calloc(256, 1);
assert(secure_url != NULL);
assert(storage_get_secure_origin(secure_url) > 0);
strcat(secure_url, "/devices_api/ota/Wt32-Eth01/");
strcat(secure_url, version);
ESP_LOGI(TAG, "Firmware URL: %s", secure_url);
free(secure_url);
2024-10-05 18:39:05 +00:00
// TODO (from native example)
2024-10-05 18:28:55 +00:00
return false;
}