Skip to content

Commit

Permalink
bluetooth: update when new interfaces are added
Browse files Browse the repository at this point in the history
This fixes a bug when battery info becomes available after a (~5 sec)
delay but the block does not update.
  • Loading branch information
MaxVerevkin committed Feb 27, 2023
1 parent e473555 commit 256044a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/blocks/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ impl DeviceMonitor {
.await
.error("Failed to receive updates")?;

let mut interface_added = self
.manager_proxy
.receive_interfaces_added()
.await
.error("Failed to monitor interfaces")?;

let mut interface_removed = self
.manager_proxy
.receive_interfaces_removed()
Expand All @@ -238,6 +244,13 @@ impl DeviceMonitor {
debug!("Got update for device");
return Ok(());
}
Some(event) = interface_added.next() => {
let args = event.args().error("Failed to get the args")?;
if args.object_path() == device.device.path() {
debug!("Interfaces added: {:?}", args.interfaces_and_properties().keys());
return Ok(());
}
}
Some(event) = interface_removed.next() => {
let args = event.args().error("Failed to get the args")?;
if args.object_path() == device.device.path() {
Expand Down Expand Up @@ -371,6 +384,7 @@ impl Device {
.await
.error("Failed to create Device1Proxy")?,
battery: Battery1Proxy::builder(manager_proxy.connection())
.cache_properties(zbus::CacheProperties::No)
.path(path)
.unwrap()
.build()
Expand Down

0 comments on commit 256044a

Please sign in to comment.