Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fff81be48 | |||
| 334fafe132 | |||
| 730a387f96 | |||
| 213da9e432 |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "lib/mqtt++"]
|
||||||
|
path = lib/mqtt++
|
||||||
|
url = https://Julian@git.mueller.haus/mqtt++
|
||||||
@@ -4,15 +4,14 @@ project(thrawn)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
|
||||||
|
|
||||||
include_directories("/usr/local/include")
|
include_directories("lib/mqtt++/include")
|
||||||
include_directories("/usr/local/include/mqttpp-0.1")
|
|
||||||
link_directories("/usr/local/lib/mqttpp-0.1")
|
|
||||||
|
|
||||||
find_package(spdlog CONFIG REQUIRED)
|
find_package(spdlog CONFIG REQUIRED)
|
||||||
|
find_package(OpenSSL REQUIRED)
|
||||||
include(FindLua)
|
include(FindLua)
|
||||||
find_package(lua REQUIRED)
|
find_package(lua REQUIRED)
|
||||||
|
find_package(eclipse-paho-mqtt-c CONFIG REQUIRED)
|
||||||
|
|
||||||
add_executable(thrawn src/main.cpp src src/thrawn_api.cpp src/Service.cpp src/Cache.cpp src/LuaEngine.cpp)
|
add_executable(thrawn src/main.cpp src src/thrawn_api.cpp src/Service.cpp src/Cache.cpp src/LuaEngine.cpp lib/mqtt++/src/mqtt++.cpp)
|
||||||
target_link_libraries(thrawn ${LIBS} spdlog::spdlog ${LUA_LIBRARIES} mqttpp)
|
target_link_libraries(thrawn ${LIBS} spdlog::spdlog ${LUA_LIBRARIES} OpenSSL::SSL eclipse-paho-mqtt-c::paho-mqtt3cs-static)
|
||||||
target_include_directories(thrawn PRIVATE ${LUA_INCLUDE_DIR})
|
target_include_directories(thrawn PRIVATE ${LUA_INCLUDE_DIR})
|
||||||
install(TARGETS thrawn DESTINATION bin)
|
install(TARGETS thrawn DESTINATION bin)
|
||||||
1
lib/mqtt++
Submodule
1
lib/mqtt++
Submodule
Submodule lib/mqtt++ added at a7b570ab18
@@ -76,6 +76,8 @@ LuaService::LuaService(LuaService&& service) noexcept {
|
|||||||
lua = service.lua;
|
lua = service.lua;
|
||||||
service.lua = nullptr;
|
service.lua = nullptr;
|
||||||
name = std::move(service.name);
|
name = std::move(service.name);
|
||||||
|
loaded = false;
|
||||||
|
started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaService& LuaService::operator=(LuaService&& service) noexcept {
|
LuaService& LuaService::operator=(LuaService&& service) noexcept {
|
||||||
@@ -88,9 +90,9 @@ LuaService& LuaService::operator=(LuaService&& service) noexcept {
|
|||||||
|
|
||||||
void LuaService::load() {
|
void LuaService::load() {
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
if (lua_pcall(lua, 0, 0 ,0) != 0) {
|
if (lua_pcall(lua, 0, 0 ,0) == 0) {
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
}else{
|
||||||
spdlog::error("[{}] Unable to call 'lua_pcall()' in load(). [Lua: '{}']", name, lua_tostring(lua,-1));
|
spdlog::error("[{}] Unable to call 'lua_pcall()' in load(). [Lua: '{}']", name, lua_tostring(lua,-1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#define THRAWN_MAJOR_VERSION 1
|
#define THRAWN_MAJOR_VERSION 1
|
||||||
#define THRAWN_MINOR_VERSION 0
|
#define THRAWN_MINOR_VERSION 0
|
||||||
#define THRAWN_PATCH_VERSION 2
|
#define THRAWN_PATCH_VERSION 4
|
||||||
|
|
||||||
#endif // VERSION_H
|
#endif // VERSION_H
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "Service.h"
|
#include "Service.h"
|
||||||
#include "thrawn_api.h"
|
#include "thrawn_api.h"
|
||||||
#include "mqttpp.h"
|
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "LuaEngine.h"
|
#include "LuaEngine.h"
|
||||||
@@ -11,6 +10,7 @@
|
|||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include "mqtt++.h"
|
||||||
|
|
||||||
std::vector<std::string> lua_scripts_in_folder(const std::string& path_str) {
|
std::vector<std::string> lua_scripts_in_folder(const std::string& path_str) {
|
||||||
std::vector<std::string> scripts;
|
std::vector<std::string> scripts;
|
||||||
@@ -35,6 +35,7 @@ int main(int argc, char* argv[]) {
|
|||||||
std::string mqttServerURI = "tcp://chimaera:1883";
|
std::string mqttServerURI = "tcp://chimaera:1883";
|
||||||
mqttpp::LastWill last_will {"dev/thrawn/status", "0"};
|
mqttpp::LastWill last_will {"dev/thrawn/status", "0"};
|
||||||
std::string version_topic = "dev/thrawn/version";
|
std::string version_topic = "dev/thrawn/version";
|
||||||
|
|
||||||
std::string version_topic_value = std::to_string(THRAWN_MAJOR_VERSION) + "." + std::to_string(THRAWN_MINOR_VERSION) + "." + std::to_string(THRAWN_PATCH_VERSION);
|
std::string version_topic_value = std::to_string(THRAWN_MAJOR_VERSION) + "." + std::to_string(THRAWN_MINOR_VERSION) + "." + std::to_string(THRAWN_PATCH_VERSION);
|
||||||
std::string lastWillConnected = "1";
|
std::string lastWillConnected = "1";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user