update
This commit is contained in:
@@ -4,6 +4,7 @@ Ex:
|
|||||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 api-prod.uspot.probesys.net /nebuleair?token=2AFF6dQk68daFZ
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 api-prod.uspot.probesys.net /nebuleair?token=2AFF6dQk68daFZ
|
||||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 webhook.site /13502b8b-201a-41ea-ae33-983516074de5
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 webhook.site /13502b8b-201a-41ea-ae33-983516074de5
|
||||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 aircarto.fr /tests/test.php
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 aircarto.fr /tests/test.php
|
||||||
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 ssl.aircarto.fr /test.php
|
||||||
|
|
||||||
|
|
||||||
First profile id:
|
First profile id:
|
||||||
@@ -99,7 +100,7 @@ ser_sara = serial.Serial(
|
|||||||
try:
|
try:
|
||||||
#step 1: import the certificate
|
#step 1: import the certificate
|
||||||
print("****")
|
print("****")
|
||||||
with open("/var/www/nebuleair_pro_4g/SARA/SSL/certificate/isrgrootx1.der", "rb") as cert_file:
|
with open("/var/www/nebuleair_pro_4g/SARA/SSL/certificate/isrg-root-x2.der", "rb") as cert_file:
|
||||||
certificate = cert_file.read()
|
certificate = cert_file.read()
|
||||||
|
|
||||||
size_of_string = len(certificate)
|
size_of_string = len(certificate)
|
||||||
@@ -107,7 +108,7 @@ try:
|
|||||||
print("\033[0;33m Import certificate\033[0m")
|
print("\033[0;33m Import certificate\033[0m")
|
||||||
# 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,"isrgrootx1",{size_of_string}\r'
|
command = f'AT+USECMNG=0,0,"isrg-root-x2",{size_of_string}\r'
|
||||||
ser_sara.write((command + '\r').encode('utf-8'))
|
ser_sara.write((command + '\r').encode('utf-8'))
|
||||||
response_SARA_1 = read_complete_response(ser_sara)
|
response_SARA_1 = read_complete_response(ser_sara)
|
||||||
print(response_SARA_1)
|
print(response_SARA_1)
|
||||||
@@ -132,13 +133,14 @@ try:
|
|||||||
# *******************************
|
# *******************************
|
||||||
# SECURITY PROFILE
|
# SECURITY PROFILE
|
||||||
# AT+USECPRF=<profile_id>[,<op_code>[,<param_val>]]
|
# AT+USECPRF=<profile_id>[,<op_code>[,<param_val>]]
|
||||||
|
security_profile_id = 0
|
||||||
|
|
||||||
|
|
||||||
# op_code: 0 -> certificate validation level
|
# op_code: 0 -> certificate validation level
|
||||||
# param_val : 0 -> Level 0 No validation; 1-> Level 1 Root certificate validation
|
# param_val : 0 -> Level 0 No validation; 1-> Level 1 Root certificate validation
|
||||||
security_profile_id = 0
|
|
||||||
print("\033[0;33mSet the security profile (params)\033[0m")
|
print("\033[0;33mSet the security profile (params)\033[0m")
|
||||||
command = f'AT+USECPRF={security_profile_id},0,0\r'
|
certification_level=0
|
||||||
|
command = f'AT+USECPRF={security_profile_id},0,{certification_level}\r'
|
||||||
ser_sara.write((command + '\r').encode('utf-8'))
|
ser_sara.write((command + '\r').encode('utf-8'))
|
||||||
response_SARA_5b = read_complete_response(ser_sara, wait_for_line="OK")
|
response_SARA_5b = read_complete_response(ser_sara, wait_for_line="OK")
|
||||||
print(response_SARA_5b)
|
print(response_SARA_5b)
|
||||||
@@ -147,7 +149,8 @@ try:
|
|||||||
# op_code: 1 -> minimum SSL/TLS version
|
# op_code: 1 -> minimum SSL/TLS version
|
||||||
# param_val : 0 -> any; server can use any version for the connection; 1-> LSv1.0;
|
# param_val : 0 -> any; server can use any version for the connection; 1-> LSv1.0;
|
||||||
print("\033[0;33mSet the security profile (params)\033[0m")
|
print("\033[0;33mSet the security profile (params)\033[0m")
|
||||||
command = f'AT+USECPRF={security_profile_id},1,0\r'
|
minimum_SSL_version = 0
|
||||||
|
command = f'AT+USECPRF={security_profile_id},1,{minimum_SSL_version}\r'
|
||||||
ser_sara.write((command + '\r').encode('utf-8'))
|
ser_sara.write((command + '\r').encode('utf-8'))
|
||||||
response_SARA_5bb = read_complete_response(ser_sara, wait_for_line="OK")
|
response_SARA_5bb = read_complete_response(ser_sara, wait_for_line="OK")
|
||||||
print(response_SARA_5bb)
|
print(response_SARA_5bb)
|
||||||
@@ -155,7 +158,8 @@ try:
|
|||||||
|
|
||||||
#op_code: 2 -> cipher suite
|
#op_code: 2 -> cipher suite
|
||||||
print("\033[0;33mSet cipher \033[0m")
|
print("\033[0;33mSet cipher \033[0m")
|
||||||
command = f'AT+USECPRF={security_profile_id},2,0\r'
|
cipher_suite = 1
|
||||||
|
command = f'AT+USECPRF={security_profile_id},2,{cipher_suite}\r'
|
||||||
ser_sara.write((command + '\r').encode('utf-8'))
|
ser_sara.write((command + '\r').encode('utf-8'))
|
||||||
response_SARA_5cc = read_complete_response(ser_sara, wait_for_line="OK")
|
response_SARA_5cc = read_complete_response(ser_sara, wait_for_line="OK")
|
||||||
print(response_SARA_5cc)
|
print(response_SARA_5cc)
|
||||||
@@ -163,7 +167,7 @@ try:
|
|||||||
|
|
||||||
# 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("\033[0;33mSet the security profile (choose cert)\033[0m")
|
||||||
command = f'AT+USECPRF={security_profile_id},3,"isrgrootx1"\r'
|
command = f'AT+USECPRF={security_profile_id},3,"isrg-root-x2"\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_line="OK")
|
response_SARA_5c = read_complete_response(ser_sara, wait_for_line="OK")
|
||||||
print(response_SARA_5c)
|
print(response_SARA_5c)
|
||||||
@@ -193,8 +197,8 @@ try:
|
|||||||
#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("\033[0;33mSET SSL\033[0m")
|
||||||
http_secure = 1
|
http_secure = 1
|
||||||
#command = f'AT+UHTTP={profile_id},6,{http_secure},{security_profile_id}\r'
|
command = f'AT+UHTTP={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'
|
||||||
|
|
||||||
ser_sara.write(command.encode('utf-8'))
|
ser_sara.write(command.encode('utf-8'))
|
||||||
response_SARA_5 = read_complete_response(ser_sara, wait_for_line="OK")
|
response_SARA_5 = read_complete_response(ser_sara, wait_for_line="OK")
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ FONCTIONNE SUR data.nebuleair.fr
|
|||||||
FONCTIONNE SUR uSpot
|
FONCTIONNE SUR uSpot
|
||||||
Ex:
|
Ex:
|
||||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTP_POST.py ttyAMA2 api-prod.uspot.probesys.net
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTP_POST.py ttyAMA2 api-prod.uspot.probesys.net
|
||||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTP_POST.py ttyAMA2 aircarto.fr
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTP_POST.py ttyAMA2 aircarto.fr /tests/test.php
|
||||||
|
/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTP_POST.py ttyAMA2 ssl.aircarto.fr /test.php
|
||||||
|
|
||||||
To do: need to add profile id as parameter
|
To do: need to add profile id as parameter
|
||||||
|
|
||||||
@@ -26,7 +27,9 @@ parameter = sys.argv[1:] # Exclude the script name
|
|||||||
#print("Parameters received:")
|
#print("Parameters received:")
|
||||||
port='/dev/'+parameter[0] # ex: ttyAMA2
|
port='/dev/'+parameter[0] # ex: ttyAMA2
|
||||||
url = parameter[1] # ex: data.mobileair.fr
|
url = parameter[1] # ex: data.mobileair.fr
|
||||||
profile_id = 0
|
endpoint = parameter[2]
|
||||||
|
|
||||||
|
profile_id = 3
|
||||||
|
|
||||||
#get baudrate
|
#get baudrate
|
||||||
def load_config(config_file):
|
def load_config(config_file):
|
||||||
@@ -156,8 +159,9 @@ try:
|
|||||||
#step 4: trigger the request (http_command=1 for GET and http_command=1 for POST)
|
#step 4: trigger the request (http_command=1 for GET and http_command=1 for POST)
|
||||||
print("****")
|
print("****")
|
||||||
print("Trigger POST REQUEST")
|
print("Trigger POST REQUEST")
|
||||||
|
command = f'AT+UHTTPC={profile_id},4,"{endpoint}","http.resp","sensordata_json.json",4\r'
|
||||||
#AirCarto
|
#AirCarto
|
||||||
command = f'AT+UHTTPC={profile_id},1,"/tests/test.php","http.resp"\r'
|
#command = f'AT+UHTTPC={profile_id},1,"/tests/test.php","http.resp"\r'
|
||||||
#command = f'AT+UHTTPC={profile_id},4,"/wifi.php","http.resp","sensordata_json.json",4\r'
|
#command = f'AT+UHTTPC={profile_id},4,"/wifi.php","http.resp","sensordata_json.json",4\r'
|
||||||
#command = f'AT+UHTTPC={profile_id},4,"/pro_4G/data.php?sensor_id=52E7573A","http.resp","sensordata_json.json",4\r'
|
#command = f'AT+UHTTPC={profile_id},4,"/pro_4G/data.php?sensor_id=52E7573A","http.resp","sensordata_json.json",4\r'
|
||||||
#AtmoSud
|
#AtmoSud
|
||||||
|
|||||||
Reference in New Issue
Block a user