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).
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#include "proxy_header.hpp"
|
||||
#include <vanetza/common/byte_order.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
|
||||
double get_signal_power(const ProxyHeader& header)
|
||||
{
|
||||
double power = ntoh(header.signal_power);
|
||||
power /= 256.0;
|
||||
return power;
|
||||
}
|
||||
|
||||
void set_signal_power(ProxyHeader& header, double dbm)
|
||||
{
|
||||
auto power = static_cast<decltype(ProxyHeader::signal_power)>(dbm * 256.0);
|
||||
header.signal_power = hton(power);
|
||||
}
|
||||
|
||||
access::AccessCategory get_access_category(const ProxyHeader& header)
|
||||
{
|
||||
return static_cast<access::AccessCategory>(header.access_category & 0x07);
|
||||
}
|
||||
|
||||
void set_access_category(ProxyHeader& header, access::AccessCategory ac)
|
||||
{
|
||||
header.access_category = static_cast<uint8_t>(ac);
|
||||
}
|
||||
|
||||
boost::iterator_range<const uint8_t*> get_payload(const ProxyHeader& header, std::size_t size)
|
||||
{
|
||||
const auto payload_offset = ntoh(header.payload_offset);
|
||||
const auto payload_size = ntoh(header.payload_size);
|
||||
|
||||
assert(size >= payload_offset + payload_size);
|
||||
assert(payload_offset >= sizeof(ProxyHeader));
|
||||
|
||||
const uint8_t* begin = reinterpret_cast<const uint8_t*>(&header);
|
||||
const uint8_t* end = begin;
|
||||
|
||||
if (size >= payload_offset + payload_size) {
|
||||
begin += payload_offset;
|
||||
end = begin + payload_size;
|
||||
}
|
||||
|
||||
return boost::make_iterator_range(begin, end);
|
||||
}
|
||||
|
||||
void set_payload(ProxyHeader& header, std::size_t size)
|
||||
{
|
||||
header.payload_offset = hton<decltype(header.payload_offset)>(sizeof(ProxyHeader));
|
||||
header.payload_size = hton<decltype(header.payload_size)>(size);
|
||||
}
|
||||
|
||||
} // namespace vanetza
|
||||
|
||||
Reference in New Issue
Block a user