Skip to content

Commit 085ca4d

Browse files
committed
Ajout version webserveur, Ajout partition pour ESP32
1 parent 215de04 commit 085ca4d

File tree

6 files changed

+49
-30
lines changed

6 files changed

+49
-30
lines changed

lightkit/software/data/firmware.html

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@ <h1 id="title">Lightkit</h1>
1616
<h2>Firmware</h2>
1717
<p>
1818
Version actuelle:<br>
19-
<span id="firmware_Version">-<!-- Filled by JS --></span>
19+
<span id="firmware_version">-<!-- Filled by JS --></span>
2020
</p>
2121
<form method='POST' id="firmware_file_form">
2222
<input type='file' name='firmware_file' id='firmware_file'>
2323
<button type='submit' class="theme">Mettre à jour</button>
24-
<div id='firmware_progress_bar'>
25-
<span id="progress_bar_label"></span>
26-
<div id='progress_bar'></div>
27-
</div>
2824
</form>
29-
<a href="index.html" class="theme">< Retour</a>
3025
</div>
3126
<div id="part_select_file">
3227
<h2>Web Serveur</h2>
@@ -37,13 +32,10 @@ <h2>Web Serveur</h2>
3732
<form method='POST' id="webserver_file_form">
3833
<input type='file' name='webserver_file' id='webserver_file'>
3934
<button type='submit' class="theme">Mettre à jour</button>
40-
<div id='webserver_progress_bar'>
41-
<span id="progress_bar_label"></span>
42-
<div id='progress_bar'></div>
43-
</div>
4435
</form>
45-
<a href="index.html" class="theme">< Retour</a>
4636
</div>
37+
<br>
38+
<a href="index.html" class="theme">< Retour</a>
4739
</div>
4840
<div id="footer">
4941
Hardware - Pascal RONDANE<br>
@@ -74,16 +66,6 @@ <h2>Web Serveur</h2>
7466

7567
set_message("ok", "Envoi en cours...");
7668

77-
// track upload progress
78-
xhr.upload.onprogress = function(evt) {
79-
if (evt.lengthComputable) {
80-
var per = evt.loaded / evt.total * 100;
81-
console.log("Uploading: " + per + "%");
82-
//$('#progress_bar_label').html('Uploading: ' + Math.round(per*100) + '%');
83-
//$('#progress_bar').css('width',Math.round(per*100) + '%');
84-
}
85-
};
86-
8769
// track completion: both successful or not
8870
xhr.onloadend = function() {
8971
if ((xhr.status == 200) && (xhr.responseText == "0")) {
@@ -133,8 +115,9 @@ <h2>Web Serveur</h2>
133115
add_file_listener('#webserver_file', 'filesystem');
134116

135117
cgi_request('/get_version', '', function(textReply) {
136-
document.getElementById('firmware_Version').innerHTML = textReply;
118+
document.getElementById('firmware_version').innerHTML = textReply;
137119
});
120+
document.getElementById('webserver_version').innerHTML = "v" + get_version();
138121
}
139122
</script>
140123
</body>

lightkit/software/data/lib.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
function get_version()
2+
{
3+
return "1.0.1";
4+
}
5+
16
/**
27
* @brief Set error message in box id=status_msg
38
*/

lightkit/software/doc/partitions.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Partitions ESP
2+
3+
Il est possible de configurer les partitions utilisées par l'ESP en éditant un fichier `*.csv`.
4+
Le fichier par défaut utilisé est localisé ici `~/.platformio/packages/framework-arduinoespressif32/tools/partitions`
5+
6+
Pour utiliser le nouveau fichier dans platformio, on édite le fichier `*.ini` :
7+
8+
```
9+
[base_esp32]
10+
board_build.partitions = src/partition/esp32_SK_1.9M_FS_320k.csv
11+
```

lightkit/software/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ lib_deps =
3232
[base_esp32]
3333
platform = espressif32
3434
board_build.filesystem = spiffs
35+
board_build.partitions = src/partition/esp32_SK_1.9M_FS_320k.csv
3536
lib_deps =
3637
${env.lib_deps}
3738
ESP32WebServer
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# app: 1.9MBB
2+
# spiffs: 320kB
3+
# Name, Type, SubType, Offset, Size, Flags
4+
nvs, data, nvs, 0x9000, 0x5000,
5+
otadata, data, ota, 0xe000, 0x2000,
6+
app0, app, ota_0, 0x10000, 0x1D0000,
7+
app1, app, ota_1, 0x1E0000,0x1D0000,
8+
spiffs, data, spiffs, 0x3B0000,0x50000,

lightkit/software/src/web/web_server.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
G_WebServer server(WEB_SERVER_HTTP_PORT);
3131

3232
// Internals
33-
static String updaterError;
33+
static String updaterError;
34+
static uint32_t updateBufferMaxSpace = 0;
3435

3536
static String getContentType(String filename)
3637
{
@@ -102,9 +103,17 @@ static void handle_update_done(void)
102103
}
103104
}
104105

106+
/**
107+
* @brief Show usage information on buffer usage
108+
* @details We don't have the actual file size
109+
* information so we display usage instead
110+
*
111+
* @param progress Size received
112+
* @param size Max size of the buffer
113+
*/
105114
static void handle_update_data_progress(uint32_t progress, uint32_t size)
106115
{
107-
log_info("Uploading : %d%% (%d kB)", (progress * 100) / size, progress / 1000);
116+
log_info("Buffer usage: %d%% (%d kB)", (progress * 100) / size, progress / 1000);
108117
}
109118

110119
static void handle_update_error()
@@ -118,26 +127,28 @@ static void handle_update_data(void)
118127
{
119128
// handler for the file upload, get's the sketch bytes, and writes
120129
// them through the Update object
121-
HTTPUpload & upload = server.upload();
122-
uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
123-
uint32_t maxFSSpace = file_sys_get_max_size();
130+
HTTPUpload & upload = server.upload();
124131

125132
if (upload.status == UPLOAD_FILE_START) {
126133
updaterError.clear();
127134

128135
log_info("Update: %s (%s)\n", upload.filename.c_str(), upload.name.c_str());
129136

130137
if (upload.name == "filesystem") {
131-
if (!Update.begin(maxFSSpace, U_CMD_FS)) { //start with max available size
138+
updateBufferMaxSpace = file_sys_get_max_size();
139+
140+
if (!Update.begin(updateBufferMaxSpace, U_CMD_FS)) {
132141
handle_update_error();
133142
}
134143
} else {
135-
if (!Update.begin(maxSketchSpace, U_FLASH)) { //start with max available size
144+
updateBufferMaxSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
145+
146+
if (!Update.begin(updateBufferMaxSpace, U_FLASH)) {
136147
handle_update_error();
137148
}
138149
}
139150
} else if (upload.status == UPLOAD_FILE_WRITE && !updaterError.length()) {
140-
handle_update_data_progress(upload.totalSize, maxSketchSpace);
151+
handle_update_data_progress(upload.totalSize, updateBufferMaxSpace);
141152

142153
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
143154
handle_update_error();

0 commit comments

Comments
 (0)