Ady Wicaksono Daily Activities

Sending SMS to J2ME application

with 14 comments

The Wireless Messaging API (WMA) is an optional package for J2ME that
provides platform-independent access to wireless communication resources
like Short Message Service (SMS). If URI for HTTP is defined by http://
then URI for SMS resource is defined by sms://. Example resource identifier
for SMS is sms://:50000, means the port of SMS is 50000.

For example you have a J2ME application that listen to specific port, then
how to send SMS to the receiver would be this J2ME application? Simple approach
is to create another J2ME application that act as sms sender. But what is the
real PDU (protocol data unit) involved for sending it?

If you see GSM 03.40 specification, you will find that we need to set some
special UDH (user data header) inside the 140 octet of TP-UD. This UDH is like this
060504C3500000, the details is:
0x06 : TP-UDHL, means the user data header length -> length of “0504C3500000” = 6 octet
0x05 : Application port addressing scheme, 16 bit address, means we have port range up
to 2^16 = 65536, so port 50000 is in the range
0x04 : Length of application port addressing scheme -> length of “C3500000” = 4 octet
0xC350: Destination port, convert 0xC350 to decimal, you will have 50000
0x0000: Source port

For working example, please run this WMA java example taken from Sun JME toolkit
On the phone side we see that application is waiting for incoming SMS at port 50000


We’re now sending the SMS using AT+command, here’s the PDU:


To break down that PDU please refer to GSM 03.40 :), meanwhile I will focus on the 1st byte
that inform us that this PDU contain UDHI (user data header indicator) and the TP-UD of SMS
which is 1F060504C3500000496E6920636F6E746F6820666C61736820534D53206C686F

1F: TP-UDL (user data length)
060504C3500000 : this is the UDH (see above)
496E6920636F6E746F6820666C61736820534D53206C686F : this is the data

and here’s the screenshot at the mobile phone after receiving this SMS


Written by adywicaksono

February 10, 2008 at 6:52 am

Posted in j2me, SMS

14 Responses

Subscribe to comments with RSS.

  1. Hello aywickasono,

    I believe this is an excellent article, I have been asked to develop something similar, If you can share your code it will be a lot clearer.



    October 9, 2008 at 8:50 am

  2. Hi aywickasono,
    thanks for your article,can you explain which part is encoded code is destination phone,SMSC,destination port number.


    October 20, 2008 at 3:01 pm

  3. hi,
    Could you please explain me how to send at commands in a MDLEt?, how do you achive that, could you share the code or only these part of the code.
    I made an app. which send sms to many phones, everything goes fine but the messages(which app. said are sent) never arrived to the phones?


    November 25, 2008 at 6:11 pm

  4. Hi aywickasono,

    You can tell as to specify the port? text messaging is sms: / /: 50000, but to put it where PDU? Words and could share your code, also needs to know how to send an sms by PDU specifying the port as with SMS, which is to send the message PDU is as follows:

    +CMGW: 507

    but did not specify the destination port, please help me.


    December 18, 2008 at 1:24 am

  5. Hi!
    Can you tell me How to send SMSes to a specified port of a phone by using AT commands across GSM modemm??
    please help me


    January 6, 2009 at 5:26 am

  6. Hello aywickasono,,

    This article was really helpful.Can u pls give the code..



    January 15, 2009 at 11:22 am

  7. Can you send me the source code of this app please.
    I have some new SMS to read from device side and do some stuff.

    please provide me it so help full.


    February 16, 2009 at 4:34 am

  8. Thank’s coi


    August 21, 2009 at 10:08 am

  9. Hi

    Thanks for your article. Could you please explain me how to send at commands in a MDLET? and can you explain which part is encoded code is destination phone,SMSC,destination port number.

    Sending SMS

    October 22, 2009 at 10:23 am

  10. Hi!
    If I understood well U have developed a MIDLET that send SMS coded like PDUs.
    Could u please share the code?

    Tks a lot.


    November 15, 2009 at 7:54 am

  11. post details to me


    January 1, 2010 at 4:06 am

  12. Your Visual Description
    had given me confidence, that we can get sms by listening on specific port through java code. Could u tell me, how u have send the sms on mobile by modifying UDH. What application to use to send such type of message (basically binary sms)?

    Satyadev Chauhan

    March 25, 2011 at 10:31 am

    • it’s AT+command only to send SMS using mobile connected to serial/USB


      May 28, 2011 at 6:12 am

  13. mas..buku pemrograman aplikasi wireless dengan java nya..apakah masih????
    lg butuh nih…


    June 9, 2011 at 9:04 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: