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

50 lines
1.1 KiB
C++

#include "pdu_conversion.hpp"
#include "serialization_buffer.hpp"
#include <cassert>
namespace vanetza
{
namespace convertible
{
typedef std::unique_ptr<vanetza::geonet::Pdu> PduPtr;
void byte_buffer_impl<PduPtr>::convert(ByteBuffer& dest) const
{
assert(m_pdu);
dest.clear();
geonet::serialize_into_buffer(*m_pdu, dest);
}
std::size_t byte_buffer_impl<PduPtr>::size() const
{
assert(m_pdu);
return get_length(*m_pdu);
}
std::unique_ptr<byte_buffer> byte_buffer_impl<PduPtr>::duplicate() const
{
assert(m_pdu);
PduPtr duplicate { m_pdu->clone() };
std::unique_ptr<byte_buffer> result {
new byte_buffer_impl<PduPtr>(std::move(duplicate))
};
return result;
}
} // namespace convertible
namespace geonet
{
Pdu* pdu_cast(ByteBufferConvertible& convertible)
{
using convertible_pdu_t = convertible::byte_buffer_impl<std::unique_ptr<Pdu>>;
auto convertible_pdu = dynamic_cast<convertible_pdu_t*>(convertible.ptr());
return convertible_pdu ? convertible_pdu->m_pdu.get() : nullptr;
}
} // namespace geonet
} // namespace vanetza