CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

SMS command recognizing

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
HUTHAIFA.N
Guest







SMS command recognizing
PostPosted: Fri Sep 12, 2008 10:04 pm     Reply with quote

Hi all
I want someone to help me with this.
I am new to SMS world but I learn how to use the PIC to send and receive SMS (text mode). I am preparing the code until the GSM is received from the seller.
The idea now that I want to send a command to the PIC via SMS and read it, so that if it is a predefined command a programmed action will be done.

I can simply send a command via SMS such as "ON" to the GSM connected to the PIC.

But now when received to the PIC i have 2 problems which i need to solve them simply. (I am not too good in programming).
I am using PCW 3.148.
First of all I used to save the messages received through:
Code:
#int_rda
void serial_isr()
{
rx[i++] = getch();
}

The first problem is:

- How to know if there is a new received message ?
Should i save the "+CNMI" in a variable such as : strcpy(s,"+CNMI")
and then compare it with the first 5 characters saved in "rx" ?

Or no need for this step ?
So just try to read the first message in a loop until it is a command message ?

- The second problem is:

How to know the command received ?
Is it right to put a symbol before the command such as "$" and search the message saved in "rx" for that symbol and when find it, try to know what is the characters followed it such as :
Code:

strcpy(cmd,"$ON")            // saving the command
x=0;                             
flag = 1;                        //flag
while(1)
{
data = rx[x];                  // character by character
if (data =="$")                // the symbol
{
  for(i = x;i<x+2;i++)
       if (rx[i] != cmd[i-x+1])      // Ensure just to compare cmd[0],cmd[1]
flag = 0;                     // Change the flag due to condition

........
and continue the code...............

hope you all help me .....
thx b4
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group