From 8596690f32691886b30184a6622bcd73d7a6026f Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 23 Jan 2025 16:44:43 +0100 Subject: [PATCH] update --- SARA/SSL/full_test_HTTPS_POST.py | 16 +++++++++------- SARA/SSL/full_test_HTTP_POST.py | 22 +++++++++------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/SARA/SSL/full_test_HTTPS_POST.py b/SARA/SSL/full_test_HTTPS_POST.py index a959794..67e6e86 100755 --- a/SARA/SSL/full_test_HTTPS_POST.py +++ b/SARA/SSL/full_test_HTTPS_POST.py @@ -2,6 +2,8 @@ Script to set the URL for a HTTP request and trigger the POST Request Ex: /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 api-prod.uspot.probesys.net +/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 webhook.site +/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/full_test_HTTPS_POST.py ttyAMA2 aircarto.fr First profile id: @@ -96,7 +98,7 @@ ser_sara = serial.Serial( try: #step 1: import the certificate print("****") - with open("/var/www/nebuleair_pro_4g/SARA/SSL/certificate/e6.der", "rb") as cert_file: + with open("/var/www/nebuleair_pro_4g/SARA/SSL/certificate/isrgrootx1.der", "rb") as cert_file: certificate = cert_file.read() size_of_string = len(certificate) @@ -104,7 +106,7 @@ try: print("\033[0;33m Import certificate\033[0m") # AT+USECMNG=0,,, # type-> 0 -> trusted root CA - command = f'AT+USECMNG=0,0,"e6",{size_of_string}\r' + command = f'AT+USECMNG=0,0,"isrgrootx1",{size_of_string}\r' ser_sara.write((command + '\r').encode('utf-8')) response_SARA_1 = read_complete_response(ser_sara) print(response_SARA_1) @@ -160,7 +162,7 @@ try: # 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,"e6"\r' + command = f'AT+USECPRF={security_profile_id},3,"isrgrootx1"\r' ser_sara.write((command + '\r').encode('utf-8')) response_SARA_5c = read_complete_response(ser_sara, wait_for_line="OK") print(response_SARA_5c) @@ -190,8 +192,8 @@ try: #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={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},{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_line="OK") @@ -257,9 +259,9 @@ try: print("****") print("\033[0;33mPOST REQUEST\033[0m") #AIRCARTO - #command = f'AT+UHTTPC={profile_id},4,"/tests/test.php","https.resp","sensordata_json.json",4\r' + command = f'AT+UHTTPC={profile_id},4,"/tests/test.php","https.resp","sensordata_json.json",4\r' #uSPOT - command = f'AT+UHTTPC={profile_id},4,"/nebuleair?token=2AFF6dQk68daFZ","https.resp","sensordata_json.json",4\r' + #command = f'AT+UHTTPC={profile_id},4,"/nebuleair?token=2AFF6dQk68daFZ","https.resp","sensordata_json.json",4\r' #AtmoSud #command = f'AT+UHTTPC={profile_id},1,"/","https.resp"\r' #Webhook diff --git a/SARA/SSL/full_test_HTTP_POST.py b/SARA/SSL/full_test_HTTP_POST.py index efb4d85..8fe65c9 100755 --- a/SARA/SSL/full_test_HTTP_POST.py +++ b/SARA/SSL/full_test_HTTP_POST.py @@ -4,6 +4,7 @@ FONCTIONNE SUR data.nebuleair.fr FONCTIONNE SUR uSpot 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 aircarto.fr To do: need to add profile id as parameter @@ -25,7 +26,7 @@ parameter = sys.argv[1:] # Exclude the script name #print("Parameters received:") port='/dev/'+parameter[0] # ex: ttyAMA2 url = parameter[1] # ex: data.mobileair.fr -profile_id = 1 +profile_id = 0 #get baudrate def load_config(config_file): @@ -82,19 +83,11 @@ try: print(response_SARA_5) time.sleep(1) - #step 4: set url to SSL (op_code = 6) (http_secure = 1 for HTTPS)(USECMNG_PROFILE = 2) - print("****") - print("SET SSL") - command = f'AT+UHTTP={profile_id},6,0\r' - ser_sara.write(command.encode('utf-8')) - response_SARA_5 = read_complete_response(ser_sara) - print(response_SARA_5) - time.sleep(1) #step 4: set PORT (op_code = 5) print("****") print("SET PORT") - command = f'AT+UHTTP={profile_id},5,81\r' + command = f'AT+UHTTP={profile_id},5,80\r' ser_sara.write((command + '\r').encode('utf-8')) response_SARA_55 = read_complete_response(ser_sara) print(response_SARA_55) @@ -163,10 +156,13 @@ try: #step 4: trigger the request (http_command=1 for GET and http_command=1 for POST) print("****") print("Trigger POST REQUEST") - #command = f'AT+UHTTPC={profile_id},1,"/tests/test.php","http.resp"\r' - command = f'AT+UHTTPC={profile_id},4,"/nebuleair?token=2AFF6dQk68daFZ","http.resp","sensordata_json.json",4\r' + #AirCarto + 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,"/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 + #command = f'AT+UHTTPC={profile_id},4,"/nebuleair?token=2AFF6dQk68daFZ","http.resp","sensordata_json.json",4\r' + ser_sara.write(command.encode('utf-8'))