我从调制解调器读取了一些短信(通过 AT 命令)。我使用 gsmcomm 库。我将读取的 SMS 保存为字符串。但是 gsmcomm 可以与 smsPDU 列表一起使用。我有一些代码 - 从设备读取 SMS(不是在字符串中)。如何将我的字符串转换为列表?或添加到列表?
//I read sms with string
string input = ExecCommand("AT+CMGL=\"ALL\"", 5000, "Failed to read the messages.");
//other code with read long sms where read from device (not AT command)
List<string> messagesList = new List<messageList>();
List<SmsPdu> multiPartMsg = new List<SmsPdu>();
foreach (var i in modem.ReadMessages(PhoneMessageStatus.All, PhoneStorageType.Phone))
{
string msg;
if (SmartMessageDecoder.IsPartOfConcatMessage(((SmsDeliverPdu)i.Data)))
{
multiPartMsg.Add(i.Data);
try
{
if (SmartMessageDecoder.AreAllConcatPartsPresent(multiPartMsg))
{
msg= SmartMessageDecoder.CombineConcatMessageText(multiPartMsg);
messagesList.Add(msg);
multiPartMsg.Clear();
}
}
catch (Exception ex) {}
}
else
{
msg = ((SmsDeliverPdu)i.Data).UserDataText;
messagesList.Add(msg);
}
}
请帮帮我。