pub struct ModemMode(_);

Implementations§

source§

impl ModemMode

source

pub fn new() -> Self

Creates a new ModemNode where no mode is allowed.

source

pub fn is_any(&self) -> bool

Any Mode is allowed, only allowed for POTS modems.

source

pub fn set_any(&mut self)

Set the mode to Any.

source

pub fn is_none(&self) -> bool

No Mode is allowed.

source

pub fn has_cs(&self) -> bool

CSD, GSM, and other circuit-switched technologies.

source

pub fn set_cs(&mut self)

Sets the CS mode (CSD, GSM, and other circuit-switched technologies).

source

pub fn has_2g(&self) -> bool

GPRS, EDGE.

Examples found in repository?
examples/network.rs (line 57)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
fn main() {

	let dbus = NetworkManager::connect().unwrap();

	for device in dbus.devices().unwrap() {
		let state = device.state().unwrap();
		let kind = device.kind().unwrap();
		let interface = device.interface().unwrap();

		println!("{:?} {:?} {:?}", interface, kind, state);
		if let Ok(apn) = device.modem_apn() {
			println!("- has apn {:?}", apn);
		}

		if matches!(state, DeviceState::Activated) {
			let ipv4 = device.ipv4_config().unwrap()
				.addresses().unwrap();
			println!("- addresses {:?}", ipv4);
		}
	}

	let dbus = ModemManager::connect().unwrap();

	for modem in dbus.modems().unwrap() {
		println!(
			"modem {:?} {:?} {:?}",
			modem.model().unwrap(),
			modem.manufacturer().unwrap(),
			modem.device().unwrap()
		);

		println!(
			"- carrier configuration: {:?}",
			modem.carrier_configuration().unwrap()
		);

		println!(
			"- state: {:?}, signal: {:?}",
			modem.state().unwrap(),
			modem.signal_quality().unwrap()
		);

		let (allowed_modes, preffered_modes) = modem.current_modes().unwrap();
		println!(
			"- allowed modes: 2g: {} 3g: {} 4g: {} 5g: {}",
			allowed_modes.has_2g(),
			allowed_modes.has_3g(),
			allowed_modes.has_4g(),
			allowed_modes.has_5g()
		);

		println!(
			"- prefered modes: 2g: {} 3g: {} 4g: {} 5g: {}",
			preffered_modes.has_2g(),
			preffered_modes.has_3g(),
			preffered_modes.has_4g(),
			preffered_modes.has_5g()
		);

		println!(
			"- bands: {:?}",
			modem.current_bands().unwrap()
		);

		modem.signal_setup(10).unwrap();
		thread::sleep(Duration::from_secs(1));

		if let Ok(cdma) = modem.signal_cdma() {
			println!("- cdma: {:?}", cdma);
		}

		if let Ok(evdo) = modem.signal_evdo() {
			println!("- evdo: {:?}", evdo);
		}

		if let Ok(gsm) = modem.signal_gsm() {
			println!("- gsm: {:?}", gsm);
		}

		if let Ok(umts) = modem.signal_umts() {
			println!("- umts: {:?}", umts);
		}

		if let Ok(lte) = modem.signal_lte() {
			println!("- lte: {:?}", lte);
		}

		if let Ok(nr5g) = modem.signal_nr5g() {
			println!("- nr5g: {:?}", nr5g);
		}
	}

}
source

pub fn set_2g(&mut self)

Sets the 2g mode (GPRS, EDGE).

source

pub fn has_3g(&self) -> bool

UMTS, HSxPA.

