From 09a60f807e15ded6170a578d7e188a9f9f908724 Mon Sep 17 00:00:00 2001 From: George G Date: Sat, 21 Dec 2024 01:13:48 +0200 Subject: [PATCH 01/11] usb_gadget.rs: increase UDC name to info logging This is too important information to be left out with the debug flag. Also, it doesn't produce a lot of output, so it won't clog the regular log. --- src/usb_gadget.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usb_gadget.rs b/src/usb_gadget.rs index ad75ea4..d0301be 100644 --- a/src/usb_gadget.rs +++ b/src/usb_gadget.rs @@ -67,7 +67,7 @@ impl UsbGadgetState { if let Ok(entries) = fs::read_dir(&udc_dir) { for entry in entries { if let Ok(entry) = entry { - debug!("Using UDC: {:?}", entry.file_name()); + info!("Using UDC: {:?}", entry.file_name()); if let Ok(fname) = entry.file_name().into_string() { state.udc_name.push_str(fname.as_str()); break; From 9aa213e0ced3ec3957ece7fd89cac67999be9250 Mon Sep 17 00:00:00 2001 From: George G Date: Sun, 22 Dec 2024 01:34:16 +0200 Subject: [PATCH 02/11] Add --udc argument Allow the user to specify which udc controller to use. DWC2 / usb-gadget / fe98000.usb is not the only one available. --- README.md | 1 + src/main.rs | 12 +++++++++++- src/usb_gadget.rs | 29 ++++++++++++++++++++--------- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index bf945c8..a73f15f 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ OPTIONS: -l, --logfile Log file path [default: /var/log/aa-proxy-rs.log] -s, --stats-interval Interval of showing data transfer statistics (0 = disabled) [default: 0] + -u, --udc Specify UDC Controller to use -V, --version Print version information ``` Most options are self explanatory, but these needs some more attention:
diff --git a/src/main.rs b/src/main.rs index a52eccb..73241ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,6 +57,14 @@ struct Args { /// Interval of showing data transfer statistics (0 = disabled) #[clap(short, long, value_name = "SECONDS", default_value_t = 0)] stats_interval: u16, + + /// UDC Controller name + #[clap( + short, + long + )] + udc: Option, + } fn logging_init(debug: bool, log_path: &PathBuf) { @@ -106,6 +114,7 @@ async fn tokio_main( advertise: bool, legacy: bool, connect: Option
, + udc: Option, need_restart: Arc, tcp_start: Arc, ) { @@ -117,7 +126,7 @@ async fn tokio_main( std::thread::spawn(|| uevent_listener(accessory_started_cloned)); } - let mut usb = UsbGadgetState::new(legacy); + let mut usb = UsbGadgetState::new(legacy, udc); loop { if let Err(e) = usb.init() { error!("{} 🔌 USB init error: {}", NAME, e); @@ -203,6 +212,7 @@ fn main() { args.advertise, args.legacy, args.connect, + args.udc, need_restart, tcp_start, ) diff --git a/src/usb_gadget.rs b/src/usb_gadget.rs index d0301be..a5f0b6a 100644 --- a/src/usb_gadget.rs +++ b/src/usb_gadget.rs @@ -53,27 +53,38 @@ pub struct UsbGadgetState { configfs_path: PathBuf, udc_name: String, legacy: bool, + udc: Option, } impl UsbGadgetState { - pub fn new(legacy: bool) -> UsbGadgetState { + pub fn new(legacy: bool, udc: Option) -> UsbGadgetState { let mut state = UsbGadgetState { configfs_path: PathBuf::from("/sys/kernel/config/usb_gadget"), udc_name: String::new(), legacy, + udc }; - let udc_dir = PathBuf::from("/sys/class/udc"); - if let Ok(entries) = fs::read_dir(&udc_dir) { - for entry in entries { - if let Ok(entry) = entry { - info!("Using UDC: {:?}", entry.file_name()); - if let Ok(fname) = entry.file_name().into_string() { - state.udc_name.push_str(fname.as_str()); - break; + // If UDC argument is passed, use it, otherwise check sys + match state.udc { + None => { + let udc_dir = PathBuf::from("/sys/class/udc"); + if let Ok(entries) = fs::read_dir(&udc_dir) { + for entry in entries { + if let Ok(entry) = entry { + info!("Using UDC: {:?}", entry.file_name()); + if let Ok(fname) = entry.file_name().into_string() { + state.udc_name.push_str(fname.as_str()); + break; + } + } } } } + Some(ref udcname) => { + info!("Using UDC: {:?}", udcname); + state.udc_name.push_str(&udcname); + } } return state; From 2e11eef6eef0d11afafba8cca55ad89f48094b4f Mon Sep 17 00:00:00 2001 From: George G Date: Sun, 22 Dec 2024 19:56:51 +0200 Subject: [PATCH 03/11] Parse Wi-Fi Hotspot information from system AA Wireless Dongle and derivatives work by creating a Wi-Fi hotspot by setting values in /etc/hostapd/hostapd.conf and relying on the host system having static interface named "wlan0" and ip "10.0.0.1" Instead of having these values hardcoded, parse hostapd.conf and check the "wlan0" interface for its IPv4 address, and use those. In an upcoming commit, we should become able to specify the interface. --- Cargo.lock | 18 ++++++++++++++++++ Cargo.toml | 2 ++ src/bluetooth.rs | 48 ++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d56da2..636d673 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,10 +15,12 @@ dependencies = [ "kobject-uevent", "log", "mac_address", + "netif", "netlink-sys", "protobuf", "protobuf-codegen", "protoc-bin-vendored", + "simple_config_parser", "simplelog", "tokio", "tokio-fd", @@ -746,6 +748,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "netif" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29a01b9f018d6b7b277fef6c79fdbd9bf17bb2d1e298238055cafab49baa5ee" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "netlink-sys" version = "0.8.6" @@ -1162,6 +1174,12 @@ dependencies = [ "libc", ] +[[package]] +name = "simple_config_parser" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d562b7cb7cef3d30257e59582674255342665ced8462ad861412e074c653b11" + [[package]] name = "simplelog" version = "0.11.2" diff --git a/Cargo.toml b/Cargo.toml index baee6ba..5f3e3e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,8 @@ simplelog = { version = "0.11.2", features = ["paris", "ansi_term"] } clap = { version = "3.0.13", features = ["derive"] } humantime = "2.1.0" log = "0.4.22" +simple_config_parser = "1.0.0" +netif = "0.1.6" [build-dependencies] protoc-bin-vendored = "3.1.0" diff --git a/src/bluetooth.rs b/src/bluetooth.rs index 6b9c2c4..de4000a 100644 --- a/src/bluetooth.rs +++ b/src/bluetooth.rs @@ -8,6 +8,7 @@ use bluer::{ }; use futures::StreamExt; use simplelog::*; +use simple_config_parser::Config; use std::sync::Arc; use std::time::{Duration, Instant}; use tokio::io::AsyncReadExt; @@ -36,10 +37,10 @@ const HSP_HS_UUID: Uuid = Uuid::from_u128(0x0000110800001000800000805f9b34fb); const HSP_AG_UUID: Uuid = Uuid::from_u128(0x0000111200001000800000805f9b34fb); const BT_ALIAS: &str = "WirelessAADongle"; -const WLAN_IFACE: &str = "wlan0"; -const WLAN_IP_ADDR: &str = "10.0.0.1"; -const WLAN_SSID: &str = "AAWirelessDongle"; -const WLAN_WPA_KEY: &str = "ConnectAAWirelessDongle"; +const DEFAULT_WLAN_IFACE: &str = "wlan0"; +const DEFAULT_WLAN_ADDR: &str = "10.0.0.1"; + +const HOSTAPD_FILE: &str = "/etc/hostapd/hostapd.conf"; #[derive(Debug, Clone, PartialEq)] #[repr(u16)] @@ -345,11 +346,41 @@ pub async fn bluetooth_setup_connection( let mut stage = 1; let mut started; + let mut wlan_iface = String::from(DEFAULT_WLAN_IFACE); + let mut wlan_ip_addr = String::from(DEFAULT_WLAN_ADDR); + let (state, mut stream) = power_up_and_wait_for_connection(advertise, connect).await?; + // Get UP interface and IP + for ifa in netif::up().unwrap() { + match ifa.name() { + DEFAULT_WLAN_IFACE => { + debug!("Found WLAN interface: {:?}", ifa); + // IPv4 Address contains None scope_id, while IPv6 contains Some + match ifa.scope_id() { None => { + wlan_ip_addr = ifa.address().to_string(); + break; + } + _ => (), + } + } + _ => (), + } + } + + // Create a new config from hostapd.conf + let hostapd = Config::new() + .file(HOSTAPD_FILE) + .unwrap(); + + // read SSID and WPA_KEY + let wlan_ssid = &hostapd.get_str("ssid").unwrap(); + let wlan_wpa_key = &hostapd.get_str("wpa_passphrase").unwrap(); + info!("{} 📲 Sending parameters via bluetooth to phone...", NAME); let mut start_req = WifiStartRequest::new(); - start_req.set_ip_address(String::from(WLAN_IP_ADDR)); + info!("{} 🛜 Sending Host IP Address: {}", NAME, wlan_ip_addr); + start_req.set_ip_address(String::from(wlan_ip_addr)); start_req.set_port(TCP_SERVER_PORT); send_message(&mut stream, stage, MessageId::WifiStartRequest, start_req).await?; stage += 1; @@ -357,9 +388,10 @@ pub async fn bluetooth_setup_connection( read_message(&mut stream, stage, MessageId::WifiInfoRequest, started).await?; let mut info = WifiInfoResponse::new(); - info.set_ssid(String::from(WLAN_SSID)); - info.set_key(String::from(WLAN_WPA_KEY)); - let bssid = mac_address::mac_address_by_name(WLAN_IFACE) + info.set_ssid(String::from(wlan_ssid)); + info.set_key(String::from(wlan_wpa_key)); + info!("{} 🛜 Sending Host SSID and Password: {}, {}", NAME, wlan_ssid, wlan_wpa_key); + let bssid = mac_address::mac_address_by_name(&wlan_iface) .unwrap() .unwrap() .to_string(); From 6f50dd66d0aff8b04a496e511f4d61dc0fbe73a1 Mon Sep 17 00:00:00 2001 From: George G Date: Sun, 22 Dec 2024 20:02:49 +0200 Subject: [PATCH 04/11] udc info log: fix cosmetics --- src/usb_gadget.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usb_gadget.rs b/src/usb_gadget.rs index a5f0b6a..d17b029 100644 --- a/src/usb_gadget.rs +++ b/src/usb_gadget.rs @@ -72,7 +72,7 @@ impl UsbGadgetState { if let Ok(entries) = fs::read_dir(&udc_dir) { for entry in entries { if let Ok(entry) = entry { - info!("Using UDC: {:?}", entry.file_name()); + info!("{} Using UDC: {:?}", NAME, entry.file_name()); if let Ok(fname) = entry.file_name().into_string() { state.udc_name.push_str(fname.as_str()); break; From 34f3c09318c56e3f19022bb75593eca95ba358a2 Mon Sep 17 00:00:00 2001 From: George G Date: Sun, 22 Dec 2024 20:59:07 +0200 Subject: [PATCH 05/11] Add --interface argument Allow the user to specify which network interface is creating the Wi-Fi hotspot on the host system It defaults to the wlan0, 10.0.0.1 setup of AA Wireless Dongle --- README.md | 1 + src/bluetooth.rs | 10 +++++----- src/main.rs | 12 +++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a73f15f..3e6f8c3 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,7 @@ OPTIONS: -c, --connect Auto-connect to saved phone or specified phone MAC address if provided -d, --debug Enable debug info + -i, --interface Specify Wi-Fi Hotspot network interface -l, --legacy Enable legacy mode -h, --help Print help information -l, --logfile Log file path [default: /var/log/aa-proxy-rs.log] diff --git a/src/bluetooth.rs b/src/bluetooth.rs index de4000a..65e2320 100644 --- a/src/bluetooth.rs +++ b/src/bluetooth.rs @@ -37,7 +37,6 @@ const HSP_HS_UUID: Uuid = Uuid::from_u128(0x0000110800001000800000805f9b34fb); const HSP_AG_UUID: Uuid = Uuid::from_u128(0x0000111200001000800000805f9b34fb); const BT_ALIAS: &str = "WirelessAADongle"; -const DEFAULT_WLAN_IFACE: &str = "wlan0"; const DEFAULT_WLAN_ADDR: &str = "10.0.0.1"; const HOSTAPD_FILE: &str = "/etc/hostapd/hostapd.conf"; @@ -338,6 +337,7 @@ pub async fn bluetooth_stop(state: BluetoothState) -> Result<()> { pub async fn bluetooth_setup_connection( advertise: bool, + iface: &str, connect: Option
, tcp_start: Arc, ) -> Result { @@ -346,16 +346,16 @@ pub async fn bluetooth_setup_connection( let mut stage = 1; let mut started; - let mut wlan_iface = String::from(DEFAULT_WLAN_IFACE); let mut wlan_ip_addr = String::from(DEFAULT_WLAN_ADDR); let (state, mut stream) = power_up_and_wait_for_connection(advertise, connect).await?; + // Get UP interface and IP for ifa in netif::up().unwrap() { match ifa.name() { - DEFAULT_WLAN_IFACE => { - debug!("Found WLAN interface: {:?}", ifa); + val if val == iface => { + debug!("Found interface: {:?}", ifa); // IPv4 Address contains None scope_id, while IPv6 contains Some match ifa.scope_id() { None => { wlan_ip_addr = ifa.address().to_string(); @@ -391,7 +391,7 @@ pub async fn bluetooth_setup_connection( info.set_ssid(String::from(wlan_ssid)); info.set_key(String::from(wlan_wpa_key)); info!("{} 🛜 Sending Host SSID and Password: {}, {}", NAME, wlan_ssid, wlan_wpa_key); - let bssid = mac_address::mac_address_by_name(&wlan_iface) + let bssid = mac_address::mac_address_by_name(iface) .unwrap() .unwrap() .to_string(); diff --git a/src/main.rs b/src/main.rs index 73241ed..6da7f19 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,14 @@ struct Args { long )] udc: Option, + + /// WLAN / Wi-Fi Hotspot interface + #[clap( + short, + long, + default_value = "wlan0" + )] + iface: String, } @@ -113,6 +121,7 @@ fn logging_init(debug: bool, log_path: &PathBuf) { async fn tokio_main( advertise: bool, legacy: bool, + iface: String, connect: Option
, udc: Option, need_restart: Arc, @@ -134,7 +143,7 @@ async fn tokio_main( let bt_stop; loop { - match bluetooth_setup_connection(advertise, connect, tcp_start.clone()).await { + match bluetooth_setup_connection(advertise, &iface, connect, tcp_start.clone()).await { Ok(state) => { // we're ready, gracefully shutdown bluetooth in task bt_stop = tokio::spawn(async move { bluetooth_stop(state).await }); @@ -211,6 +220,7 @@ fn main() { tokio_main( args.advertise, args.legacy, + args.iface, args.connect, args.udc, need_restart, From 97a63bcb0874a2443230b89f4e193dfcd8f7bb60 Mon Sep 17 00:00:00 2001 From: George G Date: Sun, 22 Dec 2024 21:30:02 +0200 Subject: [PATCH 06/11] Add --btalias argument Allow the user to rename the BLE advertised name of the host system --- README.md | 1 + src/bluetooth.rs | 21 ++++++++++++++++----- src/main.rs | 11 ++++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3e6f8c3..972ee7a 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ USAGE: OPTIONS: -a, --advertise BLE advertising + -b, --btalias Specify the BLE name of the device -c, --connect Auto-connect to saved phone or specified phone MAC address if provided -d, --debug Enable debug info diff --git a/src/bluetooth.rs b/src/bluetooth.rs index 65e2320..fd4c65c 100644 --- a/src/bluetooth.rs +++ b/src/bluetooth.rs @@ -74,13 +74,23 @@ pub async fn get_cpu_serial_number_suffix() -> Result { async fn power_up_and_wait_for_connection( advertise: bool, + btalias: Option, connect: Option
, ) -> Result<(BluetoothState, Stream)> { // setting BT alias for further use - let alias = match get_cpu_serial_number_suffix().await { - Ok(suffix) => format!("{}-{}", BT_ALIAS, suffix), - Err(_) => String::from(BT_ALIAS), - }; + let alias: String; + + match btalias { + None => { + alias = match get_cpu_serial_number_suffix().await { + Ok(suffix) => format!("{}-{}", BT_ALIAS, suffix), + Err(_) => String::from(BT_ALIAS), + }; + } + Some(btalias) => { + alias = btalias; + } + } info!("{} 🥏 Bluetooth alias: {}", NAME, alias); let session = bluer::Session::new().await?; @@ -337,6 +347,7 @@ pub async fn bluetooth_stop(state: BluetoothState) -> Result<()> { pub async fn bluetooth_setup_connection( advertise: bool, + btalias: Option, iface: &str, connect: Option
, tcp_start: Arc, @@ -348,7 +359,7 @@ pub async fn bluetooth_setup_connection( let mut wlan_ip_addr = String::from(DEFAULT_WLAN_ADDR); - let (state, mut stream) = power_up_and_wait_for_connection(advertise, connect).await?; + let (state, mut stream) = power_up_and_wait_for_connection(advertise, btalias, connect).await?; // Get UP interface and IP diff --git a/src/main.rs b/src/main.rs index 6da7f19..a82268d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,6 +72,13 @@ struct Args { default_value = "wlan0" )] iface: String, + + /// BLE device name + #[clap( + short, + long + )] + btalias: Option, } @@ -120,6 +127,7 @@ fn logging_init(debug: bool, log_path: &PathBuf) { async fn tokio_main( advertise: bool, + btalias: Option, legacy: bool, iface: String, connect: Option
, @@ -143,7 +151,7 @@ async fn tokio_main( let bt_stop; loop { - match bluetooth_setup_connection(advertise, &iface, connect, tcp_start.clone()).await { + match bluetooth_setup_connection(advertise, btalias.clone(), &iface, connect, tcp_start.clone()).await { Ok(state) => { // we're ready, gracefully shutdown bluetooth in task bt_stop = tokio::spawn(async move { bluetooth_stop(state).await }); @@ -219,6 +227,7 @@ fn main() { runtime.spawn(async move { tokio_main( args.advertise, + args.btalias, args.legacy, args.iface, args.connect, From 754f958e76859a3f25df19a1fe0b461c47993e87 Mon Sep 17 00:00:00 2001 From: Mariusz Bialonczyk Date: Mon, 23 Dec 2024 08:11:39 +0100 Subject: [PATCH 07/11] cargo fmt --- src/bluetooth.rs | 19 ++++++++++--------- src/main.rs | 29 +++++++++++++---------------- src/usb_gadget.rs | 2 +- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/bluetooth.rs b/src/bluetooth.rs index fd4c65c..0dfbd36 100644 --- a/src/bluetooth.rs +++ b/src/bluetooth.rs @@ -7,8 +7,8 @@ use bluer::{ Adapter, Address, Uuid, }; use futures::StreamExt; -use simplelog::*; use simple_config_parser::Config; +use simplelog::*; use std::sync::Arc; use std::time::{Duration, Instant}; use tokio::io::AsyncReadExt; @@ -88,7 +88,7 @@ async fn power_up_and_wait_for_connection( }; } Some(btalias) => { - alias = btalias; + alias = btalias; } } info!("{} 🥏 Bluetooth alias: {}", NAME, alias); @@ -361,15 +361,15 @@ pub async fn bluetooth_setup_connection( let (state, mut stream) = power_up_and_wait_for_connection(advertise, btalias, connect).await?; - // Get UP interface and IP for ifa in netif::up().unwrap() { match ifa.name() { val if val == iface => { debug!("Found interface: {:?}", ifa); // IPv4 Address contains None scope_id, while IPv6 contains Some - match ifa.scope_id() { None => { - wlan_ip_addr = ifa.address().to_string(); + match ifa.scope_id() { + None => { + wlan_ip_addr = ifa.address().to_string(); break; } _ => (), @@ -380,9 +380,7 @@ pub async fn bluetooth_setup_connection( } // Create a new config from hostapd.conf - let hostapd = Config::new() - .file(HOSTAPD_FILE) - .unwrap(); + let hostapd = Config::new().file(HOSTAPD_FILE).unwrap(); // read SSID and WPA_KEY let wlan_ssid = &hostapd.get_str("ssid").unwrap(); @@ -401,7 +399,10 @@ pub async fn bluetooth_setup_connection( let mut info = WifiInfoResponse::new(); info.set_ssid(String::from(wlan_ssid)); info.set_key(String::from(wlan_wpa_key)); - info!("{} 🛜 Sending Host SSID and Password: {}, {}", NAME, wlan_ssid, wlan_wpa_key); + info!( + "{} 🛜 Sending Host SSID and Password: {}, {}", + NAME, wlan_ssid, wlan_wpa_key + ); let bssid = mac_address::mac_address_by_name(iface) .unwrap() .unwrap() diff --git a/src/main.rs b/src/main.rs index a82268d..0ced2a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,27 +59,16 @@ struct Args { stats_interval: u16, /// UDC Controller name - #[clap( - short, - long - )] + #[clap(short, long)] udc: Option, /// WLAN / Wi-Fi Hotspot interface - #[clap( - short, - long, - default_value = "wlan0" - )] + #[clap(short, long, default_value = "wlan0")] iface: String, - /// BLE device name - #[clap( - short, - long - )] + /// BLE device name + #[clap(short, long)] btalias: Option, - } fn logging_init(debug: bool, log_path: &PathBuf) { @@ -151,7 +140,15 @@ async fn tokio_main( let bt_stop; loop { - match bluetooth_setup_connection(advertise, btalias.clone(), &iface, connect, tcp_start.clone()).await { + match bluetooth_setup_connection( + advertise, + btalias.clone(), + &iface, + connect, + tcp_start.clone(), + ) + .await + { Ok(state) => { // we're ready, gracefully shutdown bluetooth in task bt_stop = tokio::spawn(async move { bluetooth_stop(state).await }); diff --git a/src/usb_gadget.rs b/src/usb_gadget.rs index d17b029..5b9356b 100644 --- a/src/usb_gadget.rs +++ b/src/usb_gadget.rs @@ -62,7 +62,7 @@ impl UsbGadgetState { configfs_path: PathBuf::from("/sys/kernel/config/usb_gadget"), udc_name: String::new(), legacy, - udc + udc, }; // If UDC argument is passed, use it, otherwise check sys From ec216b4fd81fc3339d88a726f25c5974d0d35bb9 Mon Sep 17 00:00:00 2001 From: Mariusz Bialonczyk Date: Mon, 23 Dec 2024 08:13:24 +0100 Subject: [PATCH 08/11] README: update help to clap auto-generated --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 972ee7a..5bca5bb 100644 --- a/README.md +++ b/README.md @@ -123,17 +123,17 @@ USAGE: OPTIONS: -a, --advertise BLE advertising - -b, --btalias Specify the BLE name of the device + -b, --btalias BLE device name -c, --connect Auto-connect to saved phone or specified phone MAC address if provided -d, --debug Enable debug info - -i, --interface Specify Wi-Fi Hotspot network interface - -l, --legacy Enable legacy mode -h, --help Print help information + -i, --iface WLAN / Wi-Fi Hotspot interface [default: wlan0] + -l, --legacy Enable legacy mode -l, --logfile Log file path [default: /var/log/aa-proxy-rs.log] -s, --stats-interval Interval of showing data transfer statistics (0 = disabled) [default: 0] - -u, --udc Specify UDC Controller to use + -u, --udc UDC Controller name -V, --version Print version information ``` Most options are self explanatory, but these needs some more attention:
From ab3449952cb2de4b01ec445de3ff518bfd33365f Mon Sep 17 00:00:00 2001 From: Mariusz Bialonczyk Date: Mon, 23 Dec 2024 08:22:23 +0100 Subject: [PATCH 09/11] bluetooth: simplify set_ip_address() call --- src/bluetooth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bluetooth.rs b/src/bluetooth.rs index 0dfbd36..f66a0f6 100644 --- a/src/bluetooth.rs +++ b/src/bluetooth.rs @@ -389,7 +389,7 @@ pub async fn bluetooth_setup_connection( info!("{} 📲 Sending parameters via bluetooth to phone...", NAME); let mut start_req = WifiStartRequest::new(); info!("{} 🛜 Sending Host IP Address: {}", NAME, wlan_ip_addr); - start_req.set_ip_address(String::from(wlan_ip_addr)); + start_req.set_ip_address(wlan_ip_addr); start_req.set_port(TCP_SERVER_PORT); send_message(&mut stream, stage, MessageId::WifiStartRequest, start_req).await?; stage += 1; From ad39ac558b2658777aee070be7fbe7bebc610f4e Mon Sep 17 00:00:00 2001 From: Mariusz Bialonczyk Date: Mon, 23 Dec 2024 08:37:52 +0100 Subject: [PATCH 10/11] bluetooth: simplify matching alias --- src/bluetooth.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/bluetooth.rs b/src/bluetooth.rs index f66a0f6..2a45fe2 100644 --- a/src/bluetooth.rs +++ b/src/bluetooth.rs @@ -78,19 +78,13 @@ async fn power_up_and_wait_for_connection( connect: Option
, ) -> Result<(BluetoothState, Stream)> { // setting BT alias for further use - let alias: String; - - match btalias { - None => { - alias = match get_cpu_serial_number_suffix().await { - Ok(suffix) => format!("{}-{}", BT_ALIAS, suffix), - Err(_) => String::from(BT_ALIAS), - }; - } - Some(btalias) => { - alias = btalias; - } - } + let alias = match btalias { + None => match get_cpu_serial_number_suffix().await { + Ok(suffix) => format!("{}-{}", BT_ALIAS, suffix), + Err(_) => String::from(BT_ALIAS), + }, + Some(btalias) => btalias, + }; info!("{} 🥏 Bluetooth alias: {}", NAME, alias); let session = bluer::Session::new().await?; From 24323e02a9f0eb77b86e32db7ba90893b429080b Mon Sep 17 00:00:00 2001 From: Mariusz Bialonczyk Date: Mon, 23 Dec 2024 09:45:15 +0100 Subject: [PATCH 11/11] bluetooth: fix hostapd.conf location --- src/bluetooth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bluetooth.rs b/src/bluetooth.rs index 2a45fe2..166d18e 100644 --- a/src/bluetooth.rs +++ b/src/bluetooth.rs @@ -39,7 +39,7 @@ const BT_ALIAS: &str = "WirelessAADongle"; const DEFAULT_WLAN_ADDR: &str = "10.0.0.1"; -const HOSTAPD_FILE: &str = "/etc/hostapd/hostapd.conf"; +const HOSTAPD_FILE: &str = "/etc/hostapd.conf"; #[derive(Debug, Clone, PartialEq)] #[repr(u16)]