Skip to content
Snippets Groups Projects
Commit 952e4c9a authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "floss: Add GetDiscoverableTimeout API"

parents a71e9c25 58837b82
No related branches found
No related tags found
No related merge requests found
......@@ -269,6 +269,7 @@ impl CommandHandler {
let name = adapter_dbus.get_name();
let uuids = adapter_dbus.get_uuids();
let is_discoverable = adapter_dbus.get_discoverable();
let discoverable_timeout = adapter_dbus.get_discoverable_timeout();
let cod = adapter_dbus.get_bluetooth_class();
let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported();
let le_ext_adv_supported = adapter_dbus.is_le_extended_advertising_supported();
......@@ -276,6 +277,7 @@ impl CommandHandler {
print_info!("Name: {}", name);
print_info!("State: {}", if enabled { "enabled" } else { "disabled" });
print_info!("Discoverable: {}", is_discoverable);
print_info!("DiscoverableTimeout: {}s", discoverable_timeout);
print_info!("Class: {:#06x}", cod);
print_info!("IsMultiAdvertisementSupported: {}", multi_adv_supported);
print_info!("IsLeExtendedAdvertisingSupported: {}", le_ext_adv_supported);
......
......@@ -313,6 +313,10 @@ impl IBluetooth for BluetoothDBus {
self.client_proxy.method("GetDiscoverable", ())
}
fn get_discoverable_timeout(&self) -> u32 {
self.client_proxy.method("GetDiscoverableTimeout", ())
}
fn set_discoverable(&self, mode: bool, duration: u32) -> bool {
self.client_proxy.method("SetDiscoverable", (mode, duration))
}
......
......@@ -147,22 +147,27 @@ impl IBluetooth for IBluetoothDBus {
#[dbus_method("GetDiscoverable")]
fn get_discoverable(&self) -> bool {
true
dbus_generated!()
}
#[dbus_method("GetDiscoverableTimeout")]
fn get_discoverable_timeout(&self) -> u32 {
dbus_generated!()
}
#[dbus_method("SetDiscoverable")]
fn set_discoverable(&self, mode: bool, duration: u32) -> bool {
true
dbus_generated!()
}
#[dbus_method("IsMultiAdvertisementSupported")]
fn is_multi_advertisement_supported(&self) -> bool {
true
dbus_generated!()
}
#[dbus_method("IsLeExtendedAdvertisingSupported")]
fn is_le_extended_advertising_supported(&self) -> bool {
true
dbus_generated!()
}
#[dbus_method("StartDiscovery")]
......
......@@ -73,6 +73,9 @@ pub trait IBluetooth {
/// Returns whether the adapter is discoverable.
fn get_discoverable(&self) -> bool;
/// Returns the adapter discoverable timeout.
fn get_discoverable_timeout(&self) -> u32;
/// Sets discoverability. If discoverable, limits the duration with given value.
fn set_discoverable(&self, mode: bool, duration: u32) -> bool;
......@@ -856,6 +859,16 @@ impl IBluetooth for Bluetooth {
}
}
fn get_discoverable_timeout(&self) -> u32 {
match self.properties.get(&BtPropertyType::AdapterDiscoverableTimeout) {
Some(prop) => match prop {
BluetoothProperty::AdapterDiscoverableTimeout(timeout) => timeout.clone(),
_ => 0,
},
_ => 0,
}
}
fn set_discoverable(&self, mode: bool, duration: u32) -> bool {
self.intf
.lock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment