pub struct Modem { /* private fields */ }
network
only.Implementations§
Source§impl Modem
impl Modem
Sourcepub fn manufacturer(&self) -> Result<String, Error>
pub fn manufacturer(&self) -> Result<String, Error>
The equipment manufacturer, as reported by the modem.
Examples found in repository?
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 model(&self) -> Result<String, Error>
pub fn model(&self) -> Result<String, Error>
The equipment model, as reported by the modem.
Examples found in repository?
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 carrier_configuration(&self) -> Result<String, Error>
pub fn carrier_configuration(&self) -> Result<String, Error>
The description of the carrier-specific configuration (MCFG) in use by the modem.
Examples found in repository?
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 device(&self) -> Result<String, Error>
pub fn device(&self) -> Result<String, Error>
The physical modem device reference (ie, USB, PCI, PCMCIA device), which may be dependent upon the operating system.
In Linux for example, this points to a sysfs path of the usb_device object.
This value may also be set by the user using the MM_ID_PHYSDEV_UID udev tag (e.g. binding the tag to a specific sysfs path).
Examples found in repository?
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 state(&self) -> Result<ModemState, Error>
pub fn state(&self) -> Result<ModemState, Error>
Overall state of the modem, given as a MMModemState value.
If the device’s state cannot be determined, MM_MODEM_STATE_UNKNOWN will be reported.
Examples found in repository?
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 access_techs(&self) -> Result<ModemAccessTechs, Error>
pub fn access_techs(&self) -> Result<ModemAccessTechs, Error>
The current network access technologies used by the device to communicate with the network.
If the device’s access technology cannot be determined, Unknown will be reported.
Sourcepub fn signal_quality(&self) -> Result<(u32, bool), Error>
pub fn signal_quality(&self) -> Result<(u32, bool), Error>
Signal quality in percent (0 - 100) of the dominant access technology
the device is using to communicate with the network. Always 0 for
POTS devices.
The additional boolean value indicates if the quality value given was
recently taken.
Examples found in repository?
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 supported_modes(&self) -> Result<Vec<(ModemMode, ModemMode)>, Error>
pub fn supported_modes(&self) -> Result<Vec<(ModemMode, ModemMode)>, Error>
This property exposes the supported mode combinations, given as an array of unsigned integer pairs, where:
The first integer is a bitmask of MMModemMode values, specifying the allowed modes.
The second integer is a single MMModemMode, which specifies the preferred access technology, among the ones defined in the allowed modes.
Sourcepub fn current_modes(&self) -> Result<(ModemMode, ModemMode), Error>
pub fn current_modes(&self) -> Result<(ModemMode, ModemMode), Error>
A pair of MMModemMode values, where the first one is a bitmask specifying the access technologies (eg 2G/3G/4G) the device is currently allowed to use when connecting to a network, and the second one is the preferred mode of those specified as allowed.
Examples found in repository?
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 set_current_modes(
&self,
(allowed, preferred): (ModemMode, ModemMode),
) -> Result<(), Error>
pub fn set_current_modes( &self, (allowed, preferred): (ModemMode, ModemMode), ) -> Result<(), Error>
Set the access technologies (e.g. 2G/3G/4G preference) the device is currently allowed to use when connecting to a network.
The given combination should be supported by the modem, as specified in the “SupportedModes” property.
A pair of MMModemMode values, where the first one is a bitmask of allowed modes, and the second one the preferred mode, if any.
Sourcepub fn supported_bands(&self) -> Result<Vec<ModemBand>, Error>
pub fn supported_bands(&self) -> Result<Vec<ModemBand>, Error>
List of MMModemBand values, specifying the radio frequency and technology bands supported by the device.
For POTS devices, only the MM_MODEM_BAND_ANY mode will be returned.
Sourcepub fn current_bands(&self) -> Result<Vec<ModemBand>, Error>
pub fn current_bands(&self) -> Result<Vec<ModemBand>, Error>
List of MMModemBand values, specifying the radio frequency and technology bands the device is currently using when connecting to a network.
It must be a subset of “SupportedBands”.
Examples found in repository?
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 set_current_bands(&self, bands: &[ModemBand]) -> Result<(), Error>
pub fn set_current_bands(&self, bands: &[ModemBand]) -> Result<(), Error>
Set the radio frequency and technology bands the device is currently allowed to use when connecting to a network.
List of MMModemBand values, to specify the bands to be used.
Sourcepub fn signal_setup(&self, rate: u32) -> Result<(), Error>
pub fn signal_setup(&self, rate: u32) -> Result<(), Error>
Examples found in repository?
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 signal_cdma(&self) -> Result<SignalCdma, Error>
pub fn signal_cdma(&self) -> Result<SignalCdma, Error>
Available signal information for the CDMA1x access technology.
Examples found in repository?
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 signal_evdo(&self) -> Result<SignalEvdo, Error>
pub fn signal_evdo(&self) -> Result<SignalEvdo, Error>
Available signal information for the CDMA EV-DO access technology.
Examples found in repository?
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 signal_gsm(&self) -> Result<SignalGsm, Error>
pub fn signal_gsm(&self) -> Result<SignalGsm, Error>
Available signal information for the GSM/GPRS access technology.
Examples found in repository?
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 signal_umts(&self) -> Result<SignalUmts, Error>
pub fn signal_umts(&self) -> Result<SignalUmts, Error>
Available signal information for the UMTS (WCDMA) access technology.
Examples found in repository?
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 signal_lte(&self) -> Result<SignalLte, Error>
pub fn signal_lte(&self) -> Result<SignalLte, Error>
Available signal information for the LTE access technology.
Examples found in repository?
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 signal_nr5g(&self) -> Result<SignalNr5g, Error>
pub fn signal_nr5g(&self) -> Result<SignalNr5g, Error>
Available signal information for the 5G access technology.
Examples found in repository?
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 own_numbers(&self) -> Result<Vec<String>, Error>
pub fn own_numbers(&self) -> Result<Vec<String>, Error>
List of numbers (e.g. MSISDN in 3GPP) being currently handled by this modem.
Sourcepub fn imei(&self) -> Result<String, Error>
pub fn imei(&self) -> Result<String, Error>
The IMEI of the device.
§Note
This interface will only be available once the modem is ready to be registered in the cellular network. 3GPP devices will require a valid unlocked SIM card before any of the features in the interface can be used.
Sourcepub fn registration_state(&self) -> Result<RegistrationState, Error>
pub fn registration_state(&self) -> Result<RegistrationState, Error>
A MMModem3gppRegistrationState value specifying the mobile registration status as defined in 3GPP TS 27.007 section 10.1.19.
§Note
This interface will only be available once the modem is ready to be registered in the cellular network. 3GPP devices will require a valid unlocked SIM card before any of the features in the interface can be used.
Sourcepub fn operator_code(&self) -> Result<String, Error>
pub fn operator_code(&self) -> Result<String, Error>
Code of the operator to which the mobile is currently registered.
Returned in the format “MCCMNC”, where MCC is the three-digit ITU E.212 Mobile Country Code and MNC is the two- or three-digit GSM Mobile Network Code. e.g. e“31026“ or “310260”.
If the MCC and MNC are not known or the mobile is not registered to a mobile network, this property will be a zero-length (blank) string.
§Note
This interface will only be available once the modem is ready to be registered in the cellular network. 3GPP devices will require a valid unlocked SIM card before any of the features in the interface can be used.
Sourcepub fn operator_name(&self) -> Result<String, Error>
pub fn operator_name(&self) -> Result<String, Error>
Name of the operator to which the mobile is currently registered.
If the operator name is not known or the mobile is not registered to a mobile network, this property will be an empty string.
§Note
This interface will only be available once the modem is ready to be registered in the cellular network. 3GPP devices will require a valid unlocked SIM card before any of the features in the interface can be used.