This commit is contained in:
jomjol
2022-01-09 09:43:22 +01:00
parent 63d336ba28
commit 24b46158de
15 changed files with 80 additions and 13 deletions

View File

@@ -65,6 +65,52 @@ struct file_server_data {
static const char *TAG_FILESERVER = "file_server";
#include <iostream>
#include <sys/types.h>
#include <dirent.h>
using namespace std;
static esp_err_t get_tflite_file_handler(httpd_req_t *req){
DIR *verzeichnis;
struct dirent *files;
std::string _filename, _fileext, _result = "";
std::string _delimiter = ".";
size_t pos = 0;
verzeichnis=opendir("/sdcard/config");
printf("Suche TFLITE in /sdcard/config\n");
while((files = readdir(verzeichnis)))
{
_filename = files->d_name;
_fileext = _filename;
printf("File: %s\t", _filename.c_str());
while ((pos = _fileext.find(_delimiter))) {
_fileext.erase(0, pos + _delimiter.length());
}
printf(" Extension: %s\n", _fileext.c_str());
if ((_fileext == "tfl") || (_fileext == "tflite"))
{
_result = _result + _filename + "\t";
}
}
closedir(verzeichnis);
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_set_type(req, "text/plain");
httpd_resp_sendstr_chunk(req, _result.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
/* Handler to redirect incoming GET request for /index.html to /
* This can be overridden by uploading file with same name */
// static esp_err_t index_html_get_handler(httpd_req_t *req)
@@ -804,4 +850,15 @@ 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);
*/
}

View File

@@ -378,7 +378,7 @@ httpd_handle_t start_webserver(void)
config.server_port = 80;
config.ctrl_port = 32768;
config.max_open_sockets = 5; //20210921 --> vorher 7
config.max_uri_handlers = 24;
config.max_uri_handlers = 30; // vorher 24
config.max_resp_headers = 8;
config.backlog_conn = 5;
config.lru_purge_enable = true; // dadurch werden alte Verbindungen gekappt, falls neue benögt werden.

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="8dd3a92";
const char* GIT_REV="63d336b";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2022-01-04 21:10";
const char* BUILD_TIME="2022-01-09 09:39";

View File

@@ -13,7 +13,7 @@ extern "C"
#include "Helper.h"
#include <fstream>
const char* GIT_BASE_BRANCH = "master - v10.0.2 - 2022-01-01";
const char* GIT_BASE_BRANCH = "master - v10.1.0 - 2022-01-09";
const char* git_base_branch(void)

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="8dd3a92";
const char* GIT_REV="63d336b";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2022-01-04 21:10";
const char* BUILD_TIME="2022-01-09 09:39";