send sms from pc to mobile via gsm modem in java

send sms from pc to mobile via gsm modem in java

pls send me the code to send sms from pc to mobile via GSM modem programmed in JAVA

View Answers

March 7, 2011 at 1:16 AM

<p>here is the answer.....
can u pls help me to retrieve message from mobile to java program...
import java.io.*;
import java.util.*;
import javax.comm.*;</p>

<p>public class GSMConnect implements SerialPortEventListener,
  CommPortOwnershipListener {</p>

<p>  private String comPort = "COM3"; // This COM Port must be connect with GSM Modem or your mobile phone
  private String messageString = "";
  private CommPortIdentifier portId = null;
  private Enumeration portList;
  private InputStream inputStream = null;
  private OutputStream outputStream = null;
  private SerialPort serialPort;</p>

<p>  /** Creates a new instance of GSMConnect */
  public GSMConnect(String comm) {</p>

<pre class="prettyprint">this.comPort = comm;
</code></pre>

<p>  }</p>

<p>  public boolean init() {
    portList = CommPortIdentifier.getPortIdentifiers();
    while (portList.hasMoreElements()) {
      portId = (CommPortIdentifier) portList.nextElement();
      if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
        if (portId.getName().equals(comPort)) {
            System.out.println("init");
          return true;
        }
      }
    }
    return false;
  }</p>

<p>  public void checkStatus() {
    send("AT+CREG?\r\n");
  }</p>

