Read long sms from modem

395 Views Asked by At

I read some SMS from the modem (by AT command). I use gsmcomm library. I save read SMS as a string. But gsmcomm work with List of smsPDU.. I have some code- where SMS reading from device (not in a string). How convert my string to List? or add to 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);

    }
}

Help me, please.

0

There are 0 best solutions below