mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 04:26:58 +03:00
Compare commits
11 Commits
Update-tfl
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ceb47fbc7 | ||
|
|
a413d0228e | ||
|
|
e22eaa2736 | ||
|
|
154d159595 | ||
|
|
23a5458a2b | ||
|
|
89097fa5a2 | ||
|
|
6952db0298 | ||
|
|
550889c373 | ||
|
|
1200ee1289 | ||
|
|
fceccb90b0 | ||
|
|
d68c95d626 |
@@ -61,7 +61,7 @@ struct file_server_data {
|
||||
|
||||
using namespace std;
|
||||
|
||||
string SUFFIX_ZW = "_0xge";
|
||||
string SUFFIX_ZW = "_tmp";
|
||||
|
||||
static esp_err_t send_logfile(httpd_req_t *req, bool send_full_file);
|
||||
static esp_err_t send_datafile(httpd_req_t *req, bool send_full_file);
|
||||
@@ -911,7 +911,7 @@ void delete_all_in_directory(std::string _directory)
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::string _target_bin, std::string _main, bool _initial_setup)
|
||||
std::string unzip_new(std::string _in_zip_file, std::string _html_tmp, std::string _html_final, std::string _target_bin, std::string _main, bool _initial_setup)
|
||||
{
|
||||
int i, sort_iter;
|
||||
mz_bool status;
|
||||
@@ -993,11 +993,16 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
|
||||
}
|
||||
else
|
||||
{
|
||||
zw = _target_zip + zw;
|
||||
zw = _html_tmp + zw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// files in the html folder shall be redirected to the temporary html folder
|
||||
if (zw.find(_html_final) == 0) {
|
||||
FindReplace(zw, _html_final, _html_tmp);
|
||||
}
|
||||
|
||||
string filename_zw = zw + SUFFIX_ZW;
|
||||
|
||||
ESP_LOGI(TAG, "File to extract: %s, Temp. Filename: %s", zw.c_str(), filename_zw.c_str());
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
void register_server_file_uri(httpd_handle_t server, const char *base_path);
|
||||
|
||||
void unzip(std::string _in_zip_file, std::string _target_directory);
|
||||
std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::string _target_bin, std::string _main = "/sdcard/", bool _initial_setup = false);
|
||||
std::string unzip_new(std::string _in_zip_file, std::string _html_tmp, std::string _html_final, std::string _target_bin, std::string _main = "/sdcard/", bool _initial_setup = false);
|
||||
|
||||
|
||||
void delete_all_in_directory(std::string _directory);
|
||||
|
||||
@@ -76,17 +76,32 @@ void task_do_Update_ZIP(void *pvParameter)
|
||||
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "File: " + _file_name_update + " Filetype: " + filetype);
|
||||
|
||||
|
||||
if (filetype == "ZIP")
|
||||
{
|
||||
std::string in, out, outbin, zw, retfirmware;
|
||||
std::string in, outHtml, outHtmlTmp, outHtmlOld, outbin, zw, retfirmware;
|
||||
|
||||
out = "/sdcard/html";
|
||||
outHtml = "/sdcard/html";
|
||||
outHtmlTmp = "/sdcard/html_tmp";
|
||||
outHtmlOld = "/sdcard/html_old";
|
||||
outbin = "/sdcard/firmware";
|
||||
|
||||
retfirmware = unzip_new(_file_name_update, out+"/", outbin+"/", "/sdcard/", initial_setup);
|
||||
/* Remove the old and tmp html folder in case they still exist */
|
||||
removeFolder(outHtmlTmp.c_str(), TAG);
|
||||
removeFolder(outHtmlOld.c_str(), TAG);
|
||||
|
||||
/* Extract the ZIP file. The content of the html folder gets extracted to the temporar folder html-temp. */
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Extracting ZIP file " + _file_name_update + "...");
|
||||
retfirmware = unzip_new(_file_name_update, outHtmlTmp+"/", outHtml+"/", outbin+"/", "/sdcard/", initial_setup);
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Files unzipped.");
|
||||
|
||||
/* ZIP file got extracted, replace the old html folder with the new one */
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Renaming folder " + outHtml + " to " + outHtmlOld + "...");
|
||||
::rename(outHtml.c_str(), outHtmlOld.c_str());
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Renaming folder " + outHtmlTmp + " to " + outHtml + "...");
|
||||
::rename(outHtmlTmp.c_str(), outHtml.c_str());
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Deleting folder " + outHtmlOld + "...");
|
||||
removeFolder(outHtmlOld.c_str(), TAG);
|
||||
|
||||
if (retfirmware.length() > 0)
|
||||
{
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Found firmware.bin");
|
||||
@@ -434,7 +449,6 @@ esp_err_t handler_ota_update(httpd_req_t *req)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
if ((filetype == "TFLITE") || (filetype == "TFL"))
|
||||
{
|
||||
std::string out = "/sdcard/config/" + getFileFullFileName(fn);
|
||||
|
||||
Reference in New Issue
Block a user