重新连接断开的 GSM 调制解调器的功能/AT 命令有哪些?

发布于 2024-08-21 11:25:28 字数 165 浏览 4 评论 0原文

  1. 我的 GSM 调制解调器会在一段时间后断开连接,可能是因为信号太弱。我只是想知道是否有一个 AT 命令可以检测断开连接并重新建立重新连接。

  2. 在代码(最好是Python)中是否有一种方法可以检测断开连接并重新建立重新连接?

迦特

  1. I have a GSM modem that disconnect after a while, maybe because of low signal. I am just wondering is there an AT command that can detect the disconnection and re-establish a reconnection.

  2. Is there a way in code (preferably python) I can detect the disconnection and re-establish a reconnection?

Gath

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

追风人 2024-08-28 11:25:29

您可以尝试使用 AT+CSQ 定期检查信号强度。如果信号低于给定阈值,则认为您已断开连接并强制建立新连接。

您可以尝试使用非常好的 pyserial http://pyserial.sourceforge.net/ Python 库来发送 AT向调制解调器发送命令。

我希望它有帮助

You can try to check the signal strength on a regular basis with AT+CSQ. If the signal goes under a given threshold consider that you are disconnected and force a new connection.

You can try the very nice pyserial http://pyserial.sourceforge.net/ Python library to send the AT commands to the modem.

I hope it helps

浪荡不羁 2024-08-28 11:25:28

根据连接类型(电路交换(CS)或分组交换(PS))的不同,监控会略有不同。要检测断开连接,您可以启用 UR(未经请求的结果)代码 AT+CPSB=1 来监视 PDP 上下文活动(也称为数据包交换连接)。对于电路交换呼叫,您可以使用 AT+CMER=3,0,0,2 启用的 +CIEV: UR 代码进行监控。

要重新建立连接,您必须再次设置连接。对于 CS,您要么必须知道拨打的电话号码,要么可以使用 ATD 的特殊形式,ATDL [1],它将拨打最后拨打的号码。如果调用是用 ATD(即“ATD*99*....”)启动的,那么您也可以使用 ATDL 进行 PS,这很常见,但我认为如果使用 AT+CGDATA 启动,就没有任何办法。

但是,以上与 ATD 相关的内容都不重要,因为它不是您想要的。对于 CS,您可以从 python 脚本设置调用,但那又怎样呢?收到 CONNECT 后,所有数据流量都将来自您的 python 脚本正在使用的串行连接。对于 PS,除非电话在连接建立过程中接收到来自 PC 的 PPP 流量,否则连接甚至无法成功完成。你打算让你的 python 脚本提供这个功能吗?

您真正想要的是触发您的 PC 再次尝试连接,无论这是标准操作系统拨号网络还是启动它的某些特殊应用程序。因此,使用 python 脚本监视调制解调器,然后在 PC 端采取适当的操作来重新建立连接。

[1]
ATDL 旁注:请注意,如果您想重复上次语音通话,您仍应以分号结束,即 ATDL;,否则您将开始数据通话。

Depending on what type of connection, circuit switched (CS) or packet switched (PS), the monitoring will be a little bit different. To detect a disconnect you can enable UR (unsolicited result) code AT+CPSB=1 to monitor PDP context activity (aka packet switched connections). For circuit switched calls you can monitor with the +CIEV: UR code enabled with AT+CMER=3,0,0,2.

To re-establish the connection you have to set up the connection again. For CS you will either have to know the phone number dialed, or you can use the special form of ATD, ATDL [1] which will dial the last dialed number. You can use ATDL for PS as well if the call was started with ATD (i.e. "ATD*99*....") which is quite common, but I do not think there is any way if started with AT+CGDATA for instance.

However, none of the above related to ATD matters, because it is not what you want. For CS you might set up a call from your python script, but then so what? After receiving CONNECT all the data traffic would be coming on the serial connection that your python script are using. And for PS the connection will not even finish successfully unless the phone receives PPP traffic from the PC as part of connection establishment. Do you intend your python script to supply that?

What you really want is to trigger your PC to try to connect again, whether this is standard operating system dial up networking or some special application launching it. So monitor the modem with a python script and then take appropriate action on the PC side to re-establish the connection.

[1]
Side note to ATDL: notice that if you want to repeat the last voice call you should still terminate with a semicolon, i.e. ATDL;, otherwise you would start a data call.

深爱不及久伴 2024-08-28 11:25:28

以下是我使用 Telit 设备执行此操作的方法:

我使用 AT+CGREG=1订阅未经请求的消息。文档摘录:

+CGREG - GPRS Network Registration Status
AT+CGREG=[<n>]
Set command controls the presentation of an unsolicited result code
+CGREG: (see format below).
Parameter:
<n> - result code presentation mode
0 - disable network registration unsolicited result code
1 - enable network registration unsolicited result code; if there is a change in the terminal GPRS network registration status, it is issued the unsolicited result code:
+CGREG: <stat>

我在调制解调器的串行线路上等待 +CGREG 消息。当出现某些情况时,我会检查 stat 是否为 1(连接到家庭网络)或 5(连接到漫游)。

注意:发出 AT+CGREG 时会出现不同的响应 +CGREG?这并不难隔离。

Here is how I do it with Telit devices:

I use AT+CGREG=1 to subscribe to unsolicited messages. Extract from documentation:

+CGREG - GPRS Network Registration Status
AT+CGREG=[<n>]
Set command controls the presentation of an unsolicited result code
+CGREG: (see format below).
Parameter:
<n> - result code presentation mode
0 - disable network registration unsolicited result code
1 - enable network registration unsolicited result code; if there is a change in the terminal GPRS network registration status, it is issued the unsolicited result code:
+CGREG: <stat>

And I wait on the modem's serial line for +CGREG messages. When something comes I check to see if stat is 1 (connected to the home network) or 5 (connected in roaming).

NOTE: A different response +CGREG comes when issuing the AT+CGREG? which is not hard to isolate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文