Examples found in repository?
examples/network.rs (line 58)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
fn main() {

	let dbus = NetworkManager::connect().unwrap();

	for device in dbus.devices().unwrap() {
		let state = device.state().unwrap();
		let kind = device.kind().unwrap();
		let interface = device.interface().unwrap();

		println!("{:?} {:?} {:?}", interface, kind, state);
		if let Ok(apn) = device.modem_apn() {
			println!("- has apn {:?}", apn);
		}

		if matches!(state, DeviceState::Activated) {
			let ipv4 = device.ipv4_config().unwrap()
				.addresses().unwrap();
			println!("- addresses {:?}", ipv4);
		}
	}

	let dbus = ModemManager::connect().unwrap();

	for modem in dbus.modems().unwrap() {
		println!(
			"modem {:?} {:?} {:?}",
			modem.model().unwrap(),
			modem.manufacturer().unwrap(),
			modem.device().unwrap()
		);

		println!(
			"- carrier configuration: {:?}",
			modem.carrier_configuration().unwrap()
		);

		println!(
			"- state: {:?}, signal: {:?}",
			modem.state().unwrap(),
			modem.signal_quality().unwrap()
		);

		let (allowed_modes, preffered_modes) = modem.current_modes().unwrap();
		println!(
			"- allowed modes: 2g: {} 3g: {} 4g: {} 5g: {}",
			allowed_modes.has_2g(),
			allowed_modes.has_3g(),
			allowed_modes.has_4g(),
			allowed_modes.has_5g()
		);

		println!(
			"- prefered modes: 2g: {} 3g: {} 4g: {} 5g: {}",
			preffered_modes.has_2g(),
			preffered_modes.has_3g(),
			preffered_modes.has_4g(),
			preffered_modes.has_5g()
		);

		println!(
			"- bands: {:?}",
			modem.current_bands().unwrap()
		);

		modem.signal_setup(10).unwrap();
		thread::sleep(Duration::from_secs(1));

		if let Ok(cdma) = modem.signal_cdma() {
			println!("- cdma: {:?}", cdma);
		}

		if let Ok(evdo) = modem.signal_evdo() {
			println!("- evdo: {:?}", evdo);
		}

		if let Ok(gsm) = modem.signal_gsm() {
			println!("- gsm: {:?}", gsm);
		}

		if let Ok(umts) = modem.signal_umts() {
			println!("- umts: {:?}", umts);
		}

		if let Ok(lte) = modem.signal_lte() {
			println!("- lte: {:?}", lte);
		}

		if let Ok(nr5g) = modem.signal_nr5g() {
			println!("- nr5g: {:?}", nr5g);
		}
	}

}
source

pub fn set_3g(&mut self)

Sets the 3g mode (UMTS, HSxPA).

source

pub fn has_4g(&self) -> bool

LTE.

Examples found in repository?
examples/network.rs (line 59)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
fn main() {

	let dbus = NetworkManager::connect().unwrap();

	for device in dbus.devices().unwrap() {
		let state = device.state().unwrap();
		let kind = device.kind().unwrap();
		let interface = device.interface().unwrap();

		println!("{:?} {:?} {:?}", interface, kind, state);
		if let Ok(apn) = device.modem_apn() {
			println!("- has apn {:?}", apn);
		}

		if matches!(state, DeviceState::Activated) {
			let ipv4 = device.ipv4_config().unwrap()
				.addresses().unwrap();
			println!("- addresses {:?}", ipv4);
		}
	}

	let dbus = ModemManager::connect().unwrap();

	for modem in dbus.modems().unwrap() {
		println!(
			"modem {:?} {:?} {:?}",
			modem.model().unwrap(),
			modem.manufacturer().unwrap(),
			modem.device().unwrap()
		);

		println!(
			"- carrier configuration: {:?}",
			modem.carrier_configuration().unwrap()
		);

		println!(
			"- state: {:?}, signal: {:?}",
			modem.state().unwrap(),
			modem.signal_quality().unwrap()
		);

		let (allowed_modes, preffered_modes) = modem.current_modes().unwrap();
		println!(
			"- allowed modes: 2g: {} 3g: {} 4g: {} 5g: {}",
			allowed_modes.has_2g(),
			allowed_modes.has_3g(),
			allowed_modes.has_4g(),
			allowed_modes.has_5g()
		);

		println!(
			"- prefered modes: 2g: {} 3g: {} 4g: {} 5g: {}",
			preffered_modes.has_2g(),
			preffered_modes.has_3g(),
			preffered_modes.has_4g(),
			preffered_modes.has_5g()
		);

		println!(
			"- bands: {:?}",
			modem.current_bands().unwrap()
		);

		modem.signal_setup(10).unwrap();
		thread::sleep(Duration::from_secs(1));

		if let Ok(cdma) = modem.signal_cdma() {
			println!("- cdma: {:?}", cdma);
		}

		if let Ok(evdo) = modem.signal_evdo() {
			println!("- evdo: {:?}", evdo);
		}

		if let Ok(gsm) = modem.signal_gsm() {
			println!("- gsm: {:?}", gsm);
		}

		if let Ok(umts) = modem.signal_umts() {
			println!("- umts: {:?}", umts);
		}

		if let Ok(lte) = modem.signal_lte() {
			println!("- lte: {:?}", lte);
		}

		if let Ok(nr5g) = modem.signal_nr5g() {
			println!("- nr5g: {:?}", nr5g);
		}
	}

}
source

