1

我正在通过流动命令以 PDU 模式发送短信。“长度”是显示 pdu 长度的标签。

当我编写 AT+CMGS=20 或任何长度时,我的代码正在工作,但我希望该代码采用标签值而不是在代码中编写静态值,我在下面提到的方式使用它,但它不起作用。

如果我以错误的方式做事,谁能帮助我如何编写代码?

string recievedData = ExecCommand(port, "AT", 500000, "No phone connected");
recievedData = ExecCommand(port, "AT+CMGF=0", 500000, "Failed to set message format.");

string command = "AT+CMGS=\""+ length +" \"";
recievedData = ExecCommand(port, command, 500000, "Failed to accept phoneNo");
command = p1 + char.ConvertFromUtf32(26) + "\r";
recievedData = ExecCommand(port, command, 5000, "Failed to send message");
4

1 回答 1

1

线

string command = "AT+CMGS=\""+ length +" \"";

会产生AT+CMGS="20 ". 如果你想让它变成AT+CMGS=20你应该写

string command = "AT+CMGS="+ length;
于 2012-04-21T13:09:12.167 回答