Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8e14ed2
Change systemd file
mikusaq Aug 4, 2025
4fb6c5a
Merge pull request #46 from bringauto/BAF-1129/change-systemd-service…
mikusaq Aug 5, 2025
26ec6fb
performance/networking optimizations
MarioIvancik Jul 18, 2025
ad56409
static analysis fixes
MarioIvancik Jul 18, 2025
bdf7b21
update versions
MarioIvancik Jul 21, 2025
74db3ea
dont move const references; remade logger id macros to a constexpr fu…
MarioIvancik Jul 22, 2025
81b3e80
fix cmake; add dummy communication documentation
MarioIvancik Jul 22, 2025
31746e5
fix test init
MarioIvancik Jul 22, 2025
7e9d3ad
fix some unit tests
MarioIvancik Jul 22, 2025
43ed3c7
skip not needed unit test
MarioIvancik Jul 23, 2025
115f620
made stringsEqual inaccessible in other files
MarioIvancik Jul 23, 2025
e6c80a5
added aeron classes for initial testing
MarioIvancik Jul 30, 2025
4f52450
check returned messages from aeron client
MarioIvancik Jul 31, 2025
4ce9cec
functional aeron module communication
MarioIvancik Aug 1, 2025
1b0bc73
added docstrings for AeronClient
MarioIvancik Aug 4, 2025
c90fe99
async function execution usage
MarioIvancik Sep 22, 2025
65fb0ff
async client as a package
MarioIvancik Sep 24, 2025
af19874
refactor of module library handler
MarioIvancik Oct 17, 2025
e48c5ef
Set correct system name
koudis Oct 17, 2025
049f9e3
added mutexes for async client; use filesystem::path for file paths
MarioIvancik Nov 3, 2025
9a37b77
removed memory management; added module based channel offset
MarioIvancik Nov 3, 2025
fe33fa3
added error handling to async module
MarioIvancik Nov 4, 2025
659de17
use function definitions from fleet protocol cpp
MarioIvancik Nov 21, 2025
46c7c24
Check if module defined in external-connection endpoint exists in mod…
vrygl Dec 3, 2025
933b217
dont ignore nodiscard value in std::ranged::any_of
vrygl Dec 5, 2025
3787807
Added missing param in logWarning
vrygl Dec 5, 2025
4a82a98
Introduce QuicCommunication: Add basic connection of QUIC protocol su…
Dec 18, 2025
4782233
Refactor QuicCommunication: Modularize QUIC initialization, improve l…
Dec 18, 2025
bfb354b
Enhance QuicCommunication: Add stream callback + message sending, imp…
Dec 22, 2025
1ab7c3a
Add `toString` method for `ConnectionState` in QuicCommunication for …
Dec 22, 2025
b9e2a2a
Implement message queuing and threading in QuicCommunication for bidi…
Jan 3, 2026
bad6532
Refactor `QuicCommunication`: Improve comments and documentation, rem…
Jan 5, 2026
1df1ff9
Refactor `QuicCommunication`: Extract `getStreamId` method, improve l…
Jan 5, 2026
cf7a2a6
Refactor `QuicCommunication`: Simplify `StreamSend` logic, improve er…
Jan 5, 2026
b176f3f
Refactor `QuicCommunication`: Add detailed event handling comments, i…
Jan 5, 2026
a6de815
Refactor `QuicCommunication`: Extract `getProtocolSettingsString` met…
Jan 6, 2026
f980998
Refactor `QuicCommunication`: Replace `logInfo` with `logDebug`, refi…
Jan 6, 2026
4b8e10b
Refactor `QuicCommunication`: Replace error logs with exceptions for …
Jan 6, 2026
465b408
Refactor `QuicCommunication`: Add connection state check before sendi…
Jan 6, 2026
e904d4e
Refactor `QuicCommunication`: Replace QuicCommunication::ConnectionSt…
Jan 7, 2026
cd4eb2a
Refactor `QuicCommunication`: Replace hardcoded ALPN value with `sett…
Jan 7, 2026
b3bd07d
Add `quic_example.json` configuration file for QUIC module settings
Jan 7, 2026
daed68a
Refactor `ExternalConnection`: Remove redundant `return OK` statement…
Jan 7, 2026
55947f6
Clean up includes in `ExternalClient` and `QuicCommunication` for con…
Jan 7, 2026
dceba15
Refactor `QuicCommunication`: Add `SendBuffer` abstraction for improv…
Jan 7, 2026
7f982ba
Refactor `QuicCommunication`: Replace exceptions with `settings::Logg…
Jan 7, 2026
2b4706b
Refactor `QuicCommunication`: Simplify `SendBuffer` by replacing `std…
Jan 7, 2026
1b6e8b7
Refactor `QuicCommunication`: Reorder initialization steps to ensure …
Jan 7, 2026
8fa97ba
Refactor `QuicCommunication`: Replace `std::lock_guard` with `std::sc…
Jan 7, 2026
4794e85
Refactor `QuicCommunication`: Add early exit for empty stream receive…
Jan 15, 2026
311876e
Refactor `QuicCommunication`: Replace dynamic app name parameter in `…
Jan 19, 2026
5ea491b
Refactor `QuicCommunication`: Replace `std::shared_ptr` with `std::un…
Jan 19, 2026
fa075ea
Update `README.md`: Add QUIC configuration details alongside MQTT, ex…
Jan 19, 2026
8a3391f
Refactor `QuicCommunication`: Add comments and documentation for `Sen…
Jan 19, 2026
ec8bf05
Refactor `EnumUtils`: Replace hardcoded connection state strings with…
Jan 19, 2026
bf7ee48
Add `QuicSettingsParser` to parse QUIC settings and integrate with `Q…
Jan 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMLibStorage.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
FIND_PACKAGE(CMLIB REQUIRED COMPONENTS CMCONF)

