mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2026-04-14 15:07:44 +03:00
gpio handler is working
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
@@ -20,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"
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
static const char *TAGMAIN = "main";
|
||||
|
||||
#define FLASH_GPIO GPIO_NUM_4
|
||||
//#define FLASH_GPIO GPIO_NUM_4
|
||||
|
||||
bool Init_NVS_SDCard()
|
||||
{
|
||||
@@ -107,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;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ void task_NoSDBlink(void *pvParameter)
|
||||
esp_err_t handler_gpio(httpd_req_t *req)
|
||||
{
|
||||
printf("freemem -3-: %u\n", esp_get_free_heap_size());
|
||||
gpioHandler->init();
|
||||
gpio_handler_init();
|
||||
printf("freemem -4-: %u\n", esp_get_free_heap_size());
|
||||
|
||||
char resp_str [30];
|
||||
@@ -219,14 +219,9 @@ extern "C" void app_main(void)
|
||||
camuri.user_ctx = (void*)server;
|
||||
httpd_register_uri_handler(server, &camuri);
|
||||
|
||||
#ifdef __SD_USE_ONE_LINE_MODE__
|
||||
printf("freemem -1-: %u\n", esp_get_free_heap_size());
|
||||
gpioHandler = new GpioHandler(CONFIG_FILE, server);
|
||||
printf("freemem -2-: %u\n", esp_get_free_heap_size());
|
||||
#endif
|
||||
gpio_handler_create();
|
||||
|
||||
printf("vor reg server main\n");
|
||||
|
||||
register_server_main_uri(server, "/sdcard");
|
||||
|
||||
printf("vor dotautostart\n");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "defines.h"
|
||||
#include "server_help.h"
|
||||
#include "ClassLogFile.h"
|
||||
|
||||
@@ -24,6 +25,8 @@ std::string starttime = "";
|
||||
|
||||
static const char *TAG_SERVERMAIN = "server-main";
|
||||
|
||||
static GpioHandler *gpioHandler = NULL;
|
||||
|
||||
|
||||
/* An HTTP GET handler */
|
||||
esp_err_t info_get_handler(httpd_req_t *req)
|
||||
@@ -300,7 +303,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;
|
||||
@@ -315,7 +320,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 + "\"\
|
||||
}\
|
||||
]";
|
||||
|
||||
@@ -449,4 +455,34 @@ void connect_handler(void* arg, esp_event_base_t event_base,
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_handler_create()
|
||||
{
|
||||
if (gpioHandler == NULL)
|
||||
gpioHandler = new GpioHandler(CONFIG_FILE, server);
|
||||
}
|
||||
|
||||
void gpio_handler_init()
|
||||
{
|
||||
if (gpioHandler != NULL) {
|
||||
gpioHandler->init();
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_handler_deinit() {
|
||||
if (gpioHandler != NULL) {
|
||||
gpioHandler->deinit();
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_handler_destroy()
|
||||
{
|
||||
if (gpioHandler != NULL) {
|
||||
delete gpioHandler;
|
||||
gpioHandler = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GpioHandler* gpio_handler_get()
|
||||
{
|
||||
return gpioHandler;
|
||||
}
|
||||
|
||||
@@ -16,10 +16,15 @@
|
||||
|
||||
extern httpd_handle_t server;
|
||||
|
||||
static GpioHandler *gpioHandler = NULL;
|
||||
void gpio_handler_create();
|
||||
void gpio_handler_init();
|
||||
void gpio_handler_deinit();
|
||||
void gpio_handler_destroy();
|
||||
GpioHandler* gpio_handler_get();
|
||||
|
||||
httpd_handle_t start_webserver(void);
|
||||
|
||||
void register_server_main_uri(httpd_handle_t server, const char *base_path);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const char* GIT_REV="d995c31";
|
||||
const char* GIT_REV="7b8f10a";
|
||||
const char* GIT_TAG="";
|
||||
const char* GIT_BRANCH="gpio-handler";
|
||||
const char* BUILD_TIME="2021-06-21 23:55";
|
||||
const char* BUILD_TIME="2021-07-03 00:47";
|
||||
Reference in New Issue
Block a user