Go Down

Topic: Deleting SMS after being read not always working (Read 530 times) previous topic - next topic

adamhammad

Hey guys,

I have a SIM900 shield which is setup to perform an action once it receives a text message containing a certain message. I want the text messages to be deleted after they have been read.

The problem i'm having is that the text messages that contain the message do not get deleted, yet the text messages that dont contain the message do get deleted.

Here is a copy of my loop:

Code: [Select]
void loop()
{
    if(started)
    {
        //Read if there are messages on SIM card and print them.
        sms_position=sms.IsSMSPresent(SMS_UNREAD);
        if (sms_position)
        {
            // read new SMS
           
               
             
            Serial.print("SMS postion:");
            Serial.println(sms_position,DEC);
            sms.GetSMS(sms_position, phone_number, sms_text, 100);
            // now we have phone number string in phone_num
            Serial.println(phone_number);
            // and SMS text in sms_text
            Serial.println(sms_text);
           
           
                       
           if (strcmp (sms_text,"Hello") == 0) {
             myServo.attach(9);
             
              myServo.write(90);              // tell servo to go to position in variable 'pos'
              delay(4000);                       // waits 15ms for the servo to reach the position
           
            myServo.write(180);              // tell servo to go to position in variable 'pos'
              delay(1000);     
             
             myServo.detach();
             
             return;
           }
           
                   
          sms.DeleteSMS(sms_position);   
       
        }   
        else
        {
            Serial.println("NO NEW SMS,WAITTING");
             
        }     
       
       
               
        delay(1000);
       
    }
}

Go Up