update
This commit is contained in:
@@ -646,7 +646,7 @@ try:
|
|||||||
|_____\___/ \___/|_|
|
|_____\___/ \___/|_|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
print('<h3>START LOOP</h3>')
|
print('<h3>START LOOP</h3>', end="")
|
||||||
|
|
||||||
# Check system uptime
|
# Check system uptime
|
||||||
with open('/proc/uptime', 'r') as f:
|
with open('/proc/uptime', 'r') as f:
|
||||||
@@ -854,19 +854,19 @@ try:
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
# On vérifie si le signal n'est pas à 99 pour déconnexion
|
# On vérifie si le signal n'est pas à 99 pour déconnexion
|
||||||
# si c'est le cas on essaie de se reconnecter
|
|
||||||
if signal_quality == 99:
|
if signal_quality == 99:
|
||||||
update_config_sqlite('SARA_network_status', 'disconnected')
|
update_config_sqlite('SARA_network_status', 'disconnected')
|
||||||
update_config_sqlite('SARA_signal_quality', '99')
|
update_config_sqlite('SARA_signal_quality', '99')
|
||||||
|
|
||||||
print('<span style="color: red;font-weight: bold;">⚠️ATTENTION: Signal Quality indicates no signal (99)⚠️</span>')
|
print('<span style="color: red;font-weight: bold;">⚠️ATTENTION: Signal Quality indicates no signal (99)⚠️</span>')
|
||||||
print("TRY TO RECONNECT:")
|
|
||||||
command = f'AT+COPS=1,2,"{selected_networkID}"\r'
|
#print("TRY TO RECONNECT:")
|
||||||
ser_sara.write(command.encode('utf-8'))
|
#command = f'AT+COPS=1,2,"{selected_networkID}"\r'
|
||||||
responseReconnect = read_complete_response(ser_sara, timeout=20, end_of_response_timeout=20, wait_for_lines=["OK", "+CME ERROR", "ERROR"], debug=True)
|
#ser_sara.write(command.encode('utf-8'))
|
||||||
print('<p class="text-danger-emphasis">')
|
#responseReconnect = read_complete_response(ser_sara, timeout=20, end_of_response_timeout=20, wait_for_lines=["OK", "+CME ERROR", "ERROR"], debug=True)
|
||||||
print(responseReconnect)
|
#print('<p class="text-danger-emphasis">')
|
||||||
print("</p>", end="")
|
#print(responseReconnect)
|
||||||
|
#print("</p>", end="")
|
||||||
|
|
||||||
print('🛑STOP LOOP🛑')
|
print('🛑STOP LOOP🛑')
|
||||||
print("<hr>")
|
print("<hr>")
|
||||||
@@ -938,7 +938,7 @@ try:
|
|||||||
# 1.Vérifier si la réponse contient un message d'erreur CME
|
# 1.Vérifier si la réponse contient un message d'erreur CME
|
||||||
if "+CME ERROR" in lines[-1]:
|
if "+CME ERROR" in lines[-1]:
|
||||||
print("*****")
|
print("*****")
|
||||||
print('<span style="color: red;font-weight: bold;">ATTENTION: CME ERROR</span>')
|
print('<span style="color: red;font-weight: bold;">⛔ATTENTION: CME ERROR</span>')
|
||||||
print("error:", lines[-1])
|
print("error:", lines[-1])
|
||||||
print("*****")
|
print("*****")
|
||||||
|
|
||||||
@@ -973,13 +973,13 @@ try:
|
|||||||
# 2.1 code 0 (HTTP failed) ⛔⛔⛔
|
# 2.1 code 0 (HTTP failed) ⛔⛔⛔
|
||||||
if len(parts) == 3 and parts[-1] == '0': # The third value indicates success
|
if len(parts) == 3 and parts[-1] == '0': # The third value indicates success
|
||||||
print("*****")
|
print("*****")
|
||||||
print('<span style="color: red;font-weight: bold;">ATTENTION: HTTP operation failed</span>')
|
print('<span style="color: red;font-weight: bold;">⛔ATTENTION: HTTP operation failed</span>')
|
||||||
print("*****")
|
print("*****")
|
||||||
update_config_sqlite('SARA_network_status', 'error')
|
update_config_sqlite('SARA_network_status', 'error')
|
||||||
|
|
||||||
|
|
||||||
# Get error code
|
# Get error code
|
||||||
print("Getting error code")
|
print("Getting error code", end="")
|
||||||
command = f'AT+UHTTPER={aircarto_profile_id}\r'
|
command = f'AT+UHTTPER={aircarto_profile_id}\r'
|
||||||
ser_sara.write(command.encode('utf-8'))
|
ser_sara.write(command.encode('utf-8'))
|
||||||
response_SARA_9 = read_complete_response(ser_sara, wait_for_lines=["OK","ERROR"], debug=False)
|
response_SARA_9 = read_complete_response(ser_sara, wait_for_lines=["OK","ERROR"], debug=False)
|
||||||
@@ -994,30 +994,40 @@ try:
|
|||||||
# Display interpretation based on error code
|
# Display interpretation based on error code
|
||||||
if error_code == 0:
|
if error_code == 0:
|
||||||
print('<p class="text-success">No error detected</p>', end="")
|
print('<p class="text-success">No error detected</p>', end="")
|
||||||
|
# N°4 INVALID SERVER HOSTNAME
|
||||||
elif error_code == 4:
|
elif error_code == 4:
|
||||||
print('<p class="text-danger">Error 4: Invalid server Hostname</p>', end="")
|
print('<p class="text-danger">Error 4: Invalid server Hostname</p>', end="")
|
||||||
send_error_notification(device_id, "UHTTPER (error n°4) -> Invalid Server Hostname", end="")
|
send_error_notification(device_id, "UHTTPER (error n°4) -> Invalid Server Hostname")
|
||||||
server_hostname_resets = reset_server_hostname(aircarto_profile_id)
|
server_hostname_resets = reset_server_hostname(aircarto_profile_id)
|
||||||
if server_hostname_resets:
|
if server_hostname_resets:
|
||||||
print("✅server hostname reset successfully", end="")
|
print("✅server hostname reset successfully", end="")
|
||||||
else:
|
else:
|
||||||
print("⛔There were issues with the modem server hostname reinitialize process")
|
print("⛔There were issues with the modem server hostname reinitialize process")
|
||||||
|
# N°11 SERVER CONNECTION ERROR
|
||||||
elif error_code == 11:
|
elif error_code == 11:
|
||||||
print('<p class="text-danger">Error 11: Server connection error</p>')
|
print('<p class="text-danger">Error 11: AirCarto - Server connection error</p>', end="")
|
||||||
|
hardware_reboot_success = modem_hardware_reboot()
|
||||||
|
if hardware_reboot_success:
|
||||||
|
print("✅Modem successfully rebooted and reinitialized")
|
||||||
|
else:
|
||||||
|
print("⛔There were issues with the modem reboot/reinitialize process")
|
||||||
|
# N°22 PSD CSD CONNECTION NOT ESTABLISHED
|
||||||
elif error_code == 22:
|
elif error_code == 22:
|
||||||
print('<p class="text-danger">⚠️Error 22: PSD or CSD connection not established (SARA-R5 need to reset PDP conection)⚠️</p>')
|
print('<p class="text-danger">⚠️Error 22: PSD or CSD connection not established (SARA-R5 need to reset PDP conection)⚠️</p>', end="")
|
||||||
send_error_notification(device_id, "UHTTPER (error n°22) -> PSD or CSD connection not established")
|
send_error_notification(device_id, "UHTTPER (error n°22) -> PSD or CSD connection not established")
|
||||||
psd_csd_resets = reset_PSD_CSD_connection()
|
psd_csd_resets = reset_PSD_CSD_connection()
|
||||||
if psd_csd_resets:
|
if psd_csd_resets:
|
||||||
print("✅PSD CSD connection reset successfully", end="")
|
print("✅PSD CSD connection reset successfully", end="")
|
||||||
else:
|
else:
|
||||||
print("⛔There were issues with the modem CSD PSD reinitialize process", end="")
|
print("⛔There were issues with the modem CSD PSD reinitialize process", end="")
|
||||||
|
# N°26 CONNECTION TIMED OUT
|
||||||
elif error_code == 26:
|
elif error_code == 26:
|
||||||
print('<p class="text-danger">Error 26: Connection timed out</p>', end="")
|
print('<p class="text-danger">Error 26: Connection timed out</p>', end="")
|
||||||
send_error_notification(device_id, "UHTTPER (error n°26) -> Connection timed out", end="")
|
send_error_notification(device_id, "UHTTPER (error n°26) -> Connection timed out")
|
||||||
|
# N°26 CONNECTION LOST
|
||||||
elif error_code == 44:
|
elif error_code == 44:
|
||||||
print('<p class="text-danger">Error 44: Connection lost</p>')
|
print('<p class="text-danger">Error 44: Connection lost</p>')
|
||||||
send_error_notification(device_id, "UHTTPER (error n°44) -> Connection lost", end="")
|
send_error_notification(device_id, "UHTTPER (error n°44) -> Connection lost")
|
||||||
elif error_code == 73:
|
elif error_code == 73:
|
||||||
print('<p class="text-danger">Error 73: Secure socket connect error</p>', end="")
|
print('<p class="text-danger">Error 73: Secure socket connect error</p>', end="")
|
||||||
else:
|
else:
|
||||||
@@ -1173,7 +1183,7 @@ try:
|
|||||||
|
|
||||||
|
|
||||||
#5. empty json
|
#5. empty json
|
||||||
print("Empty SARA memory:")
|
print("Empty SARA memory:", end="")
|
||||||
ser_sara.write(b'AT+UDELFILE="sensordata_csv.json"\r')
|
ser_sara.write(b'AT+UDELFILE="sensordata_csv.json"\r')
|
||||||
response_SARA_5 = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False)
|
response_SARA_5 = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False)
|
||||||
print('<p class="text-danger-emphasis">')
|
print('<p class="text-danger-emphasis">')
|
||||||
@@ -1282,7 +1292,7 @@ try:
|
|||||||
print("⛔There were issues with the modem server hostname reinitialize process")
|
print("⛔There were issues with the modem server hostname reinitialize process")
|
||||||
# SERVER CONNECTION ERROR
|
# SERVER CONNECTION ERROR
|
||||||
elif error_code == 11:
|
elif error_code == 11:
|
||||||
print('<p class="text-danger">Error 11: Server connection error</p>', end="")
|
print('<p class="text-danger">Error 11: uSpot - Server connection error</p>', end="")
|
||||||
elif error_code == 22:
|
elif error_code == 22:
|
||||||
print('<p class="text-danger">Error 22: PSD or CSD connection not established</p>', end="")
|
print('<p class="text-danger">Error 22: PSD or CSD connection not established</p>', end="")
|
||||||
elif error_code == 26:
|
elif error_code == 26:
|
||||||
@@ -1354,7 +1364,7 @@ try:
|
|||||||
|
|
||||||
|
|
||||||
#5. empty json
|
#5. empty json
|
||||||
print("Empty SARA memory:")
|
print("Empty SARA memory:", end="")
|
||||||
command = f'AT+UDELFILE="sensordata_json.json"\r'
|
command = f'AT+UDELFILE="sensordata_json.json"\r'
|
||||||
ser_sara.write((command + '\r').encode('utf-8'))
|
ser_sara.write((command + '\r').encode('utf-8'))
|
||||||
response_SARA_9t = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False)
|
response_SARA_9t = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False)
|
||||||
@@ -1366,7 +1376,8 @@ try:
|
|||||||
# Calculate and print the elapsed time
|
# Calculate and print the elapsed time
|
||||||
elapsed_time = time.time() - start_time_script
|
elapsed_time = time.time() - start_time_script
|
||||||
print(f"Elapsed time: {elapsed_time:.2f} seconds")
|
print(f"Elapsed time: {elapsed_time:.2f} seconds")
|
||||||
print("<hr>")
|
print("<hr>", end="")
|
||||||
|
print("<hr>", end="")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("An error occurred:", e)
|
print("An error occurred:", e)
|
||||||
|
|||||||
Reference in New Issue
Block a user