diff --git a/loop/SARA_send_data_v2.py b/loop/SARA_send_data_v2.py index 691f5d0..5f90228 100755 --- a/loop/SARA_send_data_v2.py +++ b/loop/SARA_send_data_v2.py @@ -577,195 +577,6 @@ def reset_server_hostname_https(profile_id): http_reset_success = False return http_reset_success -def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id): - """ - Performs a complete modem restart sequence: - 1. Reboots the modem using the appropriate command for its version - 2. Waits for the modem to restart - 3. Resets the HTTP profile - 4. For SARA-R5, resets the PDP connection - - Args: - modem_version (str): The modem version, e.g., 'SARA-R500' or 'SARA-R410' - aircarto_profile_id (int): The HTTP profile ID to reset - - Returns: - bool: True if the complete sequence was successful, False otherwise - """ - print('🔄 Complete SARA reboot and reinitialize sequence 🔄') - - # Step 1: Reboot the modem - Integrated modem_software_reboot logic - print('🔄 Software SARA reboot (CFUN)! 🔄') - - # Use different commands based on modem version - if 'R5' in modem_version: # For SARA-R5 series - command = 'AT+CFUN=16\r' # Normal restart for R5 - else: # For SARA-R4 series - command = 'AT+CFUN=15\r' # Factory reset for R4 - - #ATTENTION : AT+CFUN=16 sometimes causes the modem to reset before replying OK - - ser_sara.write(command.encode('utf-8')) - response = read_complete_response(ser_sara, wait_for_lines=["OK", "ERROR"], debug=True) - - print('
') - print(response) - print("
", end="") - - # Check if reboot command was acknowledged - if response is None or ("OK" not in response and "ERROR" in response): - print("⚠️ Reboot command may have failed or modem restarted before responding.") - # Still continue, as the modem may have rebooted correctly - else: - print("✅ Modem acknowledged reboot command.") - - # Step 2: Wait for the modem to restart (adjust time as needed) - print("Waiting for modem to restart...") - time.sleep(7) # 7 seconds should be enough for most modems to restart - - # Step 3: Check if modem is responsive after reboot - print("Checking if modem is responsive...") - - for attempt in range(5): - ser_sara.write(b'AT\r') - response_check = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=True) - if response_check and "OK" in response_check: - print("✅ Modem is responsive after reboot.") - break - print(f"⏳ Waiting for modem... attempt {attempt + 1}") - time.sleep(2) - else: - print("❌ Modem not responding after reboot.") - return False - - # Step 4: Reset AirCarto HTTP Profile - print('🔧 Resetting AirCarto HTTP Profile') - #command = f'AT+UHTTP={aircarto_profile_id},1,"data.nebuleair.fr"\r' - #ser_sara.write(command.encode('utf-8')) - #responseResetHTTP = read_complete_response(ser_sara, timeout=5, end_of_response_timeout=5,wait_for_lines=["OK", "+CME ERROR"], debug=True) - #print('') - #print(responseResetHTTP) - #print("
", end="") - - print("➡️SET URL") - command = f'AT+UHTTP={aircarto_profile_id},1,"data.nebuleair.fr"\r' - ser_sara.write((command + '\r').encode('utf-8')) - response_SARA_5 = read_complete_response(ser_sara, wait_for_lines=["OK"]) - print(response_SARA_5) - time.sleep(1) - - - http_reset_success = response_SARA_5 is not None and "OK" in response_SARA_5 - - if not http_reset_success: - print("⚠️ AirCarto HTTP profile reset failed") - # Continue anyway, don't return False here - - if send_uSpot: - print('🔧 Resetting uSpot HTTP Profile') - uSpot_profile_id = 1 - uSpot_url="api-prod.uspot.probesys.net" - security_profile_id = 1 - - #step 1: import the certificate - print("➡️ import certificate") - certificate_name = "e6" - with open("/var/www/nebuleair_pro_4g/SARA/SSL/certificate/e6.pem", "rb") as cert_file: - certificate = cert_file.read() - size_of_string = len(certificate) - - # AT+USECMNG=0,Could not extract error code from response
') - #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") - # 2.2 code 1 (✅✅HHTP / UUHTTPCR succeded✅✅) else: @@ -1379,12 +1183,6 @@ try: #Send notification (WIFI) send_error_notification(device_id, "SARA CME ERROR") - #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") #Hardware Reboot hardware_reboot_success = modem_hardware_reboot() if hardware_reboot_success: