mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
changed adress
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
#include <iostream>
|
||||
#include <mqtt/async_client.h>
|
||||
#include <paho-mqtt/MQTTAsync.h>
|
||||
|
||||
const std::string ADDRESS("tcp://localhost:1883"); // Brokeradres (Raspberry Pi)
|
||||
const std::string CLIENT_ID("cpp_subscriber");
|
||||
const std::string TOPIC("website/knop");
|
||||
|
||||
const std::string ADDRESS("tcp://ishak.ishakpi.ddns.net:1883");
|
||||
const std::string CLIENT_ID("raspberry_pi_client");
|
||||
const std::string TOPIC("home/commands");
|
||||
|
||||
class callback : public virtual mqtt::callback {
|
||||
void message_arrived(mqtt::const_message_ptr msg) override {
|
||||
@@ -15,17 +13,18 @@ class callback : public virtual mqtt::callback {
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
mqtt::async_client client(ADDRESS, CLIENT_ID);
|
||||
callback cb;
|
||||
client.set_callback(cb);
|
||||
client.set_user_name("ishak");
|
||||
client.set_password("kobuki");
|
||||
|
||||
mqtt::connect_options connOpts;
|
||||
connOpts.set_clean_session(true);
|
||||
connOpts.set_user_name("ishak");
|
||||
connOpts.set_password("kobuki");
|
||||
|
||||
try {
|
||||
std::cout << "Verbinden met broker..." << std::endl;
|
||||
client.connect()->wait();
|
||||
client.connect(connOpts)->wait();
|
||||
std::cout << "Verbonden!" << std::endl;
|
||||
|
||||
std::cout << "Abonneren op topic: " << TOPIC << std::endl;
|
||||
@@ -40,4 +39,4 @@ int main() {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user