Block 1-4: Debugging Logging, C-ITS Parser, CSV Writer, Integration

This commit is contained in:
Clawdia
2026-05-18 11:34:21 +02:00
parent 8201928316
commit 9c52097cad
3 changed files with 119 additions and 44 deletions
+28 -9
View File
@@ -23,10 +23,11 @@
#include "block2_cits_parser.h"
#include "block3_csv_writer.h"
static const char *TAG = "CITS_SNIFER_MAIN";
static const char *TAG = "CITS_SNIFFER";
/**
* Sniffer Callback - Wird vom WiFi Promiscuous Mode aufgerufen
* Jede empfangene 802.11p Nachricht wird hier geloggt
*/
static void sniffer_callback(void *recv_buf, wifi_promiscuous_pkt_type_t type)
{
@@ -37,12 +38,20 @@ static void sniffer_callback(void *recv_buf, wifi_promiscuous_pkt_type_t type)
return;
}
// Verarbeite C-ITS Nachricht
if (packet->payload != NULL && packet->rx_ctrl.sig_len > 0) {
cits_process_packet(packet->payload, packet->rx_ctrl.sig_len,
packet->rx_ctrl.timestamp / 1000000U,
packet->rx_ctrl.timestamp % 1000000U);
if (packet->payload == NULL || packet->rx_ctrl.sig_len < 20) {
return;
}
// RSSI aus dem Paket
int8_t rssi = packet->rx_ctrl.rssi;
ESP_LOGI(TAG, "[SNIFFER] 802.11p Paket empfangen: %d Bytes | RSSI: %d dBm",
packet->rx_ctrl.sig_len, rssi);
// Verarbeite C-ITS Nachricht
cits_process_packet(packet->payload, packet->rx_ctrl.sig_len,
packet->rx_ctrl.timestamp / 1000000U,
packet->rx_ctrl.timestamp % 1000000U);
}
/**
@@ -103,9 +112,19 @@ void app_main(void)
return;
}
// Hauptschleife
ESP_LOGI(TAG, "C-ITS Sniffer läuft - Warte auf C-ITS Nachrichten...");
// Hauptschleife - C-ITS Nachrichten werden im Callback verarbeitet
ESP_LOGI(TAG, "C-ITS Sniffer läuft - Empfange DSRC/C-ITS Nachrichten auf %u MHz...",
CITS_CHANNEL_0_MHZ);
ESP_LOGI(TAG, "Jede empfangene Nachricht wird geloggt und in CSV gespeichert");
// Zähler für Statistik
uint32_t packet_count = 0;
uint32_t last_report = 0;
while (1) {
vTaskDelay(pdMS_TO_TICKS(1000));
vTaskDelay(pdMS_TO_TICKS(60000)); // Alle 60 Sekunden Statistik
last_report++;
ESP_LOGI(TAG, "Laufzeit: %lu Min. | Warte auf C-ITS Nachrichten...",
(unsigned long)last_report);
}
}