update
This commit is contained in:
@@ -407,7 +407,53 @@ def modem_hardware_reboot():
|
||||
print("❌ Modem not responding after reboot.")
|
||||
return False
|
||||
|
||||
def reset_PSD_CSD_connection():
|
||||
"""
|
||||
Function that reset the PSD CSD connection for the SARA R5
|
||||
returns true or false
|
||||
"""
|
||||
print("⚠️Reseting PDP connection ")
|
||||
pdp_reset_success = True
|
||||
# Activate PDP context 1
|
||||
print('➡️ Activate PDP context 1')
|
||||
command = f'AT+CGACT=1,1\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
response_pdp1 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||
print(response_pdp1, end="")
|
||||
pdp_reset_success = pdp_reset_success and (response_pdp1 is not None and "OK" in response_pdp1)
|
||||
time.sleep(1)
|
||||
|
||||
# Set the PDP type
|
||||
print('➡️ Set the PDP type to IPv4 referring to the output of the +CGDCONT read command')
|
||||
command = f'AT+UPSD=0,0,0\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
response_pdp2 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||
print(response_pdp2, end="")
|
||||
pdp_reset_success = pdp_reset_success and (response_pdp2 is not None and "OK" in response_pdp2)
|
||||
time.sleep(1)
|
||||
|
||||
# Profile #0 is mapped on CID=1
|
||||
print('➡️ Profile #0 is mapped on CID=1.')
|
||||
command = f'AT+UPSD=0,100,1\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
response_pdp3 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||
print(response_pdp3, end="")
|
||||
pdp_reset_success = pdp_reset_success and (response_pdp3 is not None and "OK" in response_pdp3)
|
||||
time.sleep(1)
|
||||
|
||||
# Activate the PSD profile
|
||||
print('➡️ Activate the PSD profile #0: the IPv4 address is already assigned by the network.')
|
||||
command = f'AT+UPSDA=0,3\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
response_pdp4 = read_complete_response(ser_sara, wait_for_lines=["OK", "+UUPSDA"])
|
||||
print(response_pdp4, end="")
|
||||
pdp_reset_success = pdp_reset_success and (response_pdp4 is not None and ("OK" in response_pdp4 or "+UUPSDA" in response_pdp4))
|
||||
time.sleep(1)
|
||||
|
||||
if not pdp_reset_success:
|
||||
print("⚠️ PDP connection reset had some issues")
|
||||
|
||||
return pdp_reset_success
|
||||
|
||||
def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
|
||||
"""
|
||||
@@ -594,51 +640,6 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
|
||||
print(response_SARA_5fg)
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
# Step 5: For SARA-R5, reset the PDP connection
|
||||
pdp_reset_success = True
|
||||
if modem_version == "SARA-R500":
|
||||
print("⚠️ Need to reset PDP connection for SARA-R500")
|
||||
|
||||
# Activate PDP context 1
|
||||
print('➡️ Activate PDP context 1')
|
||||
command = f'AT+CGACT=1,1\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
response_pdp1 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||
print(response_pdp1, end="")
|
||||
pdp_reset_success = pdp_reset_success and (response_pdp1 is not None and "OK" in response_pdp1)
|
||||
time.sleep(1)
|
||||
|
||||
# Set the PDP type
|
||||
print('➡️ Set the PDP type to IPv4 referring to the output of the +CGDCONT read command')
|
||||
command = f'AT+UPSD=0,0,0\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
response_pdp2 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||
print(response_pdp2, end="")
|
||||
pdp_reset_success = pdp_reset_success and (response_pdp2 is not None and "OK" in response_pdp2)
|
||||
time.sleep(1)
|
||||
|
||||
# Profile #0 is mapped on CID=1
|
||||
print('➡️ Profile #0 is mapped on CID=1.')
|
||||
command = f'AT+UPSD=0,100,1\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
response_pdp3 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||
print(response_pdp3, end="")
|
||||
pdp_reset_success = pdp_reset_success and (response_pdp3 is not None and "OK" in response_pdp3)
|
||||
time.sleep(1)
|
||||
|
||||
# Activate the PSD profile
|
||||
print('➡️ Activate the PSD profile #0: the IPv4 address is already assigned by the network.')
|
||||
command = f'AT+UPSDA=0,3\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
response_pdp4 = read_complete_response(ser_sara, wait_for_lines=["OK", "+UUPSDA"])
|
||||
print(response_pdp4, end="")
|
||||
pdp_reset_success = pdp_reset_success and (response_pdp4 is not None and ("OK" in response_pdp4 or "+UUPSDA" in response_pdp4))
|
||||
time.sleep(1)
|
||||
|
||||
if not pdp_reset_success:
|
||||
print("⚠️ PDP connection reset had some issues")
|
||||
|
||||
# Return overall success
|
||||
return http_reset_success and pdp_reset_success
|
||||
|
||||
@@ -1048,6 +1049,7 @@ try:
|
||||
|
||||
# Extract just the error code
|
||||
error_code = extract_error_code(response_SARA_9)
|
||||
|
||||
if error_code is not None:
|
||||
# Display interpretation based on error code
|
||||
if error_code == 0:
|
||||
@@ -1059,6 +1061,11 @@ try:
|
||||
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>')
|
||||
send_error_notification(device_id, "UHTTPER (error n°22) -> PSD or CSD connection not established")
|
||||
psd_csd_resets = reset_PSD_CSD_connection()
|
||||
if psd_csd_resets:
|
||||
print("✅PSD CSD connection reset successfully")
|
||||
else:
|
||||
print("⛔There were issues with the modem CSD PSD reinitialize process")
|
||||
elif error_code == 26:
|
||||
print('<p class="text-danger">Error 26: Connection timed out</p>')
|
||||
send_error_notification(device_id, "UHTTPER (error n°26) -> Connection timed out")
|
||||
@@ -1074,11 +1081,11 @@ 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")
|
||||
else:
|
||||
print("⛔There were issues with the modem reboot/reinitialize process")
|
||||
#software_reboot_success = modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id)
|
||||
#if software_reboot_success:
|
||||
# print("✅Modem successfully rebooted and reinitialized")
|
||||
#else:
|
||||
# print("⛔There were issues with the modem reboot/reinitialize process")
|
||||
|
||||
|
||||
# 2.2 code 1 (✅✅HHTP / UUHTTPCR succeded✅✅)
|
||||
|
||||
Reference in New Issue
Block a user