Skip to main content

Module pdu

Module pdu 

Source
Expand description

3GPP TS 23.040 TPDUs in TS 27.005 PDU-mode form (SMSC address + TPDU).

Decoding is strict about lengths (a TP-UDL that points past the data is an error, so is an odd UCS2 payload) and lenient about values the spec tells receivers to tolerate: reserved DCS groups decode as GSM 7-bit (23.038 §4), TOA bit 7 is not checked, trailing octets after the user data are ignored, an SCTS that is not a valid date decodes as None (the raw octets stay available).

Structs§

Address
An address field: type of address octet and its value — digits (0-9 * # a b c) or, for TON 5, the decoded text. The value never carries a +; Display adds one for international numbers.
Concat
Dcs
TP-DCS for SMS (23.038 §4).
Deliver
Ie
One information element.
Mwi
Message waiting indication from DCS groups 1100/1101/1110 (23.038 §4).
Pdu
A 27.005 PDU: optional SMSC address followed by the TPDU.
Ports
StatusReport
Submit
SubmitRequest
Everything an SMS-SUBMIT needs. SubmitRequest::new(to, text) gives the usual defaults: no SMSC (modem’s), auto alphabet, MR 0, no VP, no status report, no concatenation reference (set one for text that may not fit one part).
Timestamp
TP-SCTS / TP-DT / absolute TP-VP (23.040 §9.2.3.11): local time plus the offset to UTC in signed quarter hours. Two-digit years map to 1970–2069.
Udh
User data header (23.040 §9.2.3.24).
UserData
TP-UD after UDH parsing.

Enums§

Alphabet
Body
Message body.
MwiKind
PduError
Ton
Type of number, TOA bits 6–4 (23.040 §9.1.2.5).
Tpdu
Validity
TP-VP (23.040 §9.2.3.12).

Constants§

IEI_CONCAT_8
IEI_CONCAT_16
IEI_LOCKING_SHIFT
IEI_PORTS_8
IEI_PORTS_16
IEI_SINGLE_SHIFT
TOA_ALPHANUMERIC
TOA for alphanumeric (GSM 7-bit packed) addresses.
TOA_INTERNATIONAL
TOA for international numbers, ISDN/E.164 plan.
TOA_NATIONAL
TOA for national numbers, ISDN/E.164 plan.
TOA_UNKNOWN
TOA for unknown type, ISDN/E.164 plan (what most phones send without +).

Functions§

decode
Decode PDU octets with the SMSC prefix. TP-MTI 00 is read as SMS-DELIVER, 01 as SMS-SUBMIT, 10 as SMS-STATUS-REPORT — the directions a modem hands to the host.
decode_address
TP address field (OA/DA/RA): len(digits) TOA value. Returns the address and the octets consumed.
decode_hex
Decode a hex PDU as printed by +CMGR/+CMGL/+CMT/+CDS (SMSC prefix included).
decode_semi_octets
Swapped semi-octets → digits; stops at the first F filler. digits caps the count.
decode_smsc
SMSC address field (len(octets incl. TOA) TOA value); length 0 → None.
decode_tpdu
Decode a TPDU without the SMSC prefix.
decode_tz
The time zone octet alone: signed quarter hours, None for a non-BCD digit.
decode_user_data
Decode TP-UD given TP-UDL, TP-UDHI and the DCS. ud may be longer than needed.
encode_address
Encode a TP address field (length counts digits, not +). An empty value (or a lone +) is Invalid("address").
encode_semi_octets
Digits (0-9 * # a b c, case-insensitive) → swapped semi-octets, F-padded. Err(c) names the first character that has no semi-octet value.
encode_smsc
Encode the SMSC prefix (length counts TOA + octets); None/empty → [0].
encode_submit
Encode an SMS-SUBMIT, splitting into concatenated parts when needed (which requires SubmitRequest::concat_ref).
relative_from_minutes
Smallest relative TP-VP octet covering minutes (rounded up); None beyond the 63-week maximum.
relative_minutes
Minutes encoded by a relative TP-VP octet.