From 083f42c8235b1cfe9431e777229b6a33712f494a Mon Sep 17 00:00:00 2001 From: Christophe Gagneraud Date: Thu, 24 Oct 2024 20:57:24 +0200 Subject: [PATCH 1/3] CMakeLists.txt: Added import of OpenSSL as it is required by the secured version specified with the 's' in (eclipse-paho-mqtt-c::paho-mqtt3a)s(-static) README.md: added a build option to build paho-mqtt-c library in secure mode --- CMakeLists.txt | 1 + README.md | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b47d16..b55ac16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ if(PAHO_BUILD_STATIC) set(_PAHO_MQTT_C_LIB_NAME ${_PAHO_MQTT_C_LIB_NAME}-static) endif() find_package(eclipse-paho-mqtt-c REQUIRED) +find_package(OpenSSL REQUIRED) add_definitions(-DLINUX -std=c++11) add_executable(serial2mqtt) diff --git a/README.md b/README.md index 72b1ed3..da74fe2 100644 --- a/README.md +++ b/README.md @@ -141,14 +141,13 @@ MQTT Broker ->> programmer CLI : logs deactivate serial2mqtt ``` # Logging through serial2mqtt -Everything that serial2mqtt receives on the serial port is also send on a topic.The micrcontroller will also log to the central logging system +Everything that serial2mqtt receives on the serial port is also send on a topic. The micrcontroller will also log to the central logging system # Build instructions -- install libssl-dev ( apt-get install libssl-dev ) -- git clone --recurse-submodules https://github.com/vortex314/serial2mqtt.git -- cd serial2mqtt -- cd paho.mqtt.c && cmake -DPAHO_BUILD_STATIC=true && make && cd .. -- in serial2mqtt folder : mkdir build && cd build && cmake .. && make - +- `serial2mqtt` is leveraging `paho-mqtt-c` library in secure mode, therefore it requires OpenSSL. Install libssl-dev: `apt-get install libssl-dev` +- clone repository and submodules: `git clone --recurse-submodules https://github.com/vortex314/serial2mqtt.git` +- `cd serial2mqtt` +- `cd paho.mqtt.c && cmake -DPAHO_BUILD_STATIC=true -DPAHO_WITH_SSL=true && make && cd ..` +- back in serial2mqtt folder: `mkdir build && cd build && cmake .. && make` There's an [experimental OpenWrt package](https://github.com/halfbakery/serial2mqtt-openwrt), you can build az ipk package from the git head tailored to your system in From d304e565ce1114615c0084e7f79abb5e6f8cd5d7 Mon Sep 17 00:00:00 2001 From: Gagns4395 Date: Tue, 29 Oct 2024 17:12:20 +0100 Subject: [PATCH 2/3] Update README.md Updated README.md to fit the changed CMakeLists.txt --- README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index da74fe2..1838478 100644 --- a/README.md +++ b/README.md @@ -142,12 +142,29 @@ deactivate serial2mqtt ``` # Logging through serial2mqtt Everything that serial2mqtt receives on the serial port is also send on a topic. The micrcontroller will also log to the central logging system + # Build instructions -- `serial2mqtt` is leveraging `paho-mqtt-c` library in secure mode, therefore it requires OpenSSL. Install libssl-dev: `apt-get install libssl-dev` -- clone repository and submodules: `git clone --recurse-submodules https://github.com/vortex314/serial2mqtt.git` -- `cd serial2mqtt` -- `cd paho.mqtt.c && cmake -DPAHO_BUILD_STATIC=true -DPAHO_WITH_SSL=true && make && cd ..` -- back in serial2mqtt folder: `mkdir build && cd build && cmake .. && make` +Tested with Ubuntu 22.04.4 LTS Desktop 64 bits and Ubuntu 22.04.4 LTS Server 64 bits. + +These instructions should fit any Linux distribution, suh as Debian (including Raspberry Pi) and Ubuntu distribution. + +`serial2mqtt` is leveraging `paho-mqtt-c` library in secure mode, therefore it requires OpenSSL and crypto library. + +Here are the build commands: +``` +sudo apt-get install libssl-dev +git clone --recurse-submodules https://github.com/vortex314/serial2mqtt.git +cd serial2mqtt +cd paho.mqtt.c +cmake -DPAHO_BUILD_STATIC=true -DPAHO_WITH_SSL=true +cmake --build . +make +cd .. +mkdir build +cd build +cmake .. +make +``` There's an [experimental OpenWrt package](https://github.com/halfbakery/serial2mqtt-openwrt), you can build az ipk package from the git head tailored to your system in From 61fd266752b0a5b4cdec4160fc0b231703528f93 Mon Sep 17 00:00:00 2001 From: Gagns4395 Date: Tue, 29 Oct 2024 17:16:15 +0100 Subject: [PATCH 3/3] Update CMakeLists.txt Updated CMakeLists.txt to fit the changed README.md --- CMakeLists.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b55ac16..055de45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,12 +3,7 @@ project(serial2mqtt VERSION 0.1.0) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ") set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -g ") -set(PAHO_MQTT_C_LIBRARIES paho.mqtt.c) -# add suffix when using static Paho MQTT C library variant -if(PAHO_BUILD_STATIC) - set(_PAHO_MQTT_C_LIB_NAME ${_PAHO_MQTT_C_LIB_NAME}-static) -endif() -find_package(eclipse-paho-mqtt-c REQUIRED) + find_package(OpenSSL REQUIRED) add_definitions(-DLINUX -std=c++11) add_executable(serial2mqtt) @@ -26,17 +21,22 @@ target_sources(serial2mqtt PRIVATE src/CircBuf.cpp src/Sema.cpp ) - + +# added paho.mqtt.c/src for paho-mqtt-c header files include_directories(src ArduinoJson/src + paho.mqtt.c/src ) +#Where to find the lib "libpaho-mqtt3as.a", libssl and libcrypto +link_directories(${CMAKE_SOURCE_DIR}/paho.mqtt.c/src /usr/local/lib) + +# added libpaho-mqtt3as.a, libssl.a and libcrypto.a as we build in static mode target_link_libraries(serial2mqtt - eclipse-paho-mqtt-c::paho-mqtt3as-static + libpaho-mqtt3as.a + -l:libssl.a + -l:libcrypto.a -lpthread -lrt -pthread -latomic ) - - -