主页:
https://www.celersms.com/at-emulator.htm
介绍:
The AT Emulator can be used to emulate the AT command set, also known as the Hayes command set, and the GSM AT command set (refer to ETSI GSM 07.07 and 3GPP TS 27.007). The AT commands are typically used to interact with phones, modems and other communication devices. Most GSM/3G/LTE/5G modems implement the AT command set over a serial port interface, for example: RS232 or USB. Sometimes the AT interface is implemented over TCP or telnet.支持的命令:
| 命令 | 描述 |
|---|---|
AT | 测试连接,返回OK |
ATE0/ATE1 | 关闭/开启命令回显 |
AT+CMGF=1 | 设置短信为文本模式 |
AT+CMGS="号码" | 发送短信 |
ATI2/ATI3 | 查询版本信息 |
ATZ | 重置模拟器 |
AT&V | 显示当前参数 |
ATQ0/ATQ1 | 开启/关闭响应输出 |
ATV0/ATV1 | 数字/文本格式响应 |
AT Emulator只支持模拟标准 AT命令,比如AT、AT+CMGF=1、AT+CMGS等命令,像AT+CSCS=“UCS2”、AT+CSMP等高级AT命令都不支持。
一些常用AT命令举例:
AT AT+CMGF=1 AT+CSMP=17,167,0,8 AT+CSCS="UCS2" AT+CMGS="13018886999"AT命令格式
发送命令必须以\r结尾,返回报文一般以\r\n结尾。
使用虚拟串口访问
AT Emulator本身是基于TCP的,可通过虚拟串口转发过去:
sudo socat pty,link=/dev/ttyUSB2,raw,ignoreeof,group=dialout,mode=660 tcp:127.0.0.1:2001socat要带两个地址参数,它确保数据在两个地址间双向流动,可视作加强版nc。ignoreeof参数表示不会因为客户端断链,虚拟串口就自杀。
可用picocom或screen工具连接这个虚拟串口,发送AT命令:
picocom /dev/ttyUSB2 -b 115200 --echo加上–echo是为了让你的输入被回显。顺带说一下:退出picocom用Ctrl+A加Ctrl+X
注意:socat与TCP Server联用需注意TCP连接保活,TCP Server一旦因为对端长期无动作而主动关闭连接,socat的虚拟串口也会自动销毁。若要长时间使用这样的虚拟串口,需注意。
自定义脚本
由于AT Simulator不支持一些高级命令,也可以自己写python脚本来创建虚拟串口、同时支持这些高级命令。