Tuesday, 26 March 2013

Instalasi dan configurasi Gammu - ubuntu - mysql


Untuk kesekian kalinya saya melakukan instalasi dan configurasi sms-gammu, biasanya pada windows os, tapi kali ini saya melakukan instalasi dan configurasi gammu pada linux, tepatnya ubuntu 64 bit, dengan database mysql server serta tak lupa gammu yang saya install adalah versi 1.31.0.

baiklah tanpa berlama lama mari kita coba melakukan instalasi dan configurasi gammu pada ubuntu linux.

- jika sudah terinstall ubuntu linux, silahkan login dan masuk sebagai root, jika belum ya mau ga mau instal dulu :D
- buka terminal, ketik : sudo su, kemudian masukkan user dan password root anda.
- install gammu  dengan perintah berikut diterminal,
             sudo apt-get install gammu gammu-smsd libgammu7 libgsmsd7
- masukkan modem usb, sebelumnya saya informasikan, untuk modem, segala modem yang mendukung AT Command sepertinya bisa, tp untuk lebih jelasnya silahkan cek sendiri, modem yang support dengan gammu di website resminya http://wammu.eu/phones/


kebetulan modem yang saya gunakan adalah modem wavecom M1306B, yang kebetulan adalah modem yang khusus untuk sms server/sms gateway.

- langkah selanjutnya setelah modem dihubungkan ke pc cek modem apakah sudah terkoneksi dengan benar dengan cara scanning port, dengan perintah :  


             lsusb & wvdialconf


- jika modem anda terkoneksi dengan benar, maka akan terlihat hasil seperti contoh berikut

[3] 19333
Editing `/etc/wvdial.conf'.
Scanning your serial ports for a modem.
ttyS0<*1>: ATQ0 V1 E1 -- Bus 005 Device 001: ID 1d6b:0001 Linux Foundation
1.1 root hub
Bus 004 Device 005: ID 1199:6856 Wavecom, Inc. "USB Connect 881"
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 04b3:3025 IBM Corp.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
failed with 2400 baud, next try: 9600 baud
ttyS0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
Modem Port Scan<*1>: S1 S2 S3
WvModem<*1>: Cannot get information for serial port.
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 -- M1308B
ttyUSB0<*1>: Speed 115200: AT -- OK
ttyUSB0<*1>: Max speed is 9600; that should be safe.
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
WvModem<*1>: Cannot get information for serial port.
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB2<*1>: ATQ0 V1 E1 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 Z -- AT+CPMS="SM","SM"
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB2<*1>: Modem Identifier: ATI -- ATI
ttyUSB2<*1>: Speed 115200: AT -- OK
ttyUSB2<*1>: Modem Identifier: ATI -- Manufacturer: Wavecom.
ttyUSB2<*1>: Max speed is 115200; that should be safe.
ttyUSB2<*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<Info>: Speed 115200; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
ttyUSB2<Info>: Speed 115200; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
[3] Done lsusb 

- buat configurasi gammu dengan perintah berikut : gammu-config
   isikan port modem, koneksi, log file dan log format. kemudian save hasil config.
- cek hasil configurasi dengan perintah berikut : /root/.gammurc
- cek modem apakah sudah teridentify dengan perintah : gammu --identify
hasilnya :
Device : /dev/ttyUSB2
Manufacturer : Wavecom.
Model : unknown (M1308B)
Firmware : -
IMEI : 356685013198591
SIM IMSI : 510014010262841

buat configurasi gammu dengan perintah berikut =  gammu-config

kemudian akan muncul settingan gammu sebagai berikut

Current Gammu configuration

│ P Port                                         (/dev/ttyUSB0)
│ C Connection                             (at)
│ M Model                                    ()
│ D Synchronize time                   (yes)
│ F Log file                                   (/etc/gammu)
│ O Log format                             (textall)
│ L Use locking                            ()
│ G Gammu localisation               ()
│ H Help
│ S Save


│                       <Ok>                                      <Cancel>

setelah melakukan configurase minimal gammu, ketik perintah berikut untuk melihat hasil configurasinya. = more /root/.gammurc

# This is a generated gammurc file.
# It was generated by Gammu configurator 0.4
# In Unix/Linux : copy it into your home directory and name it .gammurc
# or into /etc and name it gammurc
# In Win32 : copy it into directory with Gammu.exe and name gammurc
# Port : in Windows/DOS: "com*:",
# (instead of "*" please put "1", "2", etc.)
# in other (Linux/Unix) "/dev/ttyS%"
# or "/dev/ircomm%" ("irda" connection)
# (instead of "%" please put "0", "1", "2", etc.)
# Model : use only, when Gammu doesn't recognize your phone model.
# Put it here. Example values: "6110", "6150", "6210",
"8210"
# Connection : type of connection. Use "fbus" or "mbus" or "dlr3" or
# "irda" (Infrared over sockets) or "infrared" (DirectIR)
# or "at19200" (AT commands on 19200, 8 bits, None parity,
# 1 stop bit, no flow control) or "at115200" (AT commands
# 115200, 8 bits, None parity, 1 stop bit, no flow control)
# or "atblue" (AT over BlueTooth) or "dlr3blue" (FBUS
# over BlueTooth)
# SynchronizeTime: if you want to set time from computer to phone during
# starting connection. Do not rather use this option when
want
# to reset phone during connection (in some phones need to
# set time again after restart)
# Logfile : Use, when want to have logfile from communication.
# Logformat : What debug info and format should be used:
# "nothing" - no debug level, "text" - transmission dump in
# text format, "textall" - all possible info in text
format,
# "errors" - errors in text format, "binary" -
transmission
# dump in binary format
# Use_Locking : under Unix/Linux use "yes", if want to lock used device
# to prevent using it by other applications
# GammuLoc : name of localisation file

[gammu]
port = /dev/ttyUSB0
model =
connection = at
synchronizetime = yes
logfile = /etc/gammu
logformat = textall
use_locking =
gammuloc

kemudian, langkah selanjutnya, kita cek apakah gammu sudah dapat berkomunikasi dengan modem.
ketik perintah berikut pada terminal : gemmu --identify

Device : /dev/ttyUSB0
Manufacturer : Wavecom.
Model : unknown (M1308B)
Firmware : -
IMEI : 356685013198591
SIM IMSI : 510014010262841

jika tidak terjadi error dan muncul seperti hasil diatas, berarti gammu sudah berjalan dengan baik dan dapat berkomunikasi dengan modem.

- langkah selanjutnya adalah membuat database untuk gammu.
sebelumnya cek dulu database bawaan gammu dengan url berikut
cd /usr/share/doc/gammu/examples/sql

cek database bawaan gammu
root@gammu :/usr/share/doc/gammu/examples/sql # lsmysql.sql pgsql.sql.gz sqlite.sql.gz

create database gammu
root@gammu:/usr/share/doc/gammu/examples/sql# mysql -u root -pEnter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 147
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> create database gammu;
ok
mysql>
root@gammu:/usr/share/doc/gammu/examples/sql# mysql -u root -p gammu <
mysql.sql

Enter password:
root@gammu:/usr/share/doc/gammu/examples/sql#
mysql>
use gammu;

kemudian edit gammu-smsdrc agar gammu dapat terhubung kedatabase yang telah kita buat
disini saya menggunakan VI sebagai editor. dengan mengetikkan perintah berikut :
vi /etc/gammu-smsdrc

port = /dev/ttyUSB0
connection = at
startinfo = yes
# Debugging
logformat = textall
# SMSD configuration, see gammu-smsdrc(5)
[smsd]
service = mysql #default FILES
logfile = /etc/smsdlog
# Increase for debugging information
debuglevel = 255
user = root #user mysql anda
password = root #password mysql anda
pc = localhost
database = gammu
# 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/

nah selesai sudah configurasi gammu + config gammu-smsdrc untuk koneksi kedatabase

selanjutnya untuk pengujian ketikkan perintah berikut
echo "mama minta pulsa!" | gammu --sendsms TEXT 085555555555

If you want break, press Ctrl+C...
Sending SMS 1/1....waiting for network answer..OK, message reference=113


ups... jangan lupa yah no nya bisa diganti dengan no yang anda inginkan

untuk mengetahui kondisi modem dan status gammu anda anda bisa melihat log yang sebelumnya ditempatkan pada /etc/smsdlog

ketik perintah tail -f /etc/smsdlog

ok selesai.....



have fun with coding...

No comments:

Post a Comment