I am working on SMS communication with my phone and arduino. My intension is simple
"when somebody send sms, the arduino should read a text file located in my server and forward the content to the same number".
The problem here is, when I send a sms to my arduino, which is waiting for my message, unfortunately does not read my message. But when I separately run this example code, I see my sms received there. It means, my sms is already present in the modem memory. But Why this happens ? how to solve this ? I will describe my code stucture :
void setup()
{
GSM and GPRS initialization
Connection to server
}
void loop()
{
smss();
Reading the txt file content in server
sms.beginSMS(remoteNum);
sms.print(txtMsg);
sms.endSMS();
}
void smss() // I just want phone number
{
if (sms.available())
{
Serial.println("Message received from:");
sms.remoteNumber(remoteNum, 20);
Serial.println(remoteNum);
sms.flush();
Serial.println("MESSAGE DELETED");
}
}