Files
aes67-ESP32-P4/main/main.c
T
bsncubed 8b3bd39857 Step 5 (syslog): esp_log to remote syslog
- aes67_syslog: esp_log_set_vprintf hook chained to the UART; formats
  into a static buffer under a zero-timeout mutex (drop and count when
  busy), strips ANSI codes, parses level/tag, filters by log.level and
  queues (48 messages, non-blocking). Low-priority sender task: RFC 5424
  (<PRI>1 - HOST APP - - - MSG, no timestamp yet) or RFC 3164
  (<PRI>HOST TAG: MSG), PRI = facility*8 + severity; log.host as IP or
  resolved name; config applies live. Messages wait in the queue until
  the interface has an IP. POST /api/log/test sends an info message
  regardless of the level filter.
- Initialised first in app_main so boot messages are captured; the UDP
  socket is created only once the interface is up (creating it before
  esp_netif_init crashed at boot and the bootloader rolled back).
- Verified with a UDP listener: 5424 and 3164 formats, PRI 134/132,
  boot messages delivered after the IP came up, shutdown messages sent
  before reboot, level filter, test message, host by DNS name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 07:05:34 +10:00

45 lines
1.3 KiB
C

#include "aes67_board.h"
#include "aes67_health.h"
#include "aes67_net.h"
#include "aes67_ota.h"
#include "aes67_ptp.h"
#include "aes67_sdp_sap.h"
#include "aes67_syslog.h"
#include "aes67_tx.h"
#include "aes67_web.h"
#include "esp_app_desc.h"
#include "esp_chip_info.h"
#include "esp_log.h"
#include "project_cfg.h"
static const char *TAG = "main";
void app_main(void)
{
const esp_app_desc_t *app = esp_app_get_description();
esp_chip_info_t chip;
esp_chip_info(&chip);
ESP_LOGI(TAG, "%s %s (IDF %s, built %s %s)",
app->project_name, app->version, app->idf_ver, app->date, app->time);
ESP_LOGI(TAG, "chip rev v%d.%d, %d cores",
chip.revision / 100, chip.revision % 100, chip.cores);
project_cfg_defaults();
// First, so boot messages are queued for syslog until the interface has an IP.
ESP_ERROR_CHECK(aes67_syslog_init());
esp_eth_handle_t eth;
ESP_ERROR_CHECK(aes67_board_eth_init(&eth));
ESP_ERROR_CHECK(aes67_net_init(eth));
ESP_ERROR_CHECK(aes67_health_init());
ESP_ERROR_CHECK(aes67_ptp_init());
ESP_ERROR_CHECK(aes67_ptp_start(eth));
ESP_ERROR_CHECK(aes67_tx_init());
project_cfg_register();
ESP_ERROR_CHECK(aes67_ota_init());
ESP_ERROR_CHECK(aes67_sdp_sap_init());
ESP_ERROR_CHECK(aes67_tx_start());
ESP_ERROR_CHECK(aes67_web_start());
}