Loading system/gd/rust/linux/client/Cargo.toml +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ num-traits = "*" tokio = { version = "1", features = ['bytes', 'fs', 'io-util', 'libc', 'macros', 'memchr', 'mio', 'net', 'num_cpus', 'rt', 'rt-multi-thread', 'sync', 'time', 'tokio-macros'] } clap = "2.33.3" bitflags = "1.2" hex = "0.4.3" [build-dependencies] pkg-config = "0.3.19" Loading system/gd/rust/linux/client/src/bt_gatt.rs 0 → 100644 +44 −0 Original line number Diff line number Diff line use bitflags::bitflags; use bt_topshim::btif::BtTransport; use bt_topshim::profiles::gatt::LePhy; bitflags! { pub(crate) struct AuthReq: i32 { // reference to system/stack/include/gatt_api.h const MITM = 0x01; const SIGNED = 0x10; } } /// User preferenece of GATT operations pub(crate) struct GattClientContext { /// If set, the registered GATT client id. None otherwise. pub(crate) client_id: Option<i32>, /// Type of authentication requirement pub(crate) auth_req: AuthReq, /// Is connection going to be directed? pub(crate) is_connect_direct: bool, /// Transport of connection pub(crate) connect_transport: BtTransport, /// Is connection going to be opportunistic? pub(crate) connect_opportunistic: bool, /// Type of connect phy pub(crate) connect_phy: LePhy, } impl GattClientContext { pub(crate) fn new() -> Self { GattClientContext { client_id: None, auth_req: AuthReq::empty(), is_connect_direct: false, connect_transport: BtTransport::Le, connect_opportunistic: false, connect_phy: LePhy::Phy1m, } } pub(crate) fn get_auth_req_bits(&self) -> i32 { self.auth_req.bits() } } system/gd/rust/linux/client/src/callbacks.rs +1 −1 Original line number Diff line number Diff line Loading @@ -579,7 +579,7 @@ impl BtGattCallback { impl IBluetoothGattCallback for BtGattCallback { fn on_client_registered(&self, status: GattStatus, client_id: i32) { print_info!("GATT Client registered status = {}, client_id = {}", status, client_id); self.context.lock().unwrap().gatt_client_id = Some(client_id); self.context.lock().unwrap().gatt_client_context.client_id = Some(client_id); } fn on_client_connection_state( Loading system/gd/rust/linux/client/src/command_handler.rs +225 −80 File changed.Preview size limit exceeded, changes collapsed. Show changes system/gd/rust/linux/client/src/main.rs +6 −4 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ use dbus_crossroads::Crossroads; use tokio::sync::mpsc; use crate::bt_adv::AdvSet; use crate::bt_gatt::GattClientContext; use crate::callbacks::{ AdminCallback, AdvertisingSetCallback, BtCallback, BtConnectionCallback, BtManagerCallback, BtSocketManagerCallback, ScannerCallback, SuspendCallback, Loading @@ -28,6 +29,7 @@ use btstack::suspend::ISuspend; use manager_service::iface_bluetooth_manager::IBluetoothManager; mod bt_adv; mod bt_gatt; mod callbacks; mod command_handler; mod console; Loading Loading @@ -68,9 +70,6 @@ pub(crate) struct ClientContext { /// List of bonded devices. pub(crate) bonded_devices: HashMap<String, BluetoothDevice>, /// If set, the registered GATT client id. None otherwise. pub(crate) gatt_client_id: Option<i32>, /// Proxy for manager interface. pub(crate) manager_dbus: BluetoothManagerDBus, Loading Loading @@ -121,6 +120,9 @@ pub(crate) struct ClientContext { /// Is btclient running in restricted mode? is_restricted: bool, /// Data of GATT client preference. gatt_client_context: GattClientContext, } impl ClientContext { Loading @@ -144,7 +146,6 @@ impl ClientContext { discovering_state: false, found_devices: HashMap::new(), bonded_devices: HashMap::new(), gatt_client_id: None, manager_dbus, adapter_dbus: None, qa_dbus: None, Loading @@ -162,6 +163,7 @@ impl ClientContext { adv_sets: HashMap::new(), socket_manager_callback_id: None, is_restricted, gatt_client_context: GattClientContext::new(), } } Loading Loading
system/gd/rust/linux/client/Cargo.toml +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ num-traits = "*" tokio = { version = "1", features = ['bytes', 'fs', 'io-util', 'libc', 'macros', 'memchr', 'mio', 'net', 'num_cpus', 'rt', 'rt-multi-thread', 'sync', 'time', 'tokio-macros'] } clap = "2.33.3" bitflags = "1.2" hex = "0.4.3" [build-dependencies] pkg-config = "0.3.19" Loading
system/gd/rust/linux/client/src/bt_gatt.rs 0 → 100644 +44 −0 Original line number Diff line number Diff line use bitflags::bitflags; use bt_topshim::btif::BtTransport; use bt_topshim::profiles::gatt::LePhy; bitflags! { pub(crate) struct AuthReq: i32 { // reference to system/stack/include/gatt_api.h const MITM = 0x01; const SIGNED = 0x10; } } /// User preferenece of GATT operations pub(crate) struct GattClientContext { /// If set, the registered GATT client id. None otherwise. pub(crate) client_id: Option<i32>, /// Type of authentication requirement pub(crate) auth_req: AuthReq, /// Is connection going to be directed? pub(crate) is_connect_direct: bool, /// Transport of connection pub(crate) connect_transport: BtTransport, /// Is connection going to be opportunistic? pub(crate) connect_opportunistic: bool, /// Type of connect phy pub(crate) connect_phy: LePhy, } impl GattClientContext { pub(crate) fn new() -> Self { GattClientContext { client_id: None, auth_req: AuthReq::empty(), is_connect_direct: false, connect_transport: BtTransport::Le, connect_opportunistic: false, connect_phy: LePhy::Phy1m, } } pub(crate) fn get_auth_req_bits(&self) -> i32 { self.auth_req.bits() } }
system/gd/rust/linux/client/src/callbacks.rs +1 −1 Original line number Diff line number Diff line Loading @@ -579,7 +579,7 @@ impl BtGattCallback { impl IBluetoothGattCallback for BtGattCallback { fn on_client_registered(&self, status: GattStatus, client_id: i32) { print_info!("GATT Client registered status = {}, client_id = {}", status, client_id); self.context.lock().unwrap().gatt_client_id = Some(client_id); self.context.lock().unwrap().gatt_client_context.client_id = Some(client_id); } fn on_client_connection_state( Loading
system/gd/rust/linux/client/src/command_handler.rs +225 −80 File changed.Preview size limit exceeded, changes collapsed. Show changes
system/gd/rust/linux/client/src/main.rs +6 −4 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ use dbus_crossroads::Crossroads; use tokio::sync::mpsc; use crate::bt_adv::AdvSet; use crate::bt_gatt::GattClientContext; use crate::callbacks::{ AdminCallback, AdvertisingSetCallback, BtCallback, BtConnectionCallback, BtManagerCallback, BtSocketManagerCallback, ScannerCallback, SuspendCallback, Loading @@ -28,6 +29,7 @@ use btstack::suspend::ISuspend; use manager_service::iface_bluetooth_manager::IBluetoothManager; mod bt_adv; mod bt_gatt; mod callbacks; mod command_handler; mod console; Loading Loading @@ -68,9 +70,6 @@ pub(crate) struct ClientContext { /// List of bonded devices. pub(crate) bonded_devices: HashMap<String, BluetoothDevice>, /// If set, the registered GATT client id. None otherwise. pub(crate) gatt_client_id: Option<i32>, /// Proxy for manager interface. pub(crate) manager_dbus: BluetoothManagerDBus, Loading Loading @@ -121,6 +120,9 @@ pub(crate) struct ClientContext { /// Is btclient running in restricted mode? is_restricted: bool, /// Data of GATT client preference. gatt_client_context: GattClientContext, } impl ClientContext { Loading @@ -144,7 +146,6 @@ impl ClientContext { discovering_state: false, found_devices: HashMap::new(), bonded_devices: HashMap::new(), gatt_client_id: None, manager_dbus, adapter_dbus: None, qa_dbus: None, Loading @@ -162,6 +163,7 @@ impl ClientContext { adv_sets: HashMap::new(), socket_manager_callback_id: None, is_restricted, gatt_client_context: GattClientContext::new(), } } Loading