main/updates.c

Sun, 18 Jul 2021 11:25:55 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 18 Jul 2021 11:25:55 +0200
changeset 109
72af8958b469
parent 87
47253f294a9f
child 119
1cef3c25426b
permissions
-rw-r--r--

Version 0.3.17. Made the Hendi PWM change official.

0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * @file updates.c
4
6d1f512cd074 Updated documentation
Michiel Broek <mbroek@mbse.eu>
parents: 1
diff changeset
3 * @brief Updates management. It can download and install new firmware
6d1f512cd074 Updated documentation
Michiel Broek <mbroek@mbse.eu>
parents: 1
diff changeset
4 * downloaded from the internet.
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 #include "config.h"
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
1
ad2c8b13eb88 Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
10 #define BUFFSIZE 1024 ///< Download buffer size
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 static char ota_write_data[BUFFSIZE + 1] = { 0 };
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 static const char *TAG = "update";
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 extern sButton Buttons[MAXBUTTONS];
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 extern int Main_Screen;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 static void http_cleanup(esp_http_client_handle_t client)
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 esp_http_client_close(client);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 esp_http_client_cleanup(client);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
1
ad2c8b13eb88 Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
26 /**
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
27 * @brief Run binary update procedure
1
ad2c8b13eb88 Updated lots of doxygen comments
Michiel Broek <mbroek@mbse.eu>
parents: 0
diff changeset
28 */
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
29 void bin_update(void)
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 char temp[64];
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 esp_err_t err;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 const esp_partition_t *update_partition = NULL;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 esp_ota_handle_t update_handle = 0;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 TFT_setFont(DEJAVU18_FONT, NULL);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 _fg = TFT_CYAN;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 const esp_partition_t *running = esp_ota_get_running_partition();
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 /*
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 * Don't use https because it costs more then 100K memory.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 esp_http_client_config_t update = {
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
44 .url = "http://update.mbse.eu/ap1/fw/brewboard.bin",
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 };
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 esp_http_client_handle_t client = esp_http_client_init(&update);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 if (client == NULL) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 ESP_LOGI(TAG, "Failed to init HTTP connection");
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 goto updateerr;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 err = esp_http_client_open(client, 0);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 if (err != ESP_OK) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err));
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 esp_http_client_cleanup(client);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 goto updateerr;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
60 int content_length = esp_http_client_fetch_headers(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
61 int status_code = esp_http_client_get_status_code(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
62 if (status_code != 200) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
63 ESP_LOGE(TAG, "GET %s error %d", update.url, status_code);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
64 esp_http_client_cleanup(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
65 goto updateerr;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
66 }
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 update_partition = esp_ota_get_next_update_partition(NULL);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 if (update_partition == NULL) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 ESP_LOGE(TAG, "No update partition");
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 esp_http_client_cleanup(client);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 goto updateerr;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 ESP_LOGI(TAG, "Update to partition subtype %d at offset 0x%x", update_partition->subtype, update_partition->address);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 if (err != ESP_OK) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 ESP_LOGE(TAG, "esp_ota_begin failed (%s)", esp_err_to_name(err));
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 http_cleanup(client);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 goto updateerr;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81
67
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
82 TFT_print((char *)"Begin firmware download.\r\n", 0, LASTY);
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
83 ESP_LOGI(TAG, "Download update %s size %d", update.url, content_length);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 int binary_file_length = 0;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 /*deal with all receive packet*/
67
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
86 bool image_header_was_checked = false;
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 while (1) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 int data_read = esp_http_client_read(client, ota_write_data, BUFFSIZE);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 if (data_read < 0) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 ESP_LOGE(TAG, "Error: data read error");
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 http_cleanup(client);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 goto updateerr;;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 } else if (data_read > 0) {
67
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
94 if (image_header_was_checked == false) {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
95 esp_app_desc_t new_app_info;
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
96 if (data_read > sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t) + sizeof(esp_app_desc_t)) {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
97 // check current version with downloading
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
98 memcpy(&new_app_info, &ota_write_data[sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t)], sizeof(esp_app_desc_t));
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
99
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
100 esp_app_desc_t running_app_info;
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
101 if (esp_ota_get_partition_description(running, &running_app_info) == ESP_OK) {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
102 ESP_LOGI(TAG, "Running firmware version: %s, %s %s", running_app_info.version, running_app_info.date, running_app_info.time);
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
103 }
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
104
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
105 const esp_partition_t* last_invalid_app = esp_ota_get_last_invalid_partition();
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
106 esp_app_desc_t invalid_app_info;
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
107 if (esp_ota_get_partition_description(last_invalid_app, &invalid_app_info) == ESP_OK) {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
108 ESP_LOGI(TAG, "Last invalid firmware version: %s", invalid_app_info.version);
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
109 }
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
110
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
111 // check current sha256 with last invalid partition
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
112 if (last_invalid_app != NULL) {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
113 if (memcmp(invalid_app_info.app_elf_sha256, new_app_info.app_elf_sha256, 32) == 0) {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
114 ESP_LOGW(TAG, "New version is the same as invalid version.");
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
115 ESP_LOGW(TAG, "Previously, there was an attempt to launch the firmware with %s version, but it failed.", invalid_app_info.version);
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
116 ESP_LOGW(TAG, "The firmware has been rolled back to the previous version.");
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
117 http_cleanup(client);
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
118 goto updateok;
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
119 }
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
120 }
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
121
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
122 if (memcmp(new_app_info.app_elf_sha256, running_app_info.app_elf_sha256, 32) == 0) {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
123 ESP_LOGI(TAG, "Current running version is the same as a new.");
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
124 http_cleanup(client);
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
125 goto updateok;
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
126 }
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
127
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
128 image_header_was_checked = true;
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
129
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
130 err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle);
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
131 if (err != ESP_OK) {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
132 ESP_LOGE(TAG, "esp_ota_begin failed (%s)", esp_err_to_name(err));
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
133 http_cleanup(client);
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
134 goto updateerr;
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
135 }
87
47253f294a9f SDK settings to reduce bin size. Some log messages to debug level. Added KWH usage registration. Added equipment power usage for HLT and MLT. Equipment database upgraded to version 2, expandable. Fixed some screen errors during temperature mash steps.
Michiel Broek <mbroek@mbse.eu>
parents: 70
diff changeset
136 ESP_LOGD(TAG, "Continue upgrade application");
70
d6838a268020 Version 0.3.7. The WiFi task uses the new event handlers. Cooling temperature top is now 45 instead of 30 degreees for pitching Kveik. One extra cosmetic message during OTA update.
Michiel Broek <mbroek@mbse.eu>
parents: 67
diff changeset
137 TFT_print((char *)"Download new version.\r\n", 0, LASTY);
67
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
138 } else {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
139 ESP_LOGE(TAG, "Received package is not fit len");
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
140 http_cleanup(client);
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
141 goto updateerr;
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
142 }
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
143 }
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 err = esp_ota_write( update_handle, (const void *)ota_write_data, data_read);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 if (err != ESP_OK) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 http_cleanup(client);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 goto updateerr;;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 binary_file_length += data_read;
67
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
150 ESP_LOGD(TAG, "Written image length %d", binary_file_length);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 } else if (data_read == 0) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 break;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 ESP_LOGI(TAG, "Download complete, binary data length: %d", binary_file_length);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 http_cleanup(client);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158
67
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
159 if (binary_file_length != content_length) {
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
160 ESP_LOGE(TAG, "Incomplete file");
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
161 goto updateerr;
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
162 }
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 if (esp_ota_end(update_handle) != ESP_OK) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 ESP_LOGE(TAG, "esp_ota_end failed!");
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 goto updateerr;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 snprintf(temp, 63, "Received image %d bytes\r\n", binary_file_length);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 TFT_print(temp, 0, LASTY);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 /*
67
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
171 * Here we have new version, install and boot it.
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 err = esp_ota_set_boot_partition(update_partition);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 if (err != ESP_OK) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err));
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 goto updateerr;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 ESP_LOGI(TAG, "Prepare to restart system!");
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
180 TFT_print((char *)"Rebooting ...", 0, LASTY);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 vTaskDelay(1000 / portTICK_PERIOD_MS);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 esp_restart();
67
4badc7e7d629 Use the sha256 in the application version to see if it's a different version. Stop the upgrade download if it's not a new version.
Michiel Broek <mbroek@mbse.eu>
parents: 54
diff changeset
183 return;
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 updateerr:
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 _fg = TFT_RED;
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
187 TFT_print((char *)"Error\r\n", 0, LASTY);
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 updateok:
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 vTaskDelay(3000 / portTICK_PERIOD_MS);
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
195 /**
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
196 * @brief Download a file to /spiffs
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
197 * @param filename The name and path of the file to download.
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
198 * @return Return 0 if ok, negative if errors.
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
199 */
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
200 int DownloadSpiffs(char *filename)
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
201 {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
202 esp_err_t err;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
203 static char theurl[73], thefile[41];
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
204 FILE *f;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
205
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
206 // static char todel[41];
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
207 // snprintf(todel, 40, "/spiffs//%s", filename);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
208 // unlink(todel);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
209 // return 0;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
210
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
211 snprintf(theurl, 72, "http://update.mbse.eu/ap1/image/%s", filename);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
212 snprintf(thefile, 40, "/spiffs/%s", filename);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
213
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
214 esp_http_client_config_t update = {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
215 .url = theurl,
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
216 };
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
217
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
218 esp_http_client_handle_t client = esp_http_client_init(&update);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
219 if (client == NULL) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
220 ESP_LOGE(TAG, "Failed to init HTTP connection");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
221 return -1;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
222 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
223
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
224 err = esp_http_client_open(client, 0);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
225 if (err != ESP_OK) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
226 ESP_LOGE(TAG, "Failed to open HTTP connection: %s", esp_err_to_name(err));
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
227 esp_http_client_cleanup(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
228 return -1;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
229 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
230
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
231 int content_length = esp_http_client_fetch_headers(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
232 int status_code = esp_http_client_get_status_code(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
233 if (status_code != 200) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
234 ESP_LOGE(TAG, "GET %s error %d", update.url, status_code);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
235 esp_http_client_cleanup(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
236 return -1;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
237 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
238
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
239 /*
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
240 * Remove a possible stale download.
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
241 */
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
242 unlink("/spiffs/tmpfile");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
243 f = fopen("/spiffs/tmpfile", "w");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
244 if (f == NULL) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
245 ESP_LOGE(TAG, "Cannot create /spiffs/tmpfile");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
246 esp_http_client_cleanup(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
247 return -1;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
248 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
249
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
250 int read_length = 0;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
251 int write_length = 0;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
252 while (1) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
253 int data_read = esp_http_client_read(client, ota_write_data, BUFFSIZE);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
254 if (data_read < 0) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
255 ESP_LOGE(TAG, "Error: data read error %s", theurl);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
256 http_cleanup(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
257 return -1;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
258 } else if (data_read > 0) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
259 size_t bytes = fwrite(ota_write_data, 1, data_read, f);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
260 if (bytes != data_read) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
261 ESP_LOGE(TAG, "fwrite %s %d/%d at %d", theurl, bytes, data_read, write_length);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
262 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
263 write_length += bytes;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
264 read_length += data_read;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
265 } else if (data_read == 0) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
266 break;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
267 }
42
c6a1a6ca5437 Finished websockets screens.
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
268 vTaskDelay(10 / portTICK_PERIOD_MS);
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
269 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
270 fclose(f);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
271
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
272 if (content_length != write_length) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
273 ESP_LOGE(TAG, "Download %s size %d but got %d bytes", theurl, content_length, write_length);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
274 unlink("/spiffs/tmpfile");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
275 return -1;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
276 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
277
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
278 ESP_LOGI(TAG, "Download %s size %d Ok", theurl, content_length);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
279 unlink(thefile);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
280 rename("/spiffs/tmpfile", thefile);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
281 esp_http_client_cleanup(client);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
282 return 0;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
283 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
284
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
285
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
286
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
287 /**
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
288 * @brief Update /spiffs filesystem
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
289 */
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
290 void spiffs_update(void)
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
291 {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
292 int rc;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
293 FILE *f;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
294 char v1[12], v2[12], fn[41];
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
295
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
296 TFT_setFont(DEJAVU18_FONT, NULL);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
297 _fg = TFT_CYAN;
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
298 TFT_print((char *)"Update /spiffs ", 0, 25);
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
299
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
300 rc = rename("/spiffs/version.txt", "/spiffs/version.old");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
301 if ((rc != 0) && (errno == ENOENT)) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
302 /* No old file. */
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
303 ESP_LOGI(TAG, "No old /spiffs/version.txt");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
304 /* Download, install old and new */
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
305 DownloadSpiffs((char *)"version.txt");
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
306 rename("/spiffs/version.txt", "/spiffs/version.old");
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
307 DownloadSpiffs((char *)"version.txt");
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
308 goto spiffs_update;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
309 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
310
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
311 if (DownloadSpiffs((char *)"version.txt") < 0)
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
312 goto spiffs_error;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
313
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
314 /* Compare spiffs/version.old and /spiffs/version.txt */
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
315 v1[0] = '\0';
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
316 v2[0] = '\0';
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
317 f = fopen("/spiffs/version.old", "r");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
318 if (f) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
319 fgets(v1, 11, f);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
320 fclose(f);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
321 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
322 f = fopen("/spiffs/version.txt", "r");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
323 if (f) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
324 fgets(v2, 11, f);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
325 fclose(f);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
326 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
327 if (strcmp(v1, v2) == 0) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
328 ESP_LOGI(TAG, "/spiffs is up to date");
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
329 TFT_print((char *)"Ok\r\n", LASTX, LASTY);
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
330 unlink("/spiffs/version.old");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
331 return;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
332 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
333
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
334 spiffs_update:
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
335 /*
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
336 * Run the update, get the filelist.
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
337 */
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
338 ESP_LOGI(TAG, "Full /spiffs update");
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
339 rc = DownloadSpiffs((char *)"files.list");
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
340 if (rc < 0) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
341 unlink("/spiffs/version.txt");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
342 rename("/spiffs/version.old", "/spiffs/version.txt"); // So next time we try again.
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
343 goto spiffs_error;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
344 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
345
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
346 f = fopen("/spiffs/files.list", "r");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
347 while (fgets(fn, 40, f)) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
348 fn[strlen(fn)-1] = '\0';
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
349 rc = DownloadSpiffs(fn);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
350 if (rc < 0) {
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
351 ESP_LOGE(TAG, "Updates failed");
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
352 fclose(f);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
353 goto spiffs_error;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
354 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
355 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
356 fclose(f);
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
357 unlink("/spiffs/version.old");
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
358 TFT_print((char *)"updated\r\n", LASTX, LASTY);
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
359 return;
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
360
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
361 spiffs_error:
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
362 _fg = TFT_RED;
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
363 TFT_print((char *)"error\r\n", LASTX, LASTY);
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
364 }
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
365
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
366
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
367
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368 /*
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 * Files init function, only runs once a new screen is entered.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 void Updates_Init(void)
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372 {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373 switch (Main_Screen) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374 case MAIN_TOOLS_UPDATES:
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
375 _bg = TFT_BLACK;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376 TFT_fillScreen(_bg);
54
7b134c27fadb Upgraded esp-ide and compilers. Adjusted the sources for the new compiler warnings.
Michiel Broek <mbroek@mbse.eu>
parents: 42
diff changeset
377 TopMessage((char *)"Update");
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
378 break;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
379
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
380 default: break;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
381 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
382 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
383
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
384
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386 /*
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
387 * Updates management loop, non-blocking.
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 */
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
389 void Updates_Loop(void)
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
390 {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 switch (Main_Screen) {
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393 case MAIN_TOOLS_UPDATES:
13
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
394 spiffs_update();
8f01b74bf1dd Update /spiffs via internet. http://update.mbse.eu is now the update server.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
395 bin_update();
0
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 Main_Screen = MAIN_TOOLS;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 break;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 default: break;
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 }
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402
b74b0e4902c3 Initial checkin brewboard
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403

mercurial