Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the build intrsuctions #62

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 12 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ 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)

Expand All @@ -25,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 )



28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,30 @@ 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
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
Expand Down
Loading