Wednesday, January 27, 2010

Send Picture SMS from PC to Mobile

Introduction

Some days ago, I was wondering whether I could send a picture from my PC to mobile? After a lot of thinking, I came to know that I could do so. This article is a sample example for you in order to send a picture to your mobile. Text and picture messages have the same method for sending, but the only difference is the length of the message. You can fit your text into one message like if you just send "hello", but it's difficult to fit a picture in one message because you have a complete format for the picture. I am using OTA format for sending pictures to my mobile phone Sony Ericsson k500i.

Background

To understand this article, you must have knowledge of how to send text SMS.

OTA

Over the Air (OTA) is an image format for mobile phones which has standard size of 72x28, etc. It has only two colors, black and white. Read this article for how to convert an image into OTA format.

Details

First of all, convert your image into OTA format and copy all its data in any file like *.txt, *.doc, etc. Here is an example for the OTA data of image.

66 66 66 66 66 66 66 66 66 99 99 99 99 99 99 99 99
99 80 00 00 00 00 00 00 00 01 40 00 00 00 60 00 E0
00 02 40 00 00 0E 90 03 10 00 02 80 00 00 31 08 0C
F3 B8 01 80 00 00 40 04 11 04 44 01 40 00 00 FF FE
2F 8B 12 02 40 00 00 00 00 53 8C AA 02 80 00 00 00
00 62 89 C4 01 80 00 00 00 00 41 41 40 01 40 00 00
00 00 01 42 80 02 40 00 20 00 00 01 42 80 02 80 01
F0 00 00 00 A2 80 01 80 0F FE 00 00 00 A5 00 01 5F
FF FF FF FF FE A5 7F FA 40 0A AA 00 00 00 55 00 02
82 01 50 04 40 01 5D 08 A1 88 10 24 80 00 40 FF 02
01 40 41 00 01 00 03 AB E0 02 44 00 00 08 20 0D 55
58 82 80 10 14 40 00 1A AA AC 01 80 00 00 00 00 35
55 56 01 40 01 00 00 80 6A AA AB 02 40 00 00 00 00
55 55 55 02 80 00 00 00 00 00 00 00 01 99 99 99 99
99 99 99 99 99 66 66 66 66 66 66 66 66 66

As we know, when we send text SMS, we encode our text into PDU. So the same method will be used for the picture SMS.

PDU for Picture SMS (Encoding Picture)

The following example shows how to encode a picture SMS. The example includes a picture and a text "Test". The length of the Picture message is so long that the message must be sent as a concatenated message (in three SMS). Here is the encoded data:

First part: (length =140)

8C0B0504158A00000003010301300000045465737402010000481C0166666666
6666666666999999999999999999800000000000000001400000006000E00002
400000E900310000280000031080CF3B801800000400411044401400000FFFE2
F8B12024000000000538CAA0280000000006289C401800000000041414001400
00000001428002400020000

Second part: (length =140)

8C0B0504158A00000003010302014280028001F0000000A28001800FFE000000
A500015FFFFFFFFFFEA57FFA400AAA0000005500028201500440015D08A18810
2800040FF0201404100010003ABE00244000008200D55588280101440001AAAA
C0180000000003555560140010000806AAAAB024000000000555555028000000
000000000199999999999999

Third part: (length =23)

170B0504158A000000030103039999666666666666666666

Explanation for the First Part

  • 8C length of part 1 (280/2=140(dec) and 8C(hex) because our data is in hex)
  • 0B length of user data header
  • 05 Identifier (IEI; application port addressing scheme, 16-bit port address)
  • 04 Information Element Data Length (IEDL)
  • 158A Information Element Data (destination port)
  • 0000 Information Element Data (originator port)
  • 00 Information Element Identifier (IEI; concatenated short message, 8-bit reference number)
  • 03 Information Element Data Length (IEDL)
  • 01 Information Element Data (concatenated short message reference number)
  • 03 Information Element Data (total number of concatenated messages (0-255))
  • 01 Information Element Data (sequence number of current short message)
  • 30 Identifier for version, current version is (ASCII) zero "0". If it is not "0", stop processing of the message.
  • 00 "00"
  • 00 Text length
  • 04 Text length
  • 54657374 "Test"
  • 02 "02" =
  • 0100 value 0100(hex) = 256(dec) = 4 octets for header and the rest for OTA bitmap data
  • 00 The first byte of the bitmap must be 00 (hex); i.e., OTA bitmap header field 'number of animated icons' must hold 0, indicating that there is no animation, just a single static image.
  • 48 Width = 48(hex) = 72(dec)
  • 1C Height = 1C(hex) = 28(dec)
  • 01 The depth of the bitmap (number of grey scales)

