在 Raspberry Pi 2 上使用 AT 命令和 Python 接收空白短信 SIM800 [英] Recieving Blank SMS SIM800 using AT Commands and Python on Raspberry Pi 2

查看:50
本文介绍了在 Raspberry Pi 2 上使用 AT 命令和 Python 接收空白短信 SIM800的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 rpi2 上创建了这个 python 脚本,消息通过了,但它是一条空白消息.是编码问题吗?

I created this python script on rpi2, the message goes through, but it is a blank message. Is it a encoding issue?

import serial
import time
from sys import version_info
from curses import ascii
phone = serial.Serial("/dev/ttyAMA0", 115200, timeout=0.5)
def send_text(number,message):    
    phone.write(b'AT+CMGF=1
')
    phone.write(b'AT+CMGS="' + number.encode() + b'"
')
    phone.write(message.encode())
    phone.write(ascii.ctrl('z'))
    for i in range(len(reply)):
        reply[i] = reply[i].rstrip()
    print reply

AT 命令(其中 0000000000 是 10 位手机号码)在 Minicom 中,仍然空白消息

AT commands (where 0000000000 is a 10 digit mobile number) in Minicom, still blank message

minicom -D /dev/ttyAMA0 -b 115200 -o

AT
OK
AT+CMGS="0000000000"
>Hello
 <ctrl-z>
+CMGS: 14
OK

GSM 模块消息截图

推荐答案

文本模式 参数存在问题.下面的 AT 命令修复了它 -

There was an issue with the text mode parameters. The AT command below fixed it -

AT+CSMP=17,167,0,0

--info about it
AT+CSMP=<fo>,<vp>,<pid>,<dcs>
<fo>=17 Sets reply pat, user data header, status report request, validity period format, reject duplicates and message type.
<vp>=167 Sets validity period.
<pid>=0 Higher layer protocol indicator.
<dcs>=0 Information encode format.
OK Modem Response.

这篇关于在 Raspberry Pi 2 上使用 AT 命令和 Python 接收空白短信 SIM800的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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