Forward MAPEM and VAM from the ESP32-C5, and add a bench listener

gn_unwrap.c now passes BTP ports 2003 (MAPEM) and 2018 (VAM), signed or
not, besides CAM, DENM and SPATEM. A message over 494 bytes still does not
fit one 512-octet link message (also the largest GATT value) and is dropped
and counted, not fragmented. The bench RSU's MAPEM is 295 bytes.

CONFIG_MICROBU_BENCH_LISTEN (off in sdkconfig) is for a board whose only PC
connection is the UART0 console: it configures itself receive-only at boot
and logs every V2X_RX message; tools/bench_listen_watch.py tallies the log.
On air on 2026-10-28 it forwarded 104 MAPEM, 185 SPATEM and 472 CAM in
90 s, with nothing oversize. The RSU sent all of them unsigned.

Host tests: signed GeoBroadcast SPATEM/MAPEM frames of 58 to 1243 bytes
with every truncation length; the replay cuts frames at c5_radio.cpp's
2346 bytes (not the old C firmware's 800) and checks MAPEMs with asn1tools.
This commit is contained in:
Ashin Walpola
2026-10-28 16:48:37 +01:00
parent 9f77f9f0e4
commit fc3354a4ba
12 changed files with 246 additions and 55 deletions
+9 -2
View File
@@ -366,8 +366,15 @@ void Station::forward_raw(const ByteBuffer& frame, int rssi) {
gn_rx_t rx;
if (!gn_unwrap_its(frame.data(), static_cast<int>(frame.size()), &rx)) return;
constexpr std::size_t prefix = 14;
if (rx.truncated || rx.payload_len <= 0 ||
static_cast<std::size_t>(rx.payload_len) + prefix + link::header_size > link::maximum_message) {
const bool fits = !rx.truncated && rx.payload_len > 0 &&
static_cast<std::size_t>(rx.payload_len) + prefix + link::header_size <= link::maximum_message;
#if CONFIG_MICROBU_BENCH_LISTEN
ESP_LOGI(TAG, "V2X_RX port %u msgid %u, %d bytes, %d dBm%s%s%s", unsigned(rx.btp_dest_port),
rx.payload_len > 1 ? unsigned(rx.payload[1]) : 0u, rx.payload_len, rssi,
rx.signed_unverified ? ", signed" : "", rx.has_geo_area ? ", GBC" : "",
fits ? "" : ", OVERSIZE (dropped)");
#endif
if (!fits) {
++raw_oversize_;
static std::int64_t last_report = 0; // one line per 10 s at most, the counter has the rest
const auto now = esp_timer_get_time();