CMCONF_INIT_SYSTEM(FLEET_PROTOCOL)

SET(STORAGE_LIST DEP)

SET(STORAGE_LIST_DEP "https://github.com/bacpack-system/package-tracker.git")
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ FIND_PACKAGE(CMLIB
REQUIRED
)

SET(BRINGAUTO_MODULE_GATEWAY_VERSION 1.3.4)
SET(BRINGAUTO_MODULE_GATEWAY_VERSION 1.4.0)

SET(MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY "DEBUG" CACHE STRING "Minimum logger verbosity level for module-gateway")

CMDEF_COMPILE_DEFINITIONS(
ALL "MODULE_GATEWAY_VERSION=\"${BRINGAUTO_MODULE_GATEWAY_VERSION}\""
ALL
"MODULE_GATEWAY_VERSION=\"${BRINGAUTO_MODULE_GATEWAY_VERSION}\""
"MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY=\"${MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY}\""
)
SET(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMDEF_LIBRARY_INSTALL_DIR}")
SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD 23)

INCLUDE(CheckPIESupported)
CHECK_PIE_SUPPORTED()
Expand Down Expand Up @@ -43,13 +47,17 @@ SET(Protobuf_USE_STATIC_LIBS ON)

FIND_PACKAGE(Boost 1.74 REQUIRED CONFIG)
FIND_PACKAGE(Protobuf 3.21.12 REQUIRED)
FIND_PACKAGE(cxxopts 3.0.0 REQUIRED)
FIND_PACKAGE(nlohmann_json 3.2.0 REQUIRED)
FIND_PACKAGE(cxxopts 3.1.1 REQUIRED)
FIND_PACKAGE(nlohmann_json 3.10.5 REQUIRED)
FIND_PACKAGE(PahoMqttCpp REQUIRED)
FIND_PACKAGE(eclipse-paho-mqtt-c REQUIRED)
FIND_PACKAGE(libbringauto_logger 2.0.0 REQUIRED)
FIND_PACKAGE(fleet-protocol-interface 2.0.0 REQUIRED)
FIND_PACKAGE(ZLIB 1.2.11 REQUIRED)
FIND_PACKAGE(fleet-protocol-cxx-helpers-static 1.2.0 REQUIRED)
FIND_PACKAGE(aeron 1.48.6 REQUIRED)
FIND_PACKAGE(async-function-execution-shared 1.0.0 REQUIRED)
FIND_PACKAGE(msquic CONFIG REQUIRED)

FILE(GLOB_RECURSE source_files "source/*")
ADD_LIBRARY(module-gateway-lib STATIC "${source_files}")
Expand All @@ -67,6 +75,9 @@ TARGET_LINK_LIBRARIES(module-gateway-lib PUBLIC
eclipse-paho-mqtt-c::paho-mqtt3as
PahoMqttCpp::paho-mqttpp3
ZLIB::ZLIB
fleet-protocol-cxx-helpers-static::fleet-protocol-cxx-helpers-static
async-function-execution-shared::async-function-execution-shared
msquic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The msquic shall be added as a dependency to the Fleet Protocol Context
https://github.com/bringauto/packager-fleet-protocol-context

@koudis will add it in week 19. 1. 2026

${CMAKE_DL_LIBS}
)

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DBRINGAUTO_GET_PACKAGES_ONLY=ON

