{"id":841,"date":"2020-03-07T13:45:26","date_gmt":"2020-03-07T12:45:26","guid":{"rendered":"https:\/\/mobiletidings.com\/?p=841"},"modified":"2020-12-18T08:16:12","modified_gmt":"2020-12-18T07:16:12","slug":"more-on-the-sms-pdu","status":"publish","type":"post","link":"https:\/\/techsofar.com\/more-on-the-sms-pdu\/","title":{"rendered":"More Sending SMS In PDU Mode"},"content":{"rendered":"

As discussed in an\u00a0earlier post<\/a>, you can connect to a GSM modem and use AT commands to send SMS messages. There are 2 possible methods: text mode and PDU mode.<\/p>\n

It turns out that most devices support PDU mode, but only a few support text mode.<\/p>\n

Here is an example AT command to submit a PDU:<\/p>\n

\n
AT+CMGS=24<crlf>\n> 0001000B915121551532F400000CC8F79D9C07E54F61363B04<Ctrl-Z><\/pre>\n<\/div>\n
As explained before the size (24) is the number of octets in the PDU. The PDU itself is passed as a hex representation of those octets (48 characters). Here is what the individual octets represent:<\/div>\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Size<\/strong><\/td>\nValue<\/strong><\/td>\nDescription<\/strong><\/td>\n<\/tr>\n
1 octet<\/td>\n00<\/td>\nThis indicates that we don\u2019t supply an SMSC number. The one that is configured in the device will be used.<\/td>\n<\/tr>\n
1 octet<\/td>\n01<\/td>\nPDU type and options. This is a one octet bit-field that controls:<\/p>\n
    \n
  • Message type (here is set to 1 which means this is an SMS-SUBMIT PDU)<\/li>\n
  • Validity period format<\/li>\n
  • Reply path<\/li>\n
  • User Data header present (UDH indicator)<\/li>\n
  • Request status report<\/li>\n<\/ul>\n

    The most significant of these is the UDH indicator. More on these fields in a future post.<\/td>\n<\/tr>\n

1 octet<\/td>\n00<\/td>\nOur message reference. In case there is an error delivering the message, this number will be part of the error response so we can see which message failed.<\/td>\n<\/tr>\n
1 octet<\/td>\n0B<\/td>\nSize of the destination telephone number (in digits)<\/td>\n<\/tr>\n
1 octet<\/td>\n91<\/td>\nInternational numbering plan. This indicates that what follows is an international telephone number.<\/td>\n<\/tr>\n
6 octets<\/td>\n5121551532f4<\/td>\nTelephone number. This is the destination phone number is a reverse nibble encoding:<\/p>\n
    \n
  • octet \u201951\u2019 stands for digits 1 and 5<\/li>\n
  • octet \u201921\u2019 stands for digits 1 and 2<\/li>\n
  • octet \u201855\u2019 stands for 5 and 5<\/li>\n
  • octet \u201815\u2019 stands for 5 and 1<\/li>\n
  • octet \u201832\u2019 stands for 2 and 3<\/li>\n
  • octet \u2018f1\u2019 stands for digit 1 and the f indicates the end<\/li>\n<\/ul>\n

    So \u2018915121551532f4\u2019 translates to +1 512 555 1234.<\/td>\n<\/tr>\n

1 octet<\/td>\n00<\/td>\nProtocol identifier. This can be used to indicate a higher-level protocol. \u20180\u2019 indicates no higher-level protocol.<\/td>\n<\/tr>\n
1 octet<\/td>\n00<\/td>\nThis represents the Data Coding Scheme. A \u20180\u2019 indicates that the messages are encoded in the GSM 7 (default) alphabet.<\/p>\n
    \n
  • The message could also be encoded in UCS-2. In which case this octet would be \u201808\u2019.<\/li>\n<\/ul>\n

    \u2018There are other (fun) uses for this byte that I\u2019ll show in a future post.<\/td>\n<\/tr>\n

1 octet<\/td>\n0c<\/td>\nPayload size in septets (characters). This field is also called User Data Length.<\/td>\n<\/tr>\n
11 octets<\/td>\nC8f79D9C07E5
\n4F61363B04<\/td>\n
The payload, also known as User Data. In this case, it is just GSM encoded text. This is the tricky encoding:<\/p>\n