Skip to main content

Module urc

Module urc 

Source
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§

CallWaiting
+CCWA: <number>,<type>,<class>,[<alpha>][,<CLI validity>[,<subaddr>,<satype>[,<priority>]]] (the call waiting URC; the +CCWA: <status>,<class> query response is not this).
CallerId
+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.
CindRanges
+CIND: ("<descr>",(list of supported <ind>s)),... test-command response.
CindValues
+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
+CMT header (§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).
CnmiSupport
+CNMI: (list of <mode>s),(list of <mt>s),... test-command response, ranges expanded.
Cops
+COPS: <mode>[,<format>,<oper>[,<AcT>]] read-command response.
CopsList
+COPS: [list of (<stat>,long,short,numeric[,<AcT>])s][,,(list of <mode>s),(list of <format>s)]. The trailing mode/format lists are skipped.
CpmsStatus
+CPMS: <mem1>,<used1>,<total1>,<mem2>,... (read) or +CPMS: <used1>,<total1>,... (set).
CpmsSupport
+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.
IndicatorRange
One entry of +CIND: ("name",(range)),...; index is 1-based.
MessageHeader
+CMGL (§3.4.2) / +CMGR (§3.4.3) header; the body is the next line.
MessageIndication
+CMTI: <mem>,<index> / +CDSI: <mem>,<index> (§3.4.1).
MessageReference
+CMGS: <mr>[,<scts>|<ackpdu>] (§3.5.1) / +CMSS: <mr>[,...] (§3.5.2).
OperatorEntry
One (<stat>,long,short,numeric[,<AcT>]) entry of +COPS=?.
Registration
A +CREG / +CGREG / +CEREG / +C5GREG line, solicited (<n>,<stat>,...) or unsolicited (<stat>,...).
StorageUsage
One storage of +CPMS?.

Enums§

AccessTech
<AcT> access technology (27.007 §7.3).
CallDirection
<dir> of +CLCC.
CallState
<stat> of +CLCC.
CgevEvent
A +CGEV event. Old-style address forms (NW DEACT <PDP_type>,<PDP_addr>[,<cid>]) and the current cid forms are both decoded; anything else is CgevEvent::Other.
Cpin
+CPIN: <code>.
MessageStatus
<stat> of stored messages; numeric in PDU mode, a string in text mode.
OperatorStatus
<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. +CUSD is handled by the USSD module.