pub struct ConnectionManager {}Implementations§
Source§impl ConnectionManager
impl ConnectionManager
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/calibrating_steering.rs (line 96)
90async fn get_hub(address: &str) -> Result<Hub> {
91
92 // Converting the MAC string to btleplug::api::BDAddr type
93 let address = BDAddr::from_str(address)?;
94
95 // The ConnectionManager connects stuff - so ask it for the hub...
96 let cm = ConnectionManager::new();
97
98 // It is possible to use the name of the hub or its MAC address. That's why it's Option<>
99 // Here, only address is implemented
100 let hub = cm.get_hub(None, Some(address), 5).await?;
101
102 // Great! Let's get on with this...
103 Ok(hub)
104}More examples
examples/use_a_motor_with_arrow_keys.rs (line 135)
129async fn get_hub(address: &str) -> Result<Hub> {
130
131 // Converting the MAC string to btleplug::api::BDAddr type
132 let address = BDAddr::from_str(address)?;
133
134 // The ConnectionManager connects stuff - so ask it for the hub...
135 let cm = ConnectionManager::new();
136
137 // It is possible to use the name of the hub or its MAC address. That's why it's Option<>
138 // Here, only address is implemented
139 let hub = cm.get_hub(None, Some(address), 5).await?;
140
141 // Great! Let's get on with this...
142 Ok(hub)
143}examples/plug_and_play.rs (line 44)
34async fn main() -> Result<()> {
35 // Hub "MAC" address can be found in several ways.
36 // Connect it to a computer and continue from there...
37 let hub_mac_address = "90:84:2b:4e:5b:96";
38 let port_id = TechnicHubPorts::B;
39
40 // Converting the MAC string to btleplug::api::BDAddr type
41 let address = BDAddr::from_str(hub_mac_address)?;
42
43 // The ConnectionManager connects stuff - so ask it for the hub...
44 let cm = ConnectionManager::new();
45
46 // It is possible to use the name of the hub or its MAC address. That's why it's Option<>
47 // Here, only address is implemented
48 let hub = cm.get_hub(None, Some(address), 5).await?;
49
50 // Ask to get the motor object (pay attention to the port_id)
51 let motor = hub.get_motor(port_id as u8).await?;
52
53 // Initiate the motor with power
54 _ = motor.start_power(100, StartupAndCompletionInfo::ExecuteImmediatelyAndNoAction).await?;
55
56 // Let it hang there for 3 seconds
57 time::sleep(Duration::from_secs(3)).await;
58
59 // And stop
60 _ = motor.stop_motor(EndState::FLOAT, Profile::AccDec, StartupAndCompletionInfo::ExecuteImmediatelyAndNoAction).await?;
61
62 Ok(())
63}Sourcepub async fn get_hub(
&self,
peripheral_name: Option<String>,
bd_add: Option<BDAddr>,
scan_time_seconds: u64,
) -> Result<Hub>
pub async fn get_hub( &self, peripheral_name: Option<String>, bd_add: Option<BDAddr>, scan_time_seconds: u64, ) -> Result<Hub>
Examples found in repository?
examples/calibrating_steering.rs (line 100)
90async fn get_hub(address: &str) -> Result<Hub> {
91
92 // Converting the MAC string to btleplug::api::BDAddr type
93 let address = BDAddr::from_str(address)?;
94
95 // The ConnectionManager connects stuff - so ask it for the hub...
96 let cm = ConnectionManager::new();
97
98 // It is possible to use the name of the hub or its MAC address. That's why it's Option<>
99 // Here, only address is implemented
100 let hub = cm.get_hub(None, Some(address), 5).await?;
101
102 // Great! Let's get on with this...
103 Ok(hub)
104}More examples
examples/use_a_motor_with_arrow_keys.rs (line 139)
129async fn get_hub(address: &str) -> Result<Hub> {
130
131 // Converting the MAC string to btleplug::api::BDAddr type
132 let address = BDAddr::from_str(address)?;
133
134 // The ConnectionManager connects stuff - so ask it for the hub...
135 let cm = ConnectionManager::new();
136
137 // It is possible to use the name of the hub or its MAC address. That's why it's Option<>
138 // Here, only address is implemented
139 let hub = cm.get_hub(None, Some(address), 5).await?;
140
141 // Great! Let's get on with this...
142 Ok(hub)
143}examples/plug_and_play.rs (line 48)
34async fn main() -> Result<()> {
35 // Hub "MAC" address can be found in several ways.
36 // Connect it to a computer and continue from there...
37 let hub_mac_address = "90:84:2b:4e:5b:96";
38 let port_id = TechnicHubPorts::B;
39
40 // Converting the MAC string to btleplug::api::BDAddr type
41 let address = BDAddr::from_str(hub_mac_address)?;
42
43 // The ConnectionManager connects stuff - so ask it for the hub...
44 let cm = ConnectionManager::new();
45
46 // It is possible to use the name of the hub or its MAC address. That's why it's Option<>
47 // Here, only address is implemented
48 let hub = cm.get_hub(None, Some(address), 5).await?;
49
50 // Ask to get the motor object (pay attention to the port_id)
51 let motor = hub.get_motor(port_id as u8).await?;
52
53 // Initiate the motor with power
54 _ = motor.start_power(100, StartupAndCompletionInfo::ExecuteImmediatelyAndNoAction).await?;
55
56 // Let it hang there for 3 seconds
57 time::sleep(Duration::from_secs(3)).await;
58
59 // And stop
60 _ = motor.stop_motor(EndState::FLOAT, Profile::AccDec, StartupAndCompletionInfo::ExecuteImmediatelyAndNoAction).await?;
61
62 Ok(())
63}Auto Trait Implementations§
impl Freeze for ConnectionManager
impl RefUnwindSafe for ConnectionManager
impl Send for ConnectionManager
impl Sync for ConnectionManager
impl Unpin for ConnectionManager
impl UnwindSafe for ConnectionManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more