我正在一个项目中,我必须使用AT命令在GSM调制解调器中发送和接收SMS。从SIM卡中读取短信。我已经尝试过以下代码,希望获得实际的SMS。但是我只是得到响应“ OK”,是否有适当的方法来做到这一点?
`public void Read() { Console.WriteLine(“ Reading ...”);
gsmPort.WriteLine("AT+CMGF=1"); // SET MODE TO TEXT
Thread.Sleep(1000); //1sec to write
gsmPort.WriteLine("AT+CPMS =\"SM\""); // SET STORAGE TO SIM
Thread.Sleep(1000); //1sec to write
gsmPort.WriteLine("AT+CMGL=\"ALL\"");
gsmPort.WriteLine("AT+CMGL=\"REC UNREAD\"");
//gsmPort.WriteLine("AT+CMGR ")
Thread.Sleep(1000); //1sec to write
string response = gsmPort.ReadExisting();
if (response.EndsWith("\r\nOK\r\n"))
{
Console.WriteLine(response);
}
else
{
Console.WriteLine(response);
}
}`