Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/vanetza/asn1/tests/its_r2.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

55 lines
2.1 KiB
C++

#include <vanetza/asn1/asn1c_wrapper.hpp>
#include <vanetza/asn1/its/r2/EventHistory.h>
#include <vanetza/asn1/its/r2/EventZone.h>
#include <vanetza/asn1/its/r2/HeadingConfidence.h>
#include <vanetza/asn1/its/r2/SituationContainer.h>
#include <vanetza/asn1/its/r2/TimestampIts.h>
#include <vanetza/asn1/vam.hpp>
#include <gtest/gtest.h>
using namespace vanetza;
TEST(ItsAsn1, max_timestamp_roundtrip)
{
const std::int64_t max_timestamp = 4398046511103;
asn1::asn1c_wrapper<Vanetza_ITS2_TimestampIts_t> tx { asn_DEF_Vanetza_ITS2_TimestampIts };
asn_imax2INTEGER(&*tx, max_timestamp);
auto buffer = tx.encode();
EXPECT_EQ(6, buffer.size());
asn1::asn1c_wrapper<Vanetza_ITS2_TimestampIts_t> rx { asn_DEF_Vanetza_ITS2_TimestampIts };
EXPECT_TRUE(rx.decode(buffer));
std::int64_t rx_timestamp = 0;
asn_INTEGER2imax(&*tx, &rx_timestamp);
EXPECT_EQ(rx_timestamp, max_timestamp);
}
TEST(ItsAsn1R2, validate_vam)
{
asn1::r2::Vam vam;
vam->header.messageId = Vanetza_ITS2_MessageId_vam;
vam->header.protocolVersion = 2;
vam->header.stationId = 123;
vam->vam.generationDeltaTime = 0;
vam->vam.vamParameters.basicContainer.referencePosition.latitude = Vanetza_ITS2_Latitude_unavailable;
vam->vam.vamParameters.basicContainer.referencePosition.longitude = Vanetza_ITS2_Longitude_unavailable;
vam->vam.vamParameters.basicContainer.stationType = 5;
vam->vam.vamParameters.vruHighFrequencyContainer.heading.value = 0;
vam->vam.vamParameters.vruHighFrequencyContainer.heading.confidence = Vanetza_ITS2_HeadingConfidence_unavailable;
vam->vam.vamParameters.vruHighFrequencyContainer.speed.speedValue = 0;
vam->vam.vamParameters.vruHighFrequencyContainer.speed.speedConfidence = Vanetza_ITS2_SpeedConfidence_unavailable;
EXPECT_TRUE(vam.validate());
}
TEST(ItsAsn1R2, event_zone)
{
// just needs to compile (SituationContainer's eventZone is patched)
Vanetza_ITS2_SituationContainer_t container {};
container.eventZone = vanetza::asn1::allocate<Vanetza_ITS2_EventZone_t>();
vanetza::asn1::free(asn_DEF_Vanetza_ITS2_EventZone, container.eventZone);
}