This commit is contained in:
Your Name
2025-04-01 11:57:39 +02:00
parent d4c1178b3d
commit 9d280c6e37
3 changed files with 56 additions and 6 deletions

View File

@@ -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('➡️<p class="fw-bold">SEND TO AIRCARTO SERVERS</p>')
@@ -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('<p class="text-success">No error detected</p>')
elif error_code == 4:
print('<p class="text-danger">Error 4: Invalid server Hostname</p>')
elif error_code == 11:
print('<p class="text-danger">Error 11: Server connection error</p>')
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('<span style="font-weight: bold;">✅✅HTTP operation successful.</span>')
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("</p>", 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