-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
47 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "common" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![no_std] | ||
use core::option::{Option, Option::None, Option::Some}; | ||
|
||
pub fn split_at_response(line: &str) -> Option<(&str, &str)> { | ||
if line.starts_with('+') { | ||
if let Some(prefix_len) = line.find(": ") { | ||
let prefix = &line[1..prefix_len]; | ||
let rest = &line[prefix_len + 2..]; | ||
return Some((prefix, rest)); | ||
} | ||
} | ||
None | ||
} | ||
|
||
#[cfg(test)] | ||
mod test_at_utils { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_split_at_response() { | ||
let res = "+QMTSTAT: 0,2"; | ||
assert_eq!(split_at_response(res), Some(("QMTSTAT", "0,2"))); | ||
|
||
let res = "QMTSTAT: 0,2"; | ||
assert_eq!(split_at_response(res), None); | ||
let res = "+QMTSTAT 0,2"; | ||
assert_eq!(split_at_response(res), None); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters