Added logger - functional

This commit is contained in:
Matthias Mitscherlich
2023-01-16 15:58:24 +01:00
parent f2967862b6
commit 0dfa8fad2b
7 changed files with 482 additions and 21 deletions
+30 -6
View File
@@ -10,23 +10,23 @@
#include "driver/gpio.h"
#include "inc/gpio.h"
#include "driver/uart_select.h"
#include "inc/wifi.h"
#include "inc/logger.h"
static const uart_port_t uartPort = UART_NUM_0;
static TaskHandle_t devTaskHandle = NULL;
static void devTask(void* parameters);
static GPIO gpio0(4, GPIO_DIRECTION_OUTPUT);
static GPIO gpio1(18, GPIO_DIRECTION_OUTPUT);
static time_t currentTime;
//
//static void wifi_init(void);
static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
void wifi_init_sta(void);
extern "C" void app_main(void)
{
esp_log_level_set("*", ESP_LOG_WARN);
esp_err_t ret = nvs_flash_init();
if(ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
@@ -35,6 +35,30 @@ extern "C" void app_main(void)
ret = nvs_flash_init();
}
//--------------------------------------------
// UART
//
const uart_config_t uartConfig =
{
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT
};
ESP_ERROR_CHECK(uart_param_config(uartPort, &uartConfig));
ESP_ERROR_CHECK(uart_set_pin(uartPort, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
ESP_ERROR_CHECK(uart_driver_install(uartPort, 1024, 1024, 0, NULL, 0));
uart_write_bytes(uartPort, "helloWorld", sizeof("helloworld"));
Logger logger(10, uartPort);
logger.Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_DEBUG, "Hello World from the Logger himself");
LOGGER_DEBUG("YEAHAAA");
// Create the development task
if(xTaskCreate(devTask, "DevTask", 2048, NULL, 3, &devTaskHandle) != pdPASS)
{
@@ -60,7 +84,7 @@ extern "C" void app_main(void)
printf("%lld\n\r", currentTime);
printf("%i:%i:%i\n\r", tm.tm_hour, tm.tm_min, tm.tm_sec);
vTaskDelay(1000);
vTaskDelay(1000);
}
}