#include "spdlog/spdlog.h" #include "mqttpp.h" #include #include #include #include "Version.h" int main(int argc, const char* argv[]) { if (argc >= 2) { if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version")) { std::cout << "Version: " << MQTTEXPLORER_VERSION_MAJOR << "." << MQTTEXPLORER_VERSION_MINOR << "." << MQTTEXPLORER_VERSION_PATCH << std::endl; return 0; } } mqttpp::Client mqtt("tcp://chimaera:1883"); spdlog::info("Establishing mqtt connection to {} on port {}", "chimaera", "1883"); if (! mqtt.connect()) { spdlog::error("Cannot establish MQTT connection"); return 1; } spdlog::info("Connection established"); spdlog::info("Start subscribing"); mqtt.subscribe("#", [](const char* topic, const std::string& msg) { spdlog::info("Received on topic '{}' message '{}'", topic, msg); }); while (true) { } return 0; }