Click here to Skip to main content
15,886,830 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 757.7K   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

 
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 
GeneralMy vote of 3 Pin
BSH-Systems9-Jul-10 4:46
professionalBSH-Systems9-Jul-10 4:46 
GeneralRecieve Long sms not correctly Pin
amna_94726-May-10 17:42
amna_94726-May-10 17:42 
GeneralRecive sms problem Pin
anil_singh201013-May-10 18:17
anil_singh201013-May-10 18:17 
Generalsend and recieve sms using pdulib Pin
paks_mundiasd11-May-10 17:20
paks_mundiasd11-May-10 17:20 
Generaluse pdulib Pin
zadsdfas23-Mar-10 0:29
zadsdfas23-Mar-10 0:29 
can anybody explain me how to send and recieve sms via gsm modem connected to PC via bluetooth (serial port profile) or data cable."
QuestionService Center number missed? Pin
flexchan25-Jan-10 6:27
flexchan25-Jan-10 6:27 
AnswerRe: Service Center number missed? Pin
AzmanXE25-Sep-16 19:21
AzmanXE25-Sep-16 19:21 
GeneralWanted specification Pin
k06a18-Jan-10 5:22
k06a18-Jan-10 5:22 
GeneralRe: Wanted specification Pin
Eduard Gomolyako21-Jan-10 16:54
Eduard Gomolyako21-Jan-10 16:54 
GeneralRe: Wanted specification [modified] Pin
k06a22-Jan-10 8:14
k06a22-Jan-10 8:14 
GeneralRe: Wanted specification Pin
Eduard Gomolyako22-Jan-10 23:52
Eduard Gomolyako22-Jan-10 23:52 
GeneralRe: Wanted specification Pin
k06a23-Jan-10 7:18
k06a23-Jan-10 7:18 
GeneralThanks A lot!! Pin
adiono9-Dec-09 4:03
adiono9-Dec-09 4:03 
GeneralEncoder/Decoder Pin
Member 30541152-Nov-09 23:25
Member 30541152-Nov-09 23:25 
GeneralRe: Encoder/Decoder Pin
uncleR18-Nov-09 1:19
uncleR18-Nov-09 1:19 
GeneralRe: Encoder/Decoder Pin
ummarbhutta21-Nov-09 4:49
ummarbhutta21-Nov-09 4:49 
GeneralRe: Encoder/Decoder Pin
Member 305411522-Nov-09 22:44
Member 305411522-Nov-09 22:44 
GeneralRe: Encoder/Decoder Pin
ohinCZ24-Nov-09 0:02
ohinCZ24-Nov-09 0:02 
GeneralRe: Encoder/Decoder Pin
Member 305411525-Nov-09 8:17
Member 305411525-Nov-09 8:17 
GeneralUpdated version of this library Pin
ummarbhutta18-Oct-09 8:03
ummarbhutta18-Oct-09 8:03 
GeneralSuggestion/Doubts about receiving long SMS Pin
faber7517-Oct-09 0:17
faber7517-Oct-09 0:17 
Generalhi Pin
Member 108861211-Oct-09 19:58
Member 108861211-Oct-09 19:58 

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.