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

58 lines
1.9 KiB
C++

#include "autotalks_link.hpp"
#include "autotalks.hpp"
#include <vanetza/net/osi_layer.hpp>
const unsigned SendBufferSize = 2000;
AutotalksLink::AutotalksLink(boost::asio::io_context& io) : io_(io)
{
vanetza::autotalks::autotalks_device_init();
vanetza::autotalks::init_rx(this);
}
AutotalksLink::~AutotalksLink(void)
{
vanetza::autotalks::autotalks_device_deinit();
}
void AutotalksLink::request(const vanetza::access::DataRequest& request, std::unique_ptr<vanetza::ChunkPacket> packet)
{
uint8_t toSend[SendBufferSize];
size_t j = 0;
constexpr std::size_t layers = num_osi_layers(vanetza::OsiLayer::Physical, vanetza::OsiLayer::Application);
std::array<boost::asio::const_buffer, layers> const_buffers;
for (auto& layer : vanetza::osi_layer_range<vanetza::OsiLayer::Physical, vanetza::OsiLayer::Application>()) {
const auto index = distance(vanetza::OsiLayer::Physical, layer);
packet->layer(layer).convert(buffers_[index]);
const_buffers[index] = boost::asio::buffer(buffers_[index]);
for (size_t i = 0; i < buffers_[index].size() && j < SendBufferSize; i++)
toSend[j++] = buffers_[index][i];
}
uint16_t datalen = j;
vanetza::autotalks::insert_autotalks_header_transmit(request, packet, (uint8_t*) toSend, datalen);
}
void AutotalksLink::data_received(uint8_t* pBuf, uint16_t size, v2x_receive_params_t rx_params)
{
vanetza::ByteBuffer buffer(size);
for (uint16_t i = 0; i < size; i++)
buffer[i] = pBuf[i];
vanetza::CohesivePacket packet(std::move(buffer), vanetza::OsiLayer::Physical);
boost::optional<vanetza::EthernetHeader> eth = vanetza::autotalks::strip_autotalks_rx_header(packet, rx_params);
if (callback_ && eth)
{
boost::asio::post(io_, [this, packet = std::move(packet), eth]() mutable
{
callback_(std::move(packet), *eth);
});
}
}
void AutotalksLink::indicate(IndicationCallback cb)
{
callback_ = cb;
}