added username and password

This commit is contained in:
ishak jmilou.ishak
2024-10-21 11:12:04 +02:00
parent 82bc53e2c7
commit a87cb1b12e

View File

@@ -1,5 +1,6 @@
#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 ADDRESS("tcp://localhost:1883"); // Brokeradres (Raspberry Pi)
const std::string CLIENT_ID("cpp_subscriber"); const std::string CLIENT_ID("cpp_subscriber");
@@ -18,6 +19,9 @@ 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");
try { try {
std::cout << "Verbinden met broker..." << std::endl; std::cout << "Verbinden met broker..." << std::endl;