Esp8266 with SoftwareSerial garbled problem

I'm a arduino rookie and forgive my poor English,

I have a program use SoftwareSerial communicate with esp8266 esp01 module

here is the code:
Github

in the code,

I call esp.readData() when softwareSerial is available,

class Esp8266 will parse the receive data from rx

it will print some info like "[WIFI CONNECTED]" or "[GOT IP]" when receive correspond string

if it receive string that not recognized, it will print directly.

or i can send AT command directly and print receive string directly.

on direct mode, it just like use ReadTerm to communicate with esp

Now i have some problem,

when esp send me a WIFI CONNECTED message,

i got some garbled like:(it almost gets the same string but gets different string sometimes)

WIFI CO⸮
*⸮U⸮

but when i enter the direct mode, i got:

WIFI CONNECTED

it seems there is no problem with esp chip, so what wrong with my code?


img

did you set the baud rate in AT firmware to 9600 baud, if you have 9600 for SoftwareSerial?

Juraj:
did you set the baud rate in AT firmware to 9600 baud, if you have 9600 for SoftwareSerial?

Yes I did but garbled still shows up.