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.
103 lines
3.0 KiB
C++
103 lines
3.0 KiB
C++
#ifndef MANUAL_RUNTIME_HPP_IPFSK6ZA
|
|
#define MANUAL_RUNTIME_HPP_IPFSK6ZA
|
|
|
|
#include <vanetza/common/runtime.hpp>
|
|
#include <boost/multi_index_container.hpp>
|
|
#include <boost/multi_index/hashed_index.hpp>
|
|
#include <boost/multi_index/member.hpp>
|
|
#include <boost/multi_index/ordered_index.hpp>
|
|
|
|
namespace vanetza
|
|
{
|
|
|
|
/**
|
|
* ManualRuntime is a manually triggered Runtime implementation.
|
|
* Ensure that time progress is triggered monotonically!
|
|
*/
|
|
class ManualRuntime : public Runtime
|
|
{
|
|
public:
|
|
ManualRuntime() = default;
|
|
|
|
/**
|
|
* Create runtime
|
|
* \param init initialization value of internal clock
|
|
*/
|
|
explicit ManualRuntime(Clock::time_point init);
|
|
|
|
/**
|
|
* Trigger absolute time progress
|
|
*
|
|
* All expired callbacks will be invoked
|
|
* \param tp new time point, has to be greater than now
|
|
*/
|
|
void trigger(Clock::time_point tp);
|
|
|
|
/**
|
|
* Trigger relative time progress
|
|
*
|
|
* All expired callbacks will be invoked
|
|
* \param d advance time by this duration
|
|
*/
|
|
void trigger(Clock::duration d);
|
|
|
|
/**
|
|
* Reset runtime
|
|
*
|
|
* Drops all scheduled callbacks and resets internal clock
|
|
* \param tp new time point
|
|
*/
|
|
void reset(Clock::time_point tp);
|
|
|
|
/**
|
|
* Get time point of next scheduled event
|
|
* \note time point might belong to an expired event, i.e. next() < now()
|
|
* \return time point of next event or time_point::max if none
|
|
*/
|
|
Clock::time_point next() const;
|
|
|
|
// Runtime interface (see header there for details)
|
|
void schedule(Clock::time_point, const Callback&, const void* = nullptr) override;
|
|
void schedule(Clock::duration, const Callback&, const void* = nullptr) override;
|
|
void cancel(const void* scope) override;
|
|
Clock::time_point now() const override;
|
|
|
|
private:
|
|
struct ScheduledCallback
|
|
{
|
|
ScheduledCallback(Clock::time_point tp, const Callback& cb, const void* scope) :
|
|
deadline(tp), callback(cb), scope(scope) {}
|
|
|
|
ScheduledCallback(const ScheduledCallback&) = delete;
|
|
ScheduledCallback& operator=(const ScheduledCallback&) = delete;
|
|
|
|
ScheduledCallback(ScheduledCallback&&) = default;
|
|
ScheduledCallback& operator=(ScheduledCallback&&) = default;
|
|
|
|
Clock::time_point deadline;
|
|
Callback callback;
|
|
const void* scope;
|
|
};
|
|
|
|
struct by_deadline {};
|
|
using time_index = boost::multi_index::ordered_non_unique<
|
|
boost::multi_index::tag<by_deadline>,
|
|
boost::multi_index::member<ScheduledCallback, Clock::time_point, &ScheduledCallback::deadline>>;
|
|
struct by_scope {};
|
|
using scope_index = boost::multi_index::hashed_non_unique<
|
|
boost::multi_index::tag<by_scope>,
|
|
boost::multi_index::member<ScheduledCallback, const void*, &ScheduledCallback::scope>>;
|
|
using queue_type = boost::multi_index_container<ScheduledCallback,
|
|
boost::multi_index::indexed_by<time_index, scope_index>>;
|
|
|
|
void trigger();
|
|
|
|
Clock::time_point m_now;
|
|
queue_type m_queue;
|
|
};
|
|
|
|
} // namespace vanetza
|
|
|
|
#endif /* MANUAL_RUNTIME_HPP_IPFSK6ZA */
|
|
|