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+;Displayadds 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
- Status
Report - Submit
- Submit
Request - 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).
- User
Data - 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
Ffiller.digitscaps 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,
Nonefor a non-BCD digit. - decode_
user_ data - Decode TP-UD given TP-UDL, TP-UDHI and the DCS.
udmay be longer than needed. - encode_
address - Encode a TP address field (length counts digits, not
+). An empty value (or a lone+) isInvalid("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);Nonebeyond the 63-week maximum. - relative_
minutes - Minutes encoded by a relative TP-VP octet.