Hi altogether,
over the last few days, I did some tweaks, tryouts and research.
To cut it down simply:
The biggest problem is the esp library. Some timeouts are predefined (3000ms/10000ms) and the functions are wating for an esp response over uart (no interrupt, so the mega could do sth. else, like detecting a touch or draw the display).
I discussed pretty much with engolling and we came to the conclusion to check if a connection was lost and try again some attempts later.
Normally 4 WDs need between
400 and 700ms to receive over TCP and the sending of extra sensors comes afterwards with additional
1500ms+x (depending on the configured extra sensors amount)
Each not responding device needs sth. like
3000ms more. After this time, the createTCP (inside) function returns error and this means false.
If we try to release a connection, that has not been established (releaseTCP function on the wrong place, or no error handling of the createTCP function), it takes aroung
8000ms per device.
I added a check if the payload (http body) is in the first TCP package or in the second (sometimes the first is only the header,and the second it the body, or they come together).
I created a struct for a WD object with the following variables:
- bool WIFIunit_configured; --> it checks, if a WD is configured.
- bool WIFIunit_connected; --> It safes the state, if it is connected (or it did not have a connection loss)
- int WIFIunit_attempts; --> it counts up the attempts not trying to connect again (the variable that is being compared to that can be adjusted; e.g. 5 is sth. like 15min and 10 is like 30min; if the interval of checking data is 3min)
- char* WIFIunit_address; --> the unit adress or IP (both working at my network)
- int WIFIunit_port; --> the port of the device, if this differs and is not the standard port 80
So now a device can have another port and one can be left out in the middle also, so extra sensors 5,1;5,3 and 5,4 for example can be configured.
Right now the code is in debugging mode and not nice. I will send an Email to (you) Werk_AG and all of us can discuss how to implement it (even better) and if my recent changes could go into production branch.
If somebody also has ideas, feel free to join the discussion

.