嘿伙计们我正在尝试使用AT命令从窗体表单发送短信。但是要坚持这个功能。它说" Failed to set message format.
"
recievedData = ExecCommand(port,"AT+CMGF=1", 1000, "Failed to set message format."); // Error in this line => Failed to set message format
String command = "AT+CMGS=\"" + PhoneNo + "\"";
recievedData = ExecCommand(port,command, 300, "Failed to accept phoneNo");
command = Message + char.ConvertFromUtf32(26) + "\r";
recievedData = ExecCommand(port,command, 3000, "Failed to send message"); //3 seconds
if (recievedData.EndsWith("\r\nOK\r\n"))
{
isSend = true;
}
else if (recievedData.Contains("ERROR"))
{
isSend = false;
}
return isSend;
}
catch (Exception ex)
{
throw ex;
}
}
答案 0 :(得分:0)
首先尝试使用HyperTerminal发送消息.. 那么这就是我的代码
_serialPort.Open();
_serialPort.Write("AT+CMGF=1\r");
_serialPort.Write("AT+CMGS=\"" + mobilenumber + "\"\r\n");
_serialPort.Write("My Mesage" + "\x1A");
_serialPort.Close();