51 if (container ==
nullptr || container->status_code !=
HTTP_STATUS_OK) {
59 uint8_t *data = allocator.
allocate(container->content_length);
60 if (data ==
nullptr) {
61 std::string msg =
str_sprintf(
"Failed to allocate %zu bytes for manifest", container->content_length);
68 size_t read_index = 0;
69 while (container->get_bytes_read() < container->content_length) {
70 int read_bytes = container->read(data + read_index, MAX_READ_SIZE);
74 read_index += read_bytes;
79 std::string response((
char *) data, read_index);
80 allocator.
deallocate(data, container->content_length);
86 if (!root[
"name"].is<const char *>() || !root[
"version"].is<const char *>() || !root[
"builds"].is<JsonArray>()) {
87 ESP_LOGE(TAG,
"Manifest does not contain required fields");
93 for (
auto build : root[
"builds"].as<JsonArray>()) {
94 if (!build[
"chipFamily"].is<const char *>()) {
95 ESP_LOGE(TAG,
"Manifest does not contain required fields");
98 if (build[
"chipFamily"] == ESPHOME_VARIANT) {
99 if (!build[
"ota"].is<JsonObject>()) {
100 ESP_LOGE(TAG,
"Manifest does not contain required fields");
103 JsonObject ota = build[
"ota"].as<JsonObject>();
104 if (!ota[
"path"].is<const char *>() || !ota[
"md5"].is<const char *>()) {
105 ESP_LOGE(TAG,
"Manifest does not contain required fields");
111 if (ota[
"summary"].is<const char *>())
113 if (ota[
"release_url"].is<const char *>())
133 if (path[0] ==
'/') {
143 std::string current_version;
144#ifdef ESPHOME_PROJECT_VERSION
145 current_version = ESPHOME_PROJECT_VERSION;
147 current_version = ESPHOME_VERSION;
153 bool trigger_update_available =
false;
160 trigger_update_available =
true;
170 this_update->
defer([this_update, trigger_update_available]() {
177 if (trigger_update_available) {