From 6939b9911c06689467884dec9b0df0f6a41558e3 Mon Sep 17 00:00:00 2001 From: Kerboul Date: Sun, 27 Apr 2025 19:53:39 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20gestion=20de=20la=20connectiv?= =?UTF-8?q?it=C3=A9=20Internet=20avec=20r=C3=A9tablissement=20automatique?= =?UTF-8?q?=20et=20passage=20en=20mode=20hors=20ligne=20si=20n=C3=A9cessai?= =?UTF-8?q?re?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Automate.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Automate.py b/Automate.py index bc5e635..41b0228 100644 --- a/Automate.py +++ b/Automate.py @@ -23,6 +23,21 @@ def main(): logging.info("==================== AUTOMATISATION TIMELAPSE ====================") try: + # Vérifier la connectivité Internet avant de continuer + if not api_client.check_connection(): + logging.warning("Connexion Internet perdue. Tentative de rétablissement...") + from timelapse.sensors import micro_controller + micro_controller.reconnect_wifi() + + if not api_client.check_connection(): + logging.error("Impossible de rétablir la connexion Internet. Passage en mode hors ligne.") + online_status = False + else: + logging.info("Connexion Internet rétablie avec succès.") + online_status = True + else: + online_status = True + # Récupérer le statut de la caméra depuis l'API camera_status = api_client.get_camera_status() @@ -51,7 +66,6 @@ def main(): # Prendre une image et l'envoyer logging.info("Prise d'image en mode maintenance pour projet en cours") - online_status = api_client.check_connection() timelapse_manager.single_capture(online=online_status) # Décrémenter le compteur d'images restantes