Skip to content

Build a CentOS 7 SMS Gateway with Gammu

This article documents the steps to build a CentOS 7 SMS Gateway with Gammu.

Backgrounder

It has alway been a dream for me to interface a Linux box and a cellular phone.  In 2012, I tried to marry a biometric fingerprint reader and a cellular phone for a Human Resource Management Information System (HRIS) I was building for a client. I failed. A few years later, 2015, I attempted it again for a Global Positioning System (GPS) system I intended to use for my cross-country bike touring. In both instances, I failed miserably. There are Linux-cellular phone interface Free and Open Source Software (FOSS) projects on the Internet that everyone raves about but none of them worked in my case. I have already spent a substantial amount of time and money to acquire old-school Nokia cellular phones because that was what gammu supposedly supported.

pile-o-cellphones-702573-870x400-samgalope-gammu-centos7
A bunch of old cellular phones.

In the same manner, I purchased multi-mode usb sticks that I hoped  the usb_modeswitch utility would support, also to no avail.

Smart-Sun-Globe-Pocket-Wi-Fi-samgalope-gammu-centos7
USB Pocket Internet devices

I also delved into Gnokii but soon lost interest because I could not make usb_modeswitch to “switch” the pocket wifi from USB mass storage to GSM modem mode. I cannot put blame on these projects.

What’s the problem?

Compatibility. I cannot put blame on usb_modeswitch, gammu, and gnokii. Likewise, I cannot blame the phone manufacturers for frequently changing their chips. In the case of the former, they are community driven. They cannot be put into account for not keeping tabs of whatever manufacturers release into the market. After all, with the way technology is progressing now, it is impossible. In the latter, the cellular phones and USB pocket internet dongles are not designed for the purpose I intend to make them do.

What’s the solution?

The solution is very simple. Use devices for which they are intended to be used. Do not try to “hack”everything. Thus, instead of using a cellular phone or a usb dongle as a GSM (Global System for Mobile Communications) modem, use a damn GSM modem. End of story.

Requisites

For this tutorial, I will use the following devices and utilities:

  1. CentOS 7 frugal install
  2. USB tools (lsusb)
  3. Wget utility (wget)
  4. GNU GCC Development Environment
  5. GCC GCC-C++ NCURSES-DEVEL
  6. Gammu repository (RPM)
  7. libGammu.so.7()(64bit)

xxx

1 CentOS 7 frugal install

CentOS 7 can be downloaded from this url. In case you are wondering what frugal means, it means bare, sparing, economical, abstinent, austere, self-denying, ascetic, non-indulgent, or basic. In frugal installations, everything that is not necessary such as the Graphical User Interface (GUI), Office productivity softwares, and the like are not installed. This type of installation is for “server” use which means that every bit of CPU, RAM, and storage the hardware can offer are conserved. While this is the most efficient way to implement a server, it is most unforgiving.

samgalope-terminal-gammu-centos7
This is the terminal. In frugal installs, this comprises the entire Graphical User Interface (GUI).

For steps 2-5, please refer to this article for the installation Centos 7 Quickfixes process.

2 USB tools (lsusb)

lsusb is a utility for displaying information about USB buses in the system and the devices connected to them. For more information on this, please refer to the lsusb(8) – Linux man page.

Run lsusb to ascertain whether or not the USB GSM modem is detected or not. In this case, CentOS 7 detects the GSM device (in yellow).
[root@samgalope ~]# lsusb
Bus 008 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Now run the dmesg command to determine which USB port CentOS 7 has assigned for the GSM Device. The important bits are in yellow.
[root@samgalope ~]# dmesg
[52566.450238] usb 8-1: new full-speed USB device number 4 using uhci_hcd
[52566.591412] usb 8-1: New USB device found, idVendor=067b, idProduct=2303
[52566.591424] usb 8-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[52566.591437] usb 8-1: Product: USB-Serial Controller
[52566.591443] usb 8-1: Manufacturer: Prolific Technology Inc.
[52566.595369] pl2303 8-1:1.0: pl2303 converter detected
[52566.607981] usb 8-1: pl2303 converter now attached to ttyUSB0

6 Gammu repository (RPM)

“Gammu is the name of the project as well as name of command line utility, which you can use to control your phone. It is written in C and built on top of libGammu.

“Gammu command line utility provides access to wide range of phone features, however support level differs from phone to phone and you might want to check Gammu Phone Database for user experiences with various phones. Generally following features are supported:

  • Call listing, initiating and handling
  • SMS retrieval, backup and sending
  • MMS retrieval
  • Phonebook listing, export and import (also from standard formats such as vCard)
  • Calendar and tasks listing, export and import (also from standard formats such as vCalendar or iCalendar)
  • Retrieval of phone and network information
  • Access to phone file system (note that some phones work also as USB storage devices and those are not accessible through Gammu)

“This project has originally forked from Gnokii and up to version 0.58 has been named MyGnokii2. Then need for better name arrived and Gammu was chosen as an acronym for Gammu All Mobile Management Utilities, without knowing that Gammu from the “Heretics of Dune” book written by Frank Herbert exists.

“The Gammu package does not include just this binary, but as well Gammu SMS Daemon, Gammu library and Python bindings which you can use to develop own application accessing mobile phone.” — https://wammu.eu/gammu/

Repository:

The following files are derived from RPM PBone Search.

“RPM PBone Search” is a tool for users of Linux RPM based distributions. The aim of “RPM PBone Search” is to find the name of rpm packet which contains file given by user. It also supports “provides”, “changelog”, “summary” and “description” rpm tags. System with these properties is especially helpful for users who install or compile new software but for some reasons haven’t installed all of the required librares or files and are not able to investigate what rpm packet is missing on their system. Additionally you can narrow search down to a few releases or to one Linux release. “RPM PBone Search” is also designed to locate RPM files on various FTP servers. You have the possibility to choose one or more Linux distributions. “RPM PBone Search” is still under development. All suggestions and comments concerning the functioning of the system please sent by this form . All the suggestions are analysed with attention and if at all possible are put into practice. Thank You for giving me support for what I do. All funds I’ll receive I’ll allocate for new hardware which is very necessary.

 

Disclaimer: This website mirrors PBone Search for the mere purpose of back-up. Ownership of the files are retained by PBone.

Source RPMs:

Get the main Gammu RPM
wget http://www.samgalope.com/rpms/gammu-1.37.0-36.1.x86_64.rpm
--1980-01-09 09:48:02-- http://www.samgalope.com/rpms/gammu-1.37.3-2.fc25.x86_64.rpm
Resolving www.samgalope.com (www.samgalope.com)... 192.185.181.166
Connecting to www.samgalope.com (www.samgalope.com)|192.185.181.166|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 647374 (632K) [text/plain]
Saving to: 'gammu-1.37.0-36.1.x86_64.rpm'
.
100%[=======================================>] 647,374 201KB/s in 3.1s
.
1980-01-09 09:48:05 (201 KB/s) - 'gammu-1.37.0-36.1.x86_64.rpm' saved [647374/647374]

Get the Gammu Library
[root@samgalope tmp]# wget http://www.samgalope.com/rpms/libGammu7-1.37.0-36.1.x86_64.rpm
--1980-01-09 09:40:20-- http://www.samgalope.com/rpms/libGammu7-1.37.0-36.1.x86_64.rpm
Resolving www.samgalope.com (www.samgalope.com)... 192.185.181.166
Connecting to www.samgalope.com (www.samgalope.com)|192.185.181.166|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 483004 (472K) [text/plain]
Saving to: 'libGammu7-1.37.0-36.1.x86_64.rpm'
.
100%[==================================================>] 483,004 42.6KB/s in 12s
.
1980-01-09 09:40:33 (40.4 KB/s) - 'libGammu7-1.37.0-36.1.x86_64.rpm' saved [483004/483004]

Get the Gammu libgsmsd7-1.34.0-13.1.x86_64.rpm
[root@lappy tmp]# wget http://www.samgalope.com/rpms/libgsmsd7-1.34.0-13.1.x86_64.rpm
--1980-01-09 09:50:05-- http://www.samgalope.com/rpms/libgsmsd7-1.34.0-13.1.x86_64.rpm
Resolving www.samgalope.com (www.samgalope.com)... 192.185.181.166
Connecting to www.samgalope.com (www.samgalope.com)|192.185.181.166|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 43156 (42K) [text/plain]
Saving to: 'libgsmsd7-1.34.0-13.1.x86_64.rpm'
.
100%[==============================================>] 43,156 134KB/s in 0.3s
.
1980-01-09 09:50:06 (134 KB/s) - 'libgsmsd7-1.34.0-13.1.x86_64.rpm' saved [43156/43156]

Install the Gammu Library first
[root@samgalope tmp]# yum install libGammu7-1.37.0-36.1.x86_64.rpm
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Examining libGammu7-1.37.0-36.1.x86_64.rpm: libGammu7-1.37.0-36.1.x86_64
Marking libGammu7-1.37.0-36.1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package libGammu7.x86_64 0:1.37.0-36.1 will be installed
--> Finished Dependency Resolution
.
Dependencies Resolved
.
===============================================================================
Package Arch Version Repository Size
===============================================================================
Installing:
libGammu7 x86_64 1.37.0-36.1 /libGammu7-1.37.0-36.1.x86_64 1.7 M
.
Transaction Summary
===============================================================================
Install 1 Package
.
Total size: 1.7 M
Installed size: 1.7 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libGammu7-1.37.0-36.1.x86_64 1/1
Verifying : libGammu7-1.37.0-36.1.x86_64 1/1
.
Installed:
libGammu7.x86_64 0:1.37.0-36.1
.
Complete!

Install the Gammu libgsmsd7-1.34.0-13.1.x86_64.rpm Next
[root@samgalope tmp]# yum install libgsmsd7-1.34.0-13.1.x86_64.rpm
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Examining libgsmsd7-1.34.0-13.1.x86_64.rpm: libgsmsd7-1.34.0-13.1.x86_64
Marking libgsmsd7-1.34.0-13.1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package libgsmsd7.x86_64 0:1.34.0-13.1 will be installed
--> Processing Dependency: libdbi.so.0()(64bit) for package: libgsmsd7-1.34.0-13.1.x86_64
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirror.pregi.net
* extras: mirror.pregi.net
* updates: mirror.pregi.net
--> Processing Dependency: libodbc.so.2()(64bit) for package: libgsmsd7-1.34.0-13.1.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: libgsmsd7-1.34.0-13.1.x86_64
--> Running transaction check
---> Package libdbi.x86_64 0:0.8.4-6.el7 will be installed
---> Package postgresql-libs.x86_64 0:9.2.15-1.el7_2 will be installed
---> Package unixODBC.x86_64 0:2.3.1-11.el7 will be installed
--> Processing Dependency: libltdl.so.7()(64bit) for package: unixODBC-2.3.1-11.el7.x86_64
--> Running transaction check
---> Package libtool-ltdl.x86_64 0:2.4.2-21.el7_2 will be installed
--> Finished Dependency Resolution
.
Dependencies Resolved
.
===========================================================================
Package Arch Version Repository Size
============================================================================
Installing:
libgsmsd7 x86_64 1.34.0-13.1 /libgsmsd7-1.34.0-13.1.x86_64 106 k
Installing for dependencies:
libdbi x86_64 0.8.4-6.el7 base 42 k
libtool-ltdl x86_64 2.4.2-21.el7_2 updates 49 k
postgresql-libs x86_64 9.2.15-1.el7_2 updates 231 k
unixODBC x86_64 2.3.1-11.el7 base 413 k
.
Transaction Summary
============================================================================
Install 1 Package (+4 Dependent packages)
.
Total size: 840 k
Total download size: 734 k
Installed size: 2.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): libdbi-0.8.4-6.el7.x86_64.rpm | 42 kB 00:00:00
(2/4): libtool-ltdl-2.4.2-21.el7_2.x86_64.rpm | 49 kB 00:00:00
(3/4): postgresql-libs-9.2.15-1.el7_2.x86_64.rpm | 231 kB 00:00:07
(4/4): unixODBC-2.3.1-11.el7.x86_64.rpm | 413 kB 00:00:08
----------------------------------------------------------------------
Total 81 kB/s | 734 kB 00:00:09
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql-libs-9.2.15-1.el7_2.x86_64 1/5
Installing : libdbi-0.8.4-6.el7.x86_64 2/5
Installing : libtool-ltdl-2.4.2-21.el7_2.x86_64 3/5
Installing : unixODBC-2.3.1-11.el7.x86_64 4/5
Installing : libgsmsd7-1.34.0-13.1.x86_64 5/5
Verifying : libtool-ltdl-2.4.2-21.el7_2.x86_64 1/5
Verifying : libdbi-0.8.4-6.el7.x86_64 2/5
Verifying : unixODBC-2.3.1-11.el7.x86_64 3/5
Verifying : postgresql-libs-9.2.15-1.el7_2.x86_64 4/5
Verifying : libgsmsd7-1.34.0-13.1.x86_64 5/5
.
Installed:
libgsmsd7.x86_64 0:1.34.0-13.1
.
Dependency Installed:
.libdbi.x86_64 0:0.8.4-6.el7 libtool-ltdl.x86_64 0:2.4.2-21.el7_2
postgresql-libs.x86_64 0:9.2.15-1.el7_2 unixODBC.x86_64 0:2.3.1-11.el7
.
Complete!

Install the Gammu utility
[root@lappy tmp]# yum install gammu-1.37.3-2.fc25.x86_64.rpm
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Examining gammu-1.37.3-2.fc25.x86_64.rpm: gammu-1.37.3-2.fc25.x86_64
Marking gammu-1.37.3-2.fc25.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package gammu.x86_64 0:1.37.3-2.fc25 will be installed
--> Processing Dependency: bluez for package: gammu-1.37.3-2.fc25.x86_64
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates| 3.4 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirror.pregi.net
* extras: mirror.pregi.net
* updates: mirror.pregi.net
--> Processing Dependency: dialog for package: gammu-1.37.3-2.fc25.x86_64
--> Processing Dependency: libdbi-dbd-sqlite for package: gammu-1.37.3-2.fc25.x86_64
--> Running transaction check
---> Package bluez.x86_64 0:5.23-4.el7 will be installed
--> Processing Dependency: libicalvcal.so.1()(64bit) for package: bluez-5.23-4.el7.x86_64
--> Processing Dependency: libicalss.so.1()(64bit) for package: bluez-5.23-4.el7.x86_64
--> Processing Dependency: libical.so.1()(64bit) for package: bluez-5.23-4.el7.x86_64
---> Package dialog.x86_64 0:1.2-4.20130523.el7 will be installed
---> Package libdbi-dbd-sqlite.x86_64 0:0.8.3-16.el7 will be installed
--> Processing Dependency: libdbi-drivers(x86-64) = 0.8.3-16.el7 for package: libdbi-dbd-sqlite-0.8.3-16.el7.x86_64
--> Running transaction check
---> Package libdbi-drivers.x86_64 0:0.8.3-16.el7 will be installed
---> Package libical.x86_64 0:1.0.1-1.el7 will be installed
--> Finished Dependency Resolution
.
Dependencies Resolved
.
===========================================================================
Package Arch Version Repository Size
===========================================================================
Installing:
gammu x86_64 1.37.3-2.fc25 /gammu-1.37.3-2.fc25.x86_64 1.8 M
Installing for dependencies:
bluez x86_64 5.23-4.el7 base 991 k
dialog x86_64 1.2-4.20130523.el7 base 208 k
libdbi-dbd-sqlite x86_64 0.8.3-16.el7 base 18 k
libdbi-drivers x86_64 0.8.3-16.el7 base 371 k
libical x86_64 1.0.1-1.el7 base 175 k
.
Transaction Summary
===========================================================================
Install 1 Package (+5 Dependent packages)
.
Total size: 3.6 M
Total download size: 1.7 M
Installed size: 7.3 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): dialog-1.2-4.20130523.el7.x86_64.rpm | 208 kB 00:00:05
(2/5): libdbi-drivers-0.8.3-16.el7.x86_64.rpm | 371 kB 00:00:05
(3/5): bluez-5.23-4.el7.x86_64.rpm | 991 kB 00:00:07
(4/5): libdbi-dbd-sqlite-0.8.3-16.el7.x86_64.rpm | 18 kB 00:00:07
(5/5): libical-1.0.1-1.el7.x86_64.rpm | 175 kB 00:00:14
----------------------------------------------------------------------------
Total 124 kB/s | 1.7 MB 00:00:14
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : dialog-1.2-4.20130523.el7.x86_64 1/6
Installing : libdbi-drivers-0.8.3-16.el7.x86_64 2/6
Installing : libdbi-dbd-sqlite-0.8.3-16.el7.x86_64 3/6
Installing : libical-1.0.1-1.el7.x86_64 4/6
Installing : bluez-5.23-4.el7.x86_64 5/6
Installing : gammu-1.37.3-2.fc25.x86_64 6/6
Verifying : libdbi-dbd-sqlite-0.8.3-16.el7.x86_64 1/6
Verifying : libical-1.0.1-1.el7.x86_64 2/6
Verifying : libdbi-drivers-0.8.3-16.el7.x86_64 3/6
Verifying : gammu-1.37.3-2.fc25.x86_64 4/6
Verifying : bluez-5.23-4.el7.x86_64 5/6
Verifying : dialog-1.2-4.20130523.el7.x86_64 6/6
.
Installed:
gammu.x86_64 0:1.37.3-2.fc25
.
Dependency Installed:
bluez.x86_64 0:5.23-4.el7 dialog.x86_64 0:1.2-4.20130523.el7
libdbi-dbd-sqlite.x86_64 0:0.8.3-16.el7 libdbi-drivers.x86_64 0:0.8.3-16.el7
libical.x86_64 0:1.0.1-1.el7
.
Complete!

