Files
esp32-Serial-Logger/config.h
2026-02-24 20:19:38 +00:00

82 lines
2.7 KiB
C

#ifndef CONFIG_H
#define CONFIG_H
// ============================================================
// ESP32 Serial Logger - Configuration
// ESP-WROOM-32D DevKitC V4
// ============================================================
// --- WiFi Configuration ---
#define WIFI_SSID "YourSSID"
#define WIFI_PASSWORD "YourPassword"
#define WIFI_AP_SSID "ESP32_Logger"
#define WIFI_AP_PASSWORD "12345678"
#define WIFI_CONNECT_TIMEOUT 15000 // ms
// --- Serial2 (UART2) Pin Configuration ---
#define SERIAL2_TX_PIN 17 // GPIO17
#define SERIAL2_RX_PIN 16 // GPIO16
// --- Serial2 Default Settings ---
#define DEFAULT_BAUD_RATE 115200
#define DEFAULT_RX_BUFFER 4096
// --- VSPI SD Card Pin Configuration ---
#define SD_VSPI_MISO 19
#define SD_VSPI_MOSI 23
#define SD_VSPI_SCLK 18
#define SD_VSPI_CS 5
// --- DS3231 RTC I2C Configuration (SoftWire) ---
// 소프트웨어 I2C → 임의 GPIO 사용 가능
#define RTC_SDA_PIN 25 // I2C SDA
#define RTC_SCL_PIN 26 // I2C SCL
#define DS3231_ADDRESS 0x68 // DS3231 I2C Address
#define RTC_SYNC_INTERVAL_MS 60000 // RTC → System clock 보정 주기 (60초)
// --- FreeRTOS Task Priorities ---
#define TASK_PRIORITY_SERIAL 5 // Highest - must not miss data
#define TASK_PRIORITY_SD_LOG 3 // Medium-high - buffered writes
#define TASK_PRIORITY_WEB 2 // Medium - user interface
#define TASK_PRIORITY_RTC 1 // Low - periodic RTC sync
#define TASK_PRIORITY_NTP 1 // Lowest - periodic NTP sync
// --- FreeRTOS Task Stack Sizes ---
#define TASK_STACK_SERIAL 4096
#define TASK_STACK_SD_LOG 8192
#define TASK_STACK_WEB 8192
#define TASK_STACK_RTC 3072
#define TASK_STACK_NTP 4096
// --- Queue Configuration ---
#define QUEUE_SD_SIZE 512
#define QUEUE_WEB_SIZE 256
#define QUEUE_TX_SIZE 64
// --- Logging Configuration ---
#define LOG_LINE_MAX_LEN 512
#define SD_WRITE_INTERVAL 1000 // Flush to SD every N ms
#define LOG_DIR "/logs"
#define CSV_HEADER "Timestamp,Direction,Data\r\n"
#define LOG_MAX_FILE_SIZE (100UL * 1024 * 1024) // 100MB auto-rotate
#define LOG_ROTATE_MIDNIGHT true // New file at midnight
// --- NTP Configuration ---
#define NTP_SERVER "pool.ntp.org"
#define NTP_GMT_OFFSET 32400 // KST = UTC+9 (9*3600)
#define NTP_DAYLIGHT_OFFSET 0
// --- WebSocket Configuration ---
#define WS_PORT 81
#define WS_MAX_CLIENTS 4
// --- Log Entry Structure ---
struct LogEntry {
char timestamp[24]; // "2025-01-15 10:30:45.123"
char direction; // 'R' for RX, 'T' for TX
char data[LOG_LINE_MAX_LEN];
uint16_t dataLen;
};
#endif // CONFIG_H