Click here to Skip to main content
15,914,209 members
Articles / Programming Languages / C#

Library for Decode/Encode SMS PDU

Rate me:
Please Sign up or sign in to vote.
4.74/5 (49 votes)
18 Oct 2012CPOL 763.9K   26.6K   128   192
Library for decoding and encoding mobile short messages to/from SMS protocol data unit

Last Updates

You can find some community fixes mentioned on comments section on Project Home at Google Code[^].

Introduction

The smspdulib library is intended for more transparent interaction with SMS PDU. This thought over hierarchy of classes will allow you to create new classes for other types of short messages using the realized base functionality.

At present, the following types of short messages are supported: status report, SMS (with long (large) SMS parts support).

Hierarchy of Classes

Classes hierarchy

Enums

Sample Code

This example shows you how to decode PDU.

C#
SMSType smsType = SMSBase.GetSMSType(pduSource);
switch (smsType) {
    case SMSType.SMS:
        SMS sms = new SMS();
        SMS.Fetch(sms, ref pduSource);
        //Use instance of SMS class here
        break;
    case SMSType.StatusReport:
        SMSStatusReport statusReport = new SMSStatusReport();
        SMSStatusReport.Fetch(statusReport, ref pduSource);
        //Use instance of SMSStatusReport class here
        break;
}

This example show you how to encode SMS to PDU.

C#
SMS sms = new SMS();
sms.Direction = SMSDirection.Submited;
sms.PhoneNumber = "+74951234567";
sms.ValidityPeriod = new TimeSpan(4, 0, 0, 0);
sms.Message = "Me message here!";
string pduSource = sms.Compose(SMS.SMSEncoding.UCS2);

Useful Links

Updated

  • Updated Decode7bit method: Fixed some bugs (see comments)
  • PopDate method now doesn't recognize time zone because some phones send strange stuff

Please help me find more detailed specification of PDU format and TP-SCTS format.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: Code in VB.Net Pin
Eduard Gomolyako16-Mar-08 11:02
Eduard Gomolyako16-Mar-08 11:02 
QuestionHow to implement Unicode SMS, multipart SMS and high capacity sending Pin
William Ike8-Mar-08 21:45
William Ike8-Mar-08 21:45 
QuestionLong Messages? Pin
Nukumaar4-Jan-08 5:25
Nukumaar4-Jan-08 5:25 
AnswerRe: Long Messages? Pin
Eduard Gomolyako8-Jan-08 9:20
Eduard Gomolyako8-Jan-08 9:20 
GeneralRe: Long Messages? Pin
Nukumaar14-Jan-08 14:55
Nukumaar14-Jan-08 14:55 
GeneralRe: Long Messages? Pin
Eduard Gomolyako14-Jan-08 20:59
Eduard Gomolyako14-Jan-08 20:59 
GeneralRe: Long Messages? Pin
Nukumaar15-Jan-08 10:55
Nukumaar15-Jan-08 10:55 
GeneralRe: Long Messages? Pin
Nukumaar17-Jan-08 15:13
Nukumaar17-Jan-08 15:13 
for better reading,here are he 3 PDU strings:
1)
05913476061211390B816067960850F50
000FF11C7329A0E2287E7A0F9181DA6EBD33F

2)
059134760612040C91347666890055000070
21926142624046553719E40ED3FD72767A8C06
CDC76879392D06A5C76850B83E4683C8E932A82
C9FD3CBA0797B0E42A7D1691768999ECF41E931
1AC44E97C56510393D4603

3)
059134760612513C0B816067960850F50000FFA
0050003010302EA2074B94E2F83DA693AE81E96
CFE9AEB0B82C0791C373507A4E07CDDF20F2FB6D
66A5C768103A2C0691D36334889C2E83CE61B7BE0
CD297D37450BD0D6AA7C76850585C9683D26334C8
5E96B7D3F339889C1EA341E4B0DB0DA2CBDF743DB
9DC06D1DFF430DB1566CFDF2
GeneralRe: Long Messages? Pin
Nukumaar5-Feb-08 4:10
Nukumaar5-Feb-08 4:10 
GeneralRe: Long Messages? Pin
Eduard Gomolyako5-Feb-08 4:52
Eduard Gomolyako5-Feb-08 4:52 
GeneralRe: Long Messages? Pin
Nukumaar6-Feb-08 2:47
Nukumaar6-Feb-08 2:47 
GeneralRe: Long Messages? Pin
Eduard Gomolyako6-Feb-08 2:57
Eduard Gomolyako6-Feb-08 2:57 
GeneralRe: Long Messages? Pin
ESTAN11-Apr-08 14:20
ESTAN11-Apr-08 14:20 
GeneralRe: Long Messages? Pin
Eduard Gomolyako11-Apr-08 22:05
Eduard Gomolyako11-Apr-08 22:05 
GeneralRe: Long Messages? Pin
Ahmed Zaheer25-May-08 4:56
Ahmed Zaheer25-May-08 4:56 
QuestionIs workig it in VB.NET ? Pin
jan vokroj20-Dec-07 20:21
jan vokroj20-Dec-07 20:21 
AnswerRe: Is workig it in VB.NET ? Pin
Eduard Gomolyako8-Jan-08 9:19
Eduard Gomolyako8-Jan-08 9:19 
QuestionPDU Parsing Pin
yateee25-Oct-07 3:01
yateee25-Oct-07 3:01 
AnswerRe: PDU Parsing Pin
Eduard Gomolyako25-Oct-07 5:22
Eduard Gomolyako25-Oct-07 5:22 
AnswerRe: PDU Parsing Pin
yateee25-Oct-07 23:24
yateee25-Oct-07 23:24 
GeneralRe: PDU Parsing Pin
Eduard Gomolyako25-Oct-07 23:58
Eduard Gomolyako25-Oct-07 23:58 
GeneralPDUHelper Pin
petr_rehor7-Sep-07 2:42
petr_rehor7-Sep-07 2:42 
GeneralRe: PDUHelper Pin
Eduard Gomolyako9-Sep-07 9:27
Eduard Gomolyako9-Sep-07 9:27 
GeneralRe: PDUHelper Pin
mcampo10-Apr-08 23:17
mcampo10-Apr-08 23:17 
GeneralRe: PDUHelper Pin
Eduard Gomolyako10-Apr-08 23:46
Eduard Gomolyako10-Apr-08 23:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.