Loading system/gd/rust/linux/client/src/callbacks.rs +8 −4 Original line number Diff line number Diff line Loading @@ -807,11 +807,15 @@ impl IBluetoothSocketManagerCallbacks for BtSocketManagerCallback { fn on_outgoing_connection_result( &mut self, _connecting_id: SocketId, _result: BtStatus, _socket: Option<BluetoothSocket>, connecting_id: SocketId, result: BtStatus, socket: Option<BluetoothSocket>, ) { todo!(); if let Some(s) = socket { print_info!("Connection success on {}: {:?} for {}", connecting_id, result, s); } else { print_info!("Connection failed on {}: {:?}", connecting_id, result); } } } Loading system/gd/rust/linux/client/src/command_handler.rs +72 −2 Original line number Diff line number Diff line Loading @@ -202,7 +202,10 @@ fn build_commands() -> HashMap<String, CommandOption> { command_options.insert( String::from("socket"), CommandOption { rules: vec![String::from("socket test")], rules: vec![ String::from("socket test"), String::from("socket connect <addr> <l2cap|rfcomm> <psm|uuid>"), ], description: String::from("Socket manager utilities."), function_pointer: CommandHandler::cmd_socket, }, Loading Loading @@ -1268,8 +1271,75 @@ impl CommandHandler { } print_info!("Requested for listening using l2cap channel on socket {}", id); } _ => return Err(CommandError::InvalidArgs), "connect" => { let (addr, sock_type, psm_or_uuid) = (&get_arg(args, 1)?, &get_arg(args, 2)?, &get_arg(args, 3)?); let device = BluetoothDevice { address: addr.clone().into(), name: String::from("Socket Connect Device"), }; let SocketResult { status, id } = match &sock_type[0..] { "l2cap" => { let psm = match psm_or_uuid.clone().parse::<i32>() { Ok(v) => v, Err(e) => { return Err(CommandError::Failed(format!( "Bad PSM given. Error={}", e ))); } }; self.context .lock() .unwrap() .socket_manager_dbus .as_mut() .unwrap() .create_insecure_l2cap_channel(callback_id, device, psm) } "rfcomm" => { let uuid = match UuidHelper::parse_string(psm_or_uuid.clone()) { Some(uu) => uu, None => { return Err(CommandError::Failed(format!( "Could not parse given uuid." ))); } }; self.context .lock() .unwrap() .socket_manager_dbus .as_mut() .unwrap() .create_insecure_rfcomm_socket_to_service_record( callback_id, device, uuid, ) } _ => { return Err(CommandError::Failed(format!( "Unknown socket type: {}", sock_type ))); } }; if status != BtStatus::Success { return Err(CommandError::Failed(format!("Failed to create socket with status={:?} against {}, type {}, with psm/uuid {}", status, addr, sock_type, psm_or_uuid))); } else { return Err(CommandError::Failed(format!("Called create socket with result ({:?}, {}) against {}, type {}, with psm/uuid {}", status, id, addr, sock_type, psm_or_uuid))); } } _ => return Err(CommandError::InvalidArgs), }; Ok(()) } Loading system/gd/rust/linux/stack/src/socket_manager.rs +4 −5 Original line number Diff line number Diff line Loading @@ -194,11 +194,11 @@ impl BluetoothSocket { } } fn make_l2cap_le_channel(flags: i32, device: BluetoothDevice, psm: i32) -> Self { fn make_l2cap_channel(flags: i32, device: BluetoothDevice, psm: i32) -> Self { BluetoothSocket { id: 0, remote_device: device, sock_type: SocketType::L2capLe, sock_type: SocketType::L2cap, flags: flags, fd: None, port: psm, Loading Loading @@ -1092,8 +1092,7 @@ impl IBluetoothSocketManager for BluetoothSocketManager { return SocketResult::new(BtStatus::NotReady, INVALID_SOCKET_ID); } let socket_info = BluetoothSocket::make_l2cap_le_channel(socket::SOCK_FLAG_NONE, device, psm); let socket_info = BluetoothSocket::make_l2cap_channel(socket::SOCK_FLAG_NONE, device, psm); self.socket_connect(socket_info, callback) } Loading @@ -1108,7 +1107,7 @@ impl IBluetoothSocketManager for BluetoothSocketManager { } let socket_info = BluetoothSocket::make_l2cap_le_channel(socket::SOCK_META_FLAG_SECURE, device, psm); BluetoothSocket::make_l2cap_channel(socket::SOCK_META_FLAG_SECURE, device, psm); self.socket_connect(socket_info, callback) } Loading Loading
system/gd/rust/linux/client/src/callbacks.rs +8 −4 Original line number Diff line number Diff line Loading @@ -807,11 +807,15 @@ impl IBluetoothSocketManagerCallbacks for BtSocketManagerCallback { fn on_outgoing_connection_result( &mut self, _connecting_id: SocketId, _result: BtStatus, _socket: Option<BluetoothSocket>, connecting_id: SocketId, result: BtStatus, socket: Option<BluetoothSocket>, ) { todo!(); if let Some(s) = socket { print_info!("Connection success on {}: {:?} for {}", connecting_id, result, s); } else { print_info!("Connection failed on {}: {:?}", connecting_id, result); } } } Loading
system/gd/rust/linux/client/src/command_handler.rs +72 −2 Original line number Diff line number Diff line Loading @@ -202,7 +202,10 @@ fn build_commands() -> HashMap<String, CommandOption> { command_options.insert( String::from("socket"), CommandOption { rules: vec![String::from("socket test")], rules: vec![ String::from("socket test"), String::from("socket connect <addr> <l2cap|rfcomm> <psm|uuid>"), ], description: String::from("Socket manager utilities."), function_pointer: CommandHandler::cmd_socket, }, Loading Loading @@ -1268,8 +1271,75 @@ impl CommandHandler { } print_info!("Requested for listening using l2cap channel on socket {}", id); } _ => return Err(CommandError::InvalidArgs), "connect" => { let (addr, sock_type, psm_or_uuid) = (&get_arg(args, 1)?, &get_arg(args, 2)?, &get_arg(args, 3)?); let device = BluetoothDevice { address: addr.clone().into(), name: String::from("Socket Connect Device"), }; let SocketResult { status, id } = match &sock_type[0..] { "l2cap" => { let psm = match psm_or_uuid.clone().parse::<i32>() { Ok(v) => v, Err(e) => { return Err(CommandError::Failed(format!( "Bad PSM given. Error={}", e ))); } }; self.context .lock() .unwrap() .socket_manager_dbus .as_mut() .unwrap() .create_insecure_l2cap_channel(callback_id, device, psm) } "rfcomm" => { let uuid = match UuidHelper::parse_string(psm_or_uuid.clone()) { Some(uu) => uu, None => { return Err(CommandError::Failed(format!( "Could not parse given uuid." ))); } }; self.context .lock() .unwrap() .socket_manager_dbus .as_mut() .unwrap() .create_insecure_rfcomm_socket_to_service_record( callback_id, device, uuid, ) } _ => { return Err(CommandError::Failed(format!( "Unknown socket type: {}", sock_type ))); } }; if status != BtStatus::Success { return Err(CommandError::Failed(format!("Failed to create socket with status={:?} against {}, type {}, with psm/uuid {}", status, addr, sock_type, psm_or_uuid))); } else { return Err(CommandError::Failed(format!("Called create socket with result ({:?}, {}) against {}, type {}, with psm/uuid {}", status, id, addr, sock_type, psm_or_uuid))); } } _ => return Err(CommandError::InvalidArgs), }; Ok(()) } Loading
system/gd/rust/linux/stack/src/socket_manager.rs +4 −5 Original line number Diff line number Diff line Loading @@ -194,11 +194,11 @@ impl BluetoothSocket { } } fn make_l2cap_le_channel(flags: i32, device: BluetoothDevice, psm: i32) -> Self { fn make_l2cap_channel(flags: i32, device: BluetoothDevice, psm: i32) -> Self { BluetoothSocket { id: 0, remote_device: device, sock_type: SocketType::L2capLe, sock_type: SocketType::L2cap, flags: flags, fd: None, port: psm, Loading Loading @@ -1092,8 +1092,7 @@ impl IBluetoothSocketManager for BluetoothSocketManager { return SocketResult::new(BtStatus::NotReady, INVALID_SOCKET_ID); } let socket_info = BluetoothSocket::make_l2cap_le_channel(socket::SOCK_FLAG_NONE, device, psm); let socket_info = BluetoothSocket::make_l2cap_channel(socket::SOCK_FLAG_NONE, device, psm); self.socket_connect(socket_info, callback) } Loading @@ -1108,7 +1107,7 @@ impl IBluetoothSocketManager for BluetoothSocketManager { } let socket_info = BluetoothSocket::make_l2cap_le_channel(socket::SOCK_META_FLAG_SECURE, device, psm); BluetoothSocket::make_l2cap_channel(socket::SOCK_META_FLAG_SECURE, device, psm); self.socket_connect(socket_info, callback) } Loading