mqtt client name is now a config option

This commit is contained in:
Dreaded_X 2023-01-17 18:23:57 +01:00
parent 1a3867d951
commit 1e4d768d25
Signed by: Dreaded_X
GPG Key ID: 76BDEC4E165D8AD9
5 changed files with 6 additions and 2 deletions

View File

@ -4,6 +4,7 @@ base_url = "https://login.huizinga.dev/api/oidc"
[mqtt]
host="olympus.vpn.huizinga.dev"
port=8883
client_name="automation-ares"
username="mqtt"
password="${MQTT_PASSWORD}"
tls=true

View File

@ -4,6 +4,7 @@ base_url = "https://login.huizinga.dev/api/oidc"
[mqtt]
host="mosquitto"
port=8883
client_name="automation_rs"
username="mqtt"
password="${MQTT_PASSWORD}"

View File

@ -4,6 +4,7 @@ base_url = "https://login.huizinga.dev/api/oidc"
[mqtt]
host="olympus.lan.huizinga.dev"
port=8883
client_name="automation-zeus"
username="mqtt"
password="${MQTT_PASSWORD}"
tls=true

View File

@ -32,10 +32,11 @@ pub struct OpenIDConfig {
pub struct MqttConfig {
pub host: String,
pub port: u16,
pub client_name: String,
pub username: String,
pub password: String,
#[serde(default)]
pub tls: bool
pub tls: bool,
}
#[derive(Debug, Deserialize)]

View File

@ -61,7 +61,7 @@ async fn app() -> Result<(), Box<dyn std::error::Error>> {
// Configure MQTT
let mqtt = config.mqtt.clone();
let mut mqttoptions = MqttOptions::new("rust-test", mqtt.host, mqtt.port);
let mut mqttoptions = MqttOptions::new(mqtt.client_name, mqtt.host, mqtt.port);
mqttoptions.set_credentials(mqtt.username, mqtt.password);
mqttoptions.set_keep_alive(Duration::from_secs(5));