Initial MQTT explorer

This commit is contained in:
2020-03-25 17:11:51 +01:00
commit 67300f1c10
7 changed files with 328 additions and 0 deletions

27
src/main.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "spdlog/spdlog.h"
#include "MQTT.h"
#include <iostream>
#include <thread>
int main(int argc, const char* argv[]) {
MQTT 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;
}