Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/vanetza/geonet/dcc_information_sharing.cpp
T
Ashin Walpola 0e9525162d Keep the colleague's microbu-esp32c5 tree in this repository
obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but
that tree was gitignored, so a clone of this repository could not build the
firmware it ships. It is now committed here as ordinary files in its own
folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP
bridge's signature verification (--trust) used on the bench. Nothing is
fetched from or pushed to the colleague's repository; this repository and
its remotes carry everything. The folder's own .gitignore keeps build output,
downloaded components and private key material out, as it did there; the
committed file set is identical to that repository's tracked files.

The ESP32-C5 is still flashed from obu-firmware/, which only takes
vanetza-idf from microbu-esp32c5/, so the two stay separate folders.
FLASHING.md says how to take a newer version of the colleague's tree (copy
it over the folder, rebuild, test, commit).
2026-09-23 17:46:40 +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