Skip to content

Commit ebd8977

Browse files
authored
Support more vendors' extended command syntax (#248)
* add failing test for a $-prefixed response deserialization * recognize other common extended command prefixes in response re. #247 * use `c` for character since not really a `s`tring… * update comment
1 parent 2884123 commit ebd8977

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

serde_at/src/de/mod.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ impl<'a> Deserializer<'a> {
190190
}
191191

192192
fn parse_at(&mut self) -> Result<Option<()>> {
193-
// If we find a '+', check if it is an AT command identifier, ending in ':'
194-
if self.parse_whitespace() == Some(b'+') {
193+
// match AT command identifier starting in known prefixes and ending in ':'
194+
if self.parse_whitespace().map(|c| match c {
195+
b'+' | b'#' | b'$' | b'&' | b'%' => true,
196+
_ => false,
197+
}) == Some(true)
198+
{
195199
let index = self.index;
196200
loop {
197201
match self.peek() {
@@ -1244,4 +1248,16 @@ mod tests {
12441248
})
12451249
);
12461250
}
1251+
1252+
#[test]
1253+
fn gpsant() {
1254+
#[derive(Clone, Debug, Deserialize, PartialEq)]
1255+
pub struct GpsAntenna {
1256+
pub ant_type: u8,
1257+
}
1258+
1259+
let res = crate::from_str("$GPSAT: 1");
1260+
1261+
assert_eq!(res, Ok(GpsAntenna { ant_type: 1 }));
1262+
}
12471263
}

0 commit comments

Comments
 (0)