
Untitled
By: a guest on
Apr 30th, 2012 | syntax:
None | size: 0.68 KB | hits: 45 | expires: Never
Sending SMS AT commands to 3G modem using PHP
<?
exec("mode COM5 BAUD=9600 PARITY=N data=8 stop=1 xon=off");
$fp = fopen ("\.COM5:", "r+");
//$fp = dio_open('COM5:', O_RDWR | O_NOCTTY | O_NONBLOCK);
if (!$fp)
{
echo "Uh-oh. Port not opened.";
}
else
{
$string = "AT+CMGF=1";
$string = $string."OK";
$string = $string."AT+CMGS='+27824139864'";
$string = $string."> Hello World?<Ctrl>+<Z>";
$string = $string."+CMGS: 44";
$string = $string."OK";
fputs ($fp, $string );
echo $string."n";
fclose ($fp);
}
?>
1 second delay
+++
1 second delay
The modem should respond with "OK"
Type AT+CMGF=1
press enter key
Modem will repond with "OK"