obu-firmware builds against the vanetza-idf C-ITS library, which until now came from the colleague's microbu-esp32c5 tree beside the repository and was not tracked here, so a clone of this repository could not build the firmware it ships. The library alone is now part of obu-firmware, as obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from there by default; -DVANETZA_IDF_DIR still points the build elsewhere. The rest of the colleague's tree (their own VAM firmware, PKI tooling, station-link Python tools, the V2X2MAP bridge) stays out of this repository and gitignored; nothing is pushed to their repository. NOTES.md, docs/06, TODO.md and the pcap verifier's usage line point at the new location.
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
#include <vanetza/common/position_provider.hpp>
|
|
#include <vanetza/common/runtime.hpp>
|
|
#include <vanetza/geonet/position_updater.hpp>
|
|
#include <vanetza/geonet/router.hpp>
|
|
#include <vanetza/units/time.hpp>
|
|
#include <chrono>
|
|
|
|
namespace vanetza
|
|
{
|
|
namespace geonet
|
|
{
|
|
|
|
PositionUpdater::PositionUpdater(Runtime& rt, PositionProvider& position, Router& router) :
|
|
m_runtime(rt), m_positioning(position), m_router(router)
|
|
{
|
|
update_rate(m_router.get_mib().itsGnMinimumUpdateFrequencyEPV);
|
|
}
|
|
|
|
PositionUpdater::~PositionUpdater()
|
|
{
|
|
m_runtime.cancel(this);
|
|
}
|
|
|
|
void PositionUpdater::schedule()
|
|
{
|
|
if (m_interval > Clock::duration::zero()) {
|
|
m_runtime.schedule(m_interval, [this](Clock::time_point) {
|
|
m_router.update_position(m_positioning.position_fix());
|
|
schedule();
|
|
}, this);
|
|
}
|
|
}
|
|
|
|
void PositionUpdater::update_rate(Clock::duration interval)
|
|
{
|
|
m_interval = interval;
|
|
m_runtime.cancel(this); /*< cancel previously scheduled callback */
|
|
schedule();
|
|
}
|
|
|
|
void PositionUpdater::update_rate(units::Frequency rate)
|
|
{
|
|
if (rate > units::Frequency::from_value(0.0)) {
|
|
using namespace std::chrono;
|
|
const duration<double> interval { 1.0 / rate / units::si::second };
|
|
update_rate(duration_cast<Clock::duration>(interval));
|
|
} else {
|
|
update_rate(Clock::duration::zero());
|
|
}
|
|
}
|
|
|
|
} // namespace geonet
|
|
} // namespace vanetza
|