Buffered unsolicited codes

Hi,

If the UART goes into data mode, some unsolicited codes will be buffered, and coming out when UART back to command mode.

In some case there will be a lot of codes buffered (RING, CREG, +CMT, etc) and coming out at one time, causing troubles.

Just want to know besides subscribing all kinds of unsolicited codes, can I have a way to erase all buffered unsolicited codes just before backing to command mode ?