summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2022-06-16 00:28:36 -0400
committerScott Murray <scott.murray@konsulko.com>2022-06-17 17:44:47 -0400
commit096908375ecbfc6388d0aec69a35b2a8ffc53d47 (patch)
tree4f346d772fcdcbfc112d5aba4d379d1db175979a /src/main.cpp
parent7f647062d889b299a4dd521148a4970bf6c8e75a (diff)
Repurpose repository for a spiritual successor of the previous binding. The replacement is a daemon that demonstrates servicing HVAC actuators from the VSS schema via VIS signals from KUKSA.val. Currently the connection to KUKSA.val is websocket based using the boost::asio framework, but the plan is to migrate to grpc as that becomes more robust in KUKSA.val. Notable changes: - New code is completely C++, partly to leverage using Boost, but also to futureproof future work with grpc. - Switch from CMake to meson for ease of development and some degree of futureproofing. - Use with systemd is assumed; behavior follows the systemd daemon guidelines barring the use of journald logging prefixes, which may be addressed with future work. A systemd unit is also installed as part of the build. - SPDX license headers using SPDX "short identifiers" are used in source files rather than the full copyright headers used in the previous codebase. This follows the direction that projects such as the Linux kernel are going in. - The JSON configuration file for the LED control files for the demo platform has been migrated to a INI format configuration file matching what has been done for the VIS client configuration in other recent work. Bug-AGL: SPEC-4409 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ic2061bca9670b1e461d6f1e6591471e257fff5b9
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..6bb165f
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: Apache-2.0
+
+#include <iostream>
+#include <iomanip>
+#include <boost/asio/signal_set.hpp>
+#include <boost/bind.hpp>
+#include "hvac-service.hpp"
+
+using work_guard_type = boost::asio::executor_work_guard<boost::asio::io_context::executor_type>;
+
+int main(int argc, char** argv)
+{
+ // The io_context is required for all I/O
+ net::io_context ioc;
+
+ // Register to stop I/O context on SIGINT and SIGTERM
+ net::signal_set signals(ioc, SIGINT, SIGTERM);
+ signals.async_wait(boost::bind(&net::io_context::stop, &ioc));
+
+ // The SSL context is required, and holds certificates
+ ssl::context ctx{ssl::context::tlsv12_client};
+
+ // Launch the asynchronous operation
+ VisConfig config("agl-service-hvac");
+ std::make_shared<HvacService>(config, ioc, ctx)->run();
+
+ // Ensure I/O context continues running even if there's no work
+ work_guard_type work_guard(ioc.get_executor());
+
+ // Run the I/O context
+ ioc.run();
+
+ return 0;
+}