work on GPIO handler

bigfix: memory leak in GetJPGStream
This commit is contained in:
Zwer2k
2021-06-25 01:19:23 +02:00
parent d995c31b7b
commit 7b8f10a14e
29 changed files with 357 additions and 172 deletions

View File

@@ -31,19 +31,15 @@
#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
GpioHandler *gpioHandler = NULL;
bool Init_NVS_SDCard()
{
esp_err_t ret = nvs_flash_init();
@@ -53,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.
@@ -95,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;
@@ -190,7 +186,7 @@ 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");
@@ -207,7 +203,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();

View File

@@ -20,9 +20,10 @@
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 +199,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;
@@ -410,14 +411,14 @@ httpd_handle_t start_webserver(void)
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 +433,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,7 +444,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,16 +8,16 @@
#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;
static GpioHandler *gpioHandler = NULL;
httpd_handle_t start_webserver(void);
void register_server_main_uri(httpd_handle_t server, const char *base_path);

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="6cefc44";
const char* GIT_TAG="v7.1.0";
const char* GIT_BRANCH="master";
const char* BUILD_TIME="2021-05-30 21:47";
const char* GIT_REV="d995c31";
const char* GIT_TAG="";
const char* GIT_BRANCH="gpio-handler";
const char* BUILD_TIME="2021-06-21 23:55";