From cfc7ff3d2c4a32b45d23338a423936443793ea03 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Wed, 6 Apr 2022 19:07:09 +0100 Subject: [PATCH] Added possibility to connect to MqTT Broker with username and password --- tools/rpi/ahoy.conf.example | 2 ++ tools/rpi/ahoy.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tools/rpi/ahoy.conf.example b/tools/rpi/ahoy.conf.example index 77338d00..8aba8d0e 100644 --- a/tools/rpi/ahoy.conf.example +++ b/tools/rpi/ahoy.conf.example @@ -1,6 +1,8 @@ [mqtt] host = 192.168.84.2 port = 1883 +user = bla +password = blub [dtu] serial = 99978563412 diff --git a/tools/rpi/ahoy.py b/tools/rpi/ahoy.py index fc68a142..68db2fd0 100644 --- a/tools/rpi/ahoy.py +++ b/tools/rpi/ahoy.py @@ -18,9 +18,12 @@ cfg = ConfigParser() cfg.read('ahoy.conf') mqtt_host = cfg.get('mqtt', 'host', fallback='192.168.1.1') mqtt_port = cfg.getint('mqtt', 'port', fallback=1883) +mqtt_user = cfg.get('mqtt', 'user', fallback='') +mqtt_password = cfg.get('mqtt', 'password', fallback='') radio = RF24(22, 0, 1000000) mqtt_client = paho.mqtt.client.Client() +mqtt_client.username_pw_set(mqtt_user, mqtt_password) mqtt_client.connect(mqtt_host, mqtt_port) mqtt_client.loop_start()