Rebuild obu-firmware on Niklas Dathe's microbu-firmware
Replace the vanetza-idf port with his current station firmware (microbu-firmware e4e4bd8: main/, components/microbu_v2x, components/vanetza, external/vanetza) and re-apply the MicrOBU additions, each marked "MicrOBU:" in the sources: - V2X_RX (opcode 0x90): every received ITS message, signed or not, through gn_unwrap.c, because the stack drops unsigned and foreign-root traffic. 0x85 is the spec's RAW_FRAME and 0x86 is reserved. The body is built in v2x_rx.hpp. - Unsigned transmission (geonet.c) for security profile 1 or station security 0, from a random MAC per configuration. - Radio polled from STATION_CONFIGURE on; manual country policy, TX power read-back, static RX buffer, short frames ignored. - Battery guard (battery_policy.hpp): deep sleep below 3.30 V with no phone on USB. - No USB writes without a host; last_frame_ms() for the guard. - 80 KB NVS with the app at 0x20000, 8 MB flash, XIAO ESP32-C5 board, 20 dBm. Remove the old C firmware, the bench listener and the old vanetza-idf copy. Add docs/station-link.tex as revision 2 of the interface reference (V2X_RX, unsigned sending, battery rule, revision history). Add 39 host unit tests (make firmware in test/host) next to the existing chain, replay, fuzz and battery tests, and point tools/station_status_watch.py at the new CONFIRM-based status.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <vanetza_idf/access.hpp>
|
||||
#include <microbu_v2x/access.hpp>
|
||||
#include <esp_err.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -13,24 +13,6 @@ struct C5RadioConfig {
|
||||
bool laboratory_transmission = true;
|
||||
};
|
||||
|
||||
#if CONFIG_MICROBU_TEST_CHANNEL
|
||||
/// Result of polling the PHY's own (undocumented) CCA state as fast as possible for a
|
||||
/// fixed window (feasibility probe for EN 303 797 clause 4.6.2)
|
||||
/// to determine if the platform can observe channel-busy state at >=1 kHz at all.
|
||||
struct CcaSampleResult {
|
||||
std::uint32_t samples = 0;
|
||||
std::uint32_t duration_us = 0;
|
||||
std::uint32_t min_delta_us = 0;
|
||||
std::uint32_t max_delta_us = 0;
|
||||
std::uint32_t busy_count = 0;
|
||||
std::int32_t first_cca = 0;
|
||||
std::int32_t last_cca = 0;
|
||||
std::int32_t noise_floor_dbm = 0;
|
||||
std::int32_t cca_total_cycles_delta = 0; // out[0]/0x600a7c5c: 40 MHz free-running counter
|
||||
std::int32_t cca_busy_cycles_delta = 0; // out[1]/0x600a7c60: increments while channel busy
|
||||
std::int32_t cca_status = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
/// Snapshot of the ESP32-C5 27-bit hardware PHY counters for ETSI TS 102 687 / EN 303 797 DCC.
|
||||
/// total_cycles: 40 MHz FE clock cycles (register 0x600a7c5c[26:0]).
|
||||
@@ -38,6 +20,9 @@ struct CcaSampleResult {
|
||||
struct CcaCounters {
|
||||
std::uint32_t total_cycles = 0;
|
||||
std::uint32_t busy_cycles = 0;
|
||||
/// The counter window had completed (bit 27) and was re-armed by this read: the next reading starts a new
|
||||
/// baseline, this one closes no valid window.
|
||||
bool restarted = false;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -45,10 +30,20 @@ struct CcaCounters {
|
||||
* Direct Wi-Fi promiscuous RX mode on 5.9 GHz (ITS-G5 Channel 180, 10 MHz BW)
|
||||
* and 802.11p frame transmission via esp_wifi_80211_tx_custom.
|
||||
*/
|
||||
class C5Radio final : public vanetza_idf::Access {
|
||||
class C5Radio final : public microbu_v2x::Access {
|
||||
public:
|
||||
using Receive = std::function<void(vanetza_idf::AlDataIndication)>;
|
||||
using Receive = std::function<void(microbu_v2x::AlDataIndication)>;
|
||||
/// Raw frame tap: MPDU bytes without FCS, RSSI (dBm) and the local receive time in microseconds.
|
||||
using Capture = std::function<void(const vanetza::ByteBuffer&, int, std::uint32_t)>;
|
||||
/// MicrOBU: every received 802.11 data frame (FCS included) and its RSSI, before the stack sees it.
|
||||
using Forward = std::function<void(const vanetza::ByteBuffer&, int)>;
|
||||
/// Transmit tap: the exact 802.11 frame handed to the driver.
|
||||
using Transmitted = std::function<void(const std::uint8_t*, std::size_t)>;
|
||||
|
||||
/// Raw capture mode bits (RAW_CAPTURE, ../../docs/station-link.tex).
|
||||
static constexpr std::uint8_t capture_on = 0x01; ///< every valid frame, like the OTM receiver
|
||||
static constexpr std::uint8_t capture_broadcast_only = 0x02; ///< OTM's broadcast filter (address 1 = FF..FF)
|
||||
static constexpr std::uint8_t capture_own_tx = 0x04; ///< also the frames this radio transmits
|
||||
|
||||
/// @brief Constructs a radio adapter with the given configuration (not yet started).
|
||||
/// @param config Radio configuration; defaults to channel 180, 10 dBm, 16-deep RX queue.
|
||||
@@ -64,35 +59,26 @@ public:
|
||||
/// @brief Stops the radio and releases all resources.
|
||||
void stop();
|
||||
|
||||
// vanetza_idf::Access
|
||||
// microbu_v2x::Access
|
||||
/// @brief Encodes and transmits an ITS-G5 frame requested by the access layer.
|
||||
/// @param request Frame and transmit parameters from the access layer.
|
||||
/// @return Result of the transmit attempt.
|
||||
vanetza_idf::Result request(vanetza_idf::AlDataRequest request) override;
|
||||
microbu_v2x::Result request(microbu_v2x::AlDataRequest request) override;
|
||||
|
||||
/// @brief Dispatches queued received frames to the owning task callback.
|
||||
/// @param receive Invoked once per queued frame with its decoded indication.
|
||||
/// @param capture Optional; invoked with the raw frame bytes, RSSI and timestamp for diagnostics.
|
||||
void poll(const Receive& receive, const Capture& capture = {});
|
||||
/// @param forward Optional MicrOBU tap: called for every data frame, independent of `receive`.
|
||||
void poll(const Receive& receive, const Capture& capture = {}, const Forward& forward = {});
|
||||
|
||||
#if CONFIG_MICROBU_TEST_CHANNEL
|
||||
/// @brief Sends a burst of raw 802.11p test frames for RF characterization.
|
||||
/// @param channel ITS-G5 channel number to transmit on.
|
||||
/// @param power_dbm Transmit power in dBm.
|
||||
/// @param mcs 802.11p modulation and coding scheme index.
|
||||
/// @param count Number of frames to send.
|
||||
/// @param interval_ms Interval between frames in milliseconds.
|
||||
/// @param payload_len Length of each frame's payload in bytes.
|
||||
/// @return ESP_OK if all frames were sent, otherwise the last transmit error.
|
||||
esp_err_t transmit_burst(std::uint16_t channel, double power_dbm, unsigned mcs,
|
||||
unsigned count, unsigned interval_ms, std::size_t payload_len);
|
||||
/// @brief Switches the raw capture tap. While on, the promiscuous filter admits every frame class
|
||||
/// except bad FCS (as the OpenTrafficMap receiver firmware does); only data frames reach the stack.
|
||||
/// @param mode Combination of capture_on, capture_broadcast_only and capture_own_tx (0 = off).
|
||||
void set_capture(std::uint8_t mode);
|
||||
|
||||
/// @brief Registers the tap invoked for every successfully submitted frame while capture_own_tx is set.
|
||||
void on_transmitted(Transmitted tap);
|
||||
|
||||
/// @brief Polls the CCA state as fast as possible for a fixed window (see CcaSampleResult); requires start().
|
||||
/// @note This is a diagnostic tool/ feasibility probe for EN 303 797 clause 4.6.2 to determine if the platform can observe channel-busy state at >=1 kHz at all.
|
||||
/// @param duration_ms Duration of the sampling window in milliseconds.
|
||||
/// @return Sampling statistics and counter deltas over the window.
|
||||
CcaSampleResult sample_cca(unsigned duration_ms);
|
||||
#endif
|
||||
|
||||
/// @brief Non-blocking read of the hardware CCA counters for periodic DCC evaluation.
|
||||
/// Continuous 40 MHz hardware integration satisfies EN 303 797 Profile-1 (>=1 kHz) with zero CPU busy-wait.
|
||||
|
||||
Reference in New Issue
Block a user