Click here to Skip to main content
15,868,340 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 749.4K   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

 
QuestionLong message! Pin
cauut4713-Dec-19 6:46
cauut4713-Dec-19 6:46 
AnswerRe: Long message! Pin
cauut4713-Dec-19 6:51
cauut4713-Dec-19 6:51 
Questiondecoding Error Pin
Member 918691025-Nov-19 20:19
Member 918691025-Nov-19 20:19 
Questiondecode 7bit methode Pin
Member 1318859030-Aug-18 0:26
Member 1318859030-Aug-18 0:26 
Questioni trie to use it but it give me eror Pin
prof_ahmed12-Nov-16 2:34
prof_ahmed12-Nov-16 2:34 
QuestionService Center number missed? Pin
AzmanXE25-Sep-16 19:21
AzmanXE25-Sep-16 19:21 
QuestionConcat long SMS unicode (UCS-2) Pin
Ana98711-May-16 1:56
Ana98711-May-16 1:56 
QuestionSend a long message Pin
Member 106667001-Sep-15 14:11
Member 106667001-Sep-15 14:11 
QuestionPDU Decoder Pin
Member 160860718-Sep-14 0:14
Member 160860718-Sep-14 0:14 
QuestionPlease Help Pin
Member 859094222-Mar-13 18:03
Member 859094222-Mar-13 18:03 
CAN YOU SHOW EXAMPLE ABOUT SENDING MULTIPART/CONCATENATED SMS USING THIS LIBRARY ??
QuestionThanks Pin
ekoos711-Jan-13 10:48
ekoos711-Jan-13 10:48 
QuestionI do not download,can you send it to my email,Thanks a lot! Pin
yf200919-Oct-12 16:10
yf200919-Oct-12 16:10 
GeneralMy vote of 5 Pin
Anand Murali M S18-Oct-12 1:01
Anand Murali M S18-Oct-12 1:01 
QuestionIt Works! Pin
carloboi12-Oct-12 1:46
carloboi12-Oct-12 1:46 
QuestionHow to Encode 7bit. Pin
Khương Nguyễn11-Jun-12 22:22
Khương Nguyễn11-Jun-12 22:22 
AnswerRe: How to Encode 7bit. Pin
mosiera4-Oct-22 1:53
mosiera4-Oct-22 1:53 
QuestionWhere is the compose for 7bit and 8bit Pin
rixan13-Jul-11 1:18
rixan13-Jul-11 1:18 
AnswerRe: Where is the compose for 7bit and 8bit Pin
ummarbhutta5-Jan-12 18:44
ummarbhutta5-Jan-12 18:44 
GeneralRe: Where is the compose for 7bit and 8bit Pin
rixan8-Jan-12 20:34
rixan8-Jan-12 20:34 
GeneralRe: Where is the compose for 7bit and 8bit Pin
BlueFire233-Oct-12 17:17
BlueFire233-Oct-12 17:17 
GeneralRe: Where is the compose for 7bit and 8bit Pin
Ulen15151517-Oct-12 22:47
Ulen15151517-Oct-12 22:47 
Generalspecial char ? ^ {} [] dosnt work Pin
tenmateusz9-Feb-11 3:51
tenmateusz9-Feb-11 3:51 
GeneralMy vote of 5 Pin
farhood22-Jan-11 20:29
farhood22-Jan-11 20:29 
GeneralMy vote of 4 Pin
astri30-Oct-10 23:14
astri30-Oct-10 23:14 
GeneralCellId.ru have freelibrary for working with SMS and GSM Modem Pin
BSH-Systems9-Jul-10 4:49
professionalBSH-Systems9-Jul-10 4:49 

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.