platform: esp32: mqtt: set client id based on chip id

This commit is contained in:
Victoria Fischer 2024-12-14 15:32:52 +01:00
parent cdc82cdbf9
commit 63c913a8e6

View File

@ -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(