JAVA Program For Processing SMS Messages



Similar documents
Network/Socket Programming in Java. Rajkumar Buyya

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus

Application Development with TCP/IP. Brian S. Mitchell Drexel University

Creating a Simple, Multithreaded Chat System with Java

Building a Multi-Threaded Web Server

Communicating with a Barco projector over network. Technical note

Network Communication

Lesson: All About Sockets

TP1 : Correction. Rappels : Stream, Thread et Socket TCP

Transport layer protocols. Message destination: Socket +Port. Asynchronous vs. Synchronous. Operations of Request-Reply. Sockets

Intel Retail Client Manager Audience Analytics

Socket-based Network Communication in J2SE and J2ME

Java Network. Slides prepared by : Farzana Rahman

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

JAVA - MULTITHREADING

LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development

AVRO - SERIALIZATION

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

NETWORK PROGRAMMING IN JAVA USING SOCKETS

Learning Outcomes. Networking. Sockets. TCP/IP Networks. Hostnames and DNS TCP/IP

Overview of Web Services API

Sample CSE8A midterm Multiple Choice (circle one)

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O

ResellerPlus - Bulk Http API Specification. (This Document gives details on how to send messages via the Bulk HTTP API for the RouteSms SMPP System)

OBJECT ORIENTED PROGRAMMING LANGUAGE

Mail User Agent Project

Continuous Integration Part 2

Part I. Multiple Choice Questions (2 points each):

An Android-based Instant Message Application

File I/O - Chapter 10. Many Stream Classes. Text Files vs Binary Files

CS 121 Intro to Programming:Java - Lecture 11 Announcements

CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement

An Overview of Java. overview-1

Manual. Programmer's Guide for Java API

Java Network Programming. The java.net package contains the Socket class. This class speaks TCP (connection-oriented protocol).

Question1-part2 What undesirable consequences might there be in having too long a DNS cache entry lifetime?

Introduction to Java

Socket Programming. Announcement. Lectures moved to

T-BOXN12R. First steps with T-BOXN12R. You can make it wireless. Date: Version 1.0

Telit AppZone Programming Tips

matsimj An Overview of the new MATSim Implementation in Java Marcel Rieser VSP, TU Berlin

JAVA - FILES AND I/O

MSDG Services Integration Document Draft Ver 1.2

Capabilities of a Java Test Execution Framework by Erick Griffin

Socket Programming in Java

Agenda. Network Programming and Java Sockets. Introduction. Internet Applications Serving Local and Remote Users

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Advanced Network Programming Lab using Java. Angelos Stavrou

Topic 11 Scanner object, conditional execution

J a v a Quiz (Unit 3, Test 0 Practice)

Design of Cloud based Instant Messaging System on Android Smartphone using Internet

The Java I/O System. Binary I/O streams (ascii, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits)

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

Crash Course in Java

CS170 Lab 11 Abstract Data Types & Objects

Java from a C perspective. Plan

2014 GSM SHIELD COMPATIBLE WITH ARDUINO GSM SHIELD USING SIMCOMM (SIM900A)

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Using the Monitoring and Report Viewer Web Services

Java Memory Model: Content

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Division of Informatics, University of Edinburgh

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Self Help Guide. Please read the following carefully; Synopsis: Requirements: A Computer with a working RJ45 LAN Port All Belkin Modem Routers

JDBC. It is connected by the Native Module of dependent form of h/w like.dll or.so. ex) OCI driver for local connection to Oracle

TATJA: A Test Automation Tool for Java Applets

The MAC address, short for Media Access Control address, is a number in hexadecimal format that uniquely identifies every machine on a network.

String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivepacket.getaddress(); int port = receivepacket.

Logging in Java Applications

JAVAMAIL API - SMTP SERVERS

Performance Testing from User Perspective through Front End Software Testing Conference, 2013

Virtuozzo Virtualization SDK

TUTORIAL FOR INITIALIZING BLUETOOTH COMMUNICATION BETWEEN ANDROID AND ARDUINO

COSC Introduction to Computer Science I Section A, Summer Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

1 Hour, Closed Notes, Browser open to Java API docs is OK

App Development for Smart Devices. Lec #4: Services and Broadcast Receivers Try It Out

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

Network Programming using sockets

Zebra and MapReduce. Table of contents. 1 Overview Hadoop MapReduce APIs Zebra MapReduce APIs Zebra MapReduce Examples...

Object Oriented Software Design

VoxStack GSM Gateway API. Version: Author: Joe.Yung

Onset Computer Corporation

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

The following program is aiming to extract from a simple text file an analysis of the content such as:

Domain Name System (DNS) Omer F. Rana. Networks and Data Communications 1

Introduction to Object-Oriented Programming

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty("java.security.policy","../server.java.

DNS: Domain Names. DNS: Domain Name System. DNS: Root name servers. DNS name servers

Interactive Applications (CLI) and Math

See the Developer s Getting Started Guide for an introduction to My Docs Online Secure File Delivery and how to use it programmatically.

public static void main(string[] args) { System.out.println("hello, world"); } }

Installing Java (Windows) and Writing your First Program

Java Programming Fundamentals

Informatica e Sistemi in Tempo Reale

Transcription:

JAVA Program For Processing SMS Messages Krishna Akkulu The paper describes the Java program implemented for the MultiModem GPRS wireless modem. The MultiModem offers standards-based quad-band GSM/GPRS Class 10 performance. Also the GPRS wireless modem with an Ethernet interface provides shared Internet access with one IP address. The advantage of Ethernet interface is any machine which is on network can communicate to with the modem. The picture shows MultiModem GPRS wireless modem. Generally programmers use AT commands through Telnet to send and receive the messages from the Modem. But most of the software applications prefer to send or receive the commands through programs depends on certain events occur in an application. Example let us say a software application determines the room temperature increased or earth quake or fire alert occurred, then the program has to notify, the operator by sending SMS message etc. In such situations telnet program may not be good a solution. So, in this paper the telnet application has been simulated with Java Socket program. The present Java program demonstrates sending and receiving SMS messages to/from cell phones.

The AT commands used for receiving SMS messages are: 1) at+cmgf=1 (The command sets to text mode) 2) at+cnmi=2,2,0,0,0 (selects the procedure for message reception from the network) Now the Modem is ready to receive the SMS messages. The AT commands used for Sending SMS messages are: 1) at+cmgf=1 (if already set Text mode then not required.) 2) at+cmgs="1234567890" (type phone number and then press Enter) (now > symble will be displayed. After the symbol type message) 3) > This is test message (after the message hit <CTRL+Z> to send the message) Then the following message will be received. That means Modem indicating the SMS message has been sent successfully. +CMGS:16 OK The Java Class name is GPRSMultiModem. The class implements Runnable interface to achieve multithreading feature. The Main APIs in the program are. 1) Connect(InetAddress ModemAddress, int Port) With given IPAddress and Port number connects to the Modem. 2) ReceiveMsg() This method uses DataInputStream s readline() to read the messages from Modem. Also to the messages continuously ReceiveMsg() methods implemented as Thread function. 3) SendMsg(String strmsg, boolean bvalue) This is a general API used to send all messages to Modem. Except for SMS messages for all other messages bvalue is false. SMS Messages needs <CTRL+Z> to be hit at the end of messages. So this will be achieved with DataOutputStream s writebyte(0x1a) API. 0x1A represents <CTRL+Z>. writebyte(0x1a) will be invoked only when bvalue is true. 4) PrepareSMSMsg (String strphone, String strmsg) The method First send "at+cmgs=\""+strphone+"\"" (at+cmgs = "1234567890") Then Modem send response > Now call SendMsg(strMsg, true); 5) CloseSocket() Close Socket Connection.

*************** * Java program listing is given below * **************** import java.io.datainputstream; import java.io.dataoutputstream; import java.io.ioexception; import java.net.inetaddress; import java.net.socket; import java.net.unknownhostexception; public class GPRSMultiModem implements Runnable String m_modemaddress ="172.16.1.242"; int m_port =5000; DataInputStream is = null; Socket MultiModemSocket = null; DataOutputStream os = null; boolean bconnected =false; boolean bwaittorecv =true; Thread threadobj= new Thread(this,""); *main method *@param args public static void main(string[] args) GPRSMultiModem objgprsmultimodem = new GPRSMultiModem(); InetAddress m_modemaddress = InetAddress.getByName( objgprsmultimodem.m_modemaddress); objgprsmultimodem.connect(m_modemaddress, objgprsmultimodem.m_port); Thread.sleep(1000); objgprsmultimodem.threadobj.start(); objgprsmultimodem.sendmsg("at+cmgf=1\r\n",false); Thread.sleep(2000); objgprsmultimodem.sendmsg( "at+cnmi=2,2,0,0,0\r\n",false); Thread.sleep(1000); objgprsmultimodem.preparesmsmsg("4084449451", "Hello Krishna");

catch(exception e) System.out.println("Modem Error "); *run method of Runnable interface *@param args public void run() ReceiveMsg(); *Connect method of Runnable interface *@param InetAddress, Port public void Connect(InetAddress ModemAddress, int Port) MultiModemSocket = new Socket( ModemAddress.getHostName(), Port); os = new DataOutputStream( MultiModemSocket.getOutputStream()); is = new DataInputStream( MultiModemSocket.getInputStream()); bconnected=true; catch (UnknownHostException e) bconnected=false; System.out.println("Don't know about host - "); bconnected=false; System.out.println("Couldn't get I/O for the connection to: hostname - "); ** * Close the Socket connection * public void CloseSocket()

os.close(); is.close(); MultiModemSocket.close(); bconnected=false; System.out.println("Close Sockets"); System.out.println(e.getLocalizedMessage()); ** * Receive Messages from MultiModem. ** public void ReceiveMsg() while(bwaittorecv) String responseline=""; SendMsg("\r",false); int iter =0; if (is!= null) while (iter<20) responseline = is.readline(); Thread.sleep(1000); if(!responseline.isempty()) break; iter++; catch (UnknownHostException e) System.out.println("Trying to connect to unknown host: " + e.getlocalizedmessage());

System.out.println(e.getLocalizedMessage()); catch (Exception e) System.out.println(e.getLocalizedMessage()); if(!responseline.isempty()) System.out.println("responseLine = "+responseline); *Connect method of Runnable interface *@param String, boolean public void SendMsg(String strmsg, boolean bvalue) if (MultiModemSocket!= null && os!= null && is!= null) if(bvalue) os.writebytes(strmsg); os.writebyte(0x1a); else os.writebytes(strmsg); catch (UnknownHostException e) System.out.println("Trying to connect to unknown host: " + e.getlocalizedmessage()); System.out.println("IOException: " + e.getlocalizedmessage()); ******** * Prepare SMS Msg Command *@param String, String ******** public void PrepareSMSMsg(String strphone, String strmsg)

String Str ="at+cmgs=\""+strphone+"\""; SendMsg(Str, false); Thread.sleep(5000); SendMsg(strMsg, true); catch (Exception e) System.out.println("IOException: " + e.getlocalizedmessage());