Step four: adding SMS text capabilities – gammu

From now on, most of the work will be done via terminal. Click on the search button, type “terminal” and open a terminal window.

type su root and enter root password

then:

lsusb – make sure modem is identified.

Bus 001 Device 006: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard

In our case: (Modem/Networkcard is the important thing) – Also note the vendor and product IDs > vendor= 12d1 and product = 1506

apt-get install wvdial

wvdialconf

Found a modem on /dev/ttyUSB0.
Modem configuration written to /etc/wvdial.conf.
ttyUSB0<Info>: Speed 9600; init “ATQ0 V1 E1 S0=0 &C1 &D2”
ttyUSB2<Info>: Speed 9600; init “ATQ0 V1 E1 S0=0 &C1 &D2”
ttyUSB_utps_pcui<Info>: Speed 9600; init “ATQ0 V1 E1 S0=0 &C1 &D2”

– note the  port (/dev/ttyUSB0) and speed (9600)

(optional for if the modem doesn’t get recognised):

apt-get install usb-modeswitch

(change vendor and product numbers below to match your modem)

usb_modeswitch -W -v 19d2 -p 1506 -M “5553424312345678000000000000061b000000020000000000000000000000”

Gammu will be the controller for sending/receiving text messages. gammu-smsd is the service which constantly monitors gammu, moving incoming texts into a folder and sending outgoing texts to gammu that have been placed in a (different) folder.

we’ll look at setting persistent port later
Persistent paths for dynamic device file

apt-get install gammu
apt-get install gammu-smsd (dont worry about any error)
mkdir -p /var/log/gammu /var/spool/gammu/{inbox,outbox,sent,error}
chown www-data:www-data -R /var/spool/gammu/*
wget -c https://raw.githubusercontent.com/antonraharja/playSMS/master/contrib/gammu/linux/gammu-smsdrc
(or use this:

[gammu]
port = /dev/ttyUSB0 ** CHECK THIS
connection = at9600 ** CHECK THIS
logfile = /var/log/gammu/gammu.log
logformat = textall

[smsd]
Service = files
InboxPath = /var/spool/gammu/inbox/
OutboxPath = /var/spool/gammu/outbox/
SentSMSPath = /var/spool/gammu/sent/
ErrorSMSPath = /var/spool/gammu/error/
InboxFormat = unicode
OutboxFormat = unicode
TransmitFormat = auto
debugLevel = 1
LogFile = /var/log/gammu/smsd.log
DeliveryReport = sms
DeliveryReportDelay = 7200
CheckSecurity = 0

nano /etc/gammu-smsdrc

check port and connection speed as above

 

ln -s /etc/gammu-smsdrc /etc/gammurc

gammu -f /var/log/gammulog identify

IF THIS FAILS TRY
/etc/init.d/gammu-smsd stop

and/or apt-get install gammu-smsd
THEN TRY AGAIN

nano /etc/init.d/gammu-smsd
Edit USER=gammu to USER=root

gammu sendsms TEXT Receiver-Phone-No -text “Hello World!”

/etc/init.d/gammu-smsd start

nano /etc/rc.local

Add /etc/init.d/gammu-smsd start before exit 0

Leave a Reply