User Tools

Site Tools


configure_gammu

How to install and configure gammu

(this proc work with this reference - USB UMTS HSDPA UMTS Huawei E169 Surfstick 7,2 Mbps Modem ADSL)


- How to install gammu -

$apt-get install gammu
$apt-get install gammu-smsd


- Detect your device :

$gammu-detect

The output look like that, some usb device have multiple reference, you need to try with this reference and find the one it will work…

[gammu]
device = /dev/ttyUSB0
name = Phone on USB serial port ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ HUAWEI_Mobile
connection = at

[gammu1]
device = /dev/ttyUSB1
name = Phone on USB serial port ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ HUAWEI_Mobile
connection = at

[gammu2]
device = /dev/ttyUSB2
name = Phone on USB serial port ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ HUAWEI_Mobile
connection = at

- Create the config file for gammu daemon - smsd (for example, mine is there) :

nano /etc/gammu_config_files/.smsdttyUSB0

example_smsdttyUSB0.txt
# Configuration file for Gammu SMS Daemon
 
# Gammu library configuration, see gammurc(5)
[gammu]
port = /dev/ttyUSB0
connection = at19200
# Debugging
#logformat = textall
 
[smsd]
pin = 1234
service = files
logfile = /var/log/gammusmsd.log
# Increase for debugging information
debuglevel = 0
 
# Paths where messages are stored
inboxpath = /var/spool/gammu/inbox/
outboxpath = /var/spool/gammu/outbox/
sentsmspath = /var/spool/gammu/sent/
errorsmspath = /var/spool/gammu/error/
“port” - means the usb port where your 3G dongle is connected (remember you need to try one by one until this work)
“pin” - change with your pin

- Create the script for smsd launch and use cron -

script_smsd.sh
#!/bin/bash
ps ax | grep -w [.]smsdttyUSB0 > /dev/null
if [ $? -eq 0 ]; then
echo "process ttyUSB0 is running"
else
    gammu-smsd -c /etc/gammu_config_files/.smsdttyUSB0 &
  echo "Process ttyUSB0 is not running launch in progress."
fi
We check if the process is running, if not, run it ! If the process run, do nothing.

- Test mode -

You can launch the daemon manually for test :

gammu-smsd -c /etc/gammu_config_files/.smsdttyUSB0

And test your config :

$gammu-smsd-inject TEXT +33xxxxxxxx -text "This is a test"

you probably need to wait a minute
beside, if you dont get any message, go to you log
cat /var/log/gammusmsd.log

- Scripts Mode -

- Simple script for local hosts check -

simple_check_host.sh
#!/bin/bash
HOSTS="192.168.xxx.xxx"
 
COUNT=15
 
full_info="Router : $date - $HOSTS ."DOWN""
 
for myHost in $HOSTS
do
  count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
  if [ $count -eq 0 ];
then
    # 100% failed
    echo "Host : $myHost is down (ping failed) at $(date)"
#send sms
    gammu-smsd-inject TEXT +33xxxxxxxxx -text "$full_info"
else
    echo "Host is UP $HOSTS"
  fi
done

- Simple script for check an external host -

simple_check_external_host.sh
#!/bin/bash
 
# get the external ip
external_ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
now=$(date)
 
full_info="name_of_the_test : $now - $external_ip"
 
echo "$full_info"
 
# send the external ip
gammu-smsd-inject TEXT +33xxxxxxxxx -text "$full_info"

Source : don't remember - at least the official site : gammu


- created date : 2017.02.21 -

configure_gammu.txt · Last modified: 2018/07/28 23:35 by admin