pub fn set_4g(&mut self)

Sets the 4g mode (LTE).

source

pub fn has_5g(&self) -> bool

5GNR

Examples found in repository?
examples/network.rs (line 60)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
fn main() {

	let dbus = NetworkManager::connect().unwrap();

	for device in dbus.devices().unwrap() {
		let state = device.state().unwrap();
		let kind = device.kind().unwrap();
		let interface = device.interface().unwrap();

		println!("{:?} {:?} {:?}", interface, kind, state);
		if let Ok(apn) = device.modem_apn() {
			println!("- has apn {:?}", apn);
		}

		if matches!(state, DeviceState::Activated) {
			let ipv4 = device.ipv4_config().unwrap()
				.addresses().unwrap();
			println!("- addresses {:?}", ipv4);
		}
	}

	let dbus = ModemManager::connect().unwrap();

	for modem in dbus.modems().unwrap() {
		println!(
			"modem {:?} {:?} {:?}",
			modem.model().unwrap(),
			modem.manufacturer().unwrap(),
			modem.device().unwrap()
		);

		println!(
			"- carrier configuration: {:?}",
			modem.carrier_configuration().unwrap()
		);

		println!(
			"- state: {:?}, signal: {:?}",
			modem.state().unwrap(),
			modem.signal_quality().unwrap()
		);

		let (allowed_modes, preffered_modes) = modem.current_modes().unwrap();
		println!(
			"- allowed modes: 2g: {} 3g: {} 4g: {} 5g: {}",
			allowed_modes.has_2g(),
			allowed_modes.has_3g(),
			allowed_modes.has_4g(),
			allowed_modes.has_5g()
		);

		println!(
			"- prefered modes: 2g: {} 3g: {} 4g: {} 5g: {}",
			preffered_modes.has_2g(),
			preffered_modes.has_3g(),
			preffered_modes.has_4g(),
			preffered_modes.has_5g()
		);

		println!(
			"- bands: {:?}",
			modem.current_bands().unwrap()
		);

		modem.signal_setup(10).unwrap();
		thread::sleep(Duration::from_secs(1));

		if let Ok(cdma) = modem.signal_cdma() {
			println!("- cdma: {:?}", cdma);
		}

		if let Ok(evdo) = modem.signal_evdo() {
			println!("- evdo: {:?}", evdo);
		}

		if let Ok(gsm) = modem.signal_gsm() {
			println!("- gsm: {:?}", gsm);
		}

		if let Ok(umts) = modem.signal_umts() {
			println!("- umts: {:?}", umts);
		}

		if let Ok(lte) = modem.signal_lte() {
			println!("- lte: {:?}", lte);
		}

		if let Ok(nr5g) = modem.signal_nr5g() {
			println!("- nr5g: {:?}", nr5g);
		}
	}

}
source

pub fn set_5g(&mut self)

Sets the 5g mode (5GNR).

Trait Implementations§

source§

impl Clone for ModemMode

source§

fn clone(&self) -> ModemMode

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ModemMode

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<ModemMode> for u32

source§

fn from(mode: ModemMode) -> Self

Converts to this type from the input type.
source§

impl From<u32> for ModemMode

source§

fn from(num: u32) -> Self

Converts to this type from the input type.
source§

impl PartialEq<ModemMode> for ModemMode

source§

fn eq(&self, other: &ModemMode) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for ModemMode

source§

impl Eq for ModemMode

source§

impl StructuralEq for ModemMode

source§

impl StructuralPartialEq for ModemMode

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.