Showing posts with label SMS GTW. Show all posts
Showing posts with label SMS GTW. Show all posts

Tuesday, August 21, 2007

Gammu SMS Gateway

Source:
Please download : http://www.gammu.org/

Dependencies
Driver USB "usbserial pl2303"

Please check /var/log/messages when your modem plugged:
May 2 07:43:08 localhost kernel: usb 4-2: new full speed USB device using
uhci_hcd and address 3
May 2 07:43:08 localhost kernel: usb 4-2: configuration #1 chosen from 1
choice
May 2 07:43:08 localhost kernel: pl2303 4-2:1.0: pl2303 converter detected
May 2 07:43:08 localhost kernel: usb 4-2: pl2303 converter now attached
to ttyUSB0

If you see your LOG contain text above so the driver pl2303 has been load and ready to use.
If something problem and you can't find anything in your LOG please try :


# /sbin/modprobe -l grep serial
# /sbin/lspci grep USB
# /sbin/lsmod grep usb


Configure GAMMU
# tar -zxvf gammu-1.10.3.tar.gz
# make
# make install

Please read README first for details information. Please create MySQL account, create GRANT and load gammu mysql structure to gammu's mysql user.


Startup file for GAMMU

startgammu.sh
#!/bin/sh
export LANG=en_US.UTF-8
killall -9 gammu
/usr/local/bin/gammu --smsd MYSQL /etc/smsdrc &
echo 'Gammu SMS GTW Starting ...' /usr/local/bin/gammu --sendsmsdsms TEXT
081112223333 MYSQL /etc/smsdrc

Exec Path:
/usr/local/bin/gammu

Config File:
# /etc/gammurc
[gammu]
port = /dev/ttyUSB0
connection = at115200
logfile = /var/log/gammulog
logformat = textall
startinfo = yes
gammucoding = utf8

# /etc/smsdrc
[smsd]
PIN = 1234
logfile = /var/log/smsdlog
commtimeout = 1
sendtimeout = 10
deliveryreport = log
phoneid = PEP-SMS-GTW
# MYSQL
user = smsd
password = kunamjaya
pc = localhost
database = smsd

Startup:
/usr/local/bin/startgammu.sh

Links:
http://linux2.arinet.org/index.php?option=com_content&task=view&id=121&Itemid=2
http://aswandi.or.id/2006/09/28/sms-gateway-di-windows/#comments
http://wammu.eu/



send.php

<?
### konangsupian@gmail.com ###
### 01 Mei 2007 ###

$conn = mysql_connect("10.10.123.252","gammu","kunamjaya");
if (!$conn) {
echo mysql_error();
}
mysql_select_db("gammu");

function hexsms($kata) {
$tmp = "";
for ($i=0; $i<strlen($kata);$i++) {
$tmp_ = bin2hex($kata[$i]);
$tmp .= str_pad($tmp_, 4, "00", STR_PAD_LEFT);
}
return strtoupper($tmp);
}

function aman($myvar) {
return eregi_replace("'","`",$myvar);
}

$waktu = date("Y-m-d G:i:s");
#$Text=hexsms(aman($_POST["sms"]));
$DestinationNumber=aman($_POST["to"]);
$Coding="Default_No_Compression";
$UDH="";
$Class="-1";
$TextDecoded=aman($_POST["sms"]);
$MultiPart="false";
$RelativeValidity="255";
$SenderID="";
$SendingTimeOut="0000-00-00 00:00:00";
$DeliveryReport="default";
$CreatorID="Gammu 1.10.3";

$result = mysql_query("insert into outbox (UpdatedInDB,InsertIntoDB,SendingDateTime,Text,DestinationNumber,Coding,UDH,Class,TextDecoded,MultiPart,RelativeValidity,SenderID,
SendingTimeOut,DeliveryReport,CreatorID)
values
('now()','now()','now()','$Text','$DestinationNumber','$Coding','$UDH','$Class','$TextDecoded','$MultiPart','$RelativeValidity','$SenderID','$SendingTimeOut','$Deli
veryReport','$CreatorID')");

if (!$result) {
print mysql_error();
}

header('Location: index.html');

?>


index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MYCOMPANY - SMS Gateway Interface</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT language="JavaScript">

function rand()
{
randomku = Math.random(1234567890);
strku = String(randomku);
strku = strku.replace('0.0','');
strku = strku.replace('0.','');
return document.form1.code.value = strku;
}

</SCRIPT>
</head>

<body onLoad="JavaScript:rand()">
<br>
<br>
<form action="http://localhost/sms/send.php" method="post" name="form1">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#000000"><table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr bgcolor="#FF9933">
<td colspan="2" align="left"><font size="2" face="Arial, Helvetica, sans-serif"><strong>::: MYCOMPANY - SMS GTW
</strong></font></td>
</tr>
<tr align="left" valign="middle" bgcolor="#FFFFFF">
<td width="80" nowrap><strong><font size="2" face="Arial, Helvetica, sans-serif">To</font></strong></td>
<td width="100%"><font size="2" face="Arial, Helvetica, sans-serif">
<input name="to" type="text" value="0812">
</font></td>
</tr>

<tr align="left" valign="middle" bgcolor="#FFFFFF">
<td width="80" nowrap><strong><font size="2" face="Arial, Helvetica, sans-serif">ID</font></strong></td>
<td width="100%"> <font size="2" face="Arial, Helvetica, sans-serif">
<input name="idserver" type="text" value="PEP-SMS-GTW" readonly style="border=0;">
</font></td>
</tr>
<tr align="left" valign="middle" bgcolor="#FFFFFF">
<td width="80" nowrap><strong><font size="2" face="Arial, Helvetica, sans-serif">Code</font></strong></td>
<td width="100%"><font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="code" readonly style="border=0;">
</font></td>
</tr>
<tr align="left" valign="middle" bgcolor="#FFFFFF">
<td width="80" nowrap><font size="2" face="Arial, Helvetica, sans-serif"><strong>Length</strong></font></td>
<td width="100%"><font size="2" face="Arial, Helvetica, sans-serif">
<input name="len" type="text" size="3" maxlength="3" readonly style="border=0; font-family:; color=#ff0000;">
</font></td>
</tr>
<tr valign="top" bgcolor="#FFFFFF">
<td width="80" nowrap><strong><font size="2" face="Arial, Helvetica, sans-serif">SMS</font></strong></td>
<td width="100%"><font size="2" face="Arial, Helvetica, sans-serif">
<textarea name="sms" cols="40" rows="5" id="sms" onKeyUp="form1.len.value=this.value.length"></textarea>
</font></td>
</tr>
<tr bgcolor="#dddddd">
<td width="80" nowrap><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
<td width="100%"><font size="2" face="Arial, Helvetica, sans-serif">
<input type="submit" name="Submit" value="Submit">
</font></td>
</tr>

</table></td>
</tr>
</table>
</form>
</body>
</html>


Search Linux Resources