Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/tools/socktap/application.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

66 lines
2.0 KiB
C++

#include "application.hpp"
#include <vanetza/btp/header.hpp>
#include <vanetza/btp/header_conversion.hpp>
#include <cassert>
using namespace vanetza;
Application::DataConfirm Application::request(const DataRequest& request, DownPacketPtr packet)
{
DataConfirm confirm(DataConfirm::ResultCode::Rejected_Unspecified);
if (router_ && packet) {
btp::HeaderB btp_header;
btp_header.destination_port = this->port();
btp_header.destination_port_info = host_cast<uint16_t>(0);
packet->layer(OsiLayer::Transport) = btp_header;
switch (request.transport_type) {
case geonet::TransportType::SHB:
confirm = router_->request(request_shb(request), std::move(packet));
break;
case geonet::TransportType::GBC:
confirm = router_->request(request_gbc(request), std::move(packet));
break;
default:
// TODO remaining transport types are not implemented
break;
}
}
return confirm;
}
void initialize_request(const Application::DataRequest& generic, geonet::DataRequest& geonet)
{
geonet.upper_protocol = geonet::UpperProtocol::BTP_B;
geonet.communication_profile = generic.communication_profile;
geonet.its_aid = generic.its_aid;
if (generic.maximum_lifetime) {
geonet.maximum_lifetime = generic.maximum_lifetime.get();
}
geonet.repetition = generic.repetition;
geonet.traffic_class = generic.traffic_class;
}
geonet::GbcDataRequest Application::request_gbc(const DataRequest& generic)
{
assert(router_);
geonet::GbcDataRequest gbc(router_->get_mib());
initialize_request(generic, gbc);
gbc.destination = boost::get<geonet::Area>(generic.destination);
return gbc;
}
geonet::ShbDataRequest Application::request_shb(const DataRequest& generic)
{
assert(router_);
geonet::ShbDataRequest shb(router_->get_mib());
initialize_request(generic, shb);
return shb;
}
Application::PromiscuousHook* Application::promiscuous_hook()
{
return nullptr;
}