Click here to Skip to main content
15,898,134 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 760.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: SMS to e-mail Pin
speaderDA25-Nov-08 13:47
speaderDA25-Nov-08 13:47 
GeneralRe: SMS to e-mail Pin
Eduard Gomolyako25-Nov-08 19:24
Eduard Gomolyako25-Nov-08 19:24 
GeneralAlphanumeric address decoding Pin
benetnash8-Sep-08 3:31
benetnash8-Sep-08 3:31 
GeneralRe: Alphanumeric address decoding Pin
Eduard Gomolyako8-Sep-08 3:51
Eduard Gomolyako8-Sep-08 3:51 
GeneralRe: Alphanumeric address decoding Pin
Audi Nugraha1-Dec-10 2:51
Audi Nugraha1-Dec-10 2:51 
QuestionCould I use this library in C/C++ environment Pin
John Yueh3-Sep-08 17:39
John Yueh3-Sep-08 17:39 
AnswerRe: Could I use this library in C/C++ environment Pin
Eduard Gomolyako3-Sep-08 19:30
Eduard Gomolyako3-Sep-08 19:30 
GeneralHi Pin
banuponni7-Aug-08 4:50
banuponni7-Aug-08 4:50 
I'm doing project in SMS sending with PDU mode. now i'm checking manually using hyper terminal. here is my pdu code. when i pass this code in hyper terminal its not working it display "ERROR". here i'm using motorola mobile for sending msg. Rather than i need to send msg more than 160 character so plz check it and reply me soon its urgent.

AT
k
AT+CMGF=0
k
AT+CMGS=154
079119891440446451000C811989567198550000FFA00608044A210201E8329BFD4697D9EC37BACC66BFD16536FB8D2EB3D96F7499CD7EA3CB6CF61B5D66B3DFE8329BFD4697D9EC37BACC66BFD16536FB8D2EB3D96F7499CD66BFD16536FB8D2EB3D96F7499CD7EA3CB6CF61B5D66B3DFE8329BFD4697D9EC37BACC66BFD16536FB8D2EB3D96F7

so many sites i refer it and check that too but no result. can any one tell me y itis?. actually what problem isit in AT commands or PDU code. Reply me soon its very urgent to finish it. plz check it and reply me plz.
GeneralHi Pin
banuponni7-Aug-08 4:49
banuponni7-Aug-08 4:49 
GeneralDestinition Port Pin
Baxtiyor17-Jul-08 20:29
Baxtiyor17-Jul-08 20:29 
GeneralRe: Destinition Port Pin
Eduard Gomolyako17-Jul-08 20:35
Eduard Gomolyako17-Jul-08 20:35 
GeneralRe: Destinition Port Pin
Baxtiyor17-Jul-08 20:42
Baxtiyor17-Jul-08 20:42 
GeneralRe: Destinition Port Pin
Eduard Gomolyako17-Jul-08 20:37
Eduard Gomolyako17-Jul-08 20:37 
QuestionRe: Destinition Port [modified] Pin
Baxtiyor17-Jul-08 22:01
Baxtiyor17-Jul-08 22:01 
AnswerRe: Destinition Port Pin
Eduard Gomolyako17-Jul-08 22:58
Eduard Gomolyako17-Jul-08 22:58 
GeneralRe: Destinition Port Pin
Baxtiyor17-Jul-08 23:10
Baxtiyor17-Jul-08 23:10 
Questionlong message?? Pin
Muthuganesh10-Jul-08 18:39
Muthuganesh10-Jul-08 18:39 
Answerlong message?? Pin
sakthif129-Nov-08 18:47
sakthif129-Nov-08 18:47 
AnswerRe: long message?? Pin
Eduard Gomolyako1-Dec-08 1:43
Eduard Gomolyako1-Dec-08 1:43 
QuestionHow to set Sender Pin
yarns7-Jul-08 0:20
yarns7-Jul-08 0:20 
AnswerRe: How to set Sender Pin
Eduard Gomolyako7-Jul-08 0:28
Eduard Gomolyako7-Jul-08 0:28 
GeneralEncode PDU Fail Pin
jamesng7423-Jun-08 20:09
jamesng7423-Jun-08 20:09 
GeneralRe: Encode PDU Fail Pin
Eduard Gomolyako23-Jun-08 20:17
Eduard Gomolyako23-Jun-08 20:17 
GeneralRe: Encode PDU Fail Pin
jamesng7424-Jun-08 15:39
jamesng7424-Jun-08 15:39 
GeneralRe: Encode PDU Fail Pin
Eduard Gomolyako24-Jun-08 20:57
Eduard Gomolyako24-Jun-08 20:57 

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.