Skip to content

Commit

Permalink
CF Send issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
evoggy committed Jul 12, 2024
1 parent faaec95 commit 64a73f1
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::path::Path;
use std::sync::Arc;
use std::sync::Mutex;
use std::{thread, time};
use tokio::runtime::Runtime;

use crazyflie_lib::Crazyflie;
use futures::StreamExt;
Expand Down Expand Up @@ -156,12 +157,12 @@ async fn crazyflie_backend_connected(
) -> mpsc::Receiver<CrazyflieBackendCommand> {
let link_context = crazyflie_link::LinkContext::new(async_executors::AsyncStd);

// let cf = crazyflie_lib::Crazyflie::connect_from_uri(
// async_executors::AsyncStd,
// &link_context,
// uri.as_str(),
// )
// .await.unwrap();
let cf = crazyflie_lib::Crazyflie::connect_from_uri(
async_executors::AsyncStd,
&link_context,
uri.as_str(),
)
.await.unwrap();

// match cf {
// Ok(cf) => {
Expand Down Expand Up @@ -221,7 +222,7 @@ async fn crazyflie_backend(
crazyflie_backend_scan(ui_to_cf_rx, address.to_string(), t.clone()).await;
}
CrazyflieBackendCommand::Connect(uri) => {
println!("Connect to Crazyflie on {}", uri);
println!("Con to Crazyflie on {}", uri);
ui_to_cf_rx =
crazyflie_backend_connected(ui_to_cf_rx, uri.to_string(), t.clone()).await;
}
Expand Down Expand Up @@ -256,8 +257,13 @@ fn main() {
// This thread runs the Crazyflie backend and receives commands from the
// UI via Tauri commands
let t = app.handle();
tauri::async_runtime::spawn(async move {
crazyflie_backend(ui_to_cf_rx, t).await;
std::thread::spawn(move || {

let rt = Runtime::new().unwrap();

let _guard = rt.enter();
rt.block_on(crazyflie_backend(ui_to_cf_rx, t));

});

Ok(())
Expand Down

0 comments on commit 64a73f1

Please sign in to comment.