I’ve been able to program my PIC (in C) to transmit SMS messages using UART (RX/Tx) to my cellphone using the GM862-QUAD. My problem is, how can I program my PIC to be able to read received SMS?
So far to send SMS, I simply use character string arrays with the AT commands needed to send SMS. But I am stumped as to how I can read SMS messages sent to the SIM card on the Telit module.
You can use the command “AT+CMGR=” to read a specific text message - where is the SMS location index.
You can list a group of SMS messages using the command"AT+CMGL=" - where is the type of message (“REC UNREAD”, “REC READ”, “STO UNSENT”, “STO SENT” OR “ALL”).
I do know how to transmit the AT commands to read text messages received. My problem is not in those commands but how can I get them from the Telit when I’m programming my PIC in C?
What I mean is. I save these commands in character array string such as this:
char ReadSMS=“AT+CMGR=”;
char str*;
str = ReadSMS;
Outstring(str); //Sends the ReadSMS string which is the AT command from the PIC to the Telit through UART (TX)
so, I get the text message ON the Telit, how do I retrieve that text message from the Telit to the PIC? Do I just use UART to read from the RX? I mean, I don’t see how using function from my PIC to read something from the Telit is going to get me the whole text message. Unless I’m over thinking this and it is truly that simple.
Yes it is as simple as reading the data from the UART. Your compiler should provide some funcitons for reading a string from the UART - the data from the GM-862 will be terminated with a carriage return/line feed.
oh goodness, thanks for clearing that up. I will try that when I get home and see how it goes, but I should be fine if I don’t need to program anything on the Telit to actually send it to the PIC. If i can retrieve the received SMS from the PIC then I’m all good.
Well, I’ve been trying to receive the responses from the Telit, but I have not been successful at it :(. This is what I got…
char *str;
char at=“AT”;
str=at; //Sends “AT”
OutStr(str);
DELAY_MS(300);
WriteUART1(0x0D); //Sends ENTER
WriteUART1(0x0A);
DELAY_MS(500);
do
{
rec = ReadUART1(); //Receive input from Telit and store in rec
WriteUART1(rec); //Echoes input to the screen
x[gm_inx] = rec; //input is inserted into char buffer
gm_inx++; //increased to insert next character into buffer
}while(rec != ‘/r’); //the input process continues until hits “enter”
So this is what I have to receive the commands from the Telit. For instance when I write “AT”, I’m trying to be able to read the “OK” and store it into some array. I tried this and it did not work for me. Any suggestions? I’ll try other methods
Why all of the Delays - shouldn’t be a need for them? During the 500mS delay between sending the return and reading the data the PIC isn’t reading the serial port. All of your data will be lost.
I assume ReadUART1() and WriteUART1() read and send to the Telit module? I also assumed you want to read the telit output and echo it somewhere else (says UART2)?
Apart from the delay you use as gsm_man suggested, it looks like you send whatever you receive from the Telit module back to itself and not to your “screen”.
Michel_e_r:
Hi,
char *str;
char at=“AT”;
str=at; //Sends “AT”
OutStr(str);
DELAY_MS(300);
WriteUART1(0x0D); //Sends ENTER
WriteUART1(0x0A);
DELAY_MS(500);
do
{
rec = ReadUART1(); //Receive input from Telit and store in rec
WriteUART1(rec); //Echoes input to the screen
x[gm_inx] = rec; //input is inserted into char buffer
gm_inx++; //increased to insert next character into buffer
}while(rec != ‘/r’); //the input process continues until hits “enter”
So this is what I have to receive the commands from the Telit. For instance when I write “AT”, I’m trying to be able to read the “OK” and store it into some array. I tried this and it did not work for me. Any suggestions? I’ll try other methods