All the rest is the image data.

Explanation for the Second Part

  • 8C length of part 2 (280/2=140(dec) and 8C(hex) because our data is in hex)
  • 0B length of user data header
  • 05 Identifier (IEI; application port addressing scheme, 16-bit port address)
  • 04 Information Element Data Length (IEDL)
  • 158A Information Element Data (destination port)
  • 0000 Information Element Data (originator port)
  • 00 Information Element Identifier (IEI; concatenated short message, 8-bit reference number)
  • 03 Information Element Data Length (IEDL)
  • 01 Information Element Data (concatenated short message reference number)
  • 03 Information Element Data (total number of concatenated messages (0-255))
  • 02 Information Element Data (sequence number of current short message)

All the rest is the image data.

Explanation for the Third Part

  • 17 length of part 3 ((48-2)/2=23(dec) and 17(hex) because our data is in hex)
  • 0B length of user data header
  • 05 Identifier (IEI; application port addressing scheme, 16-bit port address)
  • 04 Information Element Data Length (IEDL)
  • 158A Information Element Data (destination port).
  • 0000 Information Element Data (originator port)
  • 00 Information Element Identifier (IEI; concatenated short message, 8-bit reference number)
  • 03 Information Element Data Length (IEDL)
  • 01 Information Element Data (concatenated short message reference number)
  • 03 Information Element Data (total number of concatenated messages (0-255))
  • 03 Information Element Data (sequence number of current short message)

All the rest is the image data.

Now we have divided our image into a number of parts. So add the following data in the front of each part.

0051000C91xxxxxxxxxxxx00F5A7

Explanation

  • 00 always added
  • 5100 not going to explain here
  • 0C length of phone number
  • 91 phone number format (91=international and 81=national)
  • xxxxxxxxxxxx 12 digit phone number (for example my phone number is 23216427434. write it as 292361244743)
  • 00F5 not going to explain here
  • A7 time limit (24 hours in this case)

Complete Example

SMS # 1:
0051000C913012467234F400F5A78C0B0504158A000000030103013000000
45465737402010000481C0166666666666666666699999999999999999980
0000000000000001400000006000E00002400000E90031000028000003108
0CF3B801800000400411044401400000FFFE2F8B12024000000000538CAA0
280000000006289C401800000000041414001400000000014280024000200000

SMS # 2:

0051000C913012467234F400F5A78C0B0504158A000000030103020142800
28001F0000000A28001800FFE000000A500015FFFFFFFFFFEA57FFA400AAA
0000005500028201500440015D08A188102800040FF0201404100010003AB
E00244000008200D55588280101440001AAAAC01800000000035555601400
10000806AAAAB024000000000555555028000000000000000199999999999999

SMS # 3:
0051000C913012467234F400F5A7170B0504158A0000000301030399996666
66666666666666

Send Picture SMS

The code for how to send a simple text SMS is attached with this article. Just paste your SMS PDU and send your cute picture massage. Remember that I am using a serial port for the communication.

Or

You can use Windows hyper terminal for sending your message.

Start->Programs->Accessories->Communications->HyperTerminal

  • And then use the following commands for sending SMS:
  • AT+CMGF=0 (pdu mode, use the command only first time if you have multiple SMS like in our case, three SMS.)
  • AT+CMGW=(length of pdu, for example 153 in SMS # 1)
    > write your pdu, in the end press ctrl+z and then press Enter. If it will display Ok, then succeeded. It will also display the message number.
  • AT+CMSS=(message number)

And now your message has been sent.

You can download code from here.

4 comments:

  1. assalamwalaikum,
    Shakeel Mumtaz, I came across ur blog for how to send a picture sms in b/w format
    from PC to mobile. and u r also working on the mms pattern using C lang,did that work?..if it did,then i have an open offer for you..please mail your reply at:-abu.ahmed786@yahoo.co.in or arbanahmed@gmail.com. FROM "lets talk business"

    ReplyDelete
  2. can anyone plz help me to send a web to mobile text sms .....plz plz

    ReplyDelete