Skip to main content

Module ussd

Module ussd 

Source
Expand description

USSD: 7-bit packing with the CBS/USSD padding rule (3GPP TS 23.038 §6.1.2.3.1), CBS data coding scheme (23.038 §5) and the +CUSD result line (TS 27.007 §7.15).

Structs§

CbsDcs
What a CBS/USSD data coding scheme says about the payload (23.038 §5).
Cusd
One +CUSD: <m>[,<str>[,<dcs>]] line.
UssdText
A decoded USSD string.

Enums§

Cscs
TE character set chosen with AT+CSCS (27.007 §5.5). With a GSM 7-bit <dcs> the modem converts <str> into it (27.007 §7.15); the parser cannot see +CSCS, so the caller says which one is active.
CusdStatus
<m> of +CUSD (27.007 §7.15).

Functions§

decode
Decode a network USSD string (the octets, not hex) per its DCS. 8-bit data is read as ISO-8859-1; compressed data (23.042) is not supported and returns None.
decode_gsm7
Packed USSD string → text (GSM 7-bit default alphabet).
encode
Text → packed USSD string (GSM 7-bit default alphabet).
pack_septets
Pack septets after fill_bits zero bits. When the last octet has 7 spare bits they carry a CR; when the text ends with CR exactly on an octet boundary another CR is appended, so the receiver can tell padding from data.
parse_cusd
Parse one logical +CUSD line (prefix case-insensitive). The string may hold commas, CR/LF and quotes; the closing quote is the last one on the line. A trailing OK glued to the line after the string or the DCS is ignored; an OK inside an unclosed string is kept as text. None if this is not a +CUSD line.
unpack_septets
Unpack every septet after fill_bits, dropping the padding CR (7 spare bits) and the extra CR added after a CR that ended on an octet boundary.