ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Apr 08, 2013 8:52 am |
|
|
Hi,
After I've parsed my TXT message into a string, I do something like this to see if I have a valid command:
Code: |
// Here we test for the 'Output 1' Cmd
if (strstr(Msg2, CMD1))
{
if (strstr(Msg2, CMD4)) // Here we test for the 'On' Cmd
{
Output1_Status = True;
ReplyMsgType = 1;
}
else if (strstr(Msg2, CMD5)) // Here we test for the 'Off' Cmd
{
Output1_Status = False;
ReplyMsgType = 1;
|
I've previously defined my commands like this:
Code: |
char CMD1[] = "OUTPUT 1 ";
char CMD4[] = "ON";
char CMD5[] = "OFF";
|
First, I check for the presence of the "OUTPUT 1" in the string, and then I check for "ON" or "OFF". Note, I use the toupper command to put everything in the MSG2 array in upper case, so it doesn't matter how the user sends it!
John |
|