Files
Ashin Walpola d107534eb2 Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
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.
2026-09-24 10:56:05 +02:00

55 lines
1.7 KiB
C++

#include <vanetza/common/runtime.hpp>
#include <vanetza/geonet/dcc_information_sharing.hpp>
#include <vanetza/geonet/location_table.hpp>
namespace vanetza
{
namespace geonet
{
DccInformationSharing::DccInformationSharing(Runtime& rt, const LocationTable& lt, dcc::ChannelLoad target, UnitInterval delay) :
m_runtime(rt), m_location_table(lt), m_cbr_target(target), m_tx_power(0),
m_trigger_interval(std::chrono::milliseconds(100)),
m_last_aggregation(m_runtime.now()),
on_global_cbr_update(m_update_hook)
{
Clock::duration initial = m_trigger_interval;
initial *= delay.value();
m_runtime.schedule(initial, [this](const Clock::time_point&) { trigger(); });
}
DccInformationSharing::DccInformationSharing(Runtime& rt, const LocationTable& lt, dcc::ChannelLoad target) :
DccInformationSharing(rt, lt, target, UnitInterval { 0.0 })
{
}
DccField DccInformationSharing::generate_dcc_field()
{
DccMcoField dcc_mco;
dcc_mco.local_cbr(m_aggregator.get_local_cbr());
dcc_mco.neighbour_cbr(m_aggregator.get_one_hop_cbr());
dcc_mco.output_power(m_tx_power);
return dcc_mco;
}
void DccInformationSharing::update_local_cbr(dcc::ChannelLoad local_cbr)
{
m_cbr_local = local_cbr;
}
void DccInformationSharing::set_tx_power(unsigned tx_power)
{
m_tx_power = tx_power;
}
void DccInformationSharing::trigger()
{
m_aggregator.aggregate(m_cbr_local, m_location_table, m_last_aggregation, m_cbr_target);
m_last_aggregation = m_runtime.now();
m_update_hook(static_cast<const CbrAggregator&>(m_aggregator));
m_runtime.schedule(m_trigger_interval, [this](const Clock::time_point&) { trigger(); });
}
} // namespace geonet
} // namespace vanetza