使用 PHP 向 3G 调制解调器发送 SMS AT 命令 [英] Sending SMS AT commands to 3G modem using PHP

查看:22
本文介绍了使用 PHP 向 3G 调制解调器发送 SMS AT 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法向连接在 COM5 上的 3G 调制解调器发送命令.调制解调器正在接受连接并接收命令.但是有一些问题(我认为这是在我的语法/AT 命令中).在超级终端中,命令返回错误.如果有人可以提供帮助,我将不胜感激.

I'm having trouble sending commands to a 3G modem connected on COM5. The modem is accepting the connection and receiving the commands. But there is something wrong (I think it is in my syntax/AT commands). In hyperterminal the commands are returning errors. If anyone can help I would gladly appreciate it.

-------下面的代码-------

-------CODE BELOW-------

<?
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."
";
    fclose ($fp);
}

?>

推荐答案

您需要在每个命令的末尾附加一个 而不是OK".OK"是您希望电话返回的响应.使用终端程序

You need to append a to the end of each command rather than an "OK". The "OK" is the response you expect to be returned by the phone. Use a terminal program

1 second delay
+++
1 second delay
The modem should respond with "OK"
Type AT+CMGF=1
press enter key
Modem will repond with "OK"

等等...可能你的手机不支持短信模式,只有pdu模式

Etc... It is possible your phone does not support SMS text mode only pdu mode

在+CMGF=?

输入回车键,如果响应是 at+CMGF (0,1),它只支持 if (0) 和 pdu.您必须在 pdu 模式下输入 SMS 消息.
有很多关于如何执行此操作的示例.

Type enter key, if the response is at+CMGF (0,1) it supports both if (0) then pdu only. You will have to enter the SMS message in pdu mode.
There are plenty of examples on how to do this.

这篇关于使用 PHP 向 3G 调制解调器发送 SMS AT 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