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,51 @@
|
||||
#pragma once
|
||||
// Dispatches station-link messages (phone -> micrOBU) to the station and sends the
|
||||
// micrOBU -> phone messages (results, indications, identifier-change events, status).
|
||||
#include "link_protocol.hpp"
|
||||
#include "station.hpp"
|
||||
|
||||
namespace microbu {
|
||||
|
||||
/// @brief Represents the transport mechanism for link messages. Either BLE or Serial
|
||||
enum class LinkTransport : std::uint8_t { serial, ble };
|
||||
|
||||
class LinkService {
|
||||
public:
|
||||
/// @brief Binds the service to a station and subscribes to its indication/id-event callbacks.
|
||||
/// @param station Station to bind to; must outlive the LinkService.
|
||||
explicit LinkService(Station& station);
|
||||
/// @brief Decodes and dispatches one received message; call from the station task.
|
||||
/// @param message Raw message bytes as received from the transport.
|
||||
/// @param origin Transport the message arrived on; replies go back on the same transport.
|
||||
void handle(const link::Bytes& message, LinkTransport origin);
|
||||
/// @brief Periodic work: broadcasts STATUS once a second.
|
||||
void tick();
|
||||
private:
|
||||
/// @brief Encodes and writes one message on the given transport.
|
||||
/// @param transport Transport to write to.
|
||||
/// @param opcode Message opcode.
|
||||
/// @param sequence Sequence number to stamp on the header.
|
||||
/// @param body Encoded message body.
|
||||
void send(LinkTransport transport, link::Opcode opcode, std::uint16_t sequence, const link::Bytes& body);
|
||||
/// @brief Sends a message on serial, and also on BLE when a phone is connected.
|
||||
/// @param opcode Message opcode.
|
||||
/// @param sequence Sequence number to stamp on the header.
|
||||
/// @param body Encoded message body.
|
||||
void broadcast(link::Opcode opcode, std::uint16_t sequence, const link::Bytes& body);
|
||||
/// @brief Sends a RESULT reply to the message's origin transport.
|
||||
/// @param origin Transport to reply on.
|
||||
/// @param sequence Sequence number of the message being replied to.
|
||||
/// @param code Result code to report.
|
||||
/// @param detail Optional result detail bytes.
|
||||
void reply(LinkTransport origin, std::uint16_t sequence, link::Code code, const link::Bytes& detail = {});
|
||||
/// @brief Builds a STATUS snapshot from the station and transport counters.
|
||||
/// @return Current status.
|
||||
link::Status status();
|
||||
Station& station_;
|
||||
std::uint16_t own_sequence_ = 0;
|
||||
link::Bytes bundle_; // credentials being provisioned
|
||||
std::uint16_t bundle_total_ = 0;
|
||||
std::int64_t last_status_us_ = 0;
|
||||
};
|
||||
|
||||
} // namespace microbu
|
||||
Reference in New Issue
Block a user