pub struct ModemManager { /* private fields */ }
Available on crate feature
network
only.Implementations§
Source§impl ModemManager
impl ModemManager
Sourcepub fn connect() -> Result<Self, Error>
pub fn connect() -> Result<Self, Error>
Examples found in repository?
examples/network.rs (line 33)
12fn main() {
13
14 let dbus = NetworkManager::connect().unwrap();
15
16 for device in dbus.devices().unwrap() {
17 let state = device.state().unwrap();
18 let kind = device.kind().unwrap();
19 let interface = device.interface().unwrap();
20
21 println!("{:?} {:?} {:?}", interface, kind, state);
22 if let Ok(apn) = device.modem_apn() {
23 println!("- has apn {:?}", apn);
24 }
25
26 if matches!(state, DeviceState::Activated) {
27 let ipv4 = device.ipv4_config().unwrap()
28 .addresses().unwrap();
29 println!("- addresses {:?}", ipv4);
30 }
31 }
32
33 let dbus = ModemManager::connect().unwrap();
34
35 for modem in dbus.modems().unwrap() {
36 println!(
37 "modem {:?} {:?} {:?}",
38 modem.model().unwrap(),
39 modem.manufacturer().unwrap(),
40 modem.device().unwrap()
41 );
42
43 println!(
44 "- carrier configuration: {:?}",
45 modem.carrier_configuration().unwrap()
46 );
47
48 println!(
49 "- state: {:?}, signal: {:?}",
50 modem.state().unwrap(),
51 modem.signal_quality().unwrap()
52 );
53
54 let (allowed_modes, preffered_modes) = modem.current_modes().unwrap();
55 println!(
56 "- allowed modes: 2g: {} 3g: {} 4g: {} 5g: {}",
57 allowed_modes.has_2g(),
58 allowed_modes.has_3g(),
59 allowed_modes.has_4g(),
60 allowed_modes.has_5g()
61 );
62
63 println!(
64 "- prefered modes: 2g: {} 3g: {} 4g: {} 5g: {}",
65 preffered_modes.has_2g(),
66 preffered_modes.has_3g(),
67 preffered_modes.has_4g(),
68 preffered_modes.has_5g()
69 );
70
71 println!(
72 "- bands: {:?}",
73 modem.current_bands().unwrap()
74 );
75
76 modem.signal_setup(10).unwrap();
77 thread::sleep(Duration::from_secs(1));
78
79 if let Ok(cdma) = modem.signal_cdma() {
80 println!("- cdma: {:?}", cdma);
81 }
82
83 if let Ok(evdo) = modem.signal_evdo() {
84 println!("- evdo: {:?}", evdo);
85 }
86
87 if let Ok(gsm) = modem.signal_gsm() {
88 println!("- gsm: {:?}", gsm);
89 }
90
91 if let Ok(umts) = modem.signal_umts() {
92 println!("- umts: {:?}", umts);
93 }
94
95 if let Ok(lte) = modem.signal_lte() {
96 println!("- lte: {:?}", lte);
97 }
98
99 if let Ok(nr5g) = modem.signal_nr5g() {
100 println!("- nr5g: {:?}", nr5g);
101 }
102 }
103
104}
Sourcepub fn modems(&self) -> Result<Vec<Modem>, Error>
pub fn modems(&self) -> Result<Vec<Modem>, Error>
Examples found in repository?
examples/network.rs (line 35)
12fn main() {
13
14 let dbus = NetworkManager::connect().unwrap();
15
16 for device in dbus.devices().unwrap() {
17 let state = device.state().unwrap();
18 let kind = device.kind().unwrap();
19 let interface = device.interface().unwrap();
20
21 println!("{:?} {:?} {:?}", interface, kind, state);
22 if let Ok(apn) = device.modem_apn() {
23 println!("- has apn {:?}", apn);
24 }
25
26 if matches!(state, DeviceState::Activated) {
27 let ipv4 = device.ipv4_config().unwrap()
28 .addresses().unwrap();
29 println!("- addresses {:?}", ipv4);
30 }
31 }
32
33 let dbus = ModemManager::connect().unwrap();
34
35 for modem in dbus.modems().unwrap() {
36 println!(
37 "modem {:?} {:?} {:?}",
38 modem.model().unwrap(),
39 modem.manufacturer().unwrap(),
40 modem.device().unwrap()
41 );
42
43 println!(
44 "- carrier configuration: {:?}",
45 modem.carrier_configuration().unwrap()
46 );
47
48 println!(
49 "- state: {:?}, signal: {:?}",
50 modem.state().unwrap(),
51 modem.signal_quality().unwrap()
52 );
53
54 let (allowed_modes, preffered_modes) = modem.current_modes().unwrap();
55 println!(
56 "- allowed modes: 2g: {} 3g: {} 4g: {} 5g: {}",
57 allowed_modes.has_2g(),
58 allowed_modes.has_3g(),
59 allowed_modes.has_4g(),
60 allowed_modes.has_5g()
61 );
62
63 println!(
64 "- prefered modes: 2g: {} 3g: {} 4g: {} 5g: {}",
65 preffered_modes.has_2g(),
66 preffered_modes.has_3g(),
67 preffered_modes.has_4g(),
68 preffered_modes.has_5g()
69 );
70
71 println!(
72 "- bands: {:?}",
73 modem.current_bands().unwrap()
74 );
75
76 modem.signal_setup(10).unwrap();
77 thread::sleep(Duration::from_secs(1));
78
79 if let Ok(cdma) = modem.signal_cdma() {
80 println!("- cdma: {:?}", cdma);
81 }
82
83 if let Ok(evdo) = modem.signal_evdo() {
84 println!("- evdo: {:?}", evdo);
85 }
86
87 if let Ok(gsm) = modem.signal_gsm() {
88 println!("- gsm: {:?}", gsm);
89 }
90
91 if let Ok(umts) = modem.signal_umts() {
92 println!("- umts: {:?}", umts);
93 }
94
95 if let Ok(lte) = modem.signal_lte() {
96 println!("- lte: {:?}", lte);
97 }
98
99 if let Ok(nr5g) = modem.signal_nr5g() {
100 println!("- nr5g: {:?}", nr5g);
101 }
102 }
103
104}
Trait Implementations§
Source§impl Clone for ModemManager
impl Clone for ModemManager
Source§fn clone(&self) -> ModemManager
fn clone(&self) -> ModemManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for ModemManager
impl !RefUnwindSafe for ModemManager
impl !Send for ModemManager
impl !Sync for ModemManager
impl Unpin for ModemManager
impl !UnwindSafe for ModemManager
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