Expand description
Typed parsers for 3GPP TS 27.007 / 27.005 information lines and unsolicited result codes.
Every parser takes ONE logical line (framing into lines is done elsewhere, e.g. by
crate::at::split_lines) and returns None when the line is not that command or is
malformed. Prefixes match ASCII case-insensitively; surrounding whitespace / CR LF is ignored.
Multi-line responses (+CMGL, +CMGR, +CMT, +CDS in PDU mode) parse the header only:
the PDU or text body is the next line.
parse_any dispatches the unsolicited forms.
use serial_codec::urc::{parse_any, AccessTech, RegStatus, Urc};
let Some(Urc::Registration(r)) = parse_any("+CEREG: 1,\"1F00\",\"79D903\",7") else { panic!() };
assert_eq!(r.n, None); // unsolicited form
assert_eq!(r.stat, RegStatus::Home);
assert_eq!((r.lac, r.ci, r.act), (Some(0x1F00), Some(0x79D903), Some(AccessTech::Eutran)));Structs§
- Call
Waiting +CCWA: <number>,<type>,<class>,[<alpha>][,<CLI validity>[,<subaddr>,<satype>[,<priority>]]](the call waiting URC; the+CCWA: <status>,<class>query response is not this).- Caller
Id +CLIP: <number>,<type>[,<subaddr>,<satype>[,[<alpha>][,<CLI validity>]]]and+COLP: <number>,<type>[,<subaddr>,<satype>[,<alpha>]].- Cds
+CDS(§3.4.1). PDU:+CDS: <length>; text:+CDS: <fo>,<mr>,[<ra>],[<tora>],<scts>,<dt>,<st>.- Cesq
+CESQ: <rxlev>,<ber>,<rscp>,<ecno>,<rsrq>,<rsrp>[,<ss_rsrq>,<ss_rsrp>,<ss_sinr>]raw values; 99 (rxlev, ber) / 255 (others) = not known.- Cgev
+CGEV: <event>: the decoded event plus the text after+CGEV:.- Ciev
+CIEV: <ind>,<value>.<ind>is the 1-based +CIND index; some modems send the name instead.- Cind
Ranges +CIND: ("<descr>",(list of supported <ind>s)),...test-command response.- Cind
Values +CIND: <ind>,<ind>,...read-command response: current values in +CIND=? order.- Clcc
+CLCC: <ccid>,<dir>,<stat>,<mode>,<mpty>[,<number>,<type>[,<alpha>[,<priority>[,<CLI validity>]]]].- Cmt
+CMTheader (§3.4.1). PDU:+CMT: [<alpha>],<length>; text:+CMT: <oa>,[<alpha>],<scts>[,<tooa>,<fo>,<pid>,<dcs>,<sca>,<tosca>,<length>].- Cnmi
+CNMI: <mode>,<mt>,<bm>,<ds>,<bfr>(§3.4.1, read).- Cnmi
Support +CNMI: (list of <mode>s),(list of <mt>s),...test-command response, ranges expanded.- Cops
+COPS: <mode>[,<format>,<oper>[,<AcT>]]read-command response.- Cops
List +COPS: [list of (<stat>,long,short,numeric[,<AcT>])s][,,(list of <mode>s),(list of <format>s)]. The trailing mode/format lists are skipped.- Cpms
Status +CPMS: <mem1>,<used1>,<total1>,<mem2>,...(read) or+CPMS: <used1>,<total1>,...(set).- Cpms
Support +CPMS: (list of <mem1>s),(list of <mem2>s),(list of <mem3>s)test-command response.- Csq
+CSQ: <rssi>,<ber>raw values; 99 = not known.- Indicator
Range - One entry of
+CIND: ("name",(range)),...;indexis 1-based. - Message
Header +CMGL(§3.4.2) /+CMGR(§3.4.3) header; the body is the next line.- Message
Indication +CMTI: <mem>,<index>/+CDSI: <mem>,<index>(§3.4.1).- Message
Reference +CMGS: <mr>[,<scts>|<ackpdu>](§3.5.1) /+CMSS: <mr>[,...](§3.5.2).- Operator
Entry - One
(<stat>,long,short,numeric[,<AcT>])entry of +COPS=?. - Registration
- A
+CREG/+CGREG/+CEREG/+C5GREGline, solicited (<n>,<stat>,...) or unsolicited (<stat>,...). - Storage
Usage - One storage of
+CPMS?.
Enums§
- Access
Tech <AcT>access technology (27.007 §7.3).- Call
Direction <dir>of +CLCC.- Call
State <stat>of +CLCC.- Cgev
Event - A
+CGEVevent. Old-style address forms (NW DEACT <PDP_type>,<PDP_addr>[,<cid>]) and the current cid forms are both decoded; anything else isCgevEvent::Other. - Cpin
+CPIN: <code>.- Message
Status <stat>of stored messages; numeric in PDU mode, a string in text mode.- Operator
Status <stat>of a +COPS=? entry.- RegKind
- Which registration command a line came from.
- RegStatus
<stat>of the registration commands.- SmsMode
- SMS mode a header was written in.
- Urc
- An unsolicited result code recognised by
parse_any.
Functions§
- parse_
any - Parses one line as any supported URC.
+CUSDis handled by the USSD module.