Sending SMS to J2ME application
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:
0×06 : TP-UDHL, means the user data header length -> length of “0504C3500000″ = 6 octet
0×05 : Application port addressing scheme, 16 bit address, means we have port range up
to 2^16 = 65536, so port 50000 is in the range
0×04 : Length of application port addressing scheme -> length of “C3500000″ = 4 octet
0xC350: Destination port, convert 0xC350 to decimal, you will have 50000
0×0000: 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:
55010A91560996658600F5A71F060504C3500000496E6920636F6E746F6820666C61736820534D53206C686F
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



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.
Thanks
Raheal
October 9, 2008 at 8:50 am
Hi aywickasono,
thanks for your article,can you explain which part is encoded code is destination phone,SMSC,destination port number.
regards
sajjad
October 20, 2008 at 3:01 pm
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?
Regards
jorge
November 25, 2008 at 6:11 pm
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:
>at+cmgw=”+40727224499″
>0054006500730074
+CMGW: 507
OK
but did not specify the destination port, please help me.
Thanks.
Minetaky
December 18, 2008 at 1:24 am
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
Thanks!
VerĂ³nica
Minetaky
January 6, 2009 at 5:26 am
Hello aywickasono,,
This article was really helpful.Can u pls give the code..
regards,
sam
samuel
January 15, 2009 at 11:22 am
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.
Prasanth
February 16, 2009 at 4:34 am
Thank’s coi
Wahyu
August 21, 2009 at 10:08 am