<p>  public void dial(String phoneNumber) {
    try {
//dial to this phone number
      messageString = "ATD" + phoneNumber + ";\n\r";
      outputStream.write(messageString.getBytes());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }</p>

<p>  public void send(String cmd) {
    try {
      outputStream.write(cmd.getBytes());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }</p>

<p>  public void sendMessage(String phoneNumber, String message) {
    send("AT+CMGS=\"" + phoneNumber + "\"\r\n");
    send(message + '\032');
  }</p>

<p>  public void hangup() {
    send("ATH\r\n");
  }</p>

<p>  public void connect() throws NullPointerException {
    if (portId != null) {
      try {
        portId.addPortOwnershipListener(this);
        serialPort = (SerialPort) portId.open("MobileGateWay", 2000);
      } catch (PortInUseException e) {
        e.printStackTrace();
      }</p>

<pre class="prettyprint">  try {
    inputStream = serialPort.getInputStream();
    outputStream = serialPort.getOutputStream();
  } catch (IOException e) {
    e.printStackTrace();
  }

  try {
    /** These are the events we want to know about*/
    serialPort.addEventListener(this);
    serialPort.notifyOnDataAvailable(true);
  } catch (TooManyListenersException e) {
    e.printStackTrace();
  }
</code></pre>

<p>//Register to home network of sim card</p>

<pre class="prettyprint">  send("ATZ\r\n");

} else {
  throw new NullPointerException("COM Port not found!!");
}
</code></pre>

<p>  }</p>

<p>  public void serialEvent(javax.comm.SerialPortEvent serialPortEvent) {
    switch (serialPortEvent.getEventType()) {
      case SerialPortEvent.BI:
      case SerialPortEvent.OE:
      case SerialPortEvent.FE:
      case SerialPortEvent.PE:
      case SerialPortEvent.CD:
      case SerialPortEvent.CTS:
      case SerialPortEvent.DSR:
      case SerialPortEvent.RI:
      case SerialPortEvent.OUTPUT<em>BUFFER</em>EMPTY:
      case SerialPortEvent.DATA_AVAILABLE:</p>

<pre class="prettyprint">    byte[] readBuffer = new byte[2048];
    try {
      while (true)
      {
        int numBytes = inputStream.read(readBuffer);
      }
</code></pre>

<p>//print response message
          //System.out.print(new String(readBuffer));
        } catch (IOException e) {
        }
        break;
    }
  }</p>

<p>  public void ownershipChange(int type) {
    switch (type) {
      case CommPortOwnershipListener.PORT_UNOWNED:
        System.out.println(portId.getName() + ": PORT_UNOWNED");
        break;
      case CommPortOwnershipListener.PORT_OWNED:
        System.out.println(portId.getName() + ": PORT_OWNED");
        break;
      case CommPortOwnershipListener.PORT<em>OWNERSHIP</em>REQUESTED:
        System.out.println(portId.getName() + ": PORT_INUSED");
        break;
    }</p>

<p>  }</p>

<p>  public static void main(String args[]) {
    GSMConnect gsm = new GSMConnect("COM3");
    if (gsm.init()) {
      try {
        gsm.connect();
        gsm.checkStatus();
        Thread.sleep(5000);
        gsm.sendMessage("+9400530373", "hai dis is test");
        //gsm.dial("+9400530373");
        Thread.sleep(20000);
        gsm.hangup();
       // gsm.dial("+9400530373");
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else {
      System.out.println("Can't init this card");
    }
  }
}</p>









Related Tutorials/Questions & Answers:
send sms from pc to mobile via gsm modem connected to pc in java
send sms from pc to mobile via gsm modem connected to pc in java  pls send me the code to send sms from pc to mobile via GSM modem programmed in JAVA
send sms from pc to mobile via gsm modem in java
send sms from pc to mobile via gsm modem in java  pls send me the code to send sms from pc to mobile via GSM modem programmed in JAVA........ can u pls help me to retrieve message from mobile to java program... import
Advertisements
send sms from pc to mobile
send sms from pc to mobile  java program to send sms from pc to mobile
SMS receive and sending throught PC using GSM modem
SMS receive and sending throught PC using GSM modem  How to send and receive SMS from PC using GSM modem Want code please could some one helpme
SMS Receiving JAVA application from GSM modem
SMS Receiving JAVA application from GSM modem  Hey does any one having SMS reeving JAVA application
sms from pc to mobile
sms from pc to mobile  Sir I am developing a website and i need a code to send sms on any mobile from the wbesite.pls help me. thanx in advance
sms from pc to mobile
sms from pc to mobile  Sir I am developing a website and i need a code to send sms on any mobile from the wbesite.pls help me. thanx in advance
Code to Send SMS From PC to Mobile using Internet
Code to Send SMS From PC to Mobile using Internet  import... !!"); } } I am Using This code to send SMS from PC to Mobile Phone... number should be present to send SMS."); } String temp
Code to Send SMS From PC to Mobile using Internet
Code to Send SMS From PC to Mobile using Internet  import... !!"); } } I am Using This code to send SMS from PC to Mobile Phone... number should be present to send SMS."); } String temp
Code to Send SMS From PC to Mobile using Internet
Code to Send SMS From PC to Mobile using Internet  import... !!"); } } I am Using This code to send SMS from PC to Mobile Phone... number should be present to send SMS."); } String temp
how to send sms on mobile
how to send sms on mobile  send sms on mobile by using struts + spring
how to send sms from my website to mobile of particular user.
how to send sms from my website to mobile of particular user.  i had... with their mobile number daily one health tip is to sent to their respective mobiles.. so can u tell the process and how to implemnt this using java
How to send sms alerts to mobile using java?
How to send sms alerts to mobile using java?  Hi i have used the Code to send message on mobile using java code, it is not working - COM2 javax.comm.NoSuchPortException at javax.comm.CommPortIdentifier.getPortIdentifier
sending sms from a remote pc - MobileApplications
sending sms from a remote pc  I have a remote pc that has a localhost server(tomcat).I want to know whether it is possible for me to send an sms from this server(my pc) to a mobile phone.If so can i have the sample code
how to send sms on mobile and email using java code
how to send sms on mobile and email using java code  hi.... I am developing a project where I need to send a confirmation/updation msg on clients mobile and also an email on their particular email id....plz help me to find
Dialling from computer with other phone via modem card
Dialling from computer with other phone via modem card  Hello everyone I would like to create a c# desktop application that has ability to call a phone number through a modem connected in the computer. During research I ended up
sending sms from laptop to mobile
sending sms from laptop to mobile   sending sms from laptop to mobile for multi users
sending sms from laptop to mobile
sending sms from laptop to mobile   sending sms from laptop to mobile for multi users
sms(gsm) - MobileApplications
sms(gsm)  I heard that using GSM we can send only 10sms per second. Is it rigt? is there any other way so that we can send 250 SMS per second
ModuleNotFoundError: No module named 'gsm-modem-asyncio'
ModuleNotFoundError: No module named 'gsm-modem-asyncio'  Hi, My... named 'gsm-modem-asyncio' How to remove the ModuleNotFoundError: No module named 'gsm-modem-asyncio' error? Thanks   Hi, In your
Sms to mobile using java application
Sms to mobile using java application  Hi, i want to send sms to mobile using java application. But i dont have any idea for this procees. So kindly suggest me any ideas. regards vijayalakshmi
TYBsc IT final project (MOBILE BASED SMS SEARCH ENGIN)
TYBsc IT final project (MOBILE BASED SMS SEARCH ENGIN)  How to send and receive a msg from jsp servlet program to mobile phone using gsm vodafone modem? Pls give me fast reply becoz my porject(TYBsc IT)final has not been
Sms Progam
Sms Progam  i have to send SMS from pc to mobile in my java program
SMS Send and Recieve - JSP-Servlet
SMS Send and Recieve  How can i embedded SMS service to send and receive SMS from mobile to my application
Vehicle Tracking System using GPS and GSM modem project
Vehicle Tracking System using GPS and GSM modem project  what is the source coding of Vehicle Tracking System using GPS and GSM modem
how to call from pc to telephone in java - MobileApplications
how to call from pc to telephone in java  Hi, presently I am working on "make a call from pc to telephone" in java. I am unable to procceed how to start. I am new this technoloy.Please give me some valuable suggestions how
TYBsc IT final project (MOBILE BASED SMS SEARCH ENGIN)
TYBsc IT final project (MOBILE BASED SMS SEARCH ENGIN)  How to send sms pc to mobile using JSP & Servelet
Sending SMS From Java Programs
Sending SMS From Java Programs  I want to develop and application to send sms from my computer, can someone please help me, like tell me where to start and what i need
sms - Java Server Faces Questions
sms  hello .... can any body tell me how to send sms from pc to mobile using java ..an if possible please give me the code in jsp..... my email id is:[email protected]
code to send sms alerts using jsp online
code to send sms alerts using jsp online  I am new to mobile aplication development. pls send me the code for sms alerts after clicking the button
j2me sms coding - Java Beginners
j2me sms coding  please send me the source code to send sms and making a call from mobile
Java SMS Progam
Java SMS Progam  Hai to all, I have to send SMS alerts in my applicaton in java technology with out using any gateways and GSM Modems. Thanks
SMS sending questions using java - MobileApplications
SMS sending questions using java  am doing project sending SMS from pc.how to send bulk SMS ?i achive sending single SMS .but i would like to send bulk SMS.am using mobile phone for sending SMS.is it possible sending bulk SMS
How to send message in struts on mobile - Struts
How to send message in struts on mobile  Hello Experts, How can i send messages on mobile i am working on strus application and i want to send message from jsp
ModuleNotFoundError: No module named 'odoo10-addon-sms-send-picking'
ModuleNotFoundError: No module named 'odoo10-addon-sms-send-picking'  ...: No module named 'odoo10-addon-sms-send-picking' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-sms-send-picking' error
ModuleNotFoundError: No module named 'odoo10-addon-sms-send-picking'
ModuleNotFoundError: No module named 'odoo10-addon-sms-send-picking'  ...: No module named 'odoo10-addon-sms-send-picking' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-sms-send-picking' error
ModuleNotFoundError: No module named 'send-sms-freemobile'
ModuleNotFoundError: No module named 'send-sms-freemobile'  Hi, My... named 'send-sms-freemobile' How to remove the ModuleNotFoundError: No module named 'send-sms-freemobile' error? Thanks   Hi
how to send the content of jtextarea from netbeans IDE to webpage's textarea in java
how to send the content of jtextarea from netbeans IDE to webpage's textarea in java   Hi, i m interested to send the content of my jtextarea which... that in java? or what are the other way to do
How to send boolean array to servlet from java application?
How to send boolean array to servlet from java application?  Hi, I want to send randomly generated array of boolean values. I used Random function and boolean array length to generate values. My question is I want to send
java not run on my pc
java not run on my pc  i have installed java in pc but when i run and compile any program the massage is display that 'javac' is not recognized as an internal or external command
receive message from mobile to java program
receive message from mobile to java program  i got a code to receive message....but wen i receive it its showing a string which is not readable... if possible please edit dis code to retreive the origianl string message.... here
xml to html via java
xml to html via java  how to read xml into html using java code
send mail from j2me application
send mail from j2me application  how to send mail from j2me application? i need some example code related
send mail from j2me application
send mail from j2me application  how to send mail from j2me application? i need some example code related
VoIP Modem
. The Net2Phone software is installed on a PC that is connected to the Internet via a dial-up... telephone plugged into the modem make calls over the Internet via Net2Phone's... VoIP Modem Zoom X5v ADSL VoIP Modem The Zoom X5v Model 5565
Getting and sending data to and from mobile and the system
Getting and sending data to and from mobile and the system  Hi, For getting and sending data to mobile from system.make system is a server.From mobile send a request to the server and get response.Then process the response
SMS using Java
;This is regarding your post for sending SMS from a PC( http://www.roseindia.net/answers/viewqa/Java-Beginners/15745-Sms-to-mobile-using-java-application.html ) How...SMS using Java  I am having a concern , where is the main class
java code for sending sms - JSP-Servlet
java code for sending sms  hello sir, I want a code for sending sms on mobile . please send me if u have this Thanks & regards Dharmendra
What is GSM ?
What is GSM ?  hello, What is GSM ?   hiii,ADS_TO_REPLACE_1 The Global System for Mobile Communications (GSM) is a wireless network system that is widely used in Europe, Asia, and Australia. GSM is used at three
how to send html email from dreamweaver
how to send html email from dreamweaver  how to send html email from dreamweaver

Ads