update
This commit is contained in:
@@ -99,6 +99,7 @@ import time
|
||||
import busio
|
||||
import re
|
||||
import os
|
||||
import requests
|
||||
import traceback
|
||||
import threading
|
||||
import sys
|
||||
@@ -325,6 +326,7 @@ try:
|
||||
row = cursor.fetchone() # Get the first (and only) row
|
||||
rtc_time_str = row[1] # '2025-02-07 12:30:45' ou '2000-01-01 00:55:21' ou 'not connected'
|
||||
print(rtc_time_str)
|
||||
|
||||
if rtc_time_str == 'not connected':
|
||||
print("⛔ Atttention RTC module not connected⛔")
|
||||
rtc_status = "disconnected"
|
||||
@@ -481,14 +483,37 @@ try:
|
||||
response2 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||
|
||||
#Here it's possible that the SARA do not repond at all
|
||||
#-> try to establish connection
|
||||
#-> TO DO : harware reboot
|
||||
#-> send notification
|
||||
#-> end loop, no need to continue
|
||||
if response2 is None or response2 == "" or not any(expected in response2 for expected in ["OK", "ERROR", "+", "AT"]):
|
||||
print("No answer from SARA module")
|
||||
print('🛑STOP LOOP🛑')
|
||||
print("<hr>")
|
||||
|
||||
# Send notification
|
||||
try:
|
||||
# Format the URL with the device_id
|
||||
alert_url = f'http://data.nebuleair.fr/pro_4G/alert.php?capteur_id={device_id}&error_type=serial_error'
|
||||
|
||||
# Send POST request with short timeout
|
||||
response = requests.post(alert_url, timeout=3)
|
||||
|
||||
if response.status_code == 200:
|
||||
print(f"Alert notification sent successfully")
|
||||
else:
|
||||
print(f"Alert notification failed with status code: {response.status_code}")
|
||||
|
||||
except Exception as e:
|
||||
# Catch any exception and continue
|
||||
print(f"Alert notification failed: {e}")
|
||||
|
||||
#end loop
|
||||
sys.exit()
|
||||
|
||||
else :
|
||||
print("✅SARA is connected over serial")
|
||||
|
||||
print('<p class="text-danger-emphasis">')
|
||||
print(response2)
|
||||
print("</p>", end="")
|
||||
@@ -730,9 +755,9 @@ try:
|
||||
|
||||
print(f'<div class="text-primary">Time difference: {time_diff:.2f} seconds</div>', end="")
|
||||
|
||||
# Check if difference is more than 10 seconds
|
||||
# Check if difference is more than 60 seconds
|
||||
# and update the RTC clock
|
||||
if time_diff > 10:
|
||||
if time_diff > 60:
|
||||
print(f'<div class="text-warning"><strong>⚠️ RTC time differs from server time by {time_diff:.2f} seconds!</strong></div>', end="")
|
||||
# Format server time for RTC update
|
||||
server_time_formatted = server_datetime.strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
Reference in New Issue
Block a user