este es mi codigo alguien me puede decir en donde estoy mal que no envia sms, uso un modem WAVECOM fASTRACK M1306B:
[Translation]
this is my code can someone tell me where I am wrong not send sms, use a modem WAVECOM FASTRACK M1306B
<script type="text/javascript">
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var element1 = document.createElement("input");
element1.type = "checkbox";
element1.name="chkbox[]";
cell1.appendChild(element1);
var cell2 = row.insertCell(1);
cell2.innerHTML = rowCount + 1;
var cell3 = row.insertCell(2);
var element2 = document.createElement("input");
element2.type = "text";
element2.name = "CTL_TEL";
cell3.appendChild(element2);
}
function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i
debugmsg("Setting up port: \"{$this->port} @ \"{$this->baud}\" baud");
exec("MODE {$this->port}: BAUD={$this->baud} PARITY=N DATA=8 STOP=1", $output, $retval);
if ($retval != 0) {
throw new Exception('Unable to setup COM port, check it is correct');
}
$this->debugmsg(implode("\n", $output));
$this->debugmsg("Opening port");
$this->fp = fopen($this->port . ':', 'r+');
if (!$this->fp) {
throw new Exception("Unable to open port \"{$this->port}\"");
}
$this->debugmsg("Port opened");
$this->debugmsg("Checking for responce from modem");
fputs($this->fp, "AT\r");
$status = $this->wait_reply("OK\r\n", 5);
if (!$status) {
throw new Exception('Did not receive responce from modem');
}
$this->debugmsg('Modem connected');
$this->debugmsg('Setting text mode');
fputs($this->fp, "AT+CMGF=1\r");
$status = $this->wait_reply("OK\r\n", 5);
if (!$status) {
throw new Exception('Unable to set text mode');
}
$this->debugmsg('Text mode set');
}
private function wait_reply($expected_result, $timeout) {
$this->debugmsg("Waiting {$timeout} seconds for expected result");
$this->buffer = '';
$timeoutat = time() + $timeout;
do {
$this->debugmsg('Now: ' . time() . ", Timeout at: {$timeoutat}");
$buffer = fread($this->fp, 1024);
$this->buffer .= $buffer;
usleep(200000);
$this->debugmsg("Received: {$buffer}");
if (preg_match('/'.preg_quote($expected_result, '/').'$/', $this->buffer)) {
$this->debugmsg('Found match');
return true;
} else if (preg_match('/\+CMS ERROR\:\ \d{1,3}\r\n$/', $this->buffer)) {
return false;
}
} while ($timeoutat > time());
$this->debugmsg('Timed out');
return false;
}
private function debugmsg($message) {
if ($this->debug == true) {
$message = preg_replace("%[^\040-\176\n\t]%", '', $message);
echo $message . "\n";
}
}
public function close() {
$this->debugmsg('Closing port');
fclose($this->fp);
}
public function send($tel, $message) {
$tel = preg_replace("%[^0-9\+]%", '', $tel);
$message = preg_replace("%[^\040-\176\r\n\t]%", '', $message);
$this->debugmsg("Sending message \"{$message}\" to \"{$tel}\"");
fputs($this->fp, "AT+CMGS=\"{$tel}\"\r");
$status = $this->wait_reply("\r\n> ", 5);
if (!$status) {
$this->debugmsg('Did not receive confirmation from modem');
return false;
}
fputs($this->fp, $message);
fputs($this->fp, chr(26));
$status = $this->wait_reply("OK\r\n", 180);
if (!$status) {
$this->debugmsg('Did not receive confirmation of messgage sent');
return false;
}
$this->debugmsg("Message sent");
return true;
}
}
?>
<html>
<head>
<title>SMS via GSM</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
.clbody {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:9pt;
font-weight:normal;
}
.clfooter {
font-family:Verdana;
font-size:7pt;
font-weight:normal;
}
h1, .h1 {
width:100%;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:18px;
font-weight:bold;
}
hr, .hr {
color:#b0b0b0;
}
</head>
<body class="clbody">
SMS via GSM
<form action="" method="post" name="myForm">
Recipient:
<INPUT type="button" value="Add Row" önClick="addRow('dataTable')" />
<INPUT type="button" value="Delete Row" önClick="deleteRow('dataTable')" />
<INPUT type="checkbox" name="chk"/>
1
<input type="text" name="tel" value="">
Message:
<input style="width: 250px" type="text" name="message" value="">
<input size="25" type="submit" value="Send" name="CTL_SEND" style="height: 23px; width: 250px">
Result code:debug = false;
$gsm_send_sms->port = 'COM7';
$gsm_send_sms->baud = 115200;
$gsm_send_sms->init();
$name="CTL_TEL[]";
$status = $gsm_send_sms->send($_POST["CTL_TEL"] , $_POST["CTL_MSG"]);
$status = $gsm_send_sms->send($tel , $_POST["CTL_MSG"]);
if ($status) {
echo "Message sent\n";
} else {
echo "Message not sent\n";
}
$gsm_send_sms->close();
?>
</form>
</body>
</html>