From 63c913a8e6ad4699641ad738ad71406d8cf68181 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Sat, 14 Dec 2024 15:32:52 +0100 Subject: [PATCH] platform: esp32: mqtt: set client id based on chip id --- src/platform/esp32.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/platform/esp32.rs b/src/platform/esp32.rs index 6edd73e..5b50c3e 100644 --- a/src/platform/esp32.rs +++ b/src/platform/esp32.rs @@ -286,12 +286,13 @@ impl MqttTask { } } - fn start_mqtt(&mut self) { + fn start_mqtt(&mut self, bus: &EventBus) { log::info!("Starting MQTT"); + let chip_id: u64 = bus.property("system.board.chip_id").unwrap().into(); let (client, mut conn) = EspMqttClient::new( "mqtt://10.0.0.2:1883", &MqttClientConfiguration { - client_id: Some("renderbug-rs"), + client_id: Some(&format!("{:X}", chip_id)), ..Default::default() } ).unwrap(); @@ -322,7 +323,7 @@ impl Task for MqttTask { ("system.network.online", Variant::Boolean(true)) => { log::info!("Registering with MQTT"); - self.start_mqtt(); + self.start_mqtt(bus); if let Some(ref mut client) = self.client { client.enqueue(