Checking connection to the cloud lost [Risolto]

I created an application on OPTA to manage a submersible water pump. The application is registered in the Arduino cloud for remote management of the pump.
For now it is still in the experimental phase and the OPTA was therefore connected via serial to the PC. Looking at the situation on the smartphone I realized that the data had not updated, and I realized that in the serial monitor it had been repeating, for several hours, that it was reconnecting to the cloud. I reset the OPTA and the system restarted.
Question: is there a method to check from the program whether the connection to the cloud is enabled or not to force the system reset?
Thanks everyone.
Claudio

I have not yet figured out how to stop the Opta from cycling when Wifi is lost. This makes the device useless for robust applications. Hope Arduino starts listening and there is a fix for this. The PLC runtime needs to continue running even when wifi is lost.

Have a look here at the details of the cloud variables.
https://docs.arduino.cc/arduino-cloud/cloud-interface/variables/

Here is some sample code that will monitor the status, but that's all.

 if(ArduinoCloud.connected()) {/*Do something*/} 
 if(ArduinoCloud.connecting()) {/*Do something*/} 
 if(ArduinoCloud.disconnected()) {/*Do something*/} 
 if(ArduinoCloud.synchronized()) {/*Do something*/} 


Ciao @crc57
take a look at callbacks as well
https://docs.arduino.cc/arduino-cloud/features/arduino-cloud-callbacks/