Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/vanetza/geonet/cbr_aggregator.hpp
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

76 lines
2.0 KiB
C++

#ifndef CBR_AGGREGATOR_HPP_VUGJW6BW
#define CBR_AGGREGATOR_HPP_VUGJW6BW
#include <vanetza/dcc/channel_load.hpp>
#include <vanetza/geonet/timestamp.hpp>
#include <array>
namespace vanetza
{
namespace geonet
{
class LocationTable;
/**
* CbrAggregator realises the CBR_G aggregation, originally specified by TS 102 636-4-2 V1.1.1
* section 5.2.2 and carried forward by TS 103 836-4-2 V2.1.1 clause 5.3 (Release 2; the
* five-step algorithm here, including using the previous cycle's local CBR in the final
* max(), matches the current text exactly).
*
* Since this algorithm relies mainly on location table entries it is placed in the geonet module.
*/
class CbrAggregator
{
public:
using ChannelLoad = dcc::ChannelLoad;
CbrAggregator();
/**
* Get local channel busy ratio, i.e. CBR_L_0_Hop
* \return CBR
*/
ChannelLoad get_local_cbr() const { return m_local_cbr[0]; }
/**
* Get one-hop channel busy ratio, i.e. CBR_L_1_Hop
* \return CBR
*/
ChannelLoad get_one_hop_cbr() const { return m_one_hop_cbr; }
/**
* Get two-hop channel busy ratio, i.e. CBR_L_2_Hop
* \return CBR
*/
ChannelLoad get_two_hop_cbr() const { return m_two_hop_cbr; }
/**
* Get global channel busy ratio
* \return CBR
*/
ChannelLoad get_global_cbr() const { return m_global_cbr; }
/**
* Aggregate {1,2}-hop CBRs from received CBR values stored in location table
* \parame local most recent local CBR measurement CBR_L_0_Hop
* \param lt location table containing LocTEX_G5 entries
* \param cbr_lifetime reject entries older than T_cbr
* \param cbr_target reference value
*/
void aggregate(ChannelLoad cbr_local, const LocationTable& lt, Timestamp cbr_lifetime, ChannelLoad cbr_target);
private:
std::array<ChannelLoad, 2> m_local_cbr;
ChannelLoad m_one_hop_cbr;
ChannelLoad m_two_hop_cbr;
ChannelLoad m_global_cbr;
};
} // namespace geonet
} // namespace vanetza
#endif /* CBR_AGGREGATOR_HPP_VUGJW6BW */