SMS Gateway menggunakan Gammu

SMS Gateway menggunakan Gammu


saya ingin membagi pengalaman mengkonfigure salah satu software sms gateway gratis yang paling populer saat ini, Gammu.
Gammu menjadi begitu populer karena fleksibilitasnya, bisa berjalan di platform windows based, maupun linux based. Gammu bisa didownload secara cuma-cuma dari situs http://wammu.eu/download/ lengkap beserta dokumentasi serta daftar dari hardware yang didukung oleh Gammu. sampai dengan saat saya menulis artikel ini, versi terbaru dari Gammu adalah versi 1.28.0.
dalam artikel ini, saya menggunakan modem huawei e180.
berikut langkah-langkah instalasinya :

ekstrak installer gammu yang telah didownload ke folder yang anda suka, saya lebih memilih ke c:\gammu\ karena kemudahan aksesnya. sebagai informasi, ketika saya menggunakan file gammua yang executable, sering kali file gammurc tidak dikenali gammu. jadi saya sarankan untuk mendownload file gammu yang dikompres saja dari situsnya.

cek dimana modem anda terhubung ke komputer pada menu device manager. cari dimana port yang digunakan modem anda. dalam kasus ini, modem saya terhubung dengan COM4.


copy file gammurc dan smsdrc dari folder share\doc\gammu\examples\config ke folder bin\
edit file gammurc yang telah dicopy tadi. sesuaikan dengan konfigurasi modem anda :

[gammu]

device = com4:
connection = at115200
; Do not use model configuration unless you really need it
;model = 6110
;synchronizetime = yes
;logfile = gammulog
;logformat = textall
;use_locking = yes
;gammuloc = locfile
;startinfo = yes
;gammucoding = utf8
;usephonedb = yes

untuk mengisi opsi connection, silakan lihat di http://wammu.eu/phones/ sesuaikan dengan modem yang anda gunakan.

cek status terhubung tidaknya modem anda dengan gammu dengan mengetikkan perintah :
c:\gammu\bin>gammu identify

apabila terhubung dengan benar, akan muncul spesifikasi modem yang anda gunakan.
jika terjadi error, silakan dicek lagi konfigurasi file gammurc anda

apabila sudah, silakan create database di mysql. apabila belum, silakan download di http://dev.mysql.com/ akan lebih baik jika anda mendownload lengkap dengan MySQL Workbench (untuk instalasi workbench, membutuhkan dotnet 2.0 dan 3.5) sebagai manager native dari mysql. install mysql sesuai dengan konfigurasi yang anda inginkan. buat data base baru dengan nama terserah anda (saya misalkan database ini dengan nama 'sapk'). buka file mysql.sql di folder C:\gammu\share\doc\gammu\examples\sql dan jalankan di workbench anda. apabila terjadi error pada script mysql.sql, buka file tersebut, cari script `TextDecoded` text NOT NULL default '', pada masing-masing inisialisasi tabel inbox, outbox, sentitem dan hilangkan perintah default '', sehingga menjad berikut ini `TextDecoded` text NOT NULL, lalu jalankan script tersebut lagi di workbench anda.

buka file smsdrc di folder c:\gammu\bin\
sesuaikan dengan konfigurasi modem dan database anda :

device = com4:
#model = 6110
connection = at115200
#synchronizetime = yes
#logfile = gammulog # this is not used at all in SMSD mode
#logformat = textall
#use_locking = yes
#gammuloc = gammu.us
#startinfo = yes

[smsd]
service = MYSQL
PIN = 4321 #isikan PIN SIM Card anda, bila tidak ada, beri tanda '#' di depan PIN
logfile = smsdlog
debuglevel = 0
#phoneid = MyPhone1
commtimeout = 10
sendtimeout = 10
#receivefrequency = 0

user = root #sesuaikan dengan user mysql anda
password = cahjoesss #sesuaikan dengan password mysql anda
pc = localhost
database = sapk #sesuaikan dengan database mysql yang baru anda buat tadi

simpan file tersebut

