Attempting to detect GSM call status

I am attempting to detect the status of a phone call; Ringing, Busy, Connected, etc. Once detected, I set a variable for future use. The below test code waits for an AT command to the GSM, then echo's the GSM response to the Monitor Serial. AT+CRSL=4 instructs the GSM module to echo the status in the form of "MO RING", "MO CONNECTED", etc.

I am fairly certain that the issue is in the statement ' if (receivedChars=="MO RING"){ '

From reading the forums it appears that I need to convert receivedChars to a string prior to doing the comparison.

Any Help would be appreciated!

const byte numChars = 32;
char receivedChars[numChars]; // an array to store the received data
boolean newData = false;
int hit=0;

void setup()
{
  Serial1.begin(115200);               // the GPRS baud rate   
  Serial.begin(9600);                 // console baud rate
  Serial1.println("AT+CRSL=4");
  Serial.println("type AT command");
}
void loop()
{
 if (Serial.available()){
    Serial1.write(Serial.read());
    delay(100);
}
 static byte ndx = 0;
 char endMarker = '\n';
 char rc;

 // if (Serial1.available() > 0) {
           while (Serial1.available() > 0 && newData == false) {
 rc = Serial1.read();
 if (rc != endMarker) {
 receivedChars[ndx] = rc;
 ndx++;
 if (ndx >= numChars) {
 ndx = numChars - 1;
 }
 }
 else {
 receivedChars[ndx] = '\0'; // terminate the string
 ndx = 0;
 newData = true;
 }
 }
 if (newData == true) {
 Serial.print("This just in ... "); 
 Serial.println(receivedChars);
  if (receivedChars=="MO RING"){
  Serial.println("HIT");  // just here for debugging
  hit=1;
 }
 newData = false;
}
}

You cant do this:

char receivedChars[numChars];   // contains null terminated string
. . .
if (receivedChars=="MO RING"){
    // do something
}

You have to do something like this:

if (strcmp(receivedChars, "MO RING") == 0) {
    // do something
}

I really appreciate your effort to help. I made the below changes to the code:

Serial.println(receivedChars);
  if (strcmp(receivedChars,"ATH") == 0) {
  Serial.println("HIT");
}

I get the below response from the serial monitor:

This just in ... ATH This just in ... OK This just in ...

I am expecting the word HIT to appear after "This just in ... ATH" inidcating a match. It appears that there may be something after the ATH. I have tried /n and /0 but still do not get the print of HIT indicating a match.

I am using ATH to simply for testing, that way I do not need to make a call to get the "MO RING", but I have tried with that also and there is not a match.

Thanks!

Just to check if you are getting extraneous characters in receivedChars which would interfere with your if statement, after:

rc = Serial1.read();

You could do something like:

Serial.print(">") ;
Serial.print(rc) ;
Serial.println("<") ;

:) That helped... the ATH was getting ATH\r\r, and the MO RING\r, I made it difficult on myself by switching to ATH for my test as I did try the /r

Thanks for all of your help. this was the last stumbling block in my project of converting an old pay phone in to a pay cell phone. :)

Thanks for your assistance!