Read SMS though D-Link DWM 156 SMS modem
Respected Sir,
I am trying to Read SMS though D-Link DWM 156 SMS modem I wrote following code. using this code I am not able to read long message
My message is
Start message
1)
2)SIOB 1204-102,ON,12/05/2012 16:71:7,6 12/05/2012 16:71:7
3)
4)
End Message
before and after message spaces is there
private void tmrRec_Tick(object sender, EventArgs e)
{
try
{
string strCommand = "AT+CMGL=\"REC UNREAD\"";
objShortMsgColl= objSMS.ReadSMS(this.port, strCommand) ;
foreach (ShortMsg msg in objShortMsgColl)
{
ListViewItem item = new ListViewItem(new string[]{ msg.Sent, msg.Sender, msg.Message });
lvwMsg.Items.Add(item);
}
Read Function
public ShortMsgColl ReadSMS(SerialPort port, string p_strCommand)
{
ShortMsgColl messages = null;
try
{
#region Execute Command
// Check connection
ExecCommand(port, "AT", 300, "No phone connected");
// Use message format "Text mode"
ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.");
// ExecCommand(port, "AT+CFUN=1", 300, "Failed to set message format.");
// ExecCommand(port, "AT+CCFC=0", 300, "Failed to set message format.");
// Use character set "PCCP437"
ExecCommand(port, "AT+CSCS=\"PCCP437\"", 300, "Failed to set character set.");
// Select SIM storage
ExecCommand(port, "AT+CPMS=\"SM\"", 300, "Failed to select message storage.");
//ExecCommand(port, "AT+CMGR=\"SM\"", 300, "Failed to select message storage.");
//AT+CPMS="ME","SM","MT"
// Read the messages
//string input = ExecCommand(port, "AT+CMGL=\"REC UNREAD\"", 5000, "Failed to read the messages.");
string input = ExecCommand(port, p_strCommand, 5000, "Failed to read the messages.");
#endregion
#region Parse messages
messages = ParseMessages(input);
#endregion
}
catch (Exception ex)
{
throw ex;
}
if (messages != null)
return messages;
else
return null;
}