Hi I am using to above library with an ESP-7 module which is connected to the MCU on Serial1 (hardware).
The program
- Sends measurement data with MQTT every second
- Sends and receives UDP packets asynchronously
There is a continuous incoming stream of UDP packets even though the program responds to only those that are addressed to it.
The problem begins when AT commands are also sent to the ESP module for example when I periodically check the WiFI connection using:
if (WiFi.status() == WL_CONNECTED) { ... }
These AT commands sent to the ESP seem to interfere with the incoming UDP traffic.
Sometimes, the ESP response to the AT command or even some UDP traffic is lost.
There is also some delay in the ESP response to AT commands which makes things even worse.
Eventually the WiFi connection itself is also lost!
The command above is issued once every 5 secs.
Increasing this time, improves performance but still its not perfect.
I then decided to use a "watchdog" timer which prevents interrogation of the WiFi status as long as UDP traffic keeps coming (which means that the connection is OK).
Only if the timer times out, the ESP is asked for status.
I am wondering if there is a better, more efficient way to do this..
I am not even sure how concurrent MQTT transmission affects all this.
Any ideas?