From 398ce3675a43a1187369d5918de80c9b709f5577 Mon Sep 17 00:00:00 2001 From: sfja Date: Mon, 30 Mar 2026 15:54:47 +0200 Subject: [PATCH] add mqtt compile arg --- backend/Makefile | 7 ++++++- backend/src/main.cpp | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/Makefile b/backend/Makefile index 19d6216..d3cbc27 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -4,7 +4,7 @@ MAKEFLAGS += -j16 CXX=g++ LD=g++ -CXXFLAGS = -std=c++23 -pedantic-errors -Wall -Wextra -Wconversion -ftemplate-backtrace-limit=0 +CXXFLAGS = -std=c++23 -pedantic-errors -Wall -Wextra -Wconversion LDFLAGS = libraries = libmosquitto @@ -30,6 +30,11 @@ ifeq ($(ASAN),1) CXXFLAGS += -fsanitize=address endif +MQTT_HOST= +ifneq ($(MQTT_HOST),) + CXXFLAGS += -DBACKEND_MQTT_HOST=\"$(MQTT_HOST)\" +endif + build_dir = build obj_dir = $(build_dir)/obj src_dir = src diff --git a/backend/src/main.cpp b/backend/src/main.cpp index aacf3f9..4d06c0e 100644 --- a/backend/src/main.cpp +++ b/backend/src/main.cpp @@ -23,10 +23,15 @@ #define BACKEND_MQTT_PORT 1883 #endif +#ifndef BACKEND_MQTT_HOST +#define BACKEND_MQTT_HOST "mosquitto" +#endif + int main(void) { - auto mqtt_client - = mst::mqtt::Client("10.133.51.127", BACKEND_MQTT_PORT, "test", "1234"); + + auto mqtt_client = mst::mqtt::Client( + BACKEND_MQTT_HOST, BACKEND_MQTT_PORT, "test", "1234"); mqtt_client.subscribe("/skateboard/update", [&](std::string_view text) { //