Hello! I'm trying to make a sim800l GSM module to send a command based on a received message, and I simply can't understand what's wrong with my code. Any message i send, it's going to enter on the first branch of the IF statement .
void loop() {
lastMessage = getLatestMessageIndex();
Serial.println(lastMessage);
if (lastMessage!=0){
String msg=readSMS(lastMessage);
if (msg.indexOf("+40741118109")>=0){
Serial.println("NR OK");
Serial.println(msg);
if (msg.indexOf("PORNESTE">=0)){ //No matter what message i send, it will ALWAYS enter this branch
Serial.println("PORNESTE, STATE="+state);
if (state != "ON"){
const char* number=strdup("telnumber");
char* text=strdup("ON.1");
sendSMS(number,text);
state="ON";
Serial.println("ON MESSAGE");
}
}
else{
if (msg.indexOf("OPRESTE">=0)){
Serial.println("OPRESTE, STATE="+state);
if (state != "OFF"){
const char* number=strdup("telNumber");
char* text=strdup("OFF.1");
sendSMS(number,text);
state="OFF";
Serial.println("OFF MESSAGE");
}
}
}
}
}
}
Have i missed something on this piece of code?...