Sunday, June 01, 2008

My Thesis - Literature Study - JSR 120

According to WMA specification [1], JSR-120 is Wireless Messaging API for J2ME. This API allows J2ME applications (MIDlets) to send and receive messages which widely known as Short Message Service (SMS). It allows MIDlets to create a message connection to both local and remote devices by using the MessageConnection class. The connection can be opened using the Connector.open(String argument) method with string of “sms://” followed by the phone number and the messaging port number as the argument. Later on, the MIDlet can use this connection to send and receive messages by using the send() and receive() method respectively. The object of the message itself can be created by using the Message class. Then, the MIDlet can put the text content of the message into the message object or get the text content out of the message object by using the setPayloadText() or the getPayloadText() method respectively.

In this thesis project, JSR-120 will be used to employ the Push Registry feature of J2ME (JSR-118). Thus, the client will be able to send a SMS in order to wake up the server application.


Reference:
[1] Wireless Messaging API (WMA) for Java 2 Micro Edition version 1.1, JSR-120 Expert Group. wma-1_1-mr-spec.pdf.

2 comments:

Anonymous said...

please provide me JSR 120 Java apps.. if you have and send me detailed steps to prepare it.

my email: santosha_vb@yahoo.co.in

Antony Gumi said...

Sorry, I cannot provide u with the app since it's attached to the main app of my thesis project. Here I provide u with part of my source code which involves JSR 120:

/*
* clsSMS.java
*
* Created on March 21, 2008, 6:31 PM
*/

package myPackage;

import java.io.IOException;
import java.io.InterruptedIOException;
import javax.microedition.io.Connector;
import javax.wireless.messaging.Message;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.MessageListener;
import javax.wireless.messaging.TextMessage;

/**
*
* @author Antony Gumi
* kerjaannyagumi.blogspot.com
*/

public class clsSMS {
//target port is port 7500, mentioned in clsGlobalSetting
clsGlobalSetting mySetting;
private MessageConnection myMC;
/** Creates a new instance of clsSMS */
public clsSMS() {
}

public void sendSMS(String myMsg, String myURL) throws IOException,Exception,SecurityException{
myURL="sms://"+myURL+":"+mySetting.mySmsPort;
myMC=(MessageConnection)Connector.open(myURL);
TextMessage myTxtMsg=(TextMessage)myMC.newMessage(MessageConnection.TEXT_MESSAGE);
myTxtMsg.setAddress(myURL);
myTxtMsg.setPayloadText(myMsg);
myMC.send(myTxtMsg);
}
public String retrieveSMS()throws Exception{
String myURL="sms://:"+mySetting.mySmsPort;
String msgContent=null;

myMC=(MessageConnection)Connector.open(myURL);
Message myMsg=null;
myMsg=myMC.receive();
if(myMsg instanceof TextMessage){
TextMessage myTxtMsg=(TextMessage)myMsg;
msgContent=myTxtMsg.getPayloadText();
}
return msgContent;
}

}