Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c508e2d

Browse filesBrowse files
author
Jonathan Pallant (42 Technology)
committed
Reworked modem on/off API.
Apparently sending AT+COPS=0 causes the modem to reset some state, making it start slower.
1 parent f4965c0 commit c508e2d
Copy full SHA for c508e2d

File tree

Expand file treeCollapse file tree

1 file changed

+13
-19
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-19
lines changed
Open diff view settings
Collapse file

‎src/modem.rs‎

Copy file name to clipboard
100755100644
Expand all lines: src/modem.rs
+13-19Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ pub fn wait_for_lte() -> Result<(), Error> {
9090
Ok(())
9191
}
9292

93+
/// Powers the modem on and sets it to auto-register, but does not wait for it
94+
/// to connect to a network.
95+
pub fn on() -> Result<(), Error> {
96+
crate::at::send_at_command("AT+CFUN=1", |_| {})?;
97+
Ok(())
98+
}
99+
100+
/// Puts the modem into flight mode.
101+
pub fn flight_mode() -> Result<(), Error> {
102+
crate::at::send_at_command("AT+CFUN=4", |_| {})?;
103+
Ok(())
104+
}
105+
93106
/// Powers the modem off.
94107
pub fn off() -> Result<(), Error> {
95108
crate::at::send_at_command("AT+CFUN=0", |_| {})?;
@@ -144,25 +157,6 @@ pub fn get_system_mode() -> Result<SystemMode, Error> {
144157
result
145158
}
146159

147-
/// Puts the modem into flight mode.
148-
pub fn flight_mode() -> Result<(), Error> {
149-
let skt = crate::at::AtSocket::new()?;
150-
// Flight Mode
151-
skt.write(b"AT+CFUN=4")?;
152-
Ok(())
153-
}
154-
155-
/// Powers the modem on and sets it to auto-register, but does not wait for it
156-
/// to connect to a network.
157-
pub fn start() -> Result<(), Error> {
158-
let skt = crate::at::AtSocket::new()?;
159-
// Auto Register
160-
skt.write(b"AT+COPS=0")?;
161-
// Normal Mode
162-
skt.write(b"AT+CFUN=1")?;
163-
Ok(())
164-
}
165-
166160
//******************************************************************************
167161
// Private Functions and Impl on Private Types
168162
//******************************************************************************

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.