Results 1 to 11 of 11
  1. #1
    btln701 is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default Sending SMS with Java

    Hello all,
    I have been researching a small project to send out SMS from a PC. I have chosen Java to do this. I have two initial questions:

    1) What hardware would I need? I have been reading about GSM or GPRS Modems, but most of those articles are 5-6 years old. Is there a newer technology/method? Will I need a valid SIM card?

    2) I'm sure there are open source packages for the software aspect of this project, any suggestions? Has any particular package worked best for you?

    Thank you for your time, I am enthusiastic about learning more regarding this topic.

  2. #2
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    Glad we have this thread :)

    In next few posts i will write about various SMS sending tools,
    and at the end i will mention principals of java solution for sending SMS.

    EPISODE 1: SENDING SMS USING Microsoft SMS Sender

    For a beginning you can play a little with your mobile phone and PC.

    You can send SMS from applications to your mobile device.

    To send SMS-A, i used this:
    1. NOKIA 6120 CLASSIC
    2. Microsoft SMS Sender
    3. bluetooth IVT BlueSOIL application
    4. USB Bluetooth stick


    Download and install Microsoft SMS Sender.

    Plug USB Bluetooth stick in usb port on your machine.

    Start app that controls Bluetooth - mine is "Bluetooth IVT BlueSOIL"

    Start bluetooth on your mobile device.

    In app that controls Bluetooth start option for finding Bluetooth device neradby (pairing)

    In Windows :
    Start => Control Panel => Phone and Model Options.
    Click modems tab.
    If pair has been made you will see something like:

    Modem Attached to
    Bluetooth DUN modem COM10

    Start Microsoft SMS Sender.
    In 'Available device' notice your: Bluetooth DUN modem

    In destination Number field type your mobile device phone number
    in international format : +38164xyzxyzz

    Write message in body.

    Send message.

    Voila !

    in next episode: SEND SMS USING HYPERTERMINAL

    stay tuned!

  3. #3
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    EPISODE 2: SEND SMS USING HYPERTERMINAL

    In previous episode i described how to connect your mobile device to your PC
    using Bluetooth.

    You need connected mobile device to finish this tutorial,
    so check previous tutorial for making connection !

    My 'Nokia's 6120 classic' modem support commands I used in HyperTerminal !

    Start HyperTerminal application:
    Windows => Start => All Programs => Accessories => Communications => HyperTerminal

    'Connect to' window:

    (My setting are: )
    Country/region: Serbia and Montenegro
    Area code: 381
    Phone Number:
    Connect using: Bluetooth DUN Modem

    Setting HyperTerminal application:
    File => Properties => tab Settings => button ASCII Setup...
    Check :
    [ ] Send line ends with line feed
    [ ] Echo typed characters locally
    Ok. Ok.

    Now you can type some commands in main HyperTerminal window
    and after you connect to your device, you can actually see and have echo
    of those commands entered.

    Type command
    AT
    to check connection.

    If you get OK
    type next commands and use Enter key at the end of command.
    (Use phone number of mobile device connect to PC.)

    AT+CMGF=1

    AT+CMGS="+38164xyzxyz"

    Now enter some message text and on the end type
    CTRL+z

    Message OK should appear.

    Main window output:

    ===========
    AT+CMGF=1

    OK
    AT+CMGS="+381642385795"

    > hello

    > (CTRL+Z)

    OK

    ==========


    SMS is sent to your mobile device.

    Voila !

    in next episode: SMS Server Tools (Stefan Frings)

    stay tuned!

  4. #4
    Aseem is offline Senior Member
    Join Date
    Mar 2009
    Location
    USA
    Posts
    127
    Rep Power
    0

    Default

    haha FON..!! i like seeing ur post..! STAY TUNED..!

  5. #5
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    EPISODE 3: SMS TOOLS SERVER (Stefan Frings)
    (send SMS to your mobile device using Windows version of SMS TOOLS SERVER)

    Project home with downloads and instructions:
    Stefan Frings - SMS Server Tools

    IN SHORT:
    "The SMS Server Tools send and receive short messages through GSM modems or mobile phones.

    You can send short messages by simply storing text files into a special spool directory.

    The program monitors this directory and sends new files automatically. It also stores received short messages into another directory as text files."


    WHAT YOU NEED:

    Step by Step instruction for Windows

    First you will need to install 'Cygwin' - a Linux-like environment for Windows. Choose carefully packages to install :
    make sure you choose devel branch amont categories an check [x] “MAKE” package (so you can perform 'make' bash command on src)

    If install went without problems you are now able to run Cygwin shell and
    run commands.

    Time to download and install SMS Server Tools.

    DOWNLOAD AND INSTALL SMS TOOLS ON WINDOWS:

    Go to homepage and download 'smstools-2.2.20.tar.gz'.

    Copy 'smstools-2.2.20.tar.gz' to DIR C:\cygwin\usr\src.

    Start Cygwin shell and go to C:\cygwin\usr\src.

    Enter this commands and watch output to see if everything went OK:

    tar -xzf smstools*.tar.gz
    cd smstools
    make
    make install


    Now you have SMS Tools Server on your file-system.


    EDIT CONFIG FILE:

    Your:
    /etc/smsd.conf
    is server config file, that yuo need to edit using this instructions:

    Configuring /etc/smsd.conf



    CONFIG WITH MOBILE DEVICE:

    On my Windows machine is connected 'NOKIA 6120 classic'
    over Bluetooth and port COM 10

    In this case config file look like this:


    Java Code:
    # Example  /etc/smsd.conf. Read the manual for a description
    
    devices = GSM1
    logfile = /var/log/smsd.log
    loglevel = 7
    
    [GSM1]
    device = /dev/com10
    incoming = yes
    #pin = 1111

    STARTING SERVICE AND SENDING SMS:


    In bash type this command
    Java Code:
    smsd -s
    If everything is OK, Nokia prints message : “Accept connection from PC?”

    In log:
    Java Code:
    c:\cygwin\var\log
    you can track job that works behind scenes, constantly sending AT
    commands to modem

    At the end you need to create outgoing sms folder on server:
    Java Code:
    C:\cygwin\var\spool\sms\outgoing
    When SMS is sent from shell using commands, this folder receives them.

    Example file: 'send_LtnFWs'
    with this content :

    Java Code:
    To: +38164xyzxyz
    
    hello

    SENDING SMS EXAMPLE:


    Start Cygwin shell.
    Enter command for starting servis
    Java Code:
    smsd -s
    Now open new shell to send SMS:
    Java Code:
    $ sendsms
    Destination: +38164xyzxyz
    Text: hello

    Got SMS?
    Voila !

    in next episode: EPISODE 4: REAL LIFE - SEND SMS FROM WEB APP USING EXTERNAL GSM MODEM WITH SIM CARD OVER 'SMS TOOLS SERVER'

    stay tuned!

  6. #6
    btln701 is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default

    FON,
    Great information so far! Thank you very much. I'm eagerly awaiting your next Episode, since it will closely resemble my original thoughts on how to perform this task! Again thank you.

  7. #7
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    EPISODE 4: REAL LIFE - SEND SMS FROM WEB APP USING EXTERNAL GSM MODEM WITH SIM CARD OVER 'SMS TOOLS SERVER'


    To fully understand this episode please refer to previous one.

    SMS SENDING PROBLEM

    There are different ways to send or to receive a SMS.

    The most simply one is with a GSM modem, but number of messages in one minute is not bigger than 10.
    You can use your own mobile phone or some external GSM modem with SIM card in it.

    Serious solution is the direct link to the SMS Center of some mobile operater.
    But this raises number of question: which hardware do i need to connect to SMSC, which protocol to use, does my company need special contract with mobile provider to use this service...

    This tutorial was written after real 'SIMPLE SMS SERVICE' as software/hardware modul was created and incorporated in web application for company who's registered clients have open accounts for shopping.

    'SIMPLE SMS SERVICE' FUNCTIONS:

    - Sending group SMS to registered users with info and promotions about new product and services offers.
    - Registered user need to know balance of his account. He sends SMS to SMS SERVICE and SMS Service sends back SMS with balance.


    WHAT DO YOU NEED:

    You need to have 'SMS TOOLS SERVER' up and running on Windows/Linux machine. If resides on remote machine, all network issues like connection
    firewall...must be solved.

    You need GSM modem with SIM card, connected to your machine
    on some port (use mobile phone or external GSM modem).

    SIM card is installed and set, so sending and receiving of SMS is possible.

    SMS can reach modem.

    Web server with main application is up and running and can communicate with SMS TOOLS Server

    DB server is up and running. DB server can communicate with Web server.

    End user (shopper) is registered through main application on web server
    and his personal data with phone number for receiving SMS and account are stored on DB server.

    MAIN SCENARIO:

    Purpose:
    End user send SMS to System to find out balance on his account.
    System sends back SMS with balance.

    Description:
    1. End user send SMS message in predefined format to System.
    Message body <BA>
    To Number: <+341987654321>

    2. SMS Server Tools automatically receive SMS and stores it in INCOMING folder.

    3. Scheduled task in main application is triggered on every 10 seconds
    and hits some web page that contains logic for SMS parsing

    4. Message details are transfered to web page for parsing

    5. Field <FROM> is taken from SMS file from INCOMING folder

    6. web page for parsing calls DB and sends <FROM> filed (unique tel. number of phone user).

    7. web page for parsing calls DB function to execute balance calculation function for given unique tel. number

    8. DB returns calculated balance value

    9. web page for parsing starts logic for creation of outgoing SMS

    10. Created outgoing SMS is written in 'SMS SERVER TOOLS' OUTGOING folder.

    11. 'SMS SERVER TOOLS' automatically behind scenes run AT modem commands for sending SMS and send message found in OUTGOING folder to end user.

    RULES FOR SMS FORMATTING

    Detailed info is here:
    Stefan Frings - SMS Server Tools

    Formatting INCOMING SMS:
    1. Each SMS text file must have unique filename
    2. Storing SMS.txt to OUTGOING folder
    3. SMS has body and header

    INCOMING SMS:

    Java Code:
    From: 384123456789
    From_TOA: 91 international, ISDN/telephone
    From_SMSC: 3845012345678
    Sent: 08-10-15 10:11:05
    Received: 08-10-15 10:10:53
    Subject: GSM1
    IMSI: 120732000477789
    Report: no
    Alphabet: ISO
    UDH: false
    
    BA

    4. Phone number is in international format without leading "+"
    5. Field "From:" is phone number of end user who sent SMS
    6. Message body that contains message "BA" is separated from
    message header with empty line
    7.Data length is 140 chars MAX
    8. Incoming messages are stored in file with this name format:
    Java Code:
    modem1.xyxyxy
    modem1 - serial number of modem
    xyxyxy - 6 random chars


    OUTGOING SMS:


    Java Code:
    To: 384123456789
    Modem: GSM1
    IMSI: 22074832000477789
    
    Your balance is 56.78 euro.

    SMS is sent to happy end user :)

    Voila!

    In next episode: SEND SMS USING SMSC OF MOBILE PROVIDER

    stay tuned!

  8. #8
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    Episode 5: SEND SMS USING SMSC OF MOBILE PROVIDER

    SMPP SPECIFICATION AND IMPLEMENTATIONS:

    Short Message Peer to Peer Protocol (SMPP)
    is a communication protocol designed for transfer of short messages
    between short message center (SMSC) and SMS application.

    Latest specification of this protocol is v5.0.

    In my previous projects I used Java implementation of specification v3.4,
    and that was 'Logica Open Source' solution.

    Versions 3.3 and 3.4 are most popular.
    They have transceiver support - one connections that can send and receive messages.
    Data exchange may be synchronous, and asynchronous.

    There are other Java implementations you could look for:
    smppapi ( smppapi Home )

    JSMPP ( jsmpp - Project Hosting on Google Code)

    Kannel is widely used Linux based SMPP ( Kannel: Open Source WAP and SMS Gateway )

    Almost every company offers not just *.jars and documentation needed for developing your implementation but
    SMSC Simulators also and other useful stuff.

    Here is a 'Logica Open Source' link with complete solution:
    Download

    There is plenty of src code in each link I posted
    so i won't write client and server example code for SMS exchange,
    but I will mention few important things form real life related
    to working with SMSC of Mobile Provider.

    Before you rush in java implementation do spend some time on
    understanding basic SMPP commands, full life cycle of one message sending
    and receiving and error codes and statuses you get from server.

    IMPLEMENTING SERVICE:


    Mobile Network Operator (MNO) offers different services to individuals and companies.

    Among them there are services related to providing some content using SMS (VAS).

    Your company (Content Provider - CP) signs contract with MNO for imlementing some SMS service that is provided using MNO's SMSC over SMPP.

    First thing CP will get from MNO is document called
    "SMSC Connection guide for Content Providers".

    Following topics and issues must be present in this document:

    - VPN connection details - full time Internet connection between SMSC and CP network.

    Connection properties:

    - SMPP protocol version (v3.3, v3.4...)
    - SMSC IP address
    - SMSC port
    - address range CP can use
    - MNO creates special account for CP with : user ID, password, short number.
    CP can have many short numbers.
    - Connection type : Transmitter (TX), Receiver (RX) or Transceiver (TRX)


    Message Format:
    has to be defined to fulfill demands defined in specification

    For every type of message MNO defines full message format and parameters
    that CP must send before send/receive message.

    To jump fast in all this terminology and protocols I recommend using free trial of this product:

    NowSMS MMSC Home Page

    When there, check documentation links for Quick Start Guide.


    JAVA IMPLEMENTATION RECOMMENDATION:

    After you define your service with MNO, handle all hardware/network issues
    and got yourself message formats and params from MNO,
    first thing you do is to choose some JAVA SMPP API.

    I will provide now few very useful instructions about how to model logic of SMS sending module and integrate it in your main application.

    - put SMSC Connection properties in file called smpp.properties
    and load and read them as needed (SMSC IP address, SMSC port...)

    - Create simple Java Bean called SMSBean that will represent simple SMS with this Strings : phoneNumber (of end user) and messageBody

    - Each time when there is a need to send SMS in your app logic,
    create new SMSBean and provide phoneNumber and messageBody.
    Call method of 'SMSManager' and send him this SMSBean

    - create separate Thread in your app for SMS sending purposes - 'SMSManager'
    This class should have a member that is List<SMSBean>, and
    synchronized methods to put and remove SMSBean in/out that list.

    In run() method of 'SMSManager' thread there is call to method sendSMS(SMSBean),
    which calls classes from concrete SMPP API you will use - for example SmppTransmitter (this is from 'Logica Open Source' API)

    - SmppTransmitter logic contains your implementation of messages that MNO specifies like 'bind to the SMSC' ...
    That is a place where all magic of sending SMS happens.

    Be patient, there is a lot of parameters to set right before first call to SMSC.

    Ideal situation for you is when there is SMSC for testing purposes on MNO side, so you can experiment and perform SMS send/receive stress test at the end of your development.

    Stay in close touch with personel of your MNO that can provide help
    like trace logs of SMSC in realtime while you send your messages.

    Is SMSC speking to your server? YES!

    Voila!

    in next episode: EPISODE 6: NON-PROGRAMMING SOLUTIONS FOR SMS SENDING

    stay tuned!

  9. #9
    hari.kr is offline Member
    Join Date
    Feb 2010
    Posts
    8
    Rep Power
    0

    Default

    Great idea to start at home.

    Regards.

  10. #10
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    5

    Default

    great information, I gonna try to do this :)

  11. #11
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    EPISODE 6: NON-PROGRAMMING SOLUTIONS FOR SMS SENDING

    Depending on your needs
    there are many non-programming solutions
    that can help you send SMS to someone.

    INDIVIDUALS:

    Mobile operators in last few years pay a lot attention to SMS services
    and offer many services which can help you finish your job.

    Send free single SMS:

    If we talk about single SMS sending, every Mobile operator
    has free service online where you can log and send for free a few SMSs daily
    just using security code step before you really send your SMS.

    From time to time someone opens some totally free SMS gateway
    so people can use it. Few month ago LightSMS 1.0.5 plug-in for Moziila
    offered sending SMS from/to many foreign countries, but now only
    works for Korean providers.

    Mobile operator make contracts with other companies letting them
    exploit infrastructure of mobile operator for some services,
    so you can find a lot of companies around that offer their SMS gateway
    and VAS services and all kind off SMS MONEYMAKING services,
    and let you send SMS all around world for some not really small
    amount of money.


    SMS trough mail client:

    Send SMS and MMS from your PC, using special mail client program (Microsoft Outlook) add-on.
    Typing SMS on phone can be very boring, using PC keyboard is much faster.
    You can also attach some image and send MMS.
    Usually there is integration with mail program address book.
    There is step with some security code exchanging with mobile operator first,
    and after that very simple GUI shows up with information about
    sender, receiver (address book choosing), and message body that you need to enter.


    COMPANIES:

    Mobile Network Operators offer today very interesting SMS services for your company.
    Usually this works like Internet business portal. After registration for service
    and signing few contracts you are able to use different services depending on
    your needs and your clients demands.

    INTERNAL SMS:
    First type of service is inter-colleague SMS sending. Your comapny has contract with Mobile Network Operator to use their mobile phones for purpose of work.
    Easy way to Send SMS to all colleagues you work with is by this service.
    No SMS to outside world here, just inside company.

    SMS to clients:
    To all customer who wish to register to this service, you can easily send group SMS.
    In administration part of this portal application, you can create few groups of users.
    User can unregister just by sending SMS to some service number.
    It's possible to schedule SMS sending in some time in future.
    Company needs to buy a package of SMS (e.g. x<1000, 1000<x<5000, x>5000), prices usually drop drastically when large package is bought.


    SMS MONEYMAKING SERVICES:

    SMS pay for info, SMS campaign, SMS ad, SMS Internet content

    There are companies who operate as mediator between your company and many Mobile Network Operators on other side,
    offering special marketing services, that can earn you (and mediator and mobile operator :rolleyes: ) serious amount of money.
    To setup some service you find mediator's web site ("Fortumo" is popular one in Europe) and very quickly you can start your SMS marketing business.

    SMS pay for info:
    SMS pay for info is SMS service in whom you get paid for some valuable info that you send to end user.
    End user send SMS with keyword to your special short number, and you send them back SMS with info requested.
    For every SMS end user sends to you, you get paid.


    SMS camaign:
    TV and radio stations worldwide use this service as big money collector these days.
    Now you can set up your campaign on-line and start it at once.
    After initial setup with service provider, you promote your campaign in media. End users send SMS with your keyword on short SMS number.
    End user may request to hear favorite song, or send some regards to friend, to ask question, to vote for his favorite freak in reality show,
    and you provide this content to user through your service.
    For every SMS end user sends to you, you get paid.

    SMS ad:
    SMS chat service let you add chat box to your web site, blog, portal.
    End users sent their messages or ads.
    For every SMS end user sends to you, you get paid.

    SMS Internet content: (you need programming knowledge )
    You can sell some content on your web site, blog, portal.
    How will end user pay? Using SMS of course.
    Mediator gives you script and you put it on your server, that can communicate with mediator's server.
    End users send SMS with your keyword on short SMS number.
    For every SMS end user sends to you, you get paid.
    You can charge your users by SMS for accessing password-protected section of your website or a restricted file,
    this usually comes at separate service.


    Instead of conclusion

    Define your needs, contact your Mobile Operator or SMS service mediators, see what
    solution they offer, what specifications and API's you can get and what hardware/network
    demands they have. Don't hesitate to bother them they are all filthy rich because of you :p.

    Feeling rich?

    Voila !

    In next episode: WAP PUSH

    stay tuned !

Similar Threads

  1. Java Mail sending
    By jazz2k8 in forum Advanced Java
    Replies: 1
    Last Post: 05-01-2011, 06:08 AM
  2. Replies: 1
    Last Post: 01-09-2010, 02:16 PM
  3. Replies: 2
    Last Post: 09-10-2009, 02:29 PM
  4. Problem in sending mail from java
    By npoorni in forum Advanced Java
    Replies: 1
    Last Post: 06-30-2009, 04:09 PM
  5. Sending SMS with Java-URGENT
    By Robert_85 in forum Advanced Java
    Replies: 1
    Last Post: 04-06-2009, 03:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •