Click here to Skip to main content
15,887,828 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 758.2K   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

 
Questioncan we use this code to compose flash sms and vcard? Pin
Cman-Lobo28-Oct-06 4:02
Cman-Lobo28-Oct-06 4:02 
AnswerRe: can we use this code to compose flash sms and vcard? Pin
Eduard Gomolyako28-Oct-06 10:41
Eduard Gomolyako28-Oct-06 10:41 
AnswerRe: can we use this code to compose flash sms and vcard? Pin
Eduard Gomolyako28-Oct-06 10:46
Eduard Gomolyako28-Oct-06 10:46 
QuestionWhich SMS server are you using? Pin
Rajib Bahar23-Oct-06 3:11
Rajib Bahar23-Oct-06 3:11 
AnswerRe: Which SMS server are you using? Pin
Eduard Gomolyako23-Oct-06 3:23
Eduard Gomolyako23-Oct-06 3:23 
GeneralRe: Which SMS server are you using? Pin
Rajib Bahar23-Oct-06 5:06
Rajib Bahar23-Oct-06 5:06 
GeneralRe: Which SMS server are you using? Pin
Eduard Gomolyako23-Oct-06 5:13
Eduard Gomolyako23-Oct-06 5:13 
GeneralRe: Which SMS server are you using? Pin
Rajib Bahar23-Oct-06 5:15
Rajib Bahar23-Oct-06 5:15 
AnswerRe: Which SMS server are you using? Pin
Eduard Gomolyako23-Oct-06 5:30
Eduard Gomolyako23-Oct-06 5:30 
GeneralThanks! Pin
Ladislav Soukup17-Oct-06 6:48
Ladislav Soukup17-Oct-06 6:48 
GeneralRe: Thanks! Pin
Eduard Gomolyako19-Oct-06 5:25
Eduard Gomolyako19-Oct-06 5:25 
GeneralRe: Thanks! Pin
Ladislav Soukup8-Dec-06 0:13
Ladislav Soukup8-Dec-06 0:13 
GeneralInteresting article Pin
Abbas_Riazi16-Oct-06 13:25
professionalAbbas_Riazi16-Oct-06 13:25 
GeneralRe: Interesting article Pin
Eduard Gomolyako17-Oct-06 1:29
Eduard Gomolyako17-Oct-06 1:29 

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.