Search code examples
c#smsat-commandhyperterminalpdu

Convert text into PDU format


I am developing a message server like thing which support PDU format (using android phone) to send messages. I have used online encoders to convert my text but i don't know the real steps to convert a text into PDU format I don't think it just a Hexadecimal number.

I used at commands for sending messages from hyper terminal.

Can someone help?

I used AT-Commands:

    at
    at+cmgf=0
    at+cmgs=25 (Length i guess)
    >"encoded message"

Solution

  • The AT+CMGS command is defined in the 3GPP 25.005 standard, and for PDU mode its syntax is given as

    +CMGS=<length><CR>
    PDU is given<ctrl-Z/ESC>
    

    and in the description it is further specified

    the PDU shall be hexadecimal format (similarly as specified for <pdu>) and given in one line; ME/TA converts this coding into the actual octets of PDU.

    The <pdu> format is defined in Message Data Parameters in chapter 3.1 Parameter Definitions:

    In the case of SMS: 3GPP TS 24.011 [6] SC address followed by 3GPP TS 23.040 [3] TPDU in hexadecimal format: ME/TA converts each octet of TP data unit into two IRA character long hexadecimal number (e.g. octet with integer value 42 is presented to TE as two characters 2A (IRA 50 and 65))

    (SC is short for Service Centre)

    And here all the fun begins because you now have to dig really, really, really deep into those other specifications to uncover the actual format...


    For instance 24.011 describes low level data format for messages sent between the mobile and the network where only parts of it is relevant in this context.

    7.3.1.2 RP‑DATA (Mobile Station to Network) This message is sent in MS ‑> MSC direction. The message is used to relay the TPDUs. The information elements are in line with 3GPP TS 23.040.

    and in the table given, the two last rows are the relevant parts, the Service Centre Address and the TPDU.

    Information element, Reference, Presence, Format, Length
    RP‑Message Type, Subclause 8.2.2, M, V, 3 bits
    RP‑Message Reference, Subclause 8.2.3, M, V, 1 octet
    RP‑Originator Address, Subclause 8.2.5.1, M, LV, 1 octet
    RP‑Destination Address, Subclause 8.2.5.2, M, LV, 1‑12 octets
    RP‑User Data, Subclause 8.2.5.3, M, LV, <= 233 octets
    

    Trying to dig further I got stuck on trying to figure out the value of the RP‑Destination Address number IEI, and I have already spent a long time writing this answer. Sorry for stopping here. The actual phone number encoding is the "normal" Called party BCD number encoding (10.5.4.7 in 24.008) and TON+NPI is the same as the <type> argument in AT+CPBW for instance. And encoding of the text is a whole story on it own...


    Trying to decipher parts of the 3GPP specifications can sometimes be really hard and the possibilities for misinterpretation might be close to endless! If you are really set on developing your own code for doing this you are probably better off by starting to read good PDU mode introductions like http://mobiletidings.com/2009/02/11/more-on-the-sms-pdu/1. Or look up the code in an already existing library/program that handles PDU mode2.

    1 Notice that good quality articles like that are far between, if the text does not include references to detailed/technical terms from the 3GPP standards that is usually a low quality indicator.

    2 Again, look hard for good quality.