When I connect to the network, I find that the data in the serial port is sent twice.
Here is the code to implement the connection.
Further, you can see that there is a dot in the first box and none in the box below. Meanwhile, printed 2 should actually be the callback when the "SYSTEM_EVENT_STA_DISCONNECTED" event was triggered, but it was triggered at connection time.
And I found that the number "2" was printed twice as often as the number of Internet connections. As you can see, the "2" was printed 4 times when I connected to the network, and the "2" was also printed 4 times when I closed the hotspot. When I connected to the network again, the "2" was printed 6 times, and likewise, when I turned off the hotspot, the "2" was still printed 6 times.
I want to know what causes this and how to avoid it.