Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2009, 04:22 AM
Authorized User
 
Join Date: May 2004
Posts: 73
Thanks: 0
Thanked 1 Time in 1 Post
Default How to get messages from mobile phone or SIM's storage?

Hi guys,

I am working on a project where i have to send and receive sms messages using a GSM modem. Currently i am using my Samsung SGH-E250 phone as a GSM modem. I can successfully send messages and receives new messages. The problem is when i give the AT commands to get messages from phone or SIM's storage it gives weird output which i can not guess what it is. Below is the piece of code which is used to get messages:

string Resp = "";

MessagePort.WriteLine("AT+CMGF=1" + "\r"); /* message format = Text */
Resp = ReadPortEx();

MessagePort.WriteLine("AT+CMEE=1" + "\r"); /* set extended error reports. */
Resp = ReadPortEx();

MessagePort.WriteLine("AT+CPMS=?" + "\r"); /* Give preferred message storage. */
Resp = ReadPortEx();

MessagePort.WriteLine("AT+CPMS=\"ME\"" + "\r"); /* Read messages from phone/modem's storage. */
Resp = ReadPortEx();

//MessagePort.WriteLine("AT+CPMS=\"SM\"" + "\r"); /* Read messages from SIM's storage. */
//Resp = ReadPortEx();

//MessagePort.WriteLine("AT+CMGL=\"ALL\"" + "\r"); /* Get list of all messages. */

MessagePort.WriteLine("AT+CMGL=\"REC UNREAD\"" + "\r"); /* Get list of unread messages. */
Resp = ReadPortEx();

and the output it gives is a very large stream of characters like this:


"\r\n+CMGL: 0,\"REC READ\",\" eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\" eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\"

eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\" eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\"

eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\" eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\"

eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\" eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\"

eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\" eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\"

eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\" eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\"

eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\" eL\",\"|\",\"\",80,0\r\n,0\r\n\r\n+CMGL: 0,\"REC READ\",\"

Please tell me what is wrong with the AT commands or i am giving some wrong parameters or missing something . Please help.
__________________
BaburMan
 
Old February 15th, 2009, 10:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Not sure on your question.
But I used the code at this post successfully on several modems.
May find some answers there modem

You may also consider the escaped line return, try use (char)13 instead of \r.
Your compiler will inderstand \r but your modem may not, just a guess...could well be wrong.
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending SMS from Computer to Mobile Phone prasanthrc Apache Tomcat 3 November 6th, 2013 05:13 AM
How to get messages from phone or SIM's storage? baburman .NET Framework 2.0 0 February 5th, 2009 07:17 AM
Getting mobile phone number yukijocelyn C# 2005 0 May 28th, 2008 11:43 PM
Query a database with my mobile phone(GSM) p2ptolu Classic ASP Professional 0 April 12th, 2006 08:25 AM
Can dotnet create program for mobile phone doctorsom .NET Framework 2.0 1 November 8th, 2004 06:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.