使用AT命令接收短信 [英] Received SMS using AT Command

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

问题描述

string recievedData = ExecCommand(port, "AT", 300, "No phone connected at ");
recievedData = ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.");
String command = "AT+CPMS?";
recievedData = ExecCommand(port, command, 1000, "Failed to count SMS message");
int uReceivedDataLength = recievedData.Length;

#endregion
//We received uReceivedDataLength 34 that false the condition
#region If command is executed successfully
if ((recievedData.Length >= 45) && (recievedData.StartsWith("AT+CPMS?")))
{

    #region Parsing SMS
    string[] strSplit = recievedData.Split(',');
    string strMessageStorageArea1 = strSplit[0];     //SM
    string strMessageExist1 = strSplit[1];           //Msgs exist in SM
    #endregion

    #region Count Total Number of SMS In SIM
    CountTotalMessages = Convert.ToInt32(strMessageExist1);
    #endregion

}



最后错误显示SIM中没有消息


At last error show "There is no message in SIM"

推荐答案

+ CPMS?是AT命令,用于获取有关设备支持哪些消息存储的信息,而不是实际获取消息。

+ CMGL =REC UNREAD是用于从消息存储读取未读消息的AT命令,使用ALL获取所有消息。

您将只检索消息从您使用+ CPMS =...命令选择的消息存储库中,+ CPMS =MT从SIM卡和手机存储中选择消息。
+CPMS? is the AT command to get information about which message stores are supported by the device, not to actually get the messages.
+CMGL="REC UNREAD" is the AT command to read unread messages from the message store, use "ALL" to get all messages.
You will only retrieve messages from the message store you have selected using a +CPMS="..." command, where +CPMS="MT" selects messages from both sim and phone storage.


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

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