I'm running a Uno R4 Wifi connected to the IoT Cloud. In addition to reporting measured parameters to the cloud, it also does some autonomous tasks that do not require a cloud connection.
The problem that I have is that if the wifi connection is lost, the device goes into a reconnection attempt loop every 500 ms (almost continuously) and while doing so, it neglects its automous functions, or does so very very slowly.
My question is whether there a way to modify how often it attempts to reconnect to wifi? If it attempted to reconnect once every minute or several minutes instead of every 500 ms, it would still be able to perform its measurements and take required autonomous actions between reconnect attempts.
It's using WiFiConnectionHandler with ArduinoIoTPreferredConnection.
Looks like there are no public way to modify the interval, and it's const. But you can modify the source of the library directly. If you ever update the library, you'll need to reapply the change. The libraries directory is in your sketchbook directory. The file is libraries/Arduino_ConnectionHandler/src/ConnectionHandlerDefinitions.h
If you pass false, the WFCH will start in its INIT state and (try to) connect; then if it disconnects, it won't try to re-INIT and will instead go to its CLOSED state. In theory, you could hook some events and manage this manually. However, calling the connect function always then set the protected _keep_alive to true, so that would only work once. Maybe you could subclass WFCH and not do that, or set it right back to false.