update
This commit is contained in:
@@ -239,8 +239,6 @@ selected_networkID = int(config.get('SARA_R4_neworkID', 0))
|
|||||||
send_uSpot = config.get('send_uSpot', False) #envoi sur MicroSpot ()
|
send_uSpot = config.get('send_uSpot', False) #envoi sur MicroSpot ()
|
||||||
wind_meter= config.get('windMeter', False)
|
wind_meter= config.get('windMeter', False)
|
||||||
|
|
||||||
reset_uSpot_url = False
|
|
||||||
|
|
||||||
#config_scripts
|
#config_scripts
|
||||||
config_scripts = load_config_scripts_sqlite()
|
config_scripts = load_config_scripts_sqlite()
|
||||||
bme_280_config = config_scripts.get('BME280/get_data_v2.py', False)
|
bme_280_config = config_scripts.get('BME280/get_data_v2.py', False)
|
||||||
@@ -408,7 +406,6 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
|
|||||||
print("⚠️ Modem reboot command failed")
|
print("⚠️ Modem reboot command failed")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
reset_uSpot_url = True
|
|
||||||
# Step 2: Wait for the modem to restart (adjust time as needed)
|
# Step 2: Wait for the modem to restart (adjust time as needed)
|
||||||
print("Waiting for modem to restart...")
|
print("Waiting for modem to restart...")
|
||||||
time.sleep(15) # 15 seconds should be enough for most modems to restart
|
time.sleep(15) # 15 seconds should be enough for most modems to restart
|
||||||
@@ -423,8 +420,8 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
|
|||||||
|
|
||||||
print("✅ Modem restarted successfully")
|
print("✅ Modem restarted successfully")
|
||||||
|
|
||||||
# Step 4: Reset the HTTP Profile
|
# Step 4: Reset AirCarto HTTP Profile
|
||||||
print('<span style="color: orange;font-weight: bold;">🔧 Resetting the HTTP Profile</span>')
|
print('<span style="color: orange;font-weight: bold;">🔧 Resetting AirCarto HTTP Profile</span>')
|
||||||
command = f'AT+UHTTP={aircarto_profile_id},1,"data.nebuleair.fr"\r'
|
command = f'AT+UHTTP={aircarto_profile_id},1,"data.nebuleair.fr"\r'
|
||||||
ser_sara.write(command.encode('utf-8'))
|
ser_sara.write(command.encode('utf-8'))
|
||||||
responseResetHTTP = read_complete_response(ser_sara, timeout=5, end_of_response_timeout=5,
|
responseResetHTTP = read_complete_response(ser_sara, timeout=5, end_of_response_timeout=5,
|
||||||
@@ -435,9 +432,76 @@ def modem_complete_reboot_and_reinitialize(modem_version, aircarto_profile_id):
|
|||||||
|
|
||||||
http_reset_success = responseResetHTTP is not None and "OK" in responseResetHTTP
|
http_reset_success = responseResetHTTP is not None and "OK" in responseResetHTTP
|
||||||
if not http_reset_success:
|
if not http_reset_success:
|
||||||
print("⚠️ HTTP profile reset failed")
|
print("⚠️ AirCarto HTTP profile reset failed")
|
||||||
# Continue anyway, don't return False here
|
# Continue anyway, don't return False here
|
||||||
|
|
||||||
|
if send_uSpot:
|
||||||
|
print('<span style="color: orange;font-weight: bold;">🔧 Resetting uSpot HTTP Profile</span>')
|
||||||
|
#2. Set uSpot URL (profile id = 1)
|
||||||
|
print('➡️Set uSpot URL')
|
||||||
|
uSpot_profile_id = 1
|
||||||
|
uSpot_url="api-prod.uspot.probesys.net"
|
||||||
|
security_profile_id = 1
|
||||||
|
|
||||||
|
#step 1: import the certificate
|
||||||
|
print("****")
|
||||||
|
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)
|
||||||
|
|
||||||
|
print("\033[0;33m Import certificate\033[0m")
|
||||||
|
# AT+USECMNG=0,<type>,<internal_name>,<data_size>
|
||||||
|
# type-> 0 -> trusted root CA
|
||||||
|
command = f'AT+USECMNG=0,0,"{certificate_name}",{size_of_string}\r'
|
||||||
|
ser_sara.write((command + '\r').encode('utf-8'))
|
||||||
|
response_SARA_1 = read_complete_response(ser_sara)
|
||||||
|
print(response_SARA_1)
|
||||||
|
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
print("\033[0;33mAdd certificate\033[0m")
|
||||||
|
ser_sara.write(certificate)
|
||||||
|
response_SARA_2 = read_complete_response(ser_sara)
|
||||||
|
print(response_SARA_2)
|
||||||
|
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
# SECURITY PROFILE
|
||||||
|
# op_code: 3 -> trusted root certificate internal name
|
||||||
|
print("\033[0;33mSet the security profile (choose cert)\033[0m")
|
||||||
|
command = f'AT+USECPRF={security_profile_id},3,"{certificate_name}"\r'
|
||||||
|
ser_sara.write((command + '\r').encode('utf-8'))
|
||||||
|
response_SARA_5c = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||||
|
print(response_SARA_5c)
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
#step 4: set url (op_code = 1)
|
||||||
|
command = f'AT+UHTTP={uSpot_profile_id},1,"{uSpot_url}"\r'
|
||||||
|
ser_sara.write(command.encode('utf-8'))
|
||||||
|
response_SARA_2 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||||
|
print(response_SARA_2)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
#step 4: set PORT (op_code = 5)
|
||||||
|
print("set port 443")
|
||||||
|
command = f'AT+UHTTP={uSpot_profile_id},5,443\r'
|
||||||
|
ser_sara.write((command + '\r').encode('utf-8'))
|
||||||
|
response_SARA_55 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||||
|
print(response_SARA_55)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
#step 4: set url to SSL (op_code = 6) (http_secure = 1 for HTTPS)(USECMNG_PROFILE = 2)
|
||||||
|
print("\033[0;33mSET SSL\033[0m")
|
||||||
|
http_secure = 1
|
||||||
|
command = f'AT+UHTTP={uSpot_profile_id},6,{http_secure},{security_profile_id}\r'
|
||||||
|
#command = f'AT+UHTTP={profile_id},6,{http_secure}\r'
|
||||||
|
|
||||||
|
ser_sara.write(command.encode('utf-8'))
|
||||||
|
response_SARA_5 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
||||||
|
print(response_SARA_5)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# Step 5: For SARA-R5, reset the PDP connection
|
# Step 5: For SARA-R5, reset the PDP connection
|
||||||
pdp_reset_success = True
|
pdp_reset_success = True
|
||||||
if modem_version == "SARA-R500":
|
if modem_version == "SARA-R500":
|
||||||
@@ -1061,72 +1125,6 @@ try:
|
|||||||
if send_uSpot:
|
if send_uSpot:
|
||||||
print('<p class="fw-bold">➡️SEND TO uSPOT SERVERS</p>', end="")
|
print('<p class="fw-bold">➡️SEND TO uSPOT SERVERS</p>', end="")
|
||||||
|
|
||||||
if reset_uSpot_url:
|
|
||||||
#2. Set uSpot URL (profile id = 1)
|
|
||||||
print('➡️Set uSpot URL')
|
|
||||||
uSpot_profile_id = 1
|
|
||||||
uSpot_url="api-prod.uspot.probesys.net"
|
|
||||||
security_profile_id = 1
|
|
||||||
|
|
||||||
#step 1: import the certificate
|
|
||||||
print("****")
|
|
||||||
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)
|
|
||||||
|
|
||||||
print("\033[0;33m Import certificate\033[0m")
|
|
||||||
# AT+USECMNG=0,<type>,<internal_name>,<data_size>
|
|
||||||
# type-> 0 -> trusted root CA
|
|
||||||
command = f'AT+USECMNG=0,0,"{certificate_name}",{size_of_string}\r'
|
|
||||||
ser_sara.write((command + '\r').encode('utf-8'))
|
|
||||||
response_SARA_1 = read_complete_response(ser_sara)
|
|
||||||
print(response_SARA_1)
|
|
||||||
|
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
||||||
print("\033[0;33mAdd certificate\033[0m")
|
|
||||||
ser_sara.write(certificate)
|
|
||||||
response_SARA_2 = read_complete_response(ser_sara)
|
|
||||||
print(response_SARA_2)
|
|
||||||
|
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
||||||
# SECURITY PROFILE
|
|
||||||
# op_code: 3 -> trusted root certificate internal name
|
|
||||||
print("\033[0;33mSet the security profile (choose cert)\033[0m")
|
|
||||||
command = f'AT+USECPRF={security_profile_id},3,"{certificate_name}"\r'
|
|
||||||
ser_sara.write((command + '\r').encode('utf-8'))
|
|
||||||
response_SARA_5c = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
|
||||||
print(response_SARA_5c)
|
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
||||||
#step 4: set url (op_code = 1)
|
|
||||||
command = f'AT+UHTTP={uSpot_profile_id},1,"{uSpot_url}"\r'
|
|
||||||
ser_sara.write(command.encode('utf-8'))
|
|
||||||
response_SARA_2 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
|
||||||
print(response_SARA_2)
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
#step 4: set PORT (op_code = 5)
|
|
||||||
print("set port 443")
|
|
||||||
command = f'AT+UHTTP={uSpot_profile_id},5,443\r'
|
|
||||||
ser_sara.write((command + '\r').encode('utf-8'))
|
|
||||||
response_SARA_55 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
|
||||||
print(response_SARA_55)
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
#step 4: set url to SSL (op_code = 6) (http_secure = 1 for HTTPS)(USECMNG_PROFILE = 2)
|
|
||||||
print("\033[0;33mSET SSL\033[0m")
|
|
||||||
http_secure = 1
|
|
||||||
command = f'AT+UHTTP={uSpot_profile_id},6,{http_secure},{security_profile_id}\r'
|
|
||||||
#command = f'AT+UHTTP={profile_id},6,{http_secure}\r'
|
|
||||||
|
|
||||||
ser_sara.write(command.encode('utf-8'))
|
|
||||||
response_SARA_5 = read_complete_response(ser_sara, wait_for_lines=["OK"])
|
|
||||||
print(response_SARA_5)
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
# 1. Open sensordata_json.json (with correct data size)
|
# 1. Open sensordata_json.json (with correct data size)
|
||||||
print("Open JSON:")
|
print("Open JSON:")
|
||||||
payload_string = json.dumps(payload_json) # Convert dict to JSON string
|
payload_string = json.dumps(payload_json) # Convert dict to JSON string
|
||||||
|
|||||||
Reference in New Issue
Block a user