Home > Open Source, Tips 'n trick > Using gammu-smsd with multiple phone

Using gammu-smsd with multiple phone

This mini tutorial will show you how to use gammu-smsd with multiple modem.

The idea of using multiple modem is you want to have backup on your system, or you want to use some scheduler where the first modem work on the day and the second one works on the night, or anything else, it’s depends on your need.

In this implementation, i’m using gammu 1.28 (compilled with MySQL support) and my modem is Sierra Wireless Aircard 881 and Wavecom Fasttrack Supreme WM20392.

OK, now let’s create smsdrc config for these two modem. You can put it anywhere, i’m choosing /etc/.smsdrc-sierra and /etc/.smsdrc-fasttrack.

This is /etc/.smsdrc-sierra configuration:

[gammu]
device = /dev/tty.sierra05
connection = at115200

[smsd]
service = MYSQL
PIN = 1234
logfile = /etc/.smsdlog-sierra
debuglevel = 255
phoneid = sierra

user = root
password = password
pc = localhost
database = kalkun

And /etc/.smsdrc-fasttrack configuration:

[gammu]
device = /dev/tty.PL2303-0000101D
connection = at115200

[smsd]
service = MYSQL
PIN = 1234
logfile = /etc/.smsdlog-fasttrack
debuglevel = 255
phoneid = fasttrack

user = root
password = password
pc = localhost
database = kalkun

Now, you can run each daemon by passing configuration parameter on it:

$ gammu-smsd -c /etc/.smsdrc-sierra

and

$ gammu-smsd -c /etc/.smsdrc-fasttrack

As you can see, the configuration for this two modem is almost the same, except for one thing, phoneid. phoneid is the key, it’s unique string for every modem you’ve configured. So, if you want to send sms through the first modem (in this case, it’s sierra), you have to specified this in your CreatorID and SenderID field on outbox parameter, for example the SQL statement should be something like this:

INSERT INTO outbox (DestinationNumber, TextDecoded, SenderID, CreatorID, Coding) VALUES (‘123456’, ‘Hi, this is sierra.’, ‘sierra’, ‘sierra’, ‘Default_No_Compression’);

Or you can easily do that with gammu-smsd-inject:

$ gammu-smsd-inject -c /etc/.smsdrc-sierra TEXT 123456 -text “Hi, this is sierra.”

Where 123456 is your destination number, you’ve to change it.

So, if you want to send sms over the second modem (in this case, fasttrack), it’s should be like this:

INSERT INTO outbox (DestinationNumber, TextDecoded, SenderID, CreatorID, Coding) VALUES (‘123456’, ‘Hi, this is fasttrack.’, ‘fasttrack’, ‘fasttrack’, ‘Default_No_Compression’);

Or, if you are using gammu-smsd-inject:

$ gammu-smsd-inject -c /etc/.smsdrc-fasttrack TEXT 123456 -text “Hi, this is fasttrack.”

OK, now sending sms over multiple modem is works like a charm.

Now, you may ask, how to detect incoming sms comes from which modem? sierra or fasttrack?

The answer is look at the RecipientID from the inbox table, it’s show which modem has the incoming sms. Quick SQL code to get incoming sms from specific modem:

SELECT * FROM inbox where RecipientID=’sierra’;

Or, if you want to get incoming sms from fasttrack:

SELECT * FROM inbox where RecipientID=’fasttrack’;

That’s all for multiple modem 😀
Kalkun should have this feature in the future 🙂

Advertisements
  1. July 29, 2010 at 2:36 am

    ditunggu fitur ini dan yg masih ditunggu adalah howto upgradenya 🙂

  2. August 3, 2010 at 9:31 pm

    Salamat poh. 😀

  3. Manda
    August 14, 2010 at 8:57 am

    Bro arie, supaya multiple modem ini bisa digunakan setiap kali reboot bagaimana ya?

  4. August 14, 2010 at 3:29 pm

    @Manda: Tergantung OS nya, kalau Linux bisa ditambahkan di startup file seperti rc.local, kalau di Windows bisa ditambahkan sebagai Services.

    Untuk lengkapnya silahkan akses dokumentasi dari gammu
    http://wammu.eu/docs/man/en/gammu-smsd.1/

  5. October 2, 2010 at 2:30 pm

    Thanks, nice posting.. sangat membantu.

  6. Wakidi
    November 3, 2010 at 1:12 am

    Salam kenal,

    terima kasih artikelnya sangat berguna bagi saya, oya, bagaimana cara mengirim sms multipart selain menggunakan gammu-smsd-inject. Soalnya saya mencoba dengan mengisi tabel outbox dan outbox-multipart selalu gagal terus, memang pesan berhasil terkirim, tetapi sms tidak dapat dibuka di nomor tujuan.
    mohon pencerahannya mas…

  7. November 8, 2010 at 7:44 am

    @Wakidi: Caranya benar yaitu dengan mengisi tabel outbox dan outbox_multipart, tapi perlu diperhatikan ID sms dan UDH nya harus berurutan, misalnya UDH di outbox = 050003D30201 maka UDH di outbox_multipart = 050003D30202 (lihat 2 digit angka terakhir), selain itu field SequencePosition juga diisi dengan urutan pesan, misalnya 2.

    Contoh lengkapnya bisa dilihat disini: http://wammu.eu/docs/man/en/gammu-smsd-tables.7/

  8. robin
    November 9, 2010 at 3:11 pm

    Thanks! Very Helpful!

  9. ari
    April 5, 2011 at 3:57 pm

    terima kasih infonya mas
    sangat3 membantu duakali ^^

  10. stwn
    April 9, 2011 at 12:54 pm

    kalau modem GSM nya ada 40-an apa gammu nya sanggup dan gak ngehang ?

  11. April 9, 2011 at 1:26 pm

    Saya belum nyoba sampai sebanyak itu pak, paling banyak 2 modem.

  12. TC
    April 12, 2011 at 4:00 pm

    Thank you! This post really helped me!

  13. Eka
    April 18, 2011 at 4:43 am

    Salam kenal ya..
    sy sedang mmbuat TA ttg sms gateway, sy menggunakan Gammu..
    tp msih blum mengerti utk instalasi dan msih ggal dlam pengiriman sms..
    maklum masih belajar, hehe 🙂
    sy menggunakan hp siemens C55 sbg modem..
    mohon pencerahannya yaa..bs via email..
    trimaksii 🙂

  14. wibi
    April 24, 2011 at 5:17 pm

    Salam Kenal,

    Saya mencoba membuat SMS Gateway menggunakan gammu+Sierra Wireless 881+WIndows 7.
    Ketika saya mencoba “gammu identify” kenapa muncul pesan “No response in specified timeout. Probably phone not connected.”??
    Padahal saya bisa melakukan sms menggunakan software bawaan sierra (sierra wireless watcher).
    Saya sudah mencoba menggunakan gammu versi 1.22.1, 1.24, dan 1.29.0.
    Settingan connection untuk gammurc yang saya gunakan at115200

    Terima Kasih

  15. April 25, 2011 at 1:57 am

    @wibi: Mungkin lokasi port yang Anda gunakan salah, coba aktifkan dan lihat log-nya. Pastikan juga tidak ada software lain yang mengakses modem tersebut.

  16. wibi
    April 25, 2011 at 2:51 am

    port yang saya gunakan sudah sesuai yang ada di “Control Panel-Modem”.
    Untuk mengecek software lain yang mengakses modem itu gimana ya Mas??

    masih stuck di no response in specified timeout:(

  17. April 25, 2011 at 3:35 am

    @wibi: Aktifkan dan lihat log-nya

  18. April 30, 2011 at 7:00 am

    “No response in specified timeout. Probably phone not connected” … saya sering mengalami masalah ini. Device/port yang saya pakai sudah benar, saya mencoba restart gammu-smsd ketika masalah ini terjadi. Dan hasilnya lumayan, gammu-smsd kembali jalan seperti biasa. Untuk mengatasi permasalahan ini yang terjadi sewaktu-waktu, saya menulis script shell di bawah ini yang dijalankan menggunakan crontab untuk menganalisa 5 baris terakhir dari smsd.log. Jika di file smsd.log ditemukan pesan erro di atas “No response in specified timeout. Probably phone not connected”, maka gammu akan di restart. Script shellnya sebagai berikut:

    #!/bin/bash
    # war49,,
    # mail: line.console49@gmail.com
    # attack-research.blogspot.com

    GAMMU_LOG_FILE=/var/log/smsd.log
    GAMMU_CONF_FILE=/etc/smsdrc
    PROC_ID=`ps ax |grep -m 1 “gammu-smsd” | awk ‘{print $1}’`

    if `tail -n 5 $GAMMU_LOG_FILE | grep ‘No response in specified timeout’ > /dev/null`; then
    # kill gammu procid
    kill -9 $PROC_ID

    # start gammu
    /usr/local/bin/gammu-smsd -c $GAMMU_CONF_FILE &
    else
    echo “tidak masalah kok” # > /dev/null
    fi

    # simpel kannn…..

  19. bobotha
    May 8, 2011 at 7:51 am

    Mas, mau tanya, saya pake sierra 881u juga, dan kmrn sempat pake gammu 1.22, tapi ktnya ga cocok ma sierra nya, karna service sering mati, dan sms ga masuk ke database.
    trus berdasarkan postingannya mas, saya ganti pake gammu 1.28.95.
    saya pake windows mas, utk setting ‘device’ di smsdrc ma gammurc nya gmn ya mas?
    kalo di versi sebelumnya kan pake ‘port’.
    mohon pencerahannya.
    Makasih banyak..

  20. May 8, 2011 at 4:16 pm

    @bobotha: Sama saja, device adalah “istilah” baru untuk port.

  21. @voy
    May 19, 2011 at 8:09 am

    Haloo semua,
    Saat saya mencoba proses inject, datanya langsung masuk ke tabel OUTBOX, pertanyaannya, bisa tidak saat proses inject, datanya tidak masuk ke tabel OUTBOX, tapi ke tabel lain, misal OUTBOX_TAMPUNG? Klo bisa, bagaimana caranya? Mohon bantuannya.

    Thank’s

  22. May 19, 2011 at 9:12 am

    @voy: Sepertinya tidak bisa karena sudah di “hardcode” di gammu, silahkan lihat-lihat disini http://gitorious.org/gammu/mainline/blobs/master/smsd/core.c bagian SMSD_InjectSMS dan disini http://gitorious.org/gammu/mainline/blobs/master/smsd/services/sql.c bagian SMSDSQL_CreateOutboxSMS.

    Apakah ada alasan khusus untuk menggunakan tabel lain selain outbox?

  23. iChsan
    May 21, 2011 at 3:52 pm

    @war49
    bisa dibikinkan yang versi Windows (batch file)? 🙂

  24. May 22, 2011 at 11:50 am

    @voy : jika anda ingin merubah tabel outbox, tentunya anda harus memodifikasi file-file bahasa C tersebut (core.c & sql.c, atau mungkin ada file-file .c lainnya) silahkan edit bagian-bagian yang mengandung outbox, seperti:

    GSM_SMSDService SMSDSQL = {

    SMSDSQL_CreateOutboxSMS,

    };

    GSM_Error SMSD_InjectSMS(GSM_SMSDConfig *Config, GSM_MultiSMSMessage *sms, char *NewID) {

    /* Store message in outbox */
    error = Config->Service->CreateOutboxSMS(sms, Config, NewID);

    }
    dan seterusnya, dst dst. Kemudian di-compile ulang (configure, make, make install atau pake cmake,… dst dst). Karena kode dimodifikasi dan dikompile, maka anda harus siap membenahi error-error yang terjadi.

    ———————
    @ichsan :
    Terus terang saya tidak bisa, karena keterbatasan pengetahuan saya. Namun, script di atas bisa anda translate ke batch jika anda faham dengan batch programming. Logikanya sederhana sesuai dengan yang saya tulis di atas. Selain itu, dengan batch cobalah menemukan nomor ID proses gammu-smsd dan dimatikan prosesnya secara otomatis. Jika di shell scripting (bash) saya menggunakan pipe ‘|’, grep dan awk untuk mendapatkan nomor ID proses hasil output dari utility PS.

  25. adi
    May 29, 2011 at 7:31 am

    Mas Azhari HArahap, saya mau tanya nih. Kalau saya menggunakan odem wavecom fastrack M1206B/M1306B Q2406B USB untuk konfigurasi bagian device = … apa ya Mas? Mohon jawabannya dan pencerahannya.

    Terima kasih

  26. adi
    May 29, 2011 at 7:53 am

    Catatan: Saya menggunakan OS WIndows

  27. May 30, 2011 at 3:39 am

    @adi: Tergantung terdeteksinya dimana pak. Kalau di Windows kalau tidak salah ada di Control Panel –> Phone/Modem.

  28. May 30, 2011 at 10:14 am

    mas ari, saya mencoba mengkonfigurasi beberapa modem sekaligus (misalnya 8 modem) karena ada banyak sekali operator di indonesia tercinta ini. saya menempatkan masing-masing 1 sim card operator kedalam 1 modem. nah, semua sudah terdeteksi oleh gammu. kemudian saya ingin sms yang dikirim/diterima itu berdasarkan modemnya, misalnya sms dari/ke telkomsel di modem ke-1, sms dari/ke XL di modem ke-2 dst, termasuk operator cdma. gimana konfigurasinya mas, terus gimana mengaitkannya dengan kalkun?

  29. May 30, 2011 at 10:26 am

    @ahmadsobandi: Caranya ya seperti yang saya jelaskan di posting diatas pak. Jadi setiap modem punya phoneid yang berbeda/unik. Untuk menyambungkan dengan Kalkun caranya ada di https://github.com/back2arie/Kalkun/wiki/Multiple-Modem.

  30. iChsan
    June 7, 2011 at 1:32 am

    @adi
    System Properties [shortcut = windows key + pause break] -> Hardware -> Device Manager -> Ports (COM & LPT) -> Prolific USB-to-Serial Bridge (COMx)

  31. September 20, 2011 at 8:22 am

    Pak, apakah perlu menggunakan multiple modem untuk menerima sms masuk apabila traffic penerimaan sms tinggi. Kalau iya, bagaimana sistem kerjanya ?
    Terima kasih untuk jawabannya dan aplikasi yang bermanfaat ini. Bravo!!

  32. October 9, 2011 at 1:50 pm

    ardinoto wahono :

    Pak, apakah perlu menggunakan multiple modem untuk menerima sms masuk apabila traffic penerimaan sms tinggi. Kalau iya, bagaimana sistem kerjanya ?
    Terima kasih untuk jawabannya dan aplikasi yang bermanfaat ini. Bravo!!

    Tentunya itu tergantung dari kondisi real di perusahaan bapak, jika memang satu modem dirasa tidak cukup, maka bisa menggunakan modem tambahan untuk memisah trafik, tapi tentunya dengan nomer yang berbeda. Gammu sudah mendukung multiple modem, hanya tinggal mengkonfigurasi di bagian phoneid di smsdrc saja seperti yang dijelaskan di postingan di atas.

  33. November 3, 2011 at 8:54 am

    I have installed Gammu and trying to add multiple modems but not working please suggest.

  34. November 9, 2011 at 12:11 pm

    Huzoor Bux :

    I have installed Gammu and trying to add multiple modems but not working please suggest.

    Can you provide error or logs?

  35. November 9, 2011 at 2:04 pm

    i want to use gammu-smsd multiple modems 3, 4 all the time on single machine.

  36. November 9, 2011 at 2:07 pm

    Azhari Harahap :

    Huzoor Bux :
    I have installed Gammu and trying to add multiple modems but not working please suggest.

    Can you provide error or logs?

    This is the error i am getting.

    “Error at init connection: Error opening device, it dosen’t exist. (DEVICENOTEXIST[4])”

  37. November 10, 2011 at 4:06 pm

    Have you by any chance configure and test modem connection one by one? it’s looks like gammu can’t find your phone location.

  38. November 14, 2011 at 5:05 am

    Azhari Harahap :
    Have you by any chance configure and test modem connection one by one? it’s looks like gammu can’t find your phone location.

    Yes i have checked single modem on gammu which works fine and make a new config file as the default one but new file return this error.

  39. November 14, 2011 at 3:47 pm

    Hmmm, strange.
    Can you post your configuration here?

  40. November 15, 2011 at 6:54 am

    Azhari Harahap :
    Hmmm, strange.
    Can you post your configuration here?

    This config file works fine

    [gammu]

    device = com8:
    connection = at
    port= /dev/ttyACM0 #or /dev/ttyUSB0

    [smsd]
    service = sql
    driver = native_mysql
    LogFile = /etc/.gammurelog
    user = root
    password = 3k1k34jhai
    pc = localhost
    database = smsd

    Run with “gammu-smsd -c .gammu-smsdrc” command

    this is the 2nd file for same modem but not work i have follow the instruction of this post.

    [gammu]

    device = com8:
    connection = at
    port= /dev/ttyACM0 #or /dev/ttyUSB0

    [smsd]
    service = sql
    PIN = 12345
    phoneid = zong1
    driver = native_mysql
    LogFile = /etc/.smsdlog-zong1
    user = root
    password = 3k1k34jhai
    pc = localhost
    database = smsd

    Run with “gammu-smsd -c /etc/.smsdrc-zong1” command file saved with this name….

    This is the error i am getting.
    “Error at init connection: Error opening device, it dosen’t exist. (DEVICENOTEXIST[4])”

  41. November 22, 2011 at 3:21 pm

    Are you sure it’s the right config? what OS do you use? because your config “device = com8:” indicate that you’re using windows, but on “port = /dev/ttyACM0” is typically for UNIX.
    And also are you 2 config for same modem? because once the smsd daemon start, you can access the modem that already used.

  42. huzoorbux
    November 22, 2011 at 3:30 pm

    Azhari Harahap :
    Are you sure it’s the right config? what OS do you use? because your config “device = com8:” indicate that you’re using windows, but on “port = /dev/ttyACM0″ is typically for UNIX.
    And also are you 2 config for same modem? because once the smsd daemon start, you can access the modem that already used.

    I am using linux and i have make 2 config files for same modems but gammu-smsdrc Works fine but the 2nd one is not working giving me error.

  43. August 2, 2012 at 11:12 am

    is it possible to allocate a specific modem for use only by a particular kalkun user? i really need this functionality for users from other regions. thanks for your great work.

  44. August 2, 2012 at 4:20 pm

    Christian Stones :

    is it possible to allocate a specific modem for use only by a particular kalkun user? i really need this functionality for users from other regions. thanks for your great work.

    You can use Phone Number Prefix strategy, see (https://github.com/back2arie/Kalkun/wiki/Multiple-Modem)

  45. August 3, 2012 at 4:22 pm

    Mas Ari… tanya yah… Saya install kalkun 0.6 Wakatobi di windom7 dan appserv 2.5.10. Saat diinstall tidak ada muncul apa apa alias blank… tidak ada pesan error juga. Kenapa begitu ya? Padahal sayao coba di ubuntu 11.10 bisa lancar. Mohon pencerahan mas, terima kasih

  46. August 5, 2012 at 6:33 am

    PHP-nya versi berapa pak?

  47. August 5, 2012 at 7:44 am

    PHP 5.2.6

  48. August 5, 2012 at 10:04 am

    Coba aktifkan dan lihat log `error_reporting` di index.php dan di `log_threshold` di config.php pak.

  49. August 6, 2012 at 1:40 pm

    Azhari Harahap :
    You can use Phone Number Prefix strategy, see (https://github.com/back2arie/Kalkun/wiki/Multiple-Modem)

    i was hoping for something like a $config[‘multiple_modem_strategy’] that fixes a modem for use only by a user, for example:
    $config['multiple_modem_strategy'] = 'user';
    $config['multiple_modem'][0]['id'] = 'sierra';
    $config['multiple_modem'][0]['value'] = array('admin', 'client100');

    i hope you would consider it for future developments 😀

    thanks again…

  50. August 6, 2012 at 2:13 pm

    A PHP Error was encountered

    Severity: Warning

    Message: require(../application/third_party/MX/Router.php) [function.require]: failed to open stream: No such file or directory

    Filename: libraries/MY_Router.php

    Line Number: 4

  51. August 6, 2012 at 4:04 pm

    Coba `application_folder` di index.php di set full path pak

  52. December 24, 2012 at 2:12 am

    Thanks for the help!!!! sorry one cuestion about multiple modems on gammu…. how can I run the gammu deamon for all devices configurated?

    This command run one of those: $ gammu-smsd -c /etc/.smsdrc-sierra…. but how can I run all devices at the same time?

    THANKS!!!!!!!!!!!!!!!!!!!!!!!!

  53. mdiah
    February 1, 2013 at 3:22 am

    numpan nanya juragan,
    saya sudah ikuti petunjuk,
    pada saat instalasi gammu sudah ok,
    tapi pada saat tes gammu dengan perintah :
    # gammu
    ada error
    “gammu: error while loading shared libraries: libGammu.so.7: cannot open shared object file: No such file or directory”
    kemudian saya tambahkan :
    # ln -s /usr/local/lib/libGammu.so /usr/lib/libGammu.so.7
    # ln -s /usr/local/lib/libgsmsd.so /usr/lib/libgsmsd.so.7

    saya coba lagi dengan
    # gammu
    tetap saja error
    “gammu: error while loading shared libraries: libGammu.so.7: cannot open shared object file: No such file or directory”

    mohon pencerahan , terima kasih

  54. June 5, 2013 at 8:07 am

    Abnag / Kak,

    Minta tolong 😦

    I ada 1 modem configured dengan gammu-smsdrc (with MySQL). Ia janlan cantik 🙂

    [gammu]
    port = /dev/ttyUSB1
    connection = at115200
    phoneid = KancilSMS

    Kawan hantar sms dari mobile phone dan I dapat message dia in MySQL “inbox” table.

    Masalah & Soalan:

    Tetapi, “RecipientID” field adalah kosong (NULL). I expect “RecipientID” isi dengan value “KancilSMS”.

    Macam mana buat configuration untuk dapat value di “RecipientID” ?

    Terima Kasih.
    Dari, Spectol

  55. danny
    July 7, 2013 at 3:40 pm

    i have created a 2 users, 2 modems gammu with kalkun frontend. Multi-modem strategy is based on ‘user’ with each one tied to a modem. Sending and receiving works great, except that it will still need to depend on @user keyword or phone book to route to the right Inbox.

    I would like to have User A use only modem A, all incoming from modem A should be routed to user A as well. Likewise for User B and modem B.

    I noticed that we are able to identify via the RecipientID, but I do not see a way to use that to do the sms routing to the appropriate user.

    Any advise would be appreciated. However, do note that i have zero knowledge in mysql (just enough to follow the instructions to install kalkun), so please do use layman’s terms.

  1. February 12, 2011 at 11:09 am
  2. February 24, 2011 at 1:32 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: