Send SMS Using Gammu Command Line Tool

My teleco has provided Internet facility in which you can put data SIM card in a USB dongle and use Internet. Its call Ncell Connect. In neighboring country like India, some of them are called Reliance Netconnect+.

In such data SIM card you can only use SMS and Internet. You can't make phone calls. So to recharge or to know about the balance or data balance you have to send SMS. For Windows the software to do all of these comes bundled with the USB dongle. For Linux we'll find our own way.

Let us use awesome program called gammu. For Ubuntu, click here to install.

After pluging in the USB dongle open terminal and type:
dmesg | grep tty
This will tell you where your USB dongle is connected. For example mine is ttyUSB0. Make note of this.

Now run gammu-config to configure gammu. You only have to change one thing here. In Port the value should be /dev/ttyUSB0 where ttyUSB0 is what you noted above.

Press OK and now we are ready to run gammu.

Your SMS are saved inside folders in you SIM card. For eg: Inbox and Outbox.

To see the list of folders type:
gammu sms getsmsfolder
You need to note the folder number here. In commands like delete SMS you have to give the folder number from where you want to delete the SMS. And you can also retrieve SMS from particular folder  by using this folder number.

But if you want to get all SMS then run:
gammu getallsms 
To delete all SMS from particular folder run:
gammu deleteallsms folder-number
To send SMS:
 echo "message" | gammu sendsms TEXT number
You will see the following message indicating successful message send operation.
If you want break, press Ctrl+C...
Sending SMS 1/1....waiting for network answer..OK, message reference=30
For example in Ncell connect to know the status of my data balance I'd run the following two commands:
echo "status" | gammu sendsms TEXT 9009

gammu getallsms 
To know the balance in Ncell:
echo "" | gammu sendsms TEXT 90011
To recharge in Ncell:
echo "Recharge-Card-Pin-Number" | gammu sendsms TEXT 90012
To subscribe to a data package of 500MB:
echo "500MB" | gammu sendsms TEXT 9009
Troubleshooting:
While running gammu if you get error:
No response in specified timeout. Probably phone not connected.
Check that you got ttyUSB* thing right as talked about in the first part of this guide. You can re run gammu-config.

BTW: You can also use wammu which is graphical frontend for gammu if you don't want to hassle with all these commands.

Comments

  1. From two days i am searching for gammu command this help me a lot.

    ReplyDelete
  2. Hello there. Set up Gammu on Raspberry and so far I have my Huawey stick recognized but I can't send SMS. Situation:

    pi@raspberrypi ~ $ gammu --identify
    Device : /dev/ttyUSB0
    Manufacturer : Huawei
    Model : E173 (E173)
    Firmware : 21.017.10.01.12
    IMEI : 8600xxxxxxxxxxx
    SIM IMSI : 222xxxxxxxxxxxx

    pi@raspberrypi ~ $ echo "SMS text" | gammu sendsms TEXT mob_number
    If you want break, press Ctrl+C...
    Sending SMS 1/1....waiting for network answer..error 500, message reference=-1
    Unknown error.

    Where mob_number is one of my mobile numbers

    Any idea?

    Thanks

    PS (Good post, thanks)



    ReplyDelete
    Replies
    1. Maybe network not detected or SMS not supported or out of balance? :P for the last one :D

      Delete
    2. I am facing below issue while sending SMS using gammu via dlink DWM-156 modem.

      [root@test first_install]# echo 'test' | gammu --sendsms TEXT
      If you want break, press Ctrl+C...
      Sending SMS 1/1....waiting for network answer..error -1, message reference=-1
      Unknown error

      Gammu --identify output:

      [root@test first_install]# gammu --identify
      Device : /dev/ttyUSB0
      Manufacturer : MTK1
      Model : MTK2 (MTK2)
      Firmware : 1.3.4
      IMEI : 355619054029242
      SIM IMSI : 502121518386007

      My OS is Centos 5, Gammu 1.28.0. Also I tried different SIM cards, but the result is same.

      Can you please advise what could be the issue for this error.

      Delete
    3. Did you get this to work eventually?

      Delete
  3. bro usb dongole jun use garda ni huncha?

    ReplyDelete

Post a Comment

Comments are moderated. No spam please.

Popular posts from this blog

Perm Root HTC Desire Gingerbread 2.3.3

Increase Free Space On HTC Desire Android Phones

Giving Out Google Wave Invitations