diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 00000000..637dff61
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,47 @@
+name: Build and Pack
+
+on: [push]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Cache PlatformIO
+ uses: actions/cache@v2
+ with:
+ path: ~/.platformio
+ key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ - name: Install PlatformIO
+ run: |
+ python -m pip install --upgrade pip
+ pip install --upgrade platformio
+
+ - name: Set outputs
+ id: vars
+ run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
+
+ - name: Set Versions
+ run: echo "${{ github.ref_name }} / ${{ steps.vars.outputs.sha_short }}" > "sd-card/html/version.txt"
+
+ - name: Build Firmware
+# run: touch firmware.bin # Testing
+ run: cd code; platformio run --environment esp32cam; cp .pio/build/esp32cam/firmware.bin ../firmware__${{ github.ref_name }}__${{ steps.vars.outputs.sha_short }}.bin
+
+ - name: Upload Firmware Artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: firmware__${{ github.ref_name }}__${{ steps.vars.outputs.sha_short }}
+ path: firmware__${{ github.ref_name }}__${{ steps.vars.outputs.sha_short }}.bin
+
+ - name: Upload Web interface Artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: web-interface__${{ github.ref_name }}__${{ steps.vars.outputs.sha_short }}
+ path: ./sd-card/html/*
diff --git a/README.md b/README.md
index 7bbe0c29..f0993b88 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,12 @@ In other cases you can contact the developer via email: 0)
+ {
+ zw = _main + zw;
+ }
+ else
+ {
+ zw = _target_zip + zw;
+ }
+
+ }
+
+ printf("Filename to extract: %s", zw.c_str());
+ DeleteFile(zw);
+ FILE* fpTargetFile = OpenFileAndWait(zw.c_str(), "wb");
+ fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
+ fclose(fpTargetFile);
+
+ printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
+ // printf("File data: \"%s\"\n", (const char*)p);
+
+ // We're done.
+ mz_free(p);
+ }
+
+ // Close the archive, freeing any resources it was using
+ mz_zip_reader_end(&zip_archive);
+ }
+
+ printf("Success.\n");
+ return ret;
+}
+
void unzip(std::string _in_zip_file, std::string _target_directory){
int i, sort_iter;
mz_bool status;
@@ -860,15 +945,4 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
};
httpd_register_uri_handler(server, &file_delete);
-
- /* URI handler for getting tflite files from server */
-/*
- httpd_uri_t file_tflite = {
- .uri = "/tflite", // Match all URIs of type /delete/path/to/file
- .method = HTTP_GET,
- .handler = get_tflite_file_handler,
- .user_ctx = server_data // Pass server data as context
- };
- httpd_register_uri_handler(server, &file_tflite);
-*/
}
diff --git a/code/components/jomjol_fileserver_ota/server_file.h b/code/components/jomjol_fileserver_ota/server_file.h
index c179e36e..9dbcc88f 100644
--- a/code/components/jomjol_fileserver_ota/server_file.h
+++ b/code/components/jomjol_fileserver_ota/server_file.h
@@ -4,6 +4,8 @@
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/");
+
void delete_all_in_directory(std::string _directory);
diff --git a/code/components/jomjol_fileserver_ota/server_ota.cpp b/code/components/jomjol_fileserver_ota/server_ota.cpp
index 83ab5cb0..5164e869 100644
--- a/code/components/jomjol_fileserver_ota/server_ota.cpp
+++ b/code/components/jomjol_fileserver_ota/server_ota.cpp
@@ -207,24 +207,6 @@ static void print_sha256 (const uint8_t *image_hash, const char *label)
static bool diagnostic(void)
{
-/*
- gpio_config_t io_conf;
- io_conf.intr_type = (gpio_int_type_t) GPIO_PIN_INTR_DISABLE;
- io_conf.mode = GPIO_MODE_INPUT;
- io_conf.pin_bit_mask = (1ULL << CONFIG_EXAMPLE_GPIO_DIAGNOSTIC);
- io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
- io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
- gpio_config(&io_conf);
-
- ESP_LOGI(TAGPARTOTA, "Diagnostics (5 sec)...");
- vTaskDelay(5000 / portTICK_PERIOD_MS);
-
- bool diagnostic_is_ok = gpio_get_level(CONFIG_EXAMPLE_GPIO_DIAGNOSTIC);
-
- gpio_reset_pin(CONFIG_EXAMPLE_GPIO_DIAGNOSTIC);
-
- return diagnostic_is_ok;
-*/
return true;
}
@@ -326,7 +308,7 @@ esp_err_t handler_ota_update(httpd_req_t *req)
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
{
- printf("task is found"); printf(_valuechar); printf("\n");
+ printf("task is found: "); printf(_valuechar); printf("\n");
_task = std::string(_valuechar);
}
@@ -344,6 +326,92 @@ esp_err_t handler_ota_update(httpd_req_t *req)
};
+ if (_task.compare("update") == 0)
+ {
+ std::string filetype = toUpper(getFileType(fn));
+ if (filetype.length() == 0)
+ {
+ std::string zw = "Update failed - no file specified (zip, bin, tfl, tlite)";
+ httpd_resp_sendstr_chunk(req, zw.c_str());
+ httpd_resp_sendstr_chunk(req, NULL);
+ return ESP_OK;
+ }
+
+
+ if ((filetype == "TFLITE") || (filetype == "TFL"))
+ {
+ std::string out = "/sdcard/config/" + getFileFullFileName(fn);
+ DeleteFile(out);
+ CopyFile(fn, out);
+ DeleteFile(fn);
+
+ const char* resp_str = "Neural Network File copied.";
+ httpd_resp_sendstr_chunk(req, resp_str);
+ httpd_resp_sendstr_chunk(req, NULL);
+ return ESP_OK;
+ }
+
+
+ if (filetype == "ZIP")
+ {
+ std::string in, out, outbin, zw, retfirmware;
+
+// in = "/sdcard/firmware/html.zip";
+ out = "/sdcard/html";
+ outbin = "/sdcard/firmware";
+
+// delete_all_in_directory(out);
+
+ retfirmware = unzip_new(fn, out+"/", outbin+"/");
+
+ if (retfirmware.length() > 0)
+ {
+ filetype = "BIN";
+ fn = retfirmware;
+ zw = "HTML Update Successfull!
Additioal firmware found in ZIP file.\n";
+ httpd_resp_sendstr_chunk(req, zw.c_str());
+ }
+ else
+ {
+ zw = "HTML Update Successfull!
No reboot necessary.\n";
+ httpd_resp_sendstr_chunk(req, zw.c_str());
+ httpd_resp_sendstr_chunk(req, NULL);
+ return ESP_OK;
+ }
+ }
+
+
+ if (filetype == "BIN")
+ {
+ const char* resp_str;
+ KillTFliteTasks();
+ gpio_handler_deinit();
+ if (ota_update_task(fn))
+ {
+ resp_str = "Firmware Update Successfull!
You can restart now.";
+ }
+ else
+ {
+ resp_str = "Error during Firmware Update!!!
Please check output of console.";
+ }
+
+ httpd_resp_send(req, resp_str, strlen(resp_str));
+
+ #ifdef DEBUG_DETAIL_ON
+ LogFile.WriteHeapInfo("handler_ota_update - Done");
+ #endif
+
+ return ESP_OK;
+ }
+
+
+ std::string zw = "Update failed - no valid file specified (zip, bin, tfl, tlite)";
+ httpd_resp_sendstr_chunk(req, zw.c_str());
+ httpd_resp_sendstr_chunk(req, NULL);
+ return ESP_OK;
+ }
+
+
if (_task.compare("unziphtml") == 0)
{
std::string in, out, zw;
diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp
index fe299f54..411553b0 100644
--- a/code/components/jomjol_helper/Helper.cpp
+++ b/code/components/jomjol_helper/Helper.cpp
@@ -209,6 +209,21 @@ size_t findDelimiterPos(string input, string delimiter)
return pos;
}
+void DeleteFile(string fn)
+{
+// ESP_LOGI(logTag, "Deleting file : %s", fn.c_str());
+ /* Delete file */
+ FILE* fpSourceFile = OpenFileAndWait(fn.c_str(), "rb");
+ if (!fpSourceFile) // Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
+ {
+ printf("DeleteFile: File %s existiert nicht!\n", fn.c_str());
+ return;
+ }
+ fclose(fpSourceFile);
+
+ unlink(fn.c_str());
+}
+
void CopyFile(string input, string output)
{
@@ -243,18 +258,48 @@ void CopyFile(string input, string output)
// Close The Files
fclose(fpSourceFile);
fclose(fpTargetFile);
+ printf("File copied: %s to %s", input.c_str(), output.c_str());
}
+string getFileFullFileName(string filename)
+{
+ size_t lastpos = filename.find_last_of('/');
+
+ if (lastpos == string::npos)
+ return "";
+
+// printf("Last position: %d\n", lastpos);
+
+ string zw = filename.substr(lastpos + 1, filename.size() - lastpos);
+
+ return zw;
+}
+
+string getDirectory(string filename)
+{
+ size_t lastpos = filename.find('/');
+
+ if (lastpos == string::npos)
+ return "";
+
+// printf("Directory: %d\n", lastpos);
+
+ string zw = filename.substr(0, lastpos - 1);
+ return zw;
+}
string getFileType(string filename)
{
- int lastpos = filename.find(".", 0);
- int neu_pos;
+ size_t lastpos = filename.find(".", 0);
+ size_t neu_pos;
while ((neu_pos = filename.find(".", lastpos + 1)) > -1)
{
lastpos = neu_pos;
}
+ if (lastpos == string::npos)
+ return "";
+
string zw = filename.substr(lastpos + 1, filename.size() - lastpos);
zw = toUpper(zw);
diff --git a/code/components/jomjol_helper/Helper.h b/code/components/jomjol_helper/Helper.h
index 46fbf8d6..ab263cf2 100644
--- a/code/components/jomjol_helper/Helper.h
+++ b/code/components/jomjol_helper/Helper.h
@@ -10,6 +10,7 @@ std::string FormatFileName(std::string input);
void FindReplace(std::string& line, std::string& oldString, std::string& newString);
void CopyFile(string input, string output);
+void DeleteFile(string fn);
FILE* OpenFileAndWait(const char* nm, const char* _mode, int _waitsec = 1);
@@ -19,6 +20,8 @@ string trim(string istring, string adddelimiter = "");
bool ctype_space(const char c, string adddelimiter);
string getFileType(string filename);
+string getFileFullFileName(string filename);
+string getDirectory(string filename);
int mkdir_r(const char *dir, const mode_t mode);
int removeFolder(const char* folderPath, const char* logTag);
diff --git a/code/main/version.cpp b/code/main/version.cpp
index 6eefe87b..b3344b25 100644
--- a/code/main/version.cpp
+++ b/code/main/version.cpp
@@ -1,4 +1,4 @@
-const char* GIT_REV="47da2d6";
-const char* GIT_TAG="";
-const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2022-09-04 18:01";
\ No newline at end of file
+const char* GIT_REV="N/A";
+const char* GIT_TAG="N/A";
+const char* GIT_BRANCH="N/A";
+const char* BUILD_TIME="2022-09-10 23:06";
\ No newline at end of file
diff --git a/code/platformio.ini b/code/platformio.ini
index f46a9345..39b6032c 100644
--- a/code/platformio.ini
+++ b/code/platformio.ini
@@ -12,12 +12,12 @@
[platformio]
src_dir = main
-
[env:esp32cam]
platform = espressif32@4.4.0
;platform = espressif32@5.1.0
;platform = espressif32
board = esp32cam
+;board = m5stack-core-esp32
framework = espidf
;board_build.partitions = partitions_singleapp.csv
diff --git a/code/version.cpp b/code/version.cpp
index 6eefe87b..b3344b25 100644
--- a/code/version.cpp
+++ b/code/version.cpp
@@ -1,4 +1,4 @@
-const char* GIT_REV="47da2d6";
-const char* GIT_TAG="";
-const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2022-09-04 18:01";
\ No newline at end of file
+const char* GIT_REV="N/A";
+const char* GIT_TAG="N/A";
+const char* GIT_BRANCH="N/A";
+const char* BUILD_TIME="2022-09-10 23:06";
\ No newline at end of file
diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin
index e7019eb1..ab2c3edb 100644
Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ
diff --git a/firmware/firmware.bin b/firmware/firmware.bin
index 7542cf6c..ba347797 100644
Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ
diff --git a/firmware/html.zip b/firmware/html.zip
index 57cddbaa..764810d4 100644
Binary files a/firmware/html.zip and b/firmware/html.zip differ
diff --git a/sd-card/html/common.js b/sd-card/html/common.js
index 0804cce6..130bda20 100644
--- a/sd-card/html/common.js
+++ b/sd-card/html/common.js
@@ -9,7 +9,7 @@ function LoadHostname() {
xhttp.addEventListener('load', function(event) {
if (xhttp.status >= 200 && xhttp.status < 300) {
hostname = xhttp.responseText;
- document.title = hostname + " - jomjol - AI on the edge";
+ document.title = hostname + " - AI on the edge";
document.getElementById("id_title").innerHTML = "Digitizer - AI on the edge - " + hostname;
}
else {
diff --git a/sd-card/html/edit_explain_0.html b/sd-card/html/edit_explain_0.html
index c90bff3c..d3bb9310 100644
--- a/sd-card/html/edit_explain_0.html
+++ b/sd-card/html/edit_explain_0.html
@@ -2,7 +2,7 @@