diff --git a/RTC/set_with_NTP.py b/RTC/set_with_NTP.py index 51fd756..811a110 100755 --- a/RTC/set_with_NTP.py +++ b/RTC/set_with_NTP.py @@ -1,6 +1,12 @@ #!/usr/bin/python3 """ -Script to set the RTC using an NTP server. + ____ _____ ____ + | _ \_ _/ ___| + | |_) || || | + | _ < | || |___ + |_| \_\|_| \____| + +Script to set the RTC using an NTP server (script used by web UI) RPI needs to be connected to the internet (WIFI). Requires ntplib and pytz: sudo pip3 install ntplib pytz --break-system-packages diff --git a/RTC/set_with_browserTime.py b/RTC/set_with_browserTime.py index e0c8e80..588ffb4 100755 --- a/RTC/set_with_browserTime.py +++ b/RTC/set_with_browserTime.py @@ -1,5 +1,11 @@ """ -Script to set the RTC using the browser time. + ____ _____ ____ + | _ \_ _/ ___| + | |_) || || | + | _ < | || |___ + |_| \_\|_| \____| + +Script to set the RTC using the browser time (script used by the web UI). /usr/bin/python3 /var/www/nebuleair_pro_4g/RTC/set_with_browserTime.py '2024-01-30 12:48:39' diff --git a/loop/SARA_send_data_v2.py b/loop/SARA_send_data_v2.py index 845be4d..408831b 100755 --- a/loop/SARA_send_data_v2.py +++ b/loop/SARA_send_data_v2.py @@ -290,23 +290,45 @@ try: print('
') print(response2) - print("
") + print("", end="") match = re.search(r'\+CSQ:\s*(\d+),', response2) if match: signal_quality = int(match.group(1)) @@ -425,7 +447,7 @@ try: responseReconnect = read_complete_response(ser_sara, timeout=20, end_of_response_timeout=20) print('') print(responseReconnect) - print("
") + print("", end="") print('🛑STOP LOOP🛑') print("') print(response_SARA_3) - print("
") + print("", end="") # si on recoit la réponse UHTTPCR if "+UUHTTPCR" in response_SARA_3: @@ -547,7 +569,7 @@ try: response_SARA_9 = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False) print('') print(response_SARA_9) - print("
") + print("", end="") ''' +UHTTPER: profile_id,error_class,error_code @@ -580,7 +602,7 @@ try: responseResetHTTP2_profile = read_complete_response(ser_sara, timeout=5, end_of_response_timeout=5, wait_for_lines=["OK", "+CME ERROR"], debug=True) print('') print(responseResetHTTP2_profile) - print("
") + print("", end="") # 2.2 code 1 (HHTP succeded) @@ -597,7 +619,75 @@ try: response_SARA_4 = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False) print('') print(response_SARA_4) - print('
') + print("", end="") + + #Parse the server datetime + # Extract just the date from the response + date_string = None + date_start = response_SARA_4.find("Date: ") + if date_start != -1: + date_end = response_SARA_4.find("\n", date_start) + date_string = response_SARA_4[date_start + 6:date_end].strip() + print(f'Parsed datetime: {server_datetime}
') + except Exception as e: + print(f'Error parsing date: {e}
') + + # Get RTC time from SQLite + cursor.execute("SELECT * FROM timestamp_table LIMIT 1") + row = cursor.fetchone() + rtc_time_str = row[1] # '2025-02-07 12:30:45' or '2000-01-01 00:55:21' or 'not connected' + print(f'Error comparing times: {e}
') + #Si non ne recoit pas de réponse UHTTPCR #on a peut etre une ERROR de type "+CME ERROR: No connection to phone" ou "Operation not allowed" @@ -629,7 +719,7 @@ try: responseReconnect = read_complete_response(ser_sara, timeout=5, end_of_response_timeout=120, wait_for_lines=["OK", "+CME ERROR"], debug=True) print('') print(responseReconnect) - print("
") + print("", end="") # Handle "Operation not allowed" error if error_message == "Operation not allowed": print('❓Try Resetting the HTTP Profile❓') @@ -638,7 +728,7 @@ try: responseResetHTTP_profile = read_complete_response(ser_sara, timeout=5, end_of_response_timeout=5, wait_for_lines=["OK", "+CME ERROR"], debug=True) print('') print(responseResetHTTP_profile) - print("
") + print("", end="") check_lines = responseResetHTTP_profile.strip().splitlines() for line in check_lines: if "+CME ERROR: Operation not allowed" in line: @@ -687,7 +777,7 @@ try: print('') print(response_SARA_8) - print("
") + print("", end="") # si on recoit la réponse UHTTPCR if "+UUHTTPCR" in response_SARA_8: @@ -740,7 +830,7 @@ try: response_SARA_9b = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False) print('') print(response_SARA_9b) - print("
") + print("", end="") ''' +UHTTPER: profile_id,error_class,error_code @@ -773,7 +863,7 @@ try: response_SARA_4b = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False) print('') print(response_SARA_4b) - print('
') + print("", end="")