After reading this, you should be able to send SMS from commandline using Gammu on top of Ubuntu 16.04.
I have tried this with newer versions of Ubuntu with some minor bumps in the road, but with this exact setup, it should work flawlessly.
I run this as a VM in Proxmox. The VM is assigned one CPU core, 2048 megs of memory, and a small 10 gig drive.
My modem is a Wavecom Fasttrack Supreme 10. This is a COM device, but I have paired it with my VM host with a serial to USB dongle.
In Proxmox I just passed the USB device through to the VM. More on this further down.
Also, I have a simcard from my local carrier. This is SIM Pin protected.
Bone stock Ubuntu 16.04 server
Gammu sms server daemon
… and that’s it really.
First off, you need to make sure it is updated.
sudo apt-get update && sudo apt-get upgrade
Then we can check the server if the USB device is detected.
frank@smsgw01:~$ lsusb Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
As you can see, the USB device is not present there. It’s because I haven’t assigned the device to the VM in Proxmox.
Shut down the VM, assigned the USB device, and booted it up again. Now it should look like this:
frank@smsgw01:~$ lsusb Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 002 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
So, the USB device is attached and recognized.
The next step is to se if our OS can see this device as a GSM modem.
sudo apt-get install wvdial
When the installation is finished, ron wvdialconf to check for applicable modems:
frank@smsgw01:~$ sudo wvdialconf Editing `/etc/wvdial.conf'. Scanning your serial ports for a modem. Modem Port Scan<*1>: S0 S1 S2 S3 S4 S5 S6 S7 Modem Port Scan<*1>: S8 S9 S10 S11 S12 S13 S14 S15 Modem Port Scan<*1>: S16 S17 S18 S19 S20 S21 S22 S23 Modem Port Scan<*1>: S24 S25 S26 S27 S28 S29 S30 S31 ttyUSB0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud ttyUSB0<*1>: ATQ0 V1 E1 -- �ۓ�� ttyUSB0<*1>: failed with 9600 baud, next try: 115200 baud ttyUSB0<*1>: ATQ0 V1 E1 -- OK ttyUSB0<*1>: ATQ0 V1 E1 Z -- OK ttyUSB0<*1>: ATQ0 V1 E1 S0=0 -- OK ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyUSB0<*1>: Modem Identifier: ATI -- WAVECOM MODEM ttyUSB0<*1>: Speed 230400: AT -- ttyUSB0<*1>: Speed 230400: AT -- ttyUSB0<*1>: Speed 230400: AT -- ttyUSB0<*1>: Max speed is 115200; that should be safe. ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK Found a modem on /dev/ttyUSB0. Modem configuration written to /etc/wvdial.conf. ttyUSB0: Speed 115200; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
Voilà – we have a working modem on /dev/ttyUSB0
Next, we’ll install Gammu.
sudo apt-get install gammu
When the installation is complete, use the gammu-config command to configure the communication with the GSM modem.
You should now see this:
Change everything to this,
and hit Save.
Now, if your SIM card is not Pin protected, you can try to send a SMS with the following command:
frank@smsgw01:~$ sudo gammu --sendsms TEXT <landcode and phonenumber> -text "lol" If you want break, press Ctrl+C... Sending SMS 1/1....waiting for network answer..OK, message reference=11
If your simcard is PIN Locked, check status, and give the modem a PIN with the following commands:
# sudo gammu getsecuritystatus Waiting for Pin.
# sudo gammu entersecuritycode PIN - Enter PIN code:
Congrats, you can now bug your frinds not only by texting on the phone, but also form commandline.
I have had some issues with my gateway, and this mainfests itself in Gammu with this errormessage:
Can not access SIM card.
In this case, try the following:
1. Make sure your SIM card is properly inserted into SIM tray.
2. Make sure the SIM card is activated. Test if you can send and receive messages in normal phone.
3. Powercycle your device. Please remember that you must insert a SIM card when the device is SWITCHED OFF.
In my case, Powercycling the device has hepled.