mqtt client name is now a config option

This commit is contained in:
2023-01-17 18:23:57 +01:00
parent 1a3867d951
commit 1e4d768d25
5 changed files with 6 additions and 2 deletions

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));