Click here to Skip to main content
15,898,371 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 761K   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: 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 
QuestionSend SMS Pin
Member 339753130-May-08 16:43
Member 339753130-May-08 16:43 
AnswerRe: Send SMS Pin
Eduard Gomolyako1-Jun-08 19:57
Eduard Gomolyako1-Jun-08 19:57 
Questionhow to handle USSD? Pin
jamesng7416-Apr-08 18:42
jamesng7416-Apr-08 18:42 
AnswerRe: how to handle USSD? Pin
Eduard Gomolyako16-Apr-08 20:57
Eduard Gomolyako16-Apr-08 20:57 
GeneralRe: how to handle USSD? Pin
jamesng7417-Apr-08 22:03
jamesng7417-Apr-08 22:03 
i plan to create an application to work with USSD through cell phone (siemens c55).

For example,
My GSM provider, provide a USSD tools to transfer voucher between customers. than, i want to transfer a voucher to my friend.

below is current process (manually):
1. from my cell phone, i dial a USSD number such as: *123#
2. then my phone display a USSD message. i.e "input phone number"
3. i click button "answer"
4. my cell phone display a text box:
5. input my number: +1233453455
6. then click OK
... etc

How to create a program like that?

Thanks for reply.
GeneralRe: how to handle USSD? Pin
Eduard Gomolyako18-Apr-08 1:09
Eduard Gomolyako18-Apr-08 1:09 
GeneralRe: how to handle USSD? Pin
jamesng7418-Apr-08 15:48
jamesng7418-Apr-08 15:48 
GeneralRe: how to handle USSD? Pin
Eduard Gomolyako18-Apr-08 20:15
Eduard Gomolyako18-Apr-08 20:15 
GeneralRe: how to handle USSD? Pin
jamesng7420-Apr-08 16:34
jamesng7420-Apr-08 16:34 
GeneralRe: how to handle USSD? Pin
Eduard Gomolyako20-Apr-08 22:00
Eduard Gomolyako20-Apr-08 22:00 
Generalguide me Pin
MAZHAR ALI SHAIKH17-Mar-08 9:50
MAZHAR ALI SHAIKH17-Mar-08 9:50 
GeneralRe: guide me Pin
ESTAN11-Apr-08 14:28
ESTAN11-Apr-08 14:28 
Generalguide me Pin
MAZHAR ALI SHAIKH17-Mar-08 9:49
MAZHAR ALI SHAIKH17-Mar-08 9:49 
GeneralCode in VB.Net Pin
MAZHAR ALI SHAIKH16-Mar-08 10:41
MAZHAR ALI SHAIKH16-Mar-08 10:41 
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 

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.