我从调制解调器读取了一些SMS(通过AT命令)。我使用gsmcomm库。我将读取的SMS保存为字符串。但是gsmcomm与smsPDU列表一起工作。我有一些代码,其中SMS是从设备读取的(不是字符串)。如何将我的字符串转换为List?或添加到列表中?
//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);
}
}
请帮助我。