Loading system/gd/rust/linux/client/src/command_handler.rs +23 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ use crate::bt_gatt::AuthReq; use crate::callbacks::{BtGattCallback, BtGattServerCallback}; use crate::ClientContext; use crate::{console_red, console_yellow, print_error, print_info}; use bt_topshim::btif::{BtConnectionState, BtDiscMode, BtStatus, BtTransport}; use bt_topshim::btif::{BtConnectionState, BtDiscMode, BtStatus, BtTransport, INVALID_RSSI}; use bt_topshim::profiles::hid_host::BthhReportType; use bt_topshim::profiles::sdp::{BtSdpMpsRecord, BtSdpRecord}; use bt_topshim::profiles::{gatt::LePhy, ProfileConnectionState}; Loading Loading @@ -155,6 +155,7 @@ fn build_commands() -> HashMap<String, CommandOption> { String::from("device set-pairing-pin <address> <pin|reject>"), String::from("device set-pairing-passkey <address> <passkey|reject>"), String::from("device set-alias <address> <new-alias>"), String::from("device get-rssi <address>"), ], description: String::from("Take action on a remote device. (i.e. info)"), function_pointer: CommandHandler::cmd_device, Loading Loading @@ -896,6 +897,27 @@ impl CommandHandler { passkey, ); } "get-rssi" => { let device = BluetoothDevice { address: String::from(get_arg(args, 1)?), name: String::from(""), }; match self .lock_context() .adapter_dbus .as_mut() .unwrap() .get_remote_rssi(device.clone()) { INVALID_RSSI => { println!("Invalid RSSI"); } rssi => { println!("RSSI: {}", rssi); } }; } other => { println!("Invalid argument '{}'", other); } Loading system/gd/rust/linux/client/src/dbus_iface.rs +5 −0 Original line number Diff line number Diff line Loading @@ -929,6 +929,11 @@ impl IBluetooth for BluetoothDBus { dbus_generated!() } #[dbus_method("GetRemoteRSSI")] fn get_remote_rssi(&self, device: BluetoothDevice) -> i8 { dbus_generated!() } #[dbus_method("GetConnectedDevices")] fn get_connected_devices(&self) -> Vec<BluetoothDevice> { dbus_generated!() Loading system/gd/rust/linux/service/src/iface_bluetooth.rs +5 −0 Original line number Diff line number Diff line Loading @@ -642,6 +642,11 @@ impl IBluetooth for IBluetoothDBus { dbus_generated!() } #[dbus_method("GetRemoteRSSI", DBusLog::Disable)] fn get_remote_rssi(&self, device: BluetoothDevice) -> i8 { dbus_generated!() } #[dbus_method("GetConnectedDevices", DBusLog::Disable)] fn get_connected_devices(&self) -> Vec<BluetoothDevice> { dbus_generated!() Loading system/gd/rust/linux/stack/src/bluetooth.rs +11 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ use bt_topshim::btif::{ BtAddrType, BtBondState, BtConnectionDirection, BtConnectionState, BtDeviceType, BtDiscMode, BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState, BtStatus, BtThreadEvent, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress, ToggleableProfile, Uuid, Uuid128Bit, ToggleableProfile, Uuid, Uuid128Bit, INVALID_RSSI, }; use bt_topshim::{ metrics, Loading Loading @@ -197,6 +197,9 @@ pub trait IBluetooth { /// Get the address type of the remote device. fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType; /// Get the RSSI of the remote device. fn get_remote_rssi(&self, device: BluetoothDevice) -> i8; /// Returns a list of connected devices. fn get_connected_devices(&self) -> Vec<BluetoothDevice>; Loading Loading @@ -2381,6 +2384,13 @@ impl IBluetooth for Bluetooth { } } fn get_remote_rssi(&self, device: BluetoothDevice) -> i8 { match self.get_remote_device_property(&device, &BtPropertyType::RemoteRssi) { Some(BluetoothProperty::RemoteRssi(rssi)) => rssi, _ => INVALID_RSSI, } } fn get_connected_devices(&self) -> Vec<BluetoothDevice> { let bonded_connected: HashMap<String, BluetoothDevice> = self .bonded_devices Loading system/gd/rust/topshim/src/btif.rs +7 −0 Original line number Diff line number Diff line Loading @@ -502,6 +502,13 @@ pub enum BluetoothProperty { Unknown(), } /// Unknown or invalid RSSI value. /// Per Core v5.3, Vol 4, E, 7.5.4. Valid RSSI is represent in 1-byte with the range: /// BR/EDR: -128 to 127 /// LE: -127 to 20, 127 /// Set 127 as invalid value also aligns with bluez. pub const INVALID_RSSI: i8 = 127; /// Wherever names are sent in bindings::bt_property_t, the size of the character /// arrays are 256. Keep one extra byte for null termination. const PROPERTY_NAME_MAX: usize = 255; Loading Loading
system/gd/rust/linux/client/src/command_handler.rs +23 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ use crate::bt_gatt::AuthReq; use crate::callbacks::{BtGattCallback, BtGattServerCallback}; use crate::ClientContext; use crate::{console_red, console_yellow, print_error, print_info}; use bt_topshim::btif::{BtConnectionState, BtDiscMode, BtStatus, BtTransport}; use bt_topshim::btif::{BtConnectionState, BtDiscMode, BtStatus, BtTransport, INVALID_RSSI}; use bt_topshim::profiles::hid_host::BthhReportType; use bt_topshim::profiles::sdp::{BtSdpMpsRecord, BtSdpRecord}; use bt_topshim::profiles::{gatt::LePhy, ProfileConnectionState}; Loading Loading @@ -155,6 +155,7 @@ fn build_commands() -> HashMap<String, CommandOption> { String::from("device set-pairing-pin <address> <pin|reject>"), String::from("device set-pairing-passkey <address> <passkey|reject>"), String::from("device set-alias <address> <new-alias>"), String::from("device get-rssi <address>"), ], description: String::from("Take action on a remote device. (i.e. info)"), function_pointer: CommandHandler::cmd_device, Loading Loading @@ -896,6 +897,27 @@ impl CommandHandler { passkey, ); } "get-rssi" => { let device = BluetoothDevice { address: String::from(get_arg(args, 1)?), name: String::from(""), }; match self .lock_context() .adapter_dbus .as_mut() .unwrap() .get_remote_rssi(device.clone()) { INVALID_RSSI => { println!("Invalid RSSI"); } rssi => { println!("RSSI: {}", rssi); } }; } other => { println!("Invalid argument '{}'", other); } Loading
system/gd/rust/linux/client/src/dbus_iface.rs +5 −0 Original line number Diff line number Diff line Loading @@ -929,6 +929,11 @@ impl IBluetooth for BluetoothDBus { dbus_generated!() } #[dbus_method("GetRemoteRSSI")] fn get_remote_rssi(&self, device: BluetoothDevice) -> i8 { dbus_generated!() } #[dbus_method("GetConnectedDevices")] fn get_connected_devices(&self) -> Vec<BluetoothDevice> { dbus_generated!() Loading
system/gd/rust/linux/service/src/iface_bluetooth.rs +5 −0 Original line number Diff line number Diff line Loading @@ -642,6 +642,11 @@ impl IBluetooth for IBluetoothDBus { dbus_generated!() } #[dbus_method("GetRemoteRSSI", DBusLog::Disable)] fn get_remote_rssi(&self, device: BluetoothDevice) -> i8 { dbus_generated!() } #[dbus_method("GetConnectedDevices", DBusLog::Disable)] fn get_connected_devices(&self) -> Vec<BluetoothDevice> { dbus_generated!() Loading
system/gd/rust/linux/stack/src/bluetooth.rs +11 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ use bt_topshim::btif::{ BtAddrType, BtBondState, BtConnectionDirection, BtConnectionState, BtDeviceType, BtDiscMode, BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState, BtStatus, BtThreadEvent, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress, ToggleableProfile, Uuid, Uuid128Bit, ToggleableProfile, Uuid, Uuid128Bit, INVALID_RSSI, }; use bt_topshim::{ metrics, Loading Loading @@ -197,6 +197,9 @@ pub trait IBluetooth { /// Get the address type of the remote device. fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType; /// Get the RSSI of the remote device. fn get_remote_rssi(&self, device: BluetoothDevice) -> i8; /// Returns a list of connected devices. fn get_connected_devices(&self) -> Vec<BluetoothDevice>; Loading Loading @@ -2381,6 +2384,13 @@ impl IBluetooth for Bluetooth { } } fn get_remote_rssi(&self, device: BluetoothDevice) -> i8 { match self.get_remote_device_property(&device, &BtPropertyType::RemoteRssi) { Some(BluetoothProperty::RemoteRssi(rssi)) => rssi, _ => INVALID_RSSI, } } fn get_connected_devices(&self) -> Vec<BluetoothDevice> { let bonded_connected: HashMap<String, BluetoothDevice> = self .bonded_devices Loading
system/gd/rust/topshim/src/btif.rs +7 −0 Original line number Diff line number Diff line Loading @@ -502,6 +502,13 @@ pub enum BluetoothProperty { Unknown(), } /// Unknown or invalid RSSI value. /// Per Core v5.3, Vol 4, E, 7.5.4. Valid RSSI is represent in 1-byte with the range: /// BR/EDR: -128 to 127 /// LE: -127 to 20, 127 /// Set 127 as invalid value also aligns with bluez. pub const INVALID_RSSI: i8 = 127; /// Wherever names are sent in bindings::bt_property_t, the size of the character /// arrays are 256. Keep one extra byte for null termination. const PROPERTY_NAME_MAX: usize = 255; Loading