debug file smsdrc tersebut dengan perintah :
c:\gammu\bin>gammu-smsd -c

apabila tidak terjadi pesan error, install service sms daemon dengan perintah :
c:\gammu\bin>gammu-smsd -c smsdrc -i

lalu start service sms daemon tersebut dengan perintah :
c:\gammu\bin>gammu-smsd -c smsdrc -s

catatan : untuk men stop service, ganti opsi -s dengan -k
untuk menguninstall service, gunakan perintah gammu-smsd -u

http://endricahyo.blogspot.com/2010/08/sms-gateway-menggunakan-gammu.html

konversi-“pdu-to-text”-“text-to-pdu”

konversi-“pdu-to-text”-“text-to-pdu”
Setelah kita paham teori PDU dan bagaimana perintah AT Command maka kita sudah siap untuk membuat program konversi PDU ke teks (PDU to Text) atau sebaliknya teks ke PDU (Text to PDU). Untuk membuatnya memang agak sedikit rumit karena kita harus paham terlebih dahulu algoritmanya. Tetapi jangan kuatir disini akan saya bahas bagaimana listing programnya dan Anda cukup copy paste, mudah bukan :) .

Listing program lengkapnya adalah sebagai berikut :

implementation

{$R *.dfm}

uses auxstr;

const

HexTbl: string = ’0123456789ABCDEF’;

function AsciiToInt(str1: string): integer;

var

c: integer;

len: integer;

ch: char;

begin

result := 0;

len := length(str1);

for c := len downto 1 do

begin

ch := str1[c];

result := result + ord(ch) shl ((len – c) shl 8);

end;

end;

function IntToBin(i: integer): string;

var

d: integer; // digit

digit: byte; // digit value

n: boolean;

hasil, temp, sisa: Integer;

biner: string;

begin

digit := 2;

repeat

begin

hasil := i div digit;

sisa := i mod digit;

i := hasil;

biner := IntToStr(sisa) + biner;

end

until i < digit;

biner := IntToStr(i) + biner;

Result := biner;

if Length(biner) < 7 then

Result := ’0′ + biner;

end;

function BinToInt(str1: string): integer;

var

c: integer;

len: integer;

ch: char;

begin

result := 0;

len := length(str1);

for c := len downto 1 do

begin

ch := str1[c];

if ch = ’1′ then

result := result + 1 shl (len – c);

end;

end;

function ToHex(Value: integer): string;

var

zwVal: Byte;

begin

zwVal := (Value and $0F);

Result := HexTbl[zwVal + 1];

zwVal := (Value and $F0) shr 4;

Result := HexTbl[zwVal + 1] + Result;

end;

Kemudian tempelkan button, Edit1, Edit2, Edit3, Edit4 dan memo1. Edit1 digunakan untuk inputing Teks dan Edit4 Sebagai output bahasa PDU. Kemudian procedure buttonclick diisi kode sebagai berikut :

procedure TForm1.Button1Click(Sender: TObject);

var

i, j: integer;

larik, larik1: array of string;

jumdummy: integer;

dummy, septet, octet: string;

begin

jumdummy := (length(Edit1.Text) * 8 ) – (length(Edit1.Text) * 7);

dummy := ReplStr(’0′, jumdummy);

setlength(larik, length(Edit1.Text));

for i := (length(Edit1.Text) – 1) downto 0 do

begin

larik[i] := copy(Edit1.Text, (i * 1) + 1, 1);

Edit2.Text := Edit2.Text + IntToBin(AsciiToInt(larik[i]));

Edit3.Text := dummy + Edit2.Text;

end;

setlength(larik1, length(Edit1.Text));

for j := (length(Edit1.Text) – 1) downto 0 do

begin

larik1[j] := copy(Edit3.Text, (j * 8 ) + 1, 8);

Edit4.Text := Edit4.Text + ToHex(BinToInt(larik1[j]));

Memo1.Lines.Add(larik1[j]);

end;

end;

Sekarang Anda telah memiliki program untuk mengkonversi Teks ke PDU. Bagaimana untuk konversi PDU ke Teks ? Anda dapat menggunakan fungsi dan prosedur diatas untuk melakukan konversi dari PDU ke Teks.

Selamat Mencoba ……


url \; http://ilmudelphi.wordpress.com/category/project/

sms gateway with gammu on linux

sms gateway with gammu on linux

The applications of the SMS gateway can be searched and downloaded from the internet. You would be able to found a number of SMS gateway applications from the various platforms.
One of them that will be discussed in this article is Gammu, As we are going to use Gammu application for sms gateway, because apart from we can download free also it’s easy to configure and can be use in both i.e. Windows and Linux. Another reason is to use Gammu is because MySQL can be used. But here we will discuss that how we can setup SMS gateway using Gammu with Linux.
The mobile phone that succeeded in being tried by me is Nokia 3310 and Siemens C35i using Linux platform.

Before installation is done, first read information repeatedly about Gammu here:
http://www.mwiacek.com/gsm/soft/gammu.html
Have you gathered the information?
OK.
.
Now let’s gather the requirement to develop the SMS Gateway using Gammu.

Download Gammu.

1. gammu.tar.gz
Download the gammu package from: www.mwiacek.com/zips/gsm/gammu/gammu.tar.gz
# wget www.mwiacek.com/zips/gsm/gammu/gammu.tar.gz
2. Web Server (If you have webserver, don’t ignore this, if not yet then you must install first apache, myslq, php)
3. The Nokia mobile phone 3310 or Siemens C35i. For other mobiles phone please read again:

http://www.mwiacek.com/gsm/soft/gammu.html

Gammu supports various types of the mobile phones. How come? look this: Gammu currently supports: majority of Nokia phones from DCT3 generation with Nokia operating system – for example Nokia 3210, 3310, 3315, 3410, 5110, 5130, 6110, 6510, 6610, 7210, 8310
Many AT devices – for example many Siemens, Sony Ericsson, Nokia, Alcatel models, Alcatel from BE5/BF5/BH4 generation – for example 501, 511, 512, also some functions with OBEX and Symbian devices
4. The Serial cable for the mobile phone

If you have successfully downloaded gammu.tar.gz, please extract it:

#tar xvfz gammu.tar.gz
After extracted automatically you will find the folder gammu-1.08.00, now enter into the extracted folder.
#cd gammu-1.08.00
Before installation make a custom read README, INSTALL, etc.
#. /configure
#make
Here must be paid attention by you whether being that error or not if the error occurs that means a significant library mysql you are still being more incomplete, usually an error that appear was found when MySql doesn’t support the gammu. (his installation process repeatedly try to find the mysql library which is needed)
#make shared
#make install
#make installshared
Further it’s necessary for you to upgrade the “library”
# vi/etc/ld.so.conf
Add the library link /usr/local/lib to file ld.so.conf, once you have done upgrade the library:
#/sbin/ldconfig
Note: If you did not find any error to this stage means you have successfully installed the Gammu sms Gateway.
Now tried to enter again into the folder where you extracted gammu.tar.gz and copy the available files in folder /docs/example/config/* here you will find 3 files by the name of gammurc, mysql.sql, smsdrc and gammurc.
Copy the gammurc and smsdrc into the /etc directory
#cp gammurc smsdrc /etc/
Further search edited file like this:
[gammu]
port = /dev/ttyS0 #if you are using COM2 then substitute it with ttyS1
#model = 6110 #model of mobile phone was ignored by you, because it doesn’t need often to mention the phone model.
connection = fbus #With Nokia mobile phone connection should be fbus if you used the Siemens mobile phone then substitute the fbus with at19200
#synchronizetime = yes
#logfile = gammulog
#logformat = textall
#use locking = yes
#gammuloc = locfile
#startinfo = yes
#gammucoding = utf8
#rsslevel = teststable
#usephonedb = yes

If you are still confused, inside the gammurc file it has the guidance available. If you are lazy to edit the file, then you can get the file from www.posmetropadang.com/gammu/gammurc
Now confirm if the data cable and your mobile phone are connected to port COM1 to your computer, if everything is just fine, run the following command.
#gammu –identify
I hope you could see output as being supervised here:
Manufacturer : Nokia
Model : 3310 (NHM-5)
Firmware : 06.33 F (28-11-03)
Hardware : 1012
IMEI : 350835608671298
Original IMEI : 350835608671298
Manufactured : 0802
Product code : 0505201
Simlock 1 : MCC+MNC 00101, opened, user , counter 0
Simlock 2 : GID1 0000, opened, factory, counter 0
Simlock 3 : GID2 0000, opened, factory, counter 0
Simlock 4 : MSIN 0000000001, opened, factory, counter 0
MSID : 830d50880846870ebedd126096
MCU checksum : 9C79
DSP ROM : 6
If you got the connection info like above gammu means Gammu detected your mobile phone and now you can continue to the next step.
Now let’s configure that how all the phone’s SMS’s will be kept by MySQL database to put forward on the webpage using php scripts.
OK further bro… our work has almost finished, possibly have some coffee or cigarettes that could disrupted previously hehe…??
Now try to open the file smsdrc that you copied earlier to directory /etc
#vi /etc/smsdrc
[smsd]
PIN = 1234
logfile = smsdlog
commtimeout = 1
sendtimeout = 10
Search and edit the part that you configured in the mysql database:
# ————————- SETTINGS FOR –smsd MYSQL —————————
user = root
password = password_mysql_user
pc = localhost
database = Database_name
Note: The above lines are to make connection with mysql database.
Now enter to the directory /docs/example/config/ and get the file ‘mysql.Sql’, that is a table structure. Now put this file to the database that we are creating in the MySQL database for SMS gateway.
For sms database
#mysqladmin –u root –p create sms
To create tables for gammu grab the file ‘mysql.sql’
#mysql –u root –p <>
Or it can be easier for you if you make Gammu tables through phpadmin.
http://localhost/phpmyadmin
Once you are finished, you can start the smsd deamon:
#gammu –smsd MYSQL/etc/smsdrc
The Log filename Is “smsdlog”
Press Ctrl+C to stopped the program …
After the issuing above command if output is like above means your SMS gateway is done successfully and you can use it according to your requirements. And all the available sms in your mobile phone will be entered inside the mysql database.
For your further stage is to putting forward your SMS’s to the web which is using php scripts, The required php script can be downloaded from
http://www.syednetworks.com/gammu-sms-gateway.zip
You must edit the SMS database info in the sms.php file.
If all goes well, now you can open the SMS’s through your favorite browser:

http://localhost/sms.php
Now what must be done by you??
The smsd service deamon must be running to grab the SMS’s from the phone and you and you could see on the web.
Create a Gammu startup script.sh and place it in the directory /usr/local/Bin/#cd/usr/local/bin/
#vi gammu.sh
File contents are as follows:
#! /bin/sh
export LANG=da
DK
/usr/local/bin/gam you –smsd MYSQL/etc/smsdrc
After edited that file open /etc/inittab
#vi /etc/inittab
And add the below line in the inittab
GA:345:respawn:/usr/local/bin/gammu.sh
Wow… was long enough also, hmmm hopefully did not have the problem ya… now finished your coffee, until you finished developed the SMS Gateway by using Gammu.
If you are having comments and questions, do not hesitate, just feel free to ask.

sourcecode:http://www.syednetworks.com

0 comments:

Konfigurasi Gammu

Konfigurasi Gammu

Gw lupa mulai versi berapa perlakuan gammu sedikit berbeda dengan versi dulunya,ampe megang lagi gammu sudah release v1.27.90.
Gw hanya menyoroti bagian yg langsung dipake untuk membuat aplikasi, diantaranya:
1. Konfigurasi file
Pada versi yang baru ini (v1.27.90), harus mengkonfigurasi 2 file yaitu : gammurc dan smsdrc. Sebelumnya copy dahulu 2 buah file konfigurasi tersebut dari folder “share\doc\gammu\examples\config” ke folder “bin”.
Kalo versi jadul (v1.09.00), biasanya gw edit koneksi ke hp di file gammurc dan edit koneksi ke db di file smsdrc, tetapi untuk v1.27.90 koneksi ke hp harus dilakukan pada file gammurc dan smsdrc.
[gammu]
port = com4:
connection = at19200
Script diatas merupakann contoh untuk koneksi ke hp menggunakan port : com4 dengan setting koneksi AT19200.
Untuk settingan ke databasenya jg mengalami perubahan, seperti penentukan jenis penyimpanan data ada pilihan : FILES, MYSQL, PGSQL, DBI. Berikut contoh database MYSQL untuk menyimpan data sms:
service = MYSQL
Untuk settingan login ke database masih sama seperti v1.09.00:
user = root
password =
pc = localhost
database = sms
2. Menjalankan gammu SMSD
Untuk menjalankan gammu SMSD jg mengalami perubahan, yaitu menggunakan file “gammu-smsd.exe” tidak menyatu lagi dengan file “gammu.exe”. Menjalankan gammu SMSD menggunakan konsep service pada windows, jd kita membuat service yang menyatu ke sistem komputer.
Untuk membuat service gammu dengan perintah sbb:
gammu-smsd -i -c smsdrc -n ciaGammu
Perintah diatas akan menghasilkan service gammu SMSD dengan nama ciaGammu.
Untuk menjalakankan bisa menggunakan Service Manager ( Start>RUN>”services.msc”) atau dengan perintah:
gammu-smsd -s -c smsdrc -n ciaGammu
Apabila terjadi error (Error 1053: The service did not respond to the start or control request in a timely fashion), hilangkan opsi “-f 0″ pada service yang telah dibuat tadi, dengan cara:
a. Buka Registry Editor (Start>RUN>”regedit”)
b.Cari lokasi “HKLM\SYSTEM\CurrentControlSet\Services\[nama service gammu]”
b.Edit value bagian “ImagePath”, hilangkan “-f 0″
c.Tekan OK
Coba jalankan lagi service gammunya.
Sebenarnya kita jg dapat menjalankan service tanpa menginstallnya sebagai service, tetapi gw lom berhasil menggunakan metode ini, karena selalu muncul error (Error 1063: The service process could not connect to the service controller). Untuk perintahnya sebagai berikut:
gammu-smsd -S -c smsdrc -n ciaGammu
Apabila terjadi error :
Error 27 : The drive cannot find the sector requested
Kemungkinan ada masalah dengan database :
a. Pastikan database server sudah siap/running
b.Pastikan database untuk gammu sudah ditaruh diserver
c.Pastikan nama database di server sesuai dengan nama database yang disetting pada file smsdrc
Sekalian dulu paparan gw, kali aja berguna… ^_^
*N.B : sebelum menjalankan/install service gammu daemon, pastikan settingan gammu sudah benar, untuk mengeceknya gunakan perintah :
gammu-smsd -c smsdrc
Kalo tidak ada pesan error dan di TaskManager ada proses Gammu-SMSD, berarti settingan kemungkinan sudah benar. Jika terdapat error, jangan lupa ngecek file smsdlog.
–Edit 30 Maret 2010–
Sudah dicoba di windows 7 dan sukses, beberapa yang perlu diperhatikan:
>> Waktu eksekusi command prompt, pastikan dibuka sebagai administrator (run as administrator)
>> PASTIKAN telah melewati proses identifikasi, artinya tidak ada error ketika menjalakan perintah :
gammu –identify
Apabila masih terdapat error, silakan cek kembali file gammurc dan smsdrc, konensi yg digunakan (port atau lainnya), serta database servernya sudah ready atau belum.
>> Sepertinya untuk kegagalan secara global, disebabkan oleh bagian imagepath yang tidak sesuai, pastikan properti imagepath dari service gammu yang diinstall sesuai dengan lokasi gammu yang ada di pc / laptop.

ref: http://cybercatzone.net/index.aspx/konfigurasi-gammu-versi-baru-1-27-90/