Loading system/gd/rust/linux/client/src/main.rs +17 −2 Original line number Diff line number Diff line Loading @@ -146,6 +146,9 @@ pub(crate) struct ClientContext { /// Is btclient running in restricted mode? is_restricted: bool, /// Is btclient running in interactive mode? is_interactive: bool, /// Data of GATT client preference. gatt_client_context: GattClientContext, Loading Loading @@ -174,6 +177,7 @@ impl ClientContext { dbus_crossroads: Arc<Mutex<Crossroads>>, tx: mpsc::Sender<ForegroundActions>, is_restricted: bool, is_interactive: bool, client_commands_with_callbacks: Vec<String>, ) -> ClientContext { // Manager interface is almost always available but adapter interface Loading Loading @@ -212,6 +216,7 @@ impl ClientContext { socket_manager_callback_id: None, qa_callback_id: None, is_restricted, is_interactive, gatt_client_context: GattClientContext::new(), gatt_server_context: GattServerContext::new(), socket_test_schedule: None, Loading Loading @@ -271,11 +276,19 @@ impl ClientContext { // Trigger callback registration in the foreground let fg = self.fg.clone(); let is_interactive = self.is_interactive; tokio::spawn(async move { let adapter = format!("adapter{}", idx); // Floss won't export the interface until it is ready to be used. // Wait 1 second before registering the callbacks. // Only introduce such delay on interactive mode. This is because we expect the user to // ensure the adapter interface is ready when they issue the command in non-interactive // mode. Otherwise, there will always have 1 second delay and in most of the case it is // not needed. if is_interactive { sleep(Duration::from_millis(1000)).await; } let _ = fg.send(ForegroundActions::RegisterAdapterCallback(adapter)).await; }); } Loading Loading @@ -364,6 +377,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { .get_matches(); let command = value_t!(matches, "command", String).ok(); let is_restricted = matches.is_present("restricted"); let is_interactive = command.is_none(); let timeout_secs = value_t!(matches, "timeout", u64); topstack::get_runtime().block_on(async move { Loading Loading @@ -408,6 +422,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { cr.clone(), tx.clone(), is_restricted, is_interactive, client_commands_with_callbacks, ))); Loading Loading @@ -449,7 +464,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { }; let handler = CommandHandler::new(context.clone()); if command.is_some() { if !is_interactive { // Timeout applies only to non-interactive commands. if let Ok(timeout_secs) = timeout_secs { let timeout_duration = Duration::from_secs(timeout_secs); Loading Loading
system/gd/rust/linux/client/src/main.rs +17 −2 Original line number Diff line number Diff line Loading @@ -146,6 +146,9 @@ pub(crate) struct ClientContext { /// Is btclient running in restricted mode? is_restricted: bool, /// Is btclient running in interactive mode? is_interactive: bool, /// Data of GATT client preference. gatt_client_context: GattClientContext, Loading Loading @@ -174,6 +177,7 @@ impl ClientContext { dbus_crossroads: Arc<Mutex<Crossroads>>, tx: mpsc::Sender<ForegroundActions>, is_restricted: bool, is_interactive: bool, client_commands_with_callbacks: Vec<String>, ) -> ClientContext { // Manager interface is almost always available but adapter interface Loading Loading @@ -212,6 +216,7 @@ impl ClientContext { socket_manager_callback_id: None, qa_callback_id: None, is_restricted, is_interactive, gatt_client_context: GattClientContext::new(), gatt_server_context: GattServerContext::new(), socket_test_schedule: None, Loading Loading @@ -271,11 +276,19 @@ impl ClientContext { // Trigger callback registration in the foreground let fg = self.fg.clone(); let is_interactive = self.is_interactive; tokio::spawn(async move { let adapter = format!("adapter{}", idx); // Floss won't export the interface until it is ready to be used. // Wait 1 second before registering the callbacks. // Only introduce such delay on interactive mode. This is because we expect the user to // ensure the adapter interface is ready when they issue the command in non-interactive // mode. Otherwise, there will always have 1 second delay and in most of the case it is // not needed. if is_interactive { sleep(Duration::from_millis(1000)).await; } let _ = fg.send(ForegroundActions::RegisterAdapterCallback(adapter)).await; }); } Loading Loading @@ -364,6 +377,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { .get_matches(); let command = value_t!(matches, "command", String).ok(); let is_restricted = matches.is_present("restricted"); let is_interactive = command.is_none(); let timeout_secs = value_t!(matches, "timeout", u64); topstack::get_runtime().block_on(async move { Loading Loading @@ -408,6 +422,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { cr.clone(), tx.clone(), is_restricted, is_interactive, client_commands_with_callbacks, ))); Loading Loading @@ -449,7 +464,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { }; let handler = CommandHandler::new(context.clone()); if command.is_some() { if !is_interactive { // Timeout applies only to non-interactive commands. if let Ok(timeout_secs) = timeout_secs { let timeout_duration = Duration::from_secs(timeout_secs); Loading