receiving and sending sms through gsm modem - java

How can I receive SMS through a GSM modem so that I can use this SMS for further processing and send back a reply SMS.
I do not have particular idea on how to achieve this.......
I prefer using java language for this project and I am using Linux OS.

You might want to give a look at SMSLib:
SMSLib is a programmer's library for sending and receiving SMS
messages via a GSM modem or mobile phone. SMSLib also supports a few
bulk SMS operators.

To send an SMS using a 3G modem, you need to use the appropriate AT commands. First you need to set the modem to text mode:
AT+CMGF=1
Then you send your message:
AT+CMGS=<number><CR>
<message><CTRL-Z>
Where <CR> is a carriage return (ASCII 13), and <message> is the message you want to send, <CTRL-Z> is ASCII 26, and <number> is the number you want to send your message to.
To read received messages, you do this:
AT+CMGL=<stat><CR>
Where <stat> is one of: "ALL", "REC UNREAD", "REC READ" (with the quotes), meaning all messages, unread messages, and read messages respectively.
To do this in Java you'll need to use the Java communications API. Here's a short example:
http://java.sun.com/products/javacomm/reference/docs/API_users_guide_3.html

hi i'm using RXTX library the code goes here!.. and its works fine for me , i searched a lot of things to get correct method finaly got the key to sms!.. :D
String mValue = "AT\r";// strating to communicate with port starts here!
mOutputToPort.write(mValue.getBytes());
mOutputToPort.flush();
Thread.sleep(500);
mInputFromPort.read(mBytesIn);
value = new String(mBytesIn);
System.out.println("Response from Serial Device: "+value);
mValue = "AT+cmgf=1\r";
mOutputToPort.write(mValue.getBytes());
mOutputToPort.flush();
mValue="at+cmgs=\" Mobile number\"\r";
System.out.print(mValue);
mOutputToPort.write(mValue.getBytes());
mOutputToPort.flush();
mValue="at+cmgs="\032";//calling ctrl+z
System.out.print(mValue);
mOutputToPort.write(mValue.getBytes());
mOutputToPort.flush();
mOutputToPort.close();
mInputFromPort.close();

Take a look on SMSJ: a fully functional library that allows sending and receiving SMS using either GSM modem or several popular web services.

Take a look at the Java SMSLib API.
From the web site : "SMSLib is a programmer's library for sending and receiving SMS messages via a GSM modem or mobile phone. SMSLib also supports a few bulk SMS operators."

You shoud take a look at your modem manual. Some devices support telnet connection and you can sent AT commands via command line.
If this is your case you have to learn about (sometimes specific for each device), and code an application that uses telnet to communicate with your modem.
Apache Commons Net project can be useful.
Some AT commands guides:
http://www.portech.com.tw/data/Siemens%20TC35I_AT.pdf
http://www.sierrawireless.com/resources/faq/AirLink/Redwing/Redwing_GPRS_UsersGuide.pdf
Alternatively you can try to use one of the libraries suggested by others.

U can use many methods ...
SMS Enabler
SMS Lib for java
Ozeki sms gateway
For recieving SMS best and simple solution will be
SMSenabler it will save your SMS instantly to file or database and u can retrieve it
Free version supports upto 12 characters
and if you want to send sms then you can use [enter link description here][Ozeki] Ozeki sms server gateway

Related

Sending SMS through PC using java via android mobile

I would like to connect my mobile phone in USB debugging mode and then send sms through some java code, so that the text is actually send through my cellphone using my provider sms plan. I am without any idea. I googled but could not get anything useful. Any idea, approach or link to some tutorial would be very helpful.
I'd suggest SMS lib for sending SMSs via your cell phone using Java code.
But if you are open to other ideas, I'd suggest to use a public webservice that sends in your place your SMSs, you can use for example nexmo, they have very good api and charges very cheap SMS. You have an initial credit for starting.

Is there a way out if i want to build a java application which does not require the use of a gsm modem?

I want to build a java application which would be able to send sms to any mobile number.But the problem is that i do not have a gsm modem.Is there any alternate way available.Can i use my own phone as a modem by connecting it with a usb cable?
Yes, you can connect your own phone via cable and send/receive SMS that way. It would however probably be easier to use some online service that can convert e-mail to SMS. That way your application becomes a lot simpler.
Some SO questions regarding e-mail to SMS:
Testing Email to SMS
SMS Through Email
It's possible in most cases for modern phones, but it depends on phone model. What's the model of your phone?
You require to have a subscription account with any third party SOAP or simple HTTP based SMS Service providers. As an example SimpleWire / OpenMarket is a third party messaging provider that sends SMS on your behalf and also lets your server app delivery status of that message. You need to integrate its API with your your server app and your app does not require any GSM modem to connect with for SMS processing.

SMS Based Application How To

