#pragma once #include #include #include #include #include #include #include #include #include #include namespace vanetza { namespace access { class DataRequest; } namespace rpc { class Logger; class LinkLayerClient { public: enum class ErrorCode { Ok, InvalidArgument, Unsupported, InternalError, }; enum class Technology { Unspecified, ITS_G5, LTE_V2X, }; struct Indication { Indication(vanetza::ByteBuffer); vanetza::MacAddress source; vanetza::MacAddress destination; vanetza::CohesivePacket packet; Technology technology = Technology::Unspecified; }; struct Identity { std::uint64_t id = 0; std::uint32_t version = 0; std::string info; }; using IndicationCallback = std::function; using ChannelLoadReportCallback = std::function; LinkLayerClient(kj::Timer&, kj::AsyncIoStream&, Logger* = nullptr); ~LinkLayerClient(); kj::Promise identify(); void request(const access::DataRequest&, std::unique_ptr); void indicate(IndicationCallback callback); void report_channel_load(ChannelLoadReportCallback callback); kj::Promise set_source_address(const MacAddress&); void configure(Technology); void add_task(kj::Promise&&); private: class Context; void do_indicate(Indication); void do_report(dcc::ChannelLoad); std::unique_ptr context_; std::mutex callback_mutex_; IndicationCallback indication_callback_; ChannelLoadReportCallback cbr_callback_; Technology technology_ = Technology::Unspecified; }; const char* stringify(LinkLayerClient::ErrorCode); const char* stringify(LinkLayerClient::Technology); } // namespace rpc } // namespace vanetza