mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-04 04:14:58 +00:00
changed adress
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <mqtt/async_client.h>
|
#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 {
|
class callback : public virtual mqtt::callback {
|
||||||
void message_arrived(mqtt::const_message_ptr msg) override {
|
void message_arrived(mqtt::const_message_ptr msg) override {
|
||||||
@@ -15,17 +13,18 @@ class callback : public virtual mqtt::callback {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
mqtt::async_client client(ADDRESS, CLIENT_ID);
|
mqtt::async_client client(ADDRESS, CLIENT_ID);
|
||||||
callback cb;
|
callback cb;
|
||||||
client.set_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 {
|
try {
|
||||||
std::cout << "Verbinden met broker..." << std::endl;
|
std::cout << "Verbinden met broker..." << std::endl;
|
||||||
client.connect()->wait();
|
client.connect(connOpts)->wait();
|
||||||
std::cout << "Verbonden!" << std::endl;
|
std::cout << "Verbonden!" << std::endl;
|
||||||
|
|
||||||
std::cout << "Abonneren op topic: " << TOPIC << std::endl;
|
std::cout << "Abonneren op topic: " << TOPIC << std::endl;
|
||||||
|
Reference in New Issue
Block a user