Ady Wicaksono Daily Activities

Archive for February 10th, 2008

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

choose-sim-receiver.jpg
sim-receiver-listening-for-incoming-sms.jpg

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

sim-receiver-receive-sms.jpg

Advertisements

Written by adywicaksono

February 10, 2008 at 6:52 am

Posted in j2me, SMS