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

100 lines
1.8 KiB
C++

#include "traffic_class.hpp"
#include "serialization.hpp"
namespace vanetza
{
namespace geonet
{
TrafficClass::TrafficClass() : m_tc(0)
{
}
TrafficClass::TrafficClass(bool scf, bool ch_offload, BitNumber<unsigned, 6> tc) : m_tc(0)
{
store_carry_forward(scf);
channel_offload(ch_offload);
tc_id(tc);
}
TrafficClass::TrafficClass(uint8_t raw) : m_tc(raw)
{
}
bool TrafficClass::store_carry_forward() const
{
return (m_tc & scf_mask);
}
void TrafficClass::store_carry_forward(bool flag)
{
if (flag) {
m_tc |= scf_mask;
} else {
m_tc &= ~scf_mask;
}
}
bool TrafficClass::channel_offload() const
{
return (m_tc & channel_offload_mask);
}
void TrafficClass::channel_offload(bool flag)
{
if (flag) {
m_tc |= channel_offload_mask;
} else {
m_tc &= ~channel_offload_mask;
}
}
BitNumber<unsigned, 6> TrafficClass::tc_id() const
{
return (m_tc & tc_id_mask);
}
void TrafficClass::tc_id(BitNumber<unsigned, 6> id)
{
m_tc &= ~tc_id_mask;
m_tc |= id.raw() & tc_id_mask;
}
dcc::Profile map_tc_onto_profile(const TrafficClass& tc)
{
dcc::Profile profile = dcc::Profile::DP3;
switch (tc.tc_id().raw()) {
case 0:
profile = dcc::Profile::DP0;
break;
case 1:
profile = dcc::Profile::DP1;
break;
case 2:
profile = dcc::Profile::DP2;
break;
default:
profile = dcc::Profile::DP3;
break;
}
return profile;
}
void serialize(const TrafficClass& tc, OutputArchive& ar)
{
serialize(host_cast(tc.raw()), ar);
}
void deserialize(TrafficClass& tc, InputArchive& ar)
{
decltype(tc.raw()) tmp;
deserialize(tmp, ar);
tc = TrafficClass(tmp);
}
} // namespace geonet
} // namespace vanetza