Skip to content

Commit

Permalink
Add device battery percentage property (#129)
Browse files Browse the repository at this point in the history
Allows querying of device battery percentage, if supported.
  • Loading branch information
pythops committed Feb 27, 2024
1 parent aa9477c commit e83517f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bluer/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::{
};

pub(crate) const INTERFACE: &str = "org.bluez.Device1";
pub(crate) const BATTERY_INTERFACE: &str = "org.bluez.Battery1";

/// Interface to a Bluetooth device.
#[cfg_attr(docsrs, doc(cfg(feature = "bluetoothd")))]
Expand Down Expand Up @@ -518,6 +519,13 @@ define_properties!(
mt
}),
);

/// The battery percentage of the remote device
property(
BatteryPercentage, u8,
dbus: (BATTERY_INTERFACE, "Percentage", u8, OPTIONAL),
get: (battery_percentage, v => {v.to_owned()}),
);
}
);

Expand Down

0 comments on commit e83517f

Please sign in to comment.