FROM bringauto/cpp-build-environment:latest AS mission_module_builder

ARG MISSION_MODULE_VERSION=v1.2.12
ARG MISSION_MODULE_VERSION=v1.2.13

# Install mission module dependencies
WORKDIR /home/bringauto/modules/
Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ connection is broken and as soon as the connection is up, then error aggregated
- [cmlib](https://github.com/cmakelib/cmakelib)

- [protobuf](https://github.com/protocolbuffers/protobuf/tree/main/src) >= v3.21.12
- [cxxopts](https://github.com/jarro2783/cxxopts) >= v3.0.0
- [boost](https://github.com/boostorg/boost) >= v1.74.0
- [nlohmann-json](https://github.com/nlohmann/json) >= v3.2.0
- [ba-logger](https://github.com/bringauto/ba-logger) >= v1.2.0
- [cxxopts](https://github.com/jarro2783/cxxopts) >= v3.1.1
- [boost](https://github.com/boostorg/boost) >= v1.86.0
- [nlohmann-json](https://github.com/nlohmann/json) >= v3.10.5/
- [pahomqtt](https://github.com/eclipse-paho/paho.mqtt.c) >= v1.3.9
- [pahomqttcpp](https://github.com/eclipse-paho/paho.mqtt.cpp) >= v1.3.2
- [zlib](https://github.com/madler/zlib) >= v1.2.11
- [ba-logger](https://github.com/bringauto/ba-logger) >= v2.0.0
- [fleet-protocol-interface](https://github.com/bringauto/fleet-protocol) >= v2.0.0
- [fleet-protocol-cpp](https://github.com/bringauto/fleet-protocol-cpp) >= v1.1.1
- [aeron](https://github.com/aeron-io/aeron) >= v1.48.6
- [async-function-execution](https://github.com/bringauto/async-function-execution) >= 0.1.0
- g++ >= 10 or other compiler with c++20 support

## Build
Expand All @@ -50,7 +57,7 @@ make

### Arguments

* required arguments:
* Required arguments:
* `-c <string> | --config-path=<string>`path to json configuration file ([Configs Readme](./configs/README.md))
* All arguments:
* `-h | --help` print help
Expand All @@ -77,6 +84,10 @@ make
* BRINGAUTO_SYSTEM_DEP=ON/OFF
- DEFAULT: OFF

* MODULE_GATEWAY_MINIMUM_LOGGER_VERBOSITY=DEBUG/INFO/WARNING/ERROR/CRITICAL
- DEFAULT: DEBUG
- sets the minimum logger verbosity on compile level to improve performance


* CURRENTLY UNUSED
* BRINGAUTO_SAMPLES=ON/OFF
Expand Down
8 changes: 5 additions & 3 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ SET(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE)
BA_PACKAGE_LIBRARY(protobuf v4.21.12)
BA_PACKAGE_LIBRARY(fleet-protocol-interface v2.0.0 NO_DEBUG ON)
BA_PACKAGE_LIBRARY(nlohmann-json v3.10.5 NO_DEBUG ON)
BA_PACKAGE_LIBRARY(cxxopts v3.0.5 NO_DEBUG ON)
BA_PACKAGE_LIBRARY(cxxopts v3.1.1 NO_DEBUG ON)
BA_PACKAGE_LIBRARY(boost v1.86.0)
BA_PACKAGE_LIBRARY(ba-logger v2.0.0
)
BA_PACKAGE_LIBRARY(ba-logger v2.0.0)
BA_PACKAGE_LIBRARY(pahomqttc v1.3.9)
BA_PACKAGE_LIBRARY(pahomqttcpp v1.3.2)
BA_PACKAGE_LIBRARY(zlib v1.2.11 OUTPUT_PATH_VAR ZLIB_DIR)
BA_PACKAGE_LIBRARY(fleet-protocol-cpp v1.2.0)
BA_PACKAGE_LIBRARY(aeron v1.48.6)
BA_PACKAGE_LIBRARY(async-function-execution v1.0.0)

IF (BRINGAUTO_TESTS)
BA_PACKAGE_LIBRARY(gtest v1.12.1)
Expand Down
66 changes: 60 additions & 6 deletions include/bringauto/common_utils/EnumUtils.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#include <bringauto/external_client/connection/ConnectionState.hpp>
#include <bringauto/structures/ExternalConnectionSettings.hpp>
#include <bringauto/logging/LoggerVerbosity.hpp>
#include <bringauto/settings/Constants.hpp>



Expand All @@ -24,10 +26,22 @@ class EnumUtils {
/**
* @brief Converts protocol type to string
*
* @param toEnum structures::ProtocolType
* @return std::string
* @param toString structures::ProtocolType
* @return std::string_view
*/
static std::string protocolTypeToString(structures::ProtocolType toString);
static constexpr std::string_view protocolTypeToString(structures::ProtocolType toString) {
switch(toString) {
case structures::ProtocolType::MQTT:
return settings::Constants::MQTT;
case structures::ProtocolType::QUIC:
return settings::Constants::QUIC;
case structures::ProtocolType::DUMMY:
return settings::Constants::DUMMY;
case structures::ProtocolType::INVALID:
default:
return "";
}
};

/**
* @brief Converts string to logger verbosity
Expand All @@ -41,10 +55,50 @@ class EnumUtils {
* @brief Converts logger verbosity to string
*
* @param verbosity logging::LoggerVerbosity
* @return std::string
* @return std::string_view
*/
static std::string loggerVerbosityToString(logging::LoggerVerbosity verbosity);
static constexpr std::string_view loggerVerbosityToString(logging::LoggerVerbosity verbosity) {
switch(verbosity) {
case logging::LoggerVerbosity::Debug:
return settings::Constants::LOG_LEVEL_DEBUG;
case logging::LoggerVerbosity::Info:
return settings::Constants::LOG_LEVEL_INFO;
case logging::LoggerVerbosity::Warning:
return settings::Constants::LOG_LEVEL_WARNING;
case logging::LoggerVerbosity::Error:
return settings::Constants::LOG_LEVEL_ERROR;
case logging::LoggerVerbosity::Critical:
return settings::Constants::LOG_LEVEL_CRITICAL;
default:
return settings::Constants::LOG_LEVEL_INVALID;
}
};

};
/**
* @brief Converts connection state to string
*
* @param state external_client::connection::ConnectionState
* @return std::string_view
*/
static constexpr std::string_view connectionStateToString(
external_client::connection::ConnectionState state
) {
using enum external_client::connection::ConnectionState;

switch (state) {
case NOT_INITIALIZED:
return settings::Constants::LOG_CONNECTION_STATE_NOT_INITIALIZED;
case NOT_CONNECTED:
return settings::Constants::LOG_CONNECTION_STATE_NOT_CONNECTED;
case CONNECTING:
return settings::Constants::LOG_CONNECTION_STATE_CONNECTING;
case CONNECTED:
return settings::Constants::LOG_CONNECTION_STATE_CONNECTED;
case CLOSING:
return settings::Constants::LOG_CONNECTION_STATE_CLOSING;
default:
return settings::Constants::LOG_UNKNOWN;
}
}
};
}
16 changes: 7 additions & 9 deletions include/bringauto/common_utils/ProtobufUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include <InternalProtocol.pb.h>
#include <ExternalProtocol.pb.h>
#include <fleet_protocol/common_headers/device_management.h>
#include <fleet_protocol/common_headers/memory_management.h>



Expand Down Expand Up @@ -37,7 +35,7 @@ class ProtobufUtils {
const InternalProtocol::DeviceConnectResponse_ResponseType &resType);

/**
* @brief Create a Internal Server Command message
* @brief Create an Internal Server Command message
*
* @param device Protobuf message Device
* @param command command data
Expand All @@ -47,7 +45,7 @@ class ProtobufUtils {
const modules::Buffer &command);

/**
* @brief Create a Internal Client Status message
* @brief Create an Internal Client Status message
*
* @param device Protobuf message Device
* @param status status data
Expand All @@ -67,7 +65,7 @@ class ProtobufUtils {
const modules::Buffer &status);

/**
* @brief Create a External Client Connect message
* @brief Create an External Client Connect message
*
* @param sessionId session identification
* @param company name of the company
Expand All @@ -81,7 +79,7 @@ class ProtobufUtils {
const std::vector<structures::DeviceIdentification> &devices);

/**
* @brief Create a External Client Status message
* @brief Create an External Client Status message
*
* @param sessionId session identification
* @param deviceState state of the device
Expand All @@ -97,7 +95,7 @@ class ProtobufUtils {
const modules::Buffer &errorMessage = modules::Buffer {});

/**
* @brief Create a External Client Command Response object
* @brief Create an External Client Command Response object
*
* @param sessionId session identification
* @param type command response message type
Expand All @@ -114,15 +112,15 @@ class ProtobufUtils {
* @param status status to be copied
* @param buffer buffer to copy to
*/
static void copyStatusToBuffer(const InternalProtocol::DeviceStatus &status, modules::Buffer &buffer);
static void copyStatusToBuffer(const InternalProtocol::DeviceStatus &status, const modules::Buffer &buffer);

/**
* @brief Copy command data from DeviceCommand to a Buffer
*
* @param command command to be copied
* @param buffer buffer to copy to
*/
static void copyCommandToBuffer(const InternalProtocol::DeviceCommand &command, modules::Buffer &buffer);
static void copyCommandToBuffer(const InternalProtocol::DeviceCommand &command, const modules::Buffer &buffer);

};
}
13 changes: 4 additions & 9 deletions include/bringauto/external_client/ErrorAggregator.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#pragma once

#include <bringauto/modules/ModuleManagerLibraryHandler.hpp>

#include <fleet_protocol/common_headers/memory_management.h>
#include <fleet_protocol/common_headers/device_management.h>

#include <bringauto/modules/IModuleManagerLibraryHandler.hpp>
#include <bringauto/structures/DeviceIdentification.hpp>

#include <functional>
#include <filesystem>
#include <unordered_map>

Expand All @@ -30,7 +25,7 @@ class ErrorAggregator {
* @return OK if initialization was successful
* @return NOT_OK if an error occurred
*/
int init_error_aggregator(const std::shared_ptr <modules::ModuleManagerLibraryHandler> &library);
int init_error_aggregator(const std::shared_ptr <modules::IModuleManagerLibraryHandler> &library);

/**
* @short Clean up.
Expand Down Expand Up @@ -108,15 +103,15 @@ class ErrorAggregator {
*
* @see fleet-protocol/lib/common_headers/include/device_management.h
*/
int is_device_type_supported(unsigned int device_type);
int is_device_type_supported(unsigned int device_type) const;

private:
struct DeviceState {
modules::Buffer errorMessage {};
modules::Buffer lastStatus {};
};

std::shared_ptr <modules::ModuleManagerLibraryHandler> module_ {};
std::shared_ptr <modules::IModuleManagerLibraryHandler> module_ {};

/**
* @brief Map of devices states, key is device identification converted to string
Expand Down
12 changes: 6 additions & 6 deletions include/bringauto/external_client/ExternalClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace bringauto::external_client {
class ExternalClient {
public:

ExternalClient(std::shared_ptr<structures::GlobalContext> &context,
ExternalClient(const std::shared_ptr<structures::GlobalContext> &context,
structures::ModuleLibrary &moduleLibrary,
std::shared_ptr<structures::AtomicQueue<structures::InternalClientMessage>> &toExternalQueue);
const std::shared_ptr<structures::AtomicQueue<structures::InternalClientMessage>> &toExternalQueue);

/**
* @brief Initialize connections, error aggregators
Expand Down Expand Up @@ -54,7 +54,7 @@ class ExternalClient {
void handleAggregatedMessages();

/**
* @brief Handle commands messages from from an external server
* @brief Handle commands messages from an external server
*/
void handleCommands();

Expand All @@ -68,18 +68,18 @@ class ExternalClient {
/**
* @brief Send aggregated status message to the external server
*
* @param deviceStatus aggregated status message ready to send
* @param internalMessage aggregated status message ready to send
* @return reconnect expected if true, reconnect not expected if false
*/
bool sendStatus(const structures::InternalClientMessage &deviceStatus);
bool sendStatus(const structures::InternalClientMessage &internalMessage);

bool insideConnectSequence_ { false };

/**
* @brief Map of external connections, key is number from settings
* - map is needed because of the possibility of multiple modules connected to one external server
*/
std::map<unsigned int, std::reference_wrapper<connection::ExternalConnection>> externalConnectionMap_ {};
std::unordered_map<unsigned int, std::reference_wrapper<connection::ExternalConnection>> externalConnectionMap_ {};
/// List of external connections, each device can have its own connection or multiple devices can share one connection
std::list<connection::ExternalConnection> externalConnectionsList_ {};
/// Queue for messages from module handler to external client to be sent to external server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ enum class ConnectionState {
/**
* CONNECTED - Client is connected to the External server
*/
CONNECTED
CONNECTED,
/**
* CLOSING - Client closing connection to the External server
*/
CLOSING
};
}
Loading