Tag Archives: SMSGATEWAY

WAVECOM = SMSGATEWAY USING SMSLIB ON RHEL 5.4 64 bit


Pada tutorial dijelaskan bagaimana mendeteksi dan mensetting agar bisa menerima sms dan mengirimkan sms via aplikasi web (crm). SMS gateway ini digunakan oleh salah satu client yang berada di Kebayoran Baru untuk mengirimkan & menerima sms.

Berikut adalah langkah-langkanya:

Untuk mendeteksi modem gunakan command wvdial

[root@serverrepo java]# wvdialconf /etc/wvdial.conf
Scanning your serial ports for a modem.

ttyS0<*1>: ATQ0 V1 E1 — OK
ttyS0<*1>: ATQ0 V1 E1 Z — OK
ttyS0<*1>: ATQ0 V1 E1 S0=0 — OK
ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 — OK
ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
ttyS0<*1>: Modem Identifier: ATI — WAVECOM MODEM
ttyS0<*1>: Speed 4800: AT — OK
ttyS0<*1>: Speed 9600: AT — OK
ttyS0<*1>: Speed 19200: AT — OK
ttyS0<*1>: Speed 38400: AT — OK
ttyS0<*1>: Speed 57600: AT — OK
ttyS0<*1>: Speed 115200: AT — OK
ttyS0<*1>: Max speed is 115200; that should be safe.
ttyS0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
Port Scan<*1>: S2 S3

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

Dari hasil output diatas maka dipastikan modem berada pada ttyS0

Selama hasilnya tidak OK maka ada masalah dengan cable, coba tancapkan cabut dan tancapkan kembali ke port serialnya dan jalankan command wvdial

Install Java

[root@serverrepo java]# rpm -aq | grep java
sun-javadb-docs-10.5.3-0.2
java-1.6.0-openjdk-devel-1.6.0.0-1.2.b09.el5
sun-javadb-core-10.5.3-0.2
java-1.6.0-sun-devel-1.6.0.15-1jpp.1.el5
sun-javadb-client-10.5.3-0.2
java-1.6.0-sun-1.6.0.15-1jpp.1.el5
java-1.6.0-openjdk-javadoc-1.6.0.0-1.2.b09.el5
java-1.6.0-sun-src-1.6.0.15-1jpp.1.el5
sun-javadb-demo-10.5.3-0.2
java-1.6.0-openjdk-1.6.0.0-1.2.b09.el5
java-1.6.0-sun-demo-1.6.0.15-1jpp.1.el5
java-1.6.0-sun-plugin-1.6.0.15-1jpp.1.el5
gcc-java-4.1.2-46.el5
sun-javadb-common-10.5.3-0.2
java-1.6.0-openjdk-demo-1.6.0.0-1.2.b09.el5
java-1.6.0-sun-jdbc-1.6.0.15-1jpp.1.el5
sun-javadb-javadoc-10.5.3-0.2
java-1.6.0-openjdk-src-1.6.0.0-1.2.b09.el5

[root@serverrepo java]#mkdir -p /home/smsgateway/cfg/

[root@serverrepo java]# vim /home/smsgateway/cfg/log4j.properties

Isi file dibawah ini

#log4j.rootLogger = TRACE, CONSOLE
log4j.rootLogger = DEBUG, FILE

# output to console
# ——————————————————————————
#log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender
#log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
#log4j.appender.CONSOLE.layout.conversionPattern = [%p] [%d{yyyy-MM-dd HH:mm:ss}] [%c{1}] %m%n
#log4j.appender.CONSOLE.threshold = ALL

# output to file
# ——————————————————————————
log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern = [%p] [%d{yyyy-MM-dd HH:mm:ss}] %m%n
#log4j.appender.FILE.layout.conversionPattern = [%p] [%d{yyyy-MM-dd HH:mm:ss}] [%C|%M] %m%n
#set the name of the file
log4j.appender.FILE.file=/home/smsgateway/log/sms/smsserver.log
#setting the immediate flush to true (default)
log4j.appender.FILE.immediateFlush=true
#setting the threshold
log4j.appender.FILE.threshold=ALL
#setting the append to false, overwrite
log4j.appender.FILE.append=true
#set the DatePattern
log4j.appender.FILE.datePattern=’.’yyyy-MM-dd

[root@serverrepo java]# vim /home/smsgateway/cfg/SMSServer.conf

# Set a different balancer than the default.
smsserver.balancer=RoundRobinLoadBalancer

# Set a different router than the default.
#smsserver.router=NumberPoolRouter

# Lets add a modem
gateway.0=modem1, SerialModem
modem1.port=/dev/ttyS0
modem1.baudrate=115200
modem1.manufacturer=Wavecom
modem1.model=1206B
modem1.protocol=PDU
modem1.pin=0000
modem1.inbound=yes
modem1.outbound=yes
modem1.smsc_number=
#modem1.init_string=ATZ\rATZ\rATZ\r
modem1.init_string=”ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0;+CMEE=1″

# Here is an example of a MySQL database interface.
interface.0=db1, Database
db1.type=mysql
db1.url=jdbc:mysql://localhost:3306/smscenter?autoReconnect=true
db1.driver=com.mysql.jdbc.Driver
db1.username=root
db1.password=12345
db1.tables.sms_in= smsserver_in
db1.tables.sms_out= smsserver_out
db1.tables.calls= smsserver_calls
db1.batch_size=50
db1.retries=2
db1.update_outbound_on_statusreport=yes

# Interval for processing inbound messages (in seconds)
settings.inbound_interval=60
# Interval for processing outbound queues (in seconds)
settings.outbound_interval=10

# After reading, should SMSServer delete the processed messages from the gateways?
# Default is “no” for safety. Set to “yes” if you wish to delete messages.
# If you leave it to “no”, SMSServer will process the same messages over and over again!
settings.delete_after_processing=yes

# Should SMSServer work in sync or async sending mode?

# Async mode forwards messages to gateway queues.
# Values can be “sync” and “async”.
settings.send_mode = sync

# Allowed dispatch time-fames per priority
settings.timeframe.low=0900-2200
settings.timeframe.normal=0000-2359
settings.timeframe.high=0000-2359

[root@serverrepo installer]# chmod +x jdk-6u26-linux-x64.bin

[root@serverrepo installer]# ./jdk-6u26-linux-x64.bin

Setelah finish maka akan terbentuk dir jdk1.6.0_26 dan copykan direktory ke dir /usr/java/

[root@serverrepo installer]# mv jdk1.6.0_26 /usr/java/

[root@serverrepo java]#  export JAVA_HOME=/usr/src/ jdk1.6.0_26

[root@serverrepo java]# ls -l

drwxr-xr-x 10 root root 4096 Jan 30 21:55 jdk1.6.0_26

Copykan library dibawah ini ke /usr/lib/

libLinuxSerialParallel_g.so
libLinuxSerialParallel.so
librxtxParallel.so
librxtxSerial.so

[root@serverrepo sms-cfg]# cp javax.comm.properties /usr/java/jdk1.6.0_26/jre/lib/

[root@serverrepo sms-cfg]# vim /usr/java/jdk1.6.0_26/jre/lib/javax.comm.properties

driver=com.sun.comm.LinuxDriver

# Paths to server-side serial port devices
serpath0 = /dev/ttyS0 => sesuaikan

Buat 1 file untuk menstartup sms

[root@serverrepo init.d]# vim /usr/sbin/start_sms.sh

java -Dsmsserver.configdir=/home/smsgateway/cfg/ -Dlog4j.properties=/home/smsgateway/cfg/log4j.properties -jar /home/smsgateway/bin/smsserver-linux-3.4.6.jar 1>/var/log/logsmsserver.log 2>&1 &
echo “OK. Check log to ensure that SMS Server is running well”

Buat 1 file untuk stop sms

#!/bin/sh
#
# Source function library.
. /etc/rc.d/init.d/functions
PROGRAM=”smsserver-linux”
TEMPFILE=”tmp-smsserver-linux”

ps aux | grep “$PROGRAM” | grep -v grep > /tmp/$TEMPFILE
export LINE
(
read LINE
while [ -n “$LINE” ]
do
set $LINE
read LINE
echo “Stopping SMS Server with PID $2”
kill $2
done
) < /tmp/$TEMPFILE

Test menjalankan sms dengan start_sms.sh dan stop_sms.sh

[root@serverrepo]#/usr/sbin/start_sms.sh

Testing, bisa dibuatkan 1 file php atau langsung menginsert ke table “smsserver_out”

<?php
$con = mysql_connect(“localhost”, “root”, “passwd”);
if (!$con){die(‘Could not connect: ‘ . mysql_error());}
$db_selected = mysql_select_db(“smscenter”, $con);
if (!$db_selected){die (“Can\’t use smscenter: ” . mysql_error());}
if(!empty($_REQUEST[‘recipient’]) && !empty($_REQUEST[‘msg’])){
echo “TEST”;
$recipient=trim($_REQUEST[‘recipient’]);
$msg = urldecode($_REQUEST[‘msg’]);
$query = “insert INTO smsserver_out(recipient,text,create_date) values(‘{$recipient}’,'{$msg}’,now())”;
if(mysql_query($query)){
echo “Berhasil di insert ke table smsserver_out, tunggu beberapa saat sms akan terkirim ke nomor yang ada entry”;
}else{
echo mysql_error($con);
echo “<br/>”;
echo “FORMAT : http://ip/sendsms.php?recipient=0812872640XX&msg=testing&#8221;;
}

echo mysql_error($con);
}
?>

Contoh hasil log jika sudah berjalan

[DEBUG] [2012-02-01 00:00:01] Running…
[DEBUG] [2012-02-01 00:00:04] OutboundPollingThread() run.
[INFO] [2012-02-01 00:00:04] SMSServer: sending synchronously…
[DEBUG] [2012-02-01 00:00:06] Running…
[DEBUG] [2012-02-01 00:00:09] Running…
[DEBUG] [2012-02-01 00:00:11] Running…
[DEBUG] [2012-02-01 00:00:14] OutboundPollingThread() run.
[INFO] [2012-02-01 00:00:14] SMSServer: sending synchronously…
[DEBUG] [2012-02-01 00:00:16] Running…
[DEBUG] [2012-02-01 00:00:21] Running…
[DEBUG] [2012-02-01 00:00:23] ** disabled **
[DEBUG] [2012-02-01 00:00:24] OutboundPollingThread() run.
[INFO] [2012-02-01 00:00:24] SMSServer: sending synchronously…
[DEBUG] [2012-02-01 00:00:24] Running…
[DEBUG] [2012-02-01 00:00:26] Running…
[DEBUG] [2012-02-01 00:00:31] Running…
[DEBUG] [2012-02-01 00:00:34] OutboundPollingThread() run.
[INFO] [2012-02-01 00:00:34] SMSServer: sending synchronously…
[DEBUG] [2012-02-01 00:00:36] Running…
[DEBUG] [2012-02-01 00:00:39] Running…
[DEBUG] [2012-02-01 00:00:41] Running…
[DEBUG] [2012-02-01 00:00:42] InboundPollingThread() run.
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: SEND :AT+CPMS=”SM”(cr)
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: BUFFER: +CPMS: 0,30,0,30^MOK^M
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: RECV :+CPMS: 0,30,0,30(cr)OK(cr)
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: SEND :AT+CMGL=4(cr)
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: BUFFER: OK^M
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: RECV :OK(cr)
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: SEND :AT+CPMS=”SR”(cr)
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: BUFFER: +CPMS: 0,30,0,30^MOK^M
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: RECV :+CPMS: 0,30,0,30(cr)OK(cr)
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: SEND :AT+CMGL=4(cr)
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: BUFFER: OK^M
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: RECV :OK(cr)
[DEBUG] [2012-02-01 00:00:42] GTW: modem1: CheckMpMsgList(): MAINLIST: 0
[DEBUG] [2012-02-01 00:00:44] OutboundPollingThread() run.
[INFO] [2012-02-01 00:00:44] SMSServer: sending synchronously…
[DEBUG] [2012-02-01 00:00:46] Running…
[DEBUG] [2012-02-01 00:00:47] Running…
[DEBUG] [2012-02-01 00:00:47] GTW: modem1: SEND :AT(cr)
[DEBUG] [2012-02-01 00:00:47] GTW: modem1: BUFFER: OK^M
[DEBUG] [2012-02-01 00:00:47] GTW: modem1: RECV :OK(cr)
[DEBUG] [2012-02-01 00:00:51] Running…
[DEBUG] [2012-02-01 00:00:53] ** disabled **
[DEBUG] [2012-02-01 00:00:54] OutboundPollingThread() run.

[DEBUG] [2012-02-01 18:53:04] GTW: modem1: =================================================
<< SmsSubmitPdu >>
Raw Pdu: 0011000C918021786204200000FF07F4F29C9E769F01

SMSC Address: [Length: 0 octets]
First Octet: 11 [TP-MTI: (SMS-SUBMIT), TP-RD: (allow duplicates), TP-VPF: (validity format, integer, TP-SRR: (No Status Report), TP-UDHI: (no UDH)]
Message Reference: 00
Destination Address: [Length: 12 (0C), Type: 91 (10010001), Address: 081287264002]
TP-PID: 00 (00000000)
TP-DCS: 00 (7-bit GSM Alphabet) (00000000)
TP-VPF: 10584 hours

User Data Length: 7 (07) septets
User Data (pdu) : F4F29C9E769F01
User Data (decoded): [testing]
=================================================

[DEBUG] [2012-02-01 18:53:04] GTW: modem1: Sending Pdu: 0011000C918021786204200000FF07F4F29C9E769F01
[DEBUG] [2012-02-01 18:53:04] GTW: modem1: SEND :AT+CMGS=21(cr)
[DEBUG] [2012-02-01 18:53:04] GTW: modem1: clearBuffer() called.
[DEBUG] [2012-02-01 18:53:05] GTW: modem1: SEND :0011000C918021786204200000FF07F4F29C9E769F01
[DEBUG] [2012-02-01 18:53:07] Running…
OKEBUG] [2012-02-01 18:53:08] GTW: modem1: BUFFER: +CMGS: 12
[DEBUG] [2012-02-01 18:53:08] GTW: modem1: RECV :+CMGS: 12(cr)OK(cr)
[DEBUG] [2012-02-01 18:53:08] Running…
[DEBUG] [2012-02-01 18:53:13] Running…
[DEBUG] [2012-02-01 18:53:18] OutboundPollingThread() run.
[INFO] [2012-02-01 18:53:18] SMSServer: sending synchronously…
[DEBUG] [2012-02-01 18:53:18] Running…

Apabila masih terlihat error log di /var/log/logsmsserver.log seperti ini:

SMSServer version: 3.4.6
Error loading LinuxSerialParallel: java.lang.UnsatisfiedLinkError: /usr/lib/libLinuxSerialParallel.so: /usr/lib/libLinuxSerialParallel.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
Exception in thread “Thread-5” java.lang.UnsatisfiedLinkError: com.sun.comm.Unix.isDevLink(Ljava/lang/String;)Z
at com.sun.comm.Unix.isDevLink(Native Method)
at com.sun.comm.PathBundle.add(PathBundle.java:108)
at com.sun.comm.PlatformPortBundle.<init>(PlatformPortBundle.java:44)
at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:138)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.smslib.helper.CommPortIdentifier.<clinit>(CommPortIdentifier.java:66)
at org.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:68)
at org.smslib.modem.AModemDriver.connect(AModemDriver.java:113)
at org.smslib.modem.ModemGateway.startGateway(ModemGateway.java:191)
at org.smslib.Service$1Starter.run(Service.java:321)

maka dipastikan paket paket yang dibutuhkan belum lengkap atau file libnya belum lengkap.

Thanks

Advertisements
shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: