Gprs Shield...

Hi.. I wanna know what is wrong with my codes. I want to delete any unauthorized SMS sent by other phone number not in my phonebook.. but this code deleted all sms instead, even phone book save in the SIMCARD.

if (GETSMS_AUTH_SMS == sms.GetAuthorizedSMS(1, phone_num, sms_text, 100, 1, 10)) {
                                Serial.println(phone_num);
                                Serial.println(sms_text);
                                String smscommand(sms_text);
                             if (smscommand.equalsIgnoreCase(string1)){ 
                                                    // do...something....      
                                                   Serial.println("Working");
                                                   sms.DeleteSMS(1);
                             }
                              else if  (smscommand.equalsIgnoreCase(strlock)){ 
                                              //   do...something.... 
                                               Serial.println("Working");
                                               sms.DeleteSMS(1);
                                   
                                }

                              else {
                                     sms.DeleteSMS(1);
                                      Serial.println("not working");
                               }
 }
 else {
        sms.DeleteSMS(1);
        Serial.println("Deleted");
 }

Example output....

Deleted Deleted Deleted Deleted Deleted Deleted Deleted Deleted Deleted Deleted Deleted Deleted Deleted Deleted Deleted

I would start by checking what the sms.GetAuthorizedSMS() returns. Try this:

int rc = sms.GetAuthorizedSMS(1, phone_num, sms_text, 100, 1, 10);
Serial.println(rc);

then check the meaning of the return code (rc) in your documentation.

ERROR ret. val:

—————

-1 – comm. line to the GSM module is not free

-2 – GSM module didn’t answer in timeout

-3 – position must be > 0

OK ret val:

———–

GETSMS_NO_SMS – no SMS was found at the specified position

GETSMS_NOT_AUTH_SMS – NOT authorized SMS found at the specified position

GETSMS_AUTH_SMS – authorized SMS found at the specified position

This is the document all about..

Yes, but what return code did you get? The only thing we know is you didn't get GETSMS_AUTH_SMS.