Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 63 additions & 128 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tauri-plugin-store = "2"
tokio-serial = "5.4.4"
tauri-plugin-log = { features = ["colored"] , version = "2" }
chrono = { version = "0.4.34", features = ["serde"] }
meshtastic = { git = "https://github.com/meshtastic/rust.git", rev = "6057294aa6cfa979033299f7f02cfe6ceafddeda", features = ["ts-gen", "bluetooth-le"] }
meshtastic = { git = "https://github.com/lukipuki/meshtastic-rust.git", rev = "71978de0121ed87c5953621d7fbe59f25f68fe13", features = ["ts-gen", "bluetooth-le"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aspecifically this part @ajmcquilkin

specta = { git = "https://github.com/ajmcquilkin/specta.git", rev = "6a8731d168376e28e163dd9cd328055b11d1af82", version = "1.0.3", features = ["chrono"] }
tauri-plugin-dialog = "2"
tauri-plugin-shell = "2"
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/src/device/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ impl MeshDevice {
debug!("Received health metrics, not handling");
trace!("{:?}", health_metrics);
}
protobufs::telemetry::Variant::HostMetrics(host_metrics) => {
debug!("Received host metrics, not handling");
trace!("{:?}", host_metrics);
}
}
}
} else {
Expand Down
56 changes: 12 additions & 44 deletions src-tauri/src/ipc/commands/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,49 +47,16 @@ pub async fn get_all_bluetooth() -> Result<Vec<String>, CommandError> {

const SCAN_DURATION: std::time::Duration = std::time::Duration::from_secs(5);

// Initialize Bluetooth manager
let manager = Manager::new()
let devices = meshtastic::utils::stream::available_ble_devices(SCAN_DURATION)
.await
.map_err(|e| e.to_string())?;

// Get available Bluetooth adapters
let adapters = manager.adapters().await
.map_err(|e| e.to_string())?;

let adapter = adapters
.into_iter()
.next()
.ok_or("failed to find adapter")?;

// Start scanning for devices
adapter.start_scan(ScanFilter {
services: vec![MSH_SERVICE],
}).await
.map_err(|e| e.to_string())?;

debug!("Started Bluetooth scan");

// Allow some time for devices to be discovered
time::sleep(SCAN_DURATION).await;

let peripherals = adapter.peripherals().await
.map_err(|e| e.to_string())?;

let mut devices = Vec::new();

for peripheral in peripherals {
if let Ok(Some(props)) = peripheral.properties().await {
if let Some(name) = props.local_name {
devices.push(name);
}
// else skip this peripheral
}
// else skip this peripheral
}

devices.sort();

debug!("Discovered Bluetooth devices: {:?}", devices);
.map_err(|e| format!("Error getting availabled BLE devices: {:?}", e))?
.iter()
.map(|port| match port {
BleId::Name(name) => name.to_string(),
BleId::MacAddress(_) => "".to_string(),
BleId::NameAndMac(name, _) => name.to_string(),
})
.collect();

Ok(devices)
}
Expand Down Expand Up @@ -197,8 +164,9 @@ pub async fn connect_to_bluetooth(

// Create serial connection stream

let stream =
build_ble_stream(&BleId::from_name(&bluetooth_name), Duration::from_secs(5)).await.unwrap();
let stream = build_ble_stream(&BleId::from_name(&bluetooth_name), Duration::from_secs(5))
.await
.unwrap();

// Create and persist new connection

Expand Down
Loading
Loading