I would like to develop an application which users interact with on an sms platform. Its more of an experiment to learn something new. Any pointers on technology to study and things to look at as pre-requisites before diving in? Thanks
First, you'll need a device that can act as a wireless modem to provide you with a connection for the gateway. If your cellphone supports tethering and you have an SMS plan, it would be pretty easy to use that. Otherwise you'll need to get a modem and a plan to go with it. I'm not sure how close to the metal you want to get, but you can then use SMSLib to listen on the device and wait for incoming messages. With this setup you can both send and receive messages. It is also possible to use something like Minicom to send commands directly to the modem for experimenting.
As another approach, you could also use a vendor such as Clickatell as an API for interacting with an SMS gateway. They seem to be able to handle both sending and receiving SMS on behalf of their clients.
You can easily do this with something like Twilio (where I work). Here is a howto for sending/receiving in PHP using just HTTP POST requests: http://www.twilio.com/docs/quickstart/sms/

sms through usb port using java

I have connected my nokia through data cable to USB port. I need a program in java to access the gsm module of my mobile and send text messages.
which API i need to use for it? communication need to be taken place through USB port.
Thanks & Regards,
Sri
You can use smslib. It is a very reliable solution. It supports GSM phones and GSM modems connected via serial port interfaces or IP interfaces.
Look here for more.
Have a look at Kannel. It is not a Java application, BTW.
Java API for Kannel
An Example
Sending SMS with SMPP, Kannel and Java
The phone needs to be hooked up via a serial port for RS-232. Using either a USB data cable or a USB-to-RS232 adapter and a serial data cable.
Use Java Communications API to connect to the Phone.
Then use the AT command to send and receive SMS messages. There is and example here. It is not specific to Nokia, but it is pretty much a standard command set.

What can you use to get an application to be able to receive SMS message?

Do you need to use some kind of provider?
Can you setup your own SMS server?
Does any open source solutions exist?
I am an SMS newbie so any insight on how this is accomplished would be great. I am partial to Java but any language is fine.
This is easy. Yes, you need a "sms gateway" provider. There are a lot out there. These companies provide APIs for you to send/receive SMS.
e.g. the German company Mobilant provides an easy API. If you want to receive a SMS just program a simple PHP / JSP / s.th.else dynamic web page and let Mobilant call it.
e.g.
Mobilant receives a SMS for you
Mobilant calls your web page http://yourpage.com/receive.php?message=...
You do what you need to do
You really don't want to setup your own SMS Server or Center ;-) This is really expensive, takes months to setup and costs some nice ferraris.
Use a provider and pay per SMS. It's the cheapest and fastest way.
I used kannel on a linux box with an old mobile phone connected via a serial cable to the box. Got a pre-paid card in the phone as I was using it for private use only. Worked like a charm!
You might take a look at Gammu if you're running on a Linux box:
http://www.gammu.org
Using Gammu, you can configure it to periodically poll a mobile phone for new SMS messages. When Gammu finds new messages, it can store them in an SQL database. You can then write another program to periodically poll the database and take action on new messages.
Using this general setup I successfully deployed a homemade 2-way SMS application. I configured Gammu to pull messages off of the phone over Bluetooth. Gammu placed them in a MySQL database, which I had a Tomcat web application periodically poll for new messages. When a new message was found, the system processed the message.
This is a somewhat "duct-tape and bailing wire" setup, but it worked quite well and was more reliable than many of the "professional" SMS gateways I tested beforehand. YMMV.
We've used mBlox (http://www.mblox) in the past, as they provide comprehensive international coverage, premium SMS, various levels of Quality of Service vs Price, and a solid Java-based API for both inbound and outbound SMS.
You will need an SMS gateway, googling "SMS gateway" will reveal many. I have used http://www.clickatell.com/products/sms_gateway.php with great success.
I do not know of any open source implementations, but will be monitoring this thread in case someone else does!
First, you need an SMS gateway. Take a look at Kannel SMS Gateway.
Agreed with Kannel. You can set it up on a LAMP server with a GSM modem too.
I'm not up with Java, so here's a nice guide on how to do it in Ruby on Rails: http://www.lukeredpath.co.uk/2007/8/29/sending-sms-messages-from-your-rails-application
If you want to send 'true' SMS you'll need to use an SMS gateway, (use of one is outlined in the above guide).
You can use MMS to send messages, to an email address that looks something like 1234567890# messages.whatever.com. You can use mail functions to do this. There's some information about that here: http://contentdeveloper.com/2006/06/open-source-sms-text-messaging-application/
TextMarks provides a service where they map an incoming SMS to them to an HTTP GET to a URL you provide and then send the response back as another SMS. They don't charge you if you let them add some advertising to the reply SMS. The problem is they don't provide this for free anymore for T-Mobile due to T-Mobile charging them. I'd be willing to pay per message, but they charge $0.20 per user-month, which is rather steep. Anyone know of anyone who provides this service?
You actually don't need an SMS gateway; nearly every cell phone can send/receive SMS messages to/from any email address. I built an SMS service (http://www.txtreg.net) using Nearly Free Speech's ability to forward email to a URL as a POST request. User sends a text to an email address, PHP script processes it, and sends an email right back to their phone.
Try SMS Enabler software. To receive SMS messages it uses a 3G/4G/GSM USB modem connected to a pc. It can forward incoming messages to a URL over HTTP, or store them in a database table, or write them to a CSV file, in real-time.

Categories