Initial MQTT explorer
This commit is contained in:
27
src/main.cpp
Normal file
27
src/main.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user