RSMS Ucp 1.0



RSmsUcp is a Java[TM] component that can sms messages using the Ucp protocol. The component can establish a connection to a SMSC (Short Message Service Centre) using:

About the evaluation version

The evaluation version will always insert an additional text to your sms messages.


In order to install the component you must:

if you want to use a dial up connection you will also need the Java[TM] Communications API:

if you want to use TCP/IP, no additional libraries are required.

How to send SMS Messages


The component includes a high level class called SmsSender which allows you to send sms message without having to deal with the ucp details. This class works in the following way:

  1. create SmsSender and provide the adapter as parameter (modem or tcp/ip)
  2. create message ( you can use createSMS30, createSMS01 or createSMS51)
  3. send the message with sendMessage()

1. Using a dial up connection

The following program will send a sms using a dial up connection:

// create object
Modem modem= new Modem();
modem.dataBits=SerialPort.DATABITS_8; // do not forget to check if the SMSC uses 7 or 8 bits

// open port , initialize and connect
if (modem.openPort()) {
if (modem.initializeModem())

if (modem.dial("900900900")) {

// send the sms now using the Modem adapter
SmsSender sender=new SmsSender(modem);

// close connection



2. Using a TCP/IP connection

The following program will send a sms using a tcp/ip connection:

// create object
TcpIpAdapter tcp=new TcpIpAdapter();

// send the sms now using the tcp/ip adapter
SmsSender sender=new SmsSender(tcp);



3. Using low level classes

As an alternative to the SmsSender class you can also create the ucp messages yourself. This has the advantage that you can use all available features. The low level classes can be used as follows:

  1. create a message (for example, BasicSubmitMessage() or TransferMessage51())
  2. send the message
  3. get response from SMSC
  4. evaluate response


// step 1, create message
BasicSubmitMessage currentMessage= new BasicSubmitMessage();
((BasicSubmitMessage) currentMessage).originator=from;
((BasicSubmitMessage) currentMessage).recipient=destination;
((BasicSubmitMessage) currentMessage).alphaMessage=message;

// step 2 , send message
byte[] b=currentMessage.toBytes();
adapter.transmitBytes(b,b.length); // adapter is either modem or tcpip

// step 3 get response
byte[] responseb=adapter.receiveData(UcpMessage.ETX_CHAR,30);

if (responseb==null) throw new SmsException("Response is null");

// step 4 process response

if (currentResponse==null) throw new SmsException("Could not parse "+ new String(responseb));

if (currentResponse instanceof ResponseMessage) {

if (((ResponseMessage) currentResponse).Response.compareTo("A")==0) System.out.println("Message was sent successfully");
elseif (((ResponseMessage) currentResponse).Response.compareTo("N")==0) System.out.println("Message failed: " + ((ResponseMessage) currentResponse).errorDescription);
else throw new SmsException("Response not recognized "+ new String(responseb));

else throw new SmsException("Response message not received : "+ currentResponse.getClass());