From 9d280c6e37a1203da735d2511e00aa03730398ec Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 1 Apr 2025 11:57:39 +0200 Subject: [PATCH] update --- SARA/reboot/start.py | 2 +- html/admin.html | 11 +++++++++ loop/SARA_send_data_v2.py | 49 +++++++++++++++++++++++++++++++++++---- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/SARA/reboot/start.py b/SARA/reboot/start.py index 001d93f..5d5ca8b 100644 --- a/SARA/reboot/start.py +++ b/SARA/reboot/start.py @@ -301,7 +301,7 @@ try: print(response_SARA_5cf) time.sleep(0.5) - #step 4: set url (op_code = 1) + #step 4: set url (op_code = 1) print("➡️SET URL") command = f'AT+UHTTP={uSpot_profile_id},1,"{uSpot_url}"\r' ser_sara.write((command + '\r').encode('utf-8')) diff --git a/html/admin.html b/html/admin.html index 1d109d8..9908c0a 100755 --- a/html/admin.html +++ b/html/admin.html @@ -118,6 +118,13 @@ +
+ + +
+
@@ -263,6 +270,9 @@ window.onload = function() { //windMeter (as a config not a script -> it's running with a systemd service) const checkbox_wind = document.getElementById("check_WindMeter"); checkbox_wind.checked = response["windMeter"]; + //send uSpot + const checkbox_uSpot = document.getElementById("check_uSpot"); + checkbox_uSpot.checked = response["send_uSpot"]; }, error: function(xhr, status, error) { @@ -290,6 +300,7 @@ window.onload = function() { checkbox_envea.checked = response["envea/read_value_v2.py"]; checkbox_solar.checked = response["MPPT/read.py"]; + //si sonde envea is true if (response["envea/read_value_v2.py"]) { add_sondeEnveaContainer(); diff --git a/loop/SARA_send_data_v2.py b/loop/SARA_send_data_v2.py index ca9ccb6..1faa19b 100755 --- a/loop/SARA_send_data_v2.py +++ b/loop/SARA_send_data_v2.py @@ -408,6 +408,7 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id): print("⚠️ Modem reboot command failed") return False + reset_uSpot_url = True # Step 2: Wait for the modem to restart (adjust time as needed) print("Waiting for modem to restart...") time.sleep(15) # 15 seconds should be enough for most modems to restart @@ -738,7 +739,12 @@ try: ''' - SEND TO AIRCARTO + ____ _____ _ _ ____ _ ___ ____ ____ _ ____ _____ ___ + / ___|| ____| \ | | _ \ / \ |_ _| _ \ / ___| / \ | _ \_ _/ _ \ + \___ \| _| | \| | | | | / _ \ | || |_) | | / _ \ | |_) || || | | | + ___) | |___| |\ | |_| | / ___ \ | || _ <| |___ / ___ \| _ < | || |_| | + |____/|_____|_| \_|____/ /_/ \_\___|_| \_\\____/_/ \_\_| \_\|_| \___/ + ''' print('➡️

SEND TO AIRCARTO SERVERS

') @@ -881,9 +887,9 @@ try: #Software Reboot software_reboot_success = modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id) if software_reboot_success: - print("Modem successfully rebooted and reinitialized") + print("✅Modem successfully rebooted and reinitialized") else: - print("There were issues with the modem reboot/reinitialize process") + print("⛔There were issues with the modem reboot/reinitialize process") # 2.2 code 1 (✅✅HHTP / UUHTTPCR succeded✅✅) @@ -1044,7 +1050,12 @@ try: ''' - SEND TO uSPOT + _ ____ _ + ___ ___ _ __ __| | _ _/ ___| _ __ ___ | |_ + / __|/ _ \ '_ \ / _` | | | | \___ \| '_ \ / _ \| __| + \__ \ __/ | | | (_| | | |_| |___) | |_) | (_) | |_ + |___/\___|_| |_|\__,_| \__,_|____/| .__/ \___/ \__| + |_| ''' if send_uSpot: @@ -1202,6 +1213,7 @@ try: print('

No error detected

') elif error_code == 4: print('

Error 4: Invalid server Hostname

') + elif error_code == 11: print('

Error 11: Server connection error

') elif error_code == 22: @@ -1215,13 +1227,14 @@ try: #Pas forcément un moyen de résoudre le soucis - # 2.2 code 1 (HHTP succeded) + # 2.2 code 1 (✅✅HHTP / UUHTTPCR succeded✅✅) else: # Si la commande HTTP a réussi print('✅✅HTTP operation successful.') print("Blink blue LED") led_thread = Thread(target=blink_led, args=(23, 5, 0.5)) led_thread.start() + #4. Read reply from server print("Reply from server:") ser_sara.write(b'AT+URDFILE="uSpot_server_response.txt"\r') @@ -1230,6 +1243,32 @@ try: print(response_SARA_4b) print("

", end="") + # Initialize http_response_code to 0 as a default value + http_response_code = 0 + + # Safely extract HTTP code + try: + http_prefix = "HTTP/" + # response_SARA_4b is a string, not a function - use .find() method + http_pos = response_SARA_4b.find(http_prefix) + + if http_pos != -1: + # Find the space after the HTTP version + space_pos = response_SARA_4b.find(" ", http_pos) + if space_pos != -1: + # Extract the code after the space + code_start = space_pos + 1 + code_end = response_SARA_4b.find(" ", code_start) + if code_end != -1: + # Extract and convert to integer + http_code_str = response_SARA_4b[code_start:code_end] + http_response_code = int(http_code_str) + print(f"HTTP response code: {http_response_code}") + except Exception as e: + # If any error occurs during parsing, keep the default value + print(f"Error parsing HTTP code: {e}") + + #5. empty json