-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from tlm-solutions/marenz.borzoi_integration
Refactor packet parsing and integrate borzoi sender
- Loading branch information
Showing
59 changed files
with
2,379 additions
and
1,176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (C) 2024 Transit Live Mapping Solutions | ||
* All rights reserved. | ||
* | ||
* Authors: | ||
* Marenz Schmidl | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "l2/slot.hpp" | ||
#include "l3/short_data_service_packet.hpp" | ||
|
||
struct BorzoiConverter { | ||
static auto to_json(ShortDataServicePacket* packet) -> nlohmann::json; | ||
static auto to_json(const Slots& slots) -> nlohmann::json; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2022-2024 Transit Live Mapping Solutions | ||
* All rights reserved. | ||
* | ||
* Authors: | ||
* Marenz Schmidl | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "l2/logical_link_control_packet.hpp" | ||
#include "l2/slot.hpp" | ||
#include "thread_safe_fifo.hpp" | ||
#include <atomic> | ||
#include <cpr/cpr.h> | ||
#include <thread> | ||
#include <variant> | ||
|
||
class BorzoiSender { | ||
public: | ||
BorzoiSender() = delete; | ||
|
||
/// This class sends the HTTP Post requests to borzoi. https://github.com/tlm-solutions/borzoi | ||
/// \param queue the queue holds either the parsed packets (std::unique_ptr<LogicalLinkControlPacket>) or Slots that | ||
/// failed to decode | ||
/// \param termination_flag this flag is set when the sender should terminate after finishing all work | ||
/// \param borzoi_url the URL of borzoi | ||
/// \param borzoi_uuid the station UUID of this instance of tetra-decoder sending to borzoi | ||
BorzoiSender(ThreadSafeFifo<std::variant<std::unique_ptr<LogicalLinkControlPacket>, Slots>>& queue, | ||
std::atomic_bool& termination_flag, const std::string& borzoi_url, std::string borzoi_uuid); | ||
|
||
~BorzoiSender(); | ||
|
||
private: | ||
/// The thread function for continously process incomming parsed packets or failed slots. | ||
auto worker() -> void; | ||
|
||
void send_packet(const std::unique_ptr<LogicalLinkControlPacket>& packet); | ||
void send_failed_slots(const Slots& slots); | ||
|
||
/// The input queue | ||
ThreadSafeFifo<std::variant<std::unique_ptr<LogicalLinkControlPacket>, Slots>>& queue_; | ||
|
||
/// The flag that is set when terminating the program | ||
std::atomic_bool& termination_flag_; | ||
|
||
/// The urls of borzoi | ||
cpr::Url borzoi_url_sds_; | ||
cpr::Url borzoi_url_failed_slots_; | ||
|
||
/// The Station UUID of borzoi | ||
std::string borzoi_uuid_; | ||
|
||
/// The worker thread | ||
std::thread worker_thread_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (C) 2024 Transit Live Mapping Solutions | ||
* All rights reserved. | ||
* | ||
* Authors: | ||
* Marenz Schmidl | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "l2/upper_mac_packet.hpp" | ||
#include "utils/bit_vector.hpp" | ||
#include <optional> | ||
|
||
/// The type of the basic link packet. | ||
enum class BasicLinkType { | ||
kBlAdataWithoutFcs, | ||
kBlDataWithoutFcs, | ||
kBlUdataWithoutFcs, | ||
kBlAckWithoutFcs, | ||
kBlAdataWithFcs, | ||
kBlDataWithFcs, | ||
kBlUdataWithFcs, | ||
kBlAckWithFcs, | ||
}; | ||
|
||
constexpr auto to_string(BasicLinkType type) noexcept -> const char* { | ||
switch (type) { | ||
case BasicLinkType::kBlAdataWithoutFcs: | ||
return "BL-ADATA without FCS"; | ||
case BasicLinkType::kBlDataWithoutFcs: | ||
return "BL-DATA without FCS"; | ||
case BasicLinkType::kBlUdataWithoutFcs: | ||
return "BL-UDATA without FCS"; | ||
case BasicLinkType::kBlAckWithoutFcs: | ||
return "BL-ACK without FCS"; | ||
case BasicLinkType::kBlAdataWithFcs: | ||
return "BL-ADATA with FCS"; | ||
case BasicLinkType::kBlDataWithFcs: | ||
return "BL-DATA with FCS"; | ||
case BasicLinkType::kBlUdataWithFcs: | ||
return "BL-UDATA with FCS"; | ||
case BasicLinkType::kBlAckWithFcs: | ||
return "BL-ACK with FCS"; | ||
} | ||
}; | ||
|
||
struct BasicLinkInformation { | ||
BasicLinkType basic_link_type_; | ||
std::optional<unsigned _BitInt(1)> n_r_; | ||
std::optional<unsigned _BitInt(1)> n_s_; | ||
std::optional<bool> fcs_good_; | ||
|
||
BasicLinkInformation() = delete; | ||
|
||
/// construct a BasicLinkInformation from a BitVector | ||
explicit BasicLinkInformation(BitVector& data); | ||
}; | ||
|
||
auto operator<<(std::ostream& stream, const BasicLinkInformation& bli) -> std::ostream&; | ||
|
||
/// The packet that is parsed in the logical link control layer. Currently we only implement basic link. | ||
struct LogicalLinkControlPacket : public UpperMacCPlaneSignallingPacket { | ||
std::optional<BasicLinkInformation> basic_link_information_; | ||
/// The data that is passed from the Logical Link Control layer to the Mobile Link Entity | ||
BitVector tl_sdu_; | ||
|
||
LogicalLinkControlPacket() = delete; | ||
|
||
explicit LogicalLinkControlPacket(const UpperMacCPlaneSignallingPacket& packet); | ||
}; | ||
|
||
auto operator<<(std::ostream& stream, const LogicalLinkControlPacket& llc) -> std::ostream&; |
Oops, something went wrong.