Merge branch 'rolling'

This commit is contained in:
jomjol
2021-07-14 19:52:11 +02:00
80 changed files with 4515 additions and 1729 deletions

View File

@@ -19,6 +19,7 @@
#include "connect_wlan.h"
#include "read_wlanini.h"
#include "server_main.h"
#include "server_tflite.h"
#include "server_file.h"
#include "server_ota.h"
@@ -30,16 +31,14 @@
#define __SD_USE_ONE_LINE_MODE__
#ifdef __SD_USE_ONE_LINE_MODE__
#include "server_GPIO.h"
#endif
#define BLINK_GPIO GPIO_NUM_33
static const char *TAGMAIN = "connect_wlan_main";
static const char *TAGMAIN = "main";
#define FLASH_GPIO GPIO_NUM_4
//#define FLASH_GPIO GPIO_NUM_4
bool Init_NVS_SDCard()
{
@@ -50,7 +49,7 @@ bool Init_NVS_SDCard()
}
////////////////////////////////////////////////
ESP_LOGI(TAG, "Using SDMMC peripheral");
ESP_LOGI(TAGMAIN, "Using SDMMC peripheral");
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
// This initializes the slot without card detect (CD) and write protect (WP) signals.
@@ -92,10 +91,10 @@ bool Init_NVS_SDCard()
if (ret != ESP_OK) {
if (ret == ESP_FAIL) {
ESP_LOGE(TAG, "Failed to mount filesystem. "
ESP_LOGE(TAGMAIN, "Failed to mount filesystem. "
"If you want the card to be formatted, set format_if_mount_failed = true.");
} else {
ESP_LOGE(TAG, "Failed to initialize the card (%s). "
ESP_LOGE(TAGMAIN, "Failed to initialize the card (%s). "
"Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret));
}
return false;
@@ -108,9 +107,9 @@ bool Init_NVS_SDCard()
// Init the GPIO
// Flash ausschalten
gpio_pad_select_gpio(FLASH_GPIO);
gpio_set_direction(FLASH_GPIO, GPIO_MODE_OUTPUT);
gpio_set_level(FLASH_GPIO, 0);
// gpio_pad_select_gpio(FLASH_GPIO);
// gpio_set_direction(FLASH_GPIO, GPIO_MODE_OUTPUT);
// gpio_set_level(FLASH_GPIO, 0);
return true;
}
@@ -174,11 +173,12 @@ extern "C" void app_main(void)
TickType_t xDelay;
xDelay = 2000 / portTICK_PERIOD_MS;
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
printf("main: sleep for : %ldms\n", (long) xDelay);
// LogFile.WriteToFile("Startsequence 06");
vTaskDelay( xDelay );
// LogFile.WriteToFile("Startsequence 07");
setup_time();
setBootTime();
LogFile.WriteToFile("=============================================================================================");
LogFile.WriteToFile("=================================== Main Started ============================================");
LogFile.WriteToFile("=============================================================================================");
@@ -190,7 +190,7 @@ extern "C" void app_main(void)
// Camera.InitCam();
// Camera.LightOnOff(false);
xDelay = 2000 / portTICK_PERIOD_MS;
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
printf("main: sleep for : %ldms\n", (long) xDelay);
vTaskDelay( xDelay );
server = start_webserver();
@@ -199,13 +199,12 @@ extern "C" void app_main(void)
register_server_file_uri(server, "/sdcard");
register_server_ota_sdcard_uri(server);
#ifdef __SD_USE_ONE_LINE_MODE__
register_server_GPIO_uri(server);
#endif
printf("vor reg server main\n");
gpio_handler_create(server);
printf("vor reg server main\n");
register_server_main_uri(server, "/sdcard");
printf("vor dotautostart\n");
TFliteDoAutoStart();
}

View File

@@ -20,9 +20,9 @@
httpd_handle_t server = NULL;
std::string starttime = "";
static const char *TAG_SERVERMAIN = "server-main";
/* An HTTP GET handler */
esp_err_t info_get_handler(httpd_req_t *req)
@@ -198,7 +198,7 @@ esp_err_t hello_main_handler(httpd_req_t *req)
printf("File requested: %s\n", filetosend.c_str());
if (!filename) {
ESP_LOGE(TAG, "Filename is too long");
ESP_LOGE(TAG_SERVERMAIN, "Filename is too long");
/* Respond with 500 Internal Server Error */
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Filename too long");
return ESP_FAIL;
@@ -234,7 +234,7 @@ esp_err_t img_tmp_handler(httpd_req_t *req)
filetosend = filetosend + "/img_tmp/" + std::string(filename);
printf("File to upload: %s\n", filetosend.c_str());
esp_err_t res = send_file(req, filetosend);
esp_err_t res = send_file(req, filetosend);
if (res != ESP_OK)
return res;
@@ -299,7 +299,9 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
std::string gitbranch = libfive_git_branch();
std::string gitbasebranch = git_base_branch();
std::string htmlversion = getHTMLversion();
char freeheapmem[11];
sprintf(freeheapmem, "%zu", esp_get_free_heap_size());
tcpip_adapter_ip_info_t ip_info;
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
const char *hostname;
@@ -314,7 +316,8 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
\"html\" : \"" + htmlversion + "\",\
\"cputemp\" : \"" + cputemp + "\",\
\"hostname\" : \"" + hostname + "\",\
\"IPv4\" : \"" + ip4addr_ntoa(&ip_info.ip) + "\"\
\"IPv4\" : \"" + ip4addr_ntoa(&ip_info.ip) + "\",\
\"freeHeapMem\" : \"" + freeheapmem + "\"\
}\
]";
@@ -387,7 +390,7 @@ httpd_handle_t start_webserver(void)
httpd_config_t config = { };
config.task_priority = tskIDLE_PRIORITY+5;
config.stack_size = 32384; // bei 32k stürzt das Programm beim Bilderaufnehmen ab
config.stack_size = 32768; // bei 32k stürzt das Programm beim Bilderaufnehmen ab
config.core_id = tskNO_AFFINITY;
config.server_port = 80;
config.ctrl_port = 32768;
@@ -403,21 +406,22 @@ httpd_handle_t start_webserver(void)
config.global_transport_ctx = NULL;
config.global_transport_ctx_free_fn = NULL;
config.open_fn = NULL;
config.close_fn = NULL;
config.close_fn = NULL;
config.lru_purge_enable = true; // neu, um schlechte Serverbindung zu verhindern
// config.uri_match_fn = NULL;
config.uri_match_fn = httpd_uri_match_wildcard;
starttime = gettimestring("%Y%m%d-%H%M%S");
// Start the httpd server
ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);
ESP_LOGI(TAG_SERVERMAIN, "Starting server on port: '%d'", config.server_port);
if (httpd_start(&server, &config) == ESP_OK) {
// Set URI handlers
ESP_LOGI(TAG, "Registering URI handlers");
ESP_LOGI(TAG_SERVERMAIN, "Registering URI handlers");
return server;
}
ESP_LOGI(TAG, "Error starting server!");
ESP_LOGI(TAG_SERVERMAIN, "Error starting server!");
return NULL;
}
@@ -432,7 +436,7 @@ void disconnect_handler(void* arg, esp_event_base_t event_base,
{
httpd_handle_t* server = (httpd_handle_t*) arg;
if (*server) {
ESP_LOGI(TAG, "Stopping webserver");
ESP_LOGI(TAG_SERVERMAIN, "Stopping webserver");
stop_webserver(*server);
*server = NULL;
}
@@ -443,9 +447,7 @@ void connect_handler(void* arg, esp_event_base_t event_base,
{
httpd_handle_t* server = (httpd_handle_t*) arg;
if (*server == NULL) {
ESP_LOGI(TAG, "Starting webserver");
ESP_LOGI(TAG_SERVERMAIN, "Starting webserver");
*server = start_webserver();
}
}

View File

@@ -8,18 +8,17 @@
#include <nvs_flash.h>
#include <sys/param.h>
#include "nvs_flash.h"
#include "tcpip_adapter.h"
#include "esp_netif.h"
#include "esp_eth.h"
#include "server_GPIO.h"
#include <esp_http_server.h>
static const char *TAG = "server-main";
extern httpd_handle_t server;
httpd_handle_t start_webserver(void);
void register_server_main_uri(httpd_handle_t server, const char *base_path);
#endif

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="21a59fb";
const char* GIT_TAG="v7.1.1";
const char* GIT_BRANCH="master";
const char* BUILD_TIME="2021-06-17 19:59";
const char* GIT_REV="1f6b02a";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2021-07-13 20:37";