SIM808 Message Reciving Issue

I’m running UNV SIM808 Shield with Arduino Uno using DFRobot_SIM808. The shield has no issues detecting incoming SMS while powered on. I just found out if the shield is off while sending the SMS, it won’t detect it when it becomes online again.

#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
int messageIndex = 0;

char phone[16];
char datetime[24];

#define PIN_TX    3
#define PIN_RX    2

SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

void setup() {
  mySerial.begin(9600);  Serial.begin(9600);
  while(!sim808.init())  { Serial.println("Starting Sim808...");   sim808.powerUpDown(9); }
}

void loop() {
   messageIndex = sim808.isSMSunread();     //** Detecting unread SMS **
   Serial.print("messageIndex: ");    Serial.println(messageIndex);

   if (messageIndex > 0) {       //** At least, there is one UNREAD SMS **
      sim808.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
                 
      sim808.deleteSMS(messageIndex);
      Serial.print("From number: ");           Serial.println(phone);  
      Serial.print("Datetime: ");              Serial.println(datetime);        
      Serial.print("Recieved Message: ");      Serial.println(message);    
   }
}

I’m sharing the serial monitor data after powering off the shield. I sent a this message (2:24) at 2:24 AM local time. 10 mins later, I powered the shield on and waited for the message to be detected but with no luck for 15 mins. I sent another message (2:49) local time while the shield is on and it was detected right away along with the previous message.

02:34:56.342 -> Starting Sim808...
02:35:06.958 -> Init Success, please send SMS message to me!
02:35:09.602 -> messageIndex: -1
02:40:00.686 -> messageIndex: 0
02:45:02.311 -> messageIndex: 0
02:49:26.940 -> messageIndex: 0
02:49:29.560 -> messageIndex: 0
02:49:32.216 -> messageIndex: 0
02:49:33.565 -> messageIndex: 7
02:49:36.269 -> From number: +***********
02:49:36.322 -> Datetime: 21/04/21,02:24:20+12
02:49:36.369 -> Recieved Message: 2:24
02:49:37.624 -> messageIndex: 8
02:49:40.373 -> From number: +***********
02:49:40.373 -> Datetime: 21/04/21,02:49:28+12
02:49:40.426 -> Recieved Message: 2:49
02:49:43.029 -> messageIndex: 0
02:49:45.691 -> messageIndex: 0
02:49:48.314 -> messageIndex: 0

Here is code for sim808.isSMSunread(); function. Maybe there is something can be tweaked within the code can mitigate this issue:

char DFRobot_SIM808::isSMSunread(){
    char gprsBuffer[48];  //48 is enough to see +CMGL:
    char *s;
    
    sim808_check_with_cmd("AT+CMGF=1\r\n","OK\r\n",CMD);    delay(1000);
    sim808_send_cmd(F("AT+CMGL=\"REC UNREAD\",1\r\n"));
    sim808_clean_buffer(gprsBuffer,31); 
    sim808_read_buffer(gprsBuffer,30,DEFAULT_TIMEOUT); 

    if(NULL != ( s = strstr(gprsBuffer,"OK"))) {
        delay(50);
        return 0;
    } else {
        sim808_wait_for_resp("OK\r\n", CMD);        
        sim808_send_cmd("AT+CMGL=\"REC UNREAD\",1\r\n");
        sim808_clean_buffer(gprsBuffer,48); 
        sim808_read_buffer(gprsBuffer,47,DEFAULT_TIMEOUT);
        if(NULL != ( s = strstr(gprsBuffer,"+CMGL:"))) {
            s = strstr(gprsBuffer,":");
            if (s != NULL) {
                sim808_wait_for_resp("OK\r\n", CMD);
                return atoi(s+1);
            }
        } else {
            return -1; 
        }
    } 
    return -1;
}