I have huge problem (and maybe misunderstand something) regarding compare incomming SMS with a string.
I'm comfused because it seems/should work, when print SMS to Monitor. Please look at my code below and the feedback from the monitor.
#include <SoftwareSerial.h>
#include <string.h>
String inData = "";
SoftwareSerial cell(2, 3);
void setup()
{
Serial.begin(9600);
cell.begin(9600);
Serial.flush();
cell.flush();
delay(10000); //Wait for GSM
Serial.println("Ready ..");
}
void loop()
{
if(cell.available() > 0) // Test if we receive something on the serial port.
{
char recv = cell.read(); // Read characters into recv
inData += recv; // Fill inData with characters received (recv)
if (recv == '\n') // If receiving a newline char
{
Serial.print("-------------\n"); // Print control chars (--) to ensure we have New Line and ready to compare
Serial.print(inData); // Print full string from inData
if (inData == "xxx") // Compare inData with "xxx"
{
Serial.print("OK!\n"); // If xxx is received, then print OK!
}
inData=""; // Clear inData buffer
}
}
}
/*
>>>>>>>This is what I'm receiving from incomming SMS on Serial Monitor<<<<<<<
Ready ..
-------------
-------------
+CMT: "+4512312312","","13/05/07,13:56:24+08"
-------------
xxx
*/