This commit is contained in:
Your Name
2025-04-03 09:30:54 +02:00
parent 6d3220665e
commit ee71c28d33

View File

@@ -450,7 +450,7 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
certificate = cert_file.read() certificate = cert_file.read()
size_of_string = len(certificate) size_of_string = len(certificate)
print("\033[0;33m Import certificate\033[0m") print("➡️ Import certificate")
# AT+USECMNG=0,<type>,<internal_name>,<data_size> # AT+USECMNG=0,<type>,<internal_name>,<data_size>
# type-> 0 -> trusted root CA # type-> 0 -> trusted root CA
command = f'AT+USECMNG=0,0,"{certificate_name}",{size_of_string}\r' command = f'AT+USECMNG=0,0,"{certificate_name}",{size_of_string}\r'
@@ -460,7 +460,7 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
time.sleep(0.5) time.sleep(0.5)
print("\033[0;33mAdd certificate\033[0m") print("➡️Add certificate")
ser_sara.write(certificate) ser_sara.write(certificate)
response_SARA_2 = read_complete_response(ser_sara) response_SARA_2 = read_complete_response(ser_sara)
print(response_SARA_2) print(response_SARA_2)
@@ -469,7 +469,7 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
# SECURITY PROFILE # SECURITY PROFILE
# op_code: 3 -> trusted root certificate internal name # op_code: 3 -> trusted root certificate internal name
print("\033[0;33mSet the security profile (choose cert)\033[0m") print("➡️Set the security profile (choose cert)")
command = f'AT+USECPRF={security_profile_id},3,"{certificate_name}"\r' command = f'AT+USECPRF={security_profile_id},3,"{certificate_name}"\r'
ser_sara.write((command + '\r').encode('utf-8')) ser_sara.write((command + '\r').encode('utf-8'))
response_SARA_5c = read_complete_response(ser_sara, wait_for_lines=["OK"]) response_SARA_5c = read_complete_response(ser_sara, wait_for_lines=["OK"])
@@ -484,7 +484,7 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
time.sleep(1) time.sleep(1)
#step 4: set PORT (op_code = 5) #step 4: set PORT (op_code = 5)
print("set port 443") print("➡️set port 443")
command = f'AT+UHTTP={uSpot_profile_id},5,443\r' command = f'AT+UHTTP={uSpot_profile_id},5,443\r'
ser_sara.write((command + '\r').encode('utf-8')) ser_sara.write((command + '\r').encode('utf-8'))
response_SARA_55 = read_complete_response(ser_sara, wait_for_lines=["OK"]) response_SARA_55 = read_complete_response(ser_sara, wait_for_lines=["OK"])
@@ -492,7 +492,7 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
time.sleep(1) time.sleep(1)
#step 4: set url to SSL (op_code = 6) (http_secure = 1 for HTTPS)(USECMNG_PROFILE = 2) #step 4: set url to SSL (op_code = 6) (http_secure = 1 for HTTPS)(USECMNG_PROFILE = 2)
print("\033[0;33mSET SSL\033[0m") print("SET SSL")
http_secure = 1 http_secure = 1
command = f'AT+UHTTP={uSpot_profile_id},6,{http_secure},{security_profile_id}\r' command = f'AT+UHTTP={uSpot_profile_id},6,{http_secure},{security_profile_id}\r'
#command = f'AT+UHTTP={profile_id},6,{http_secure}\r' #command = f'AT+UHTTP={profile_id},6,{http_secure}\r'
@@ -974,6 +974,7 @@ try:
#Parse the server datetime #Parse the server datetime
# Extract just the date from the response # Extract just the date from the response
date_string = None date_string = None
server_datetime = ""
date_start = response_SARA_4.find("Date: ") date_start = response_SARA_4.find("Date: ")
if date_start != -1: if date_start != -1:
date_end = response_SARA_4.find("\n", date_start) date_end = response_SARA_4.find("\n", date_start)
@@ -1196,7 +1197,7 @@ try:
led_thread.start() led_thread.start()
# Get error code # Get error code
print("Getting error code") print("Getting error code", end="")
command = f'AT+UHTTPER={uSpot_profile_id}\r' command = f'AT+UHTTPER={uSpot_profile_id}\r'
ser_sara.write(command.encode('utf-8')) ser_sara.write(command.encode('utf-8'))
response_SARA_9b = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False) response_SARA_9b = read_complete_response(ser_sara, wait_for_lines=["OK"], debug=False)
@@ -1210,15 +1211,17 @@ try:
if error_code == 0: if error_code == 0:
print('<p class="text-success">No error detected</p>') print('<p class="text-success">No error detected</p>')
elif error_code == 4: elif error_code == 4:
print('<p class="text-danger">Error 4: Invalid server Hostname</p>') print('<p class="text-danger">Error 4: Invalid server Hostname</p>', end="")
send_error_notification(device_id, "uSpot - Invalid server Hostname") send_error_notification(device_id, "uSpot - Invalid server Hostname")
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: 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>') print('<p class="text-danger">Error 22: PSD or CSD connection not established</p>', end="")
elif error_code == 73: elif error_code == 73:
print('<p class="text-danger">Error 73: Secure socket connect error</p>') print('<p class="text-danger">Error 73: Secure socket connect error</p>', end="")
send_error_notification(device_id, "uSpot - Secure socket connect error") send_error_notification(device_id, "uSpot - Secure socket connect error")
#Software Reboot ??
else: else:
print(f'<p class="text-danger">Unknown error code: {error_code}</p>') print(f'<p class="text-danger">Unknown error code: {error_code}</p>')
else: else: