我在WPF中使用this link发送带有AT命令的短信。但是当我用CMGS命令发送短信时,接收方收到的短信是Flash短信,而不是普通短信。我的代码如下:
//Check if modem allows you to send and receive SMS messages using AT commands, without the need to decode the binairy PDU field of the SMS first
rval = sp.SendCommand("AT+CMGF=1");
//set Text mode parameters
rval = sp.SendCommand("AT+CSMP=17,167,0,16");
string phonenumber = "xxxxxxxxxxx";
string Message = "test";
rval = sp.SendCommand("AT+CMGS=\"" + phonenumber + "\"");
if (rval.Equals("\r\n> "))
{
rval = sp.SendCommand(Message + char.ConvertFromUtf32(26) );
}我的SendCommand如下所示
public string SendCommand(String commandText)
{
if (!serialPort.IsOpen)
{
try
{
serialPort.Open();
}
catch (Exception ex)
{
LogEvents.InLogFile(ex.Message);
throw new Exception("COM port is busy");
}
}
try
{
serialPort.DiscardOutBuffer();
serialPort.DiscardInBuffer();
buff = "";
serialPort.Write(commandText + "\r");
Thread.Sleep(serialPort.ReadTimeout);
return buff;
}
catch (Exception)
{
throw new Exception("Error connection");
}
}有人能帮我吗?
我的其他推荐人:developershome,Sayeda Anila Nusrat
发布于 2018-11-20 19:03:36
AT+CSMP中的第四个参数设置编码方案,我不记得在哪个文档中找到了这个字节的编码,但是第7位设置了消息在显示为class 0后是应该丢弃还是应该存储
您应该将此位设置为1以使其可存储,因此更改
rval = sp.SendCommand("AT+CSMP=17,167,0,16");至
rval = sp.SendCommand("AT+CSMP=17,167,0,144");应该做好这项工作
发布于 2020-09-27 18:38:48
AT+CSMP命令的第四个参数的位0(即,最低有效位)是用于是闪存(当0)还是保存(当1) SMS的标志。
简单地说:第四个参数的偶数不会保存消息,而奇数将保存消息。
发布于 2018-10-01 23:28:25
将AT+CSMP=17,167,0,16更改为AT+CSMP=17,167,0,0。
https://stackoverflow.com/questions/51485434
复制相似问题