Problem while accessing new incoming messages with EC200U CN module

I am trying to access/print new incoming messages on serial monitor. I interfaced EC200U with ESP32 and using UART. I am not able to access messages, sometimes it gets updated in storage but giving cms error 304 while reading it.
This is my code below. Please tell some solution.

const int RX_PIN = 16;
const int TX_PIN = 17;

void setup() {
// Initialize Serial Monitor
Serial.begin(115200);

// Initialize Serial2 for EC200U communication
Serial2.begin(115200, SERIAL_8N1, RX_PIN, TX_PIN);

// Set SMS text mode
Serial2.println("AT+CMGF=0");


// Set the module to notify the MCU of incoming messages
Serial2.println("AT+CNMI=1,2,0,1,0");

}

void loop() {
// Check and print new incoming messages
if (Serial2.available()) {
String message = Serial2.readString();
Serial.print("Received message: ");
Serial.println(message);
}

Serial2.println(“AT+CPMS?”);
delay(1000);

Serial2.println(“AT+CMGL”);
delay(1000);

Serial2.println(“AT+CMGL="ALL"”);
delay(1000);

Serial2.println(“AT+CMGR=2”);
delay(1000);
}

That’s PDU mode. Text mode is: AT+CMGF=1

You’re sending incoming SMSs directly to the serial port.

There should be no SMSs in storage to read. Your +CNMI command has sent them all to the serial port instead.

What are you trying to achieve?

Ignore the commands in loop function. I want like new incoming messages should be get updated on serial. And I am not getting it.

Do you mean you’re not getting any SMS-related unsolicited result?

Are any going into SMS storage? Read command: AT+CPMS?

This is my updated code. I am not getting incoming messages on serial.

// Define pins for Serial2 communication with EC200U
const int RX_PIN = 16; // Define RX pin
const int TX_PIN = 17; // Define TX pin

// Function prototypes

void checkAndPrintNewMessages();
void readAndPrintMessage(int index);

void setup() {
// Initialize Serial Monitor
Serial.begin(115200);

// Initialize Serial2 for EC200U communication
Serial2.begin(115200, SERIAL_8N1, RX_PIN, TX_PIN);

// Set SMS text mode
Serial2.println("AT+CMGF=1");

Serial2.println("AT+CSCS=\"GSM\"");

// Set the module to notify the MCU of incoming messages
Serial2.println("AT+CNMI=2,2,0,0,0");

}

void loop() {
// Check and print new incoming messages
if (Serial2.available()) {
String message = Serial2.readString();
Serial.print("Received message: ");
Serial.println(message);
}
}

What does the AT command AT+CPMS? return?

I checked the module with QNavigator software, I am getting new incoming messages with AT+CNMI=1,2,0,1,0. But on serial I am not getting. I am not getting where is the fault. The same configuration is used in code as in QNavigator. If anyone has done then please help out.