Test it
[root@lappy tmp]# gammu
Warning: No configuration file found!
[Gammu version 1.37.3]
.
Usage: gammu [parameters] [options]
.
Parameters before command configure gammu behaviour:
-c / --config ... name of configuration file
-s / --section ... section of config file to use, eg. 42
-d / --debug ... debug level (nothing|text|textall|textalldate|binary|errors)
-f / --debug-file ... file for logging debug messages
.
Commands can be specified with or without leading --.
.
For more details, call help on specific topic (gammu --help topic). Topics are:
.
call - Calls
sms - SMS and EMS
memory - Memory (phonebooks and calls)
filesystem - Filesystem
logo - Logo and pictures
ringtone - Ringtones
calendar - Calendar notes
todo - To do lists
note - Notes
datetime - Date, time and alarms
category - Categories
backup - Backing up and restoring
nokia - Nokia specific
siemens - Siemens specific
network - Network
wap - WAP settings and bookmarks
mms - MMS and MMS settings
tests - Phone tests
fm - FM radio
info - Phone information
settings - Phone settings
other - Functions that don't fit elsewhere
gammu - Gammu information
.
Too few parameters!

Gammu Identify
[root@lappy tmp]# gammu --identify
Warning: No configuration file found!
Warning: No configuration read, using builtin defaults!
Device : /dev/ttyUSB0
Manufacturer : Wavecom
Model : MULTIBAND 900E 1800 (MULTIBAND 900E 1800)
Firmware : 641b09gg.Q2403A 1320676 061804 14:38
IMEI : 356222000811869
SIM IMSI : 515025510167382

Create Intial Configuration
[root@lappy etc]# gammu-config

Gammu Config Utility
Gammu Config Utility
Gammu Configuration File
Gammu Configuration File

Send a Text Message
[root@lappy tmp]# gammu sendsms TEXT 09267033255 -text "Halooo... Sam Galope"
If you want break, press Ctrl+C...
Sending SMS 1/1....waiting for network answer..OK, message reference=18

Get Messages
[root@lappy etc]# gammu getallsms
Location 1, folder "Inbox", SIM memory, Inbox folder
SMS message
SMSC number : "+639170000297"
Sent : Sat Sep 3 00:42:24 2016 +0800
Coding : Default GSM alphabet (no compression)
Remote number : "+639267033255"
Status : UnRead
.
Hi there.
.
1 SMS parts in 1 SMS sequences

Confirmation

CentOS 7 Gammu Send and Receive SMS confirmed!
CentOS 7 Gammu Send and Receive SMS confirmed!

Comments are closed.