update
This commit is contained in:
@@ -121,19 +121,38 @@ try:
|
||||
print('<h3>Start reboot python script</h3>')
|
||||
|
||||
#check modem status
|
||||
#Attention:
|
||||
# SARA R4 response: Manufacturer: u-blox Model: SARA-R410M-02B
|
||||
# SArA R5 response: SARA-R500S-01B-00
|
||||
print("⚙️Check SARA Status")
|
||||
command = f'ATI\r'
|
||||
ser_sara.write(command.encode('utf-8'))
|
||||
response_SARA_ATI = read_complete_response(ser_sara, wait_for_lines=["IMEI"])
|
||||
print(response_SARA_ATI)
|
||||
match = re.search(r"Model:\s*(.+)", response_SARA_ATI)
|
||||
model = match.group(1).strip() if match else "Unknown" # Strip unwanted characters
|
||||
print(f" Model: {model}")
|
||||
|
||||
# Check for SARA model with more robust regex
|
||||
model = "Unknown"
|
||||
if "SARA-R410M" in response_SARA_ATI:
|
||||
model = "SARA-R410M"
|
||||
print("📱 Detected SARA R4 modem")
|
||||
elif "SARA-R500" in response_SARA_ATI:
|
||||
model = "SARA-R500"
|
||||
print("📱 Detected SARA R5 modem")
|
||||
else:
|
||||
# Fallback to regex match if direct string match fails
|
||||
match = re.search(r"Model:\s*([A-Za-z0-9\-]+)", response_SARA_ATI)
|
||||
if match:
|
||||
model = match.group(1).strip()
|
||||
else:
|
||||
model = "Unknown"
|
||||
print("⚠️ Could not identify modem model")
|
||||
|
||||
print(f"🔍 Model: {model}")
|
||||
update_json_key(config_file, "modem_version", model)
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
# 1. Set AIRCARTO URL
|
||||
# 1. Set AIRCARTO URL (profile id = 0)
|
||||
print('➡️Set aircarto URL')
|
||||
aircarto_profile_id = 0
|
||||
aircarto_url="data.nebuleair.fr"
|
||||
@@ -143,26 +162,74 @@ try:
|
||||
print(response_SARA_1)
|
||||
time.sleep(1)
|
||||
|
||||
#2. Set 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)
|
||||
|
||||
print("set port 81")
|
||||
command = f'AT+UHTTP={uSpot_profile_id},5,81\r'
|
||||
#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)
|
||||
|
||||
#3. Get localisation (CellLocate)
|
||||
mode = 2
|
||||
sensor = 2
|
||||
mode = 2 #single shot position
|
||||
sensor = 2 #use cellular CellLocate® location information
|
||||
response_type = 0
|
||||
timeout_s = 2
|
||||
accuracy_m = 1
|
||||
|
||||
Reference in New Issue
Block a user