Centralizing the defines (#1624)

* defines changes

* Finish #define move + #define STBI_ONLY_JPEGsave 2% of Flash

* remove the defines on the old places

* ClassFlowCNNGeneral in define.h

* revert to origin

* fix translation not ready
This commit is contained in:
Nicolas Liaudat
2022-12-19 21:43:30 +01:00
committed by GitHub
parent 834fd60983
commit b0726b6c7e
45 changed files with 331 additions and 336 deletions

View File

@@ -33,7 +33,7 @@ extern "C" {
#include <esp_spiffs.h>
#include "esp_http_server.h"
#include "defines.h"
#include "../../include/defines.h"
#include "ClassLogFile.h"
#include "server_tflite.h"
@@ -47,30 +47,15 @@ extern "C" {
#include "Helper.h"
#include "miniz.h"
static const char *TAG = "OTA FILE";
/* Max length a file path can have on storage */
// #define FILE_PATH_MAX (ESP_VFS_PATH_MAX + CONFIG_SPIFFS_OBJ_NAME_LEN)
#define FILE_PATH_MAX (255)
/* Max size of an individual file. Make sure this
* value is same as that set in upload_script.html */
#define MAX_FILE_SIZE (8000*1024) // 8 MB
#define MAX_FILE_SIZE_STR "8MB"
/* Scratch buffer size */
#define SCRATCH_BUFSIZE 4096
/* Size of partial log file to return */
#define LOGFILE_LAST_PART_BYTES SCRATCH_BUFSIZE * 20 /* 80 kBytes */
struct file_server_data {
/* Base path of file storage */
char base_path[ESP_VFS_PATH_MAX + 1];
/* Scratch buffer for temporary storage during file transfer */
char scratch[SCRATCH_BUFSIZE];
char scratch[SERVER_FILER_SCRATCH_BUFSIZE];
};
@@ -236,7 +221,7 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
char *chunk = ((struct file_server_data *)req->user_ctx)->scratch;
size_t chunksize;
do {
chunksize = fread(chunk, 1, SCRATCH_BUFSIZE, fd);
chunksize = fread(chunk, 1, SERVER_FILER_SCRATCH_BUFSIZE, fd);
// ESP_LOGD(TAG, "Chunksize %d", chunksize);
if (chunksize > 0){
if (httpd_resp_send_chunk(req, chunk, chunksize) != ESP_OK) {
@@ -322,10 +307,10 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
/*
#define IS_FILE_EXT(filename, ext) \
(strcasecmp(&filename[strlen(filename) - sizeof(ext) + 1], ext) == 0)
*/
static esp_err_t logfileact_get_full_handler(httpd_req_t *req) {
return send_logfile(req, true);
@@ -405,7 +390,7 @@ static esp_err_t send_datafile(httpd_req_t *req, bool send_full_file)
size_t chunksize;
do {
/* Read file in chunks into the scratch buffer */
chunksize = fread(chunk, 1, SCRATCH_BUFSIZE, fd);
chunksize = fread(chunk, 1, SERVER_FILER_SCRATCH_BUFSIZE, fd);
/* Send the buffer contents as HTTP response chunk */
if (httpd_resp_send_chunk(req, chunk, chunksize) != ESP_OK) {
@@ -490,7 +475,7 @@ static esp_err_t send_logfile(httpd_req_t *req, bool send_full_file)
size_t chunksize;
do {
/* Read file in chunks into the scratch buffer */
chunksize = fread(chunk, 1, SCRATCH_BUFSIZE, fd);
chunksize = fread(chunk, 1, SERVER_FILER_SCRATCH_BUFSIZE, fd);
/* Send the buffer contents as HTTP response chunk */
if (httpd_resp_send_chunk(req, chunk, chunksize) != ESP_OK) {
@@ -592,7 +577,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
size_t chunksize;
do {
/* Read file in chunks into the scratch buffer */
chunksize = fread(chunk, 1, SCRATCH_BUFSIZE, fd);
chunksize = fread(chunk, 1, SERVER_FILER_SCRATCH_BUFSIZE, fd);
/* Send the buffer contents as HTTP response chunk */
if (httpd_resp_send_chunk(req, chunk, chunksize) != ESP_OK) {
@@ -684,7 +669,7 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
ESP_LOGI(TAG, "Remaining size: %d", remaining);
/* Receive the file part by part into a buffer */
if ((received = httpd_req_recv(req, buf, MIN(remaining, SCRATCH_BUFSIZE))) <= 0) {
if ((received = httpd_req_recv(req, buf, MIN(remaining, SERVER_FILER_SCRATCH_BUFSIZE))) <= 0) {
if (received == HTTPD_SOCK_ERR_TIMEOUT) {
/* Retry if timeout occurred */
continue;