Merge remote-tracking branch 'origin/gpio-handler' into rolling

This commit is contained in:
Zwer2k
2021-07-08 21:54:44 +02:00
48 changed files with 1928 additions and 380 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;
}
@@ -136,6 +135,17 @@ void task_NoSDBlink(void *pvParameter)
vTaskDelete(NULL); //Delete this task if it exits from the loop above
}
esp_err_t handler_gpio(httpd_req_t *req)
{
gpio_handler_init();
char resp_str [30];
sprintf(resp_str, "OK. freemem %u", esp_get_free_heap_size());
httpd_resp_send(req, resp_str, strlen(resp_str));
return ESP_OK;
}
extern "C" void app_main(void)
{
printf("Do Reset Camera\n");
@@ -174,11 +184,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 +201,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 +210,19 @@ 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");
httpd_uri_t camuri = { };
camuri.method = HTTP_GET;
camuri.uri = "/test";
camuri.handler = handler_gpio;
camuri.user_ctx = (void*)server;
httpd_register_uri_handler(server, &camuri);
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;
@@ -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 + "\"\
}\
]";
@@ -410,14 +413,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 +435,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 +446,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="894c7f6";
const char* GIT_REV="5414a4c";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2021-07-04 10:15";
const char* BUILD_TIME="2021-07-07 22:14";