diff --git a/.gitignore b/.gitignore index 1c1b862..3c3c4a1 100755 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ config.json .ssh/ sound_meter/moving_avg_minute.txt wifi_list.csv -envea/data/*.txt \ No newline at end of file +envea/data/*.txt +*.lock \ No newline at end of file diff --git a/SARA/sara_sendMessage.py b/SARA/sara_sendMessage.py index 7fd5187..f5e3e95 100755 --- a/SARA/sara_sendMessage.py +++ b/SARA/sara_sendMessage.py @@ -10,6 +10,7 @@ import json parameter = sys.argv[1:] # Exclude the script name port='/dev/'+parameter[0] # ex: ttyAMA2 endpoint = parameter[1] # ex: /pro_4G/notif_message.php +profile_id = parameter[2] #get baudrate def load_config(config_file): @@ -37,7 +38,7 @@ ser = serial.Serial( timeout = 2 ) -command= f'AT+UHTTPC=0,4,"{endpoint}","data.txt","sensordata.json",4\r' +command= f'AT+UHTTPC={profile_id},4,"{endpoint}","data.txt","sensordata.json",4\r' ser.write((command + '\r').encode('utf-8')) try: diff --git a/SARA/sara_setURL.py b/SARA/sara_setURL.py index 8b44565..aae85df 100755 --- a/SARA/sara_setURL.py +++ b/SARA/sara_setURL.py @@ -1,7 +1,7 @@ ''' Script to set the URL for a HTTP request Ex: -/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setURL.py ttyAMA2 data.nebuleair.fr +/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setURL.py ttyAMA2 data.nebuleair.fr 0 To do: need to add profile id as parameter First profile id: @@ -19,6 +19,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 = parameter[2] #ex: 0 #get baudrate @@ -47,7 +48,7 @@ ser = serial.Serial( timeout = 2 ) -command = f'AT+UHTTP=0,1,"{url}"\r' +command = f'AT+UHTTP={profile_id},1,"{url}"\r' ser.write((command + '\r').encode('utf-8')) print("****") diff --git a/cron_jobs b/cron_jobs index ae4f8f6..e6b633b 100755 --- a/cron_jobs +++ b/cron_jobs @@ -2,11 +2,12 @@ @reboot /var/www/nebuleair_pro_4g/boot_hotspot.sh >> /var/www/nebuleair_pro_4g/logs/app.log 2>&1 -@reboot sleep 30 && /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setURL.py ttyAMA2 data.nebuleair.fr >> /var/www/nebuleair_pro_4g/logs/app.log 2>&1 +@reboot sleep 30 && /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setURL.py ttyAMA2 data.nebuleair.fr 0 >> /var/www/nebuleair_pro_4g/logs/app.log 2>&1 @reboot sleep 45 && /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/SSL/prepareUspotProfile.py ttyAMA2 api-prod.uspot.probesys.net >> /var/www/nebuleair_pro_4g/logs/app.log 2>&1 +#* * * * * /usr/bin/python3 /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.py >> /var/www/nebuleair_pro_4g/logs/loop.log 2>&1 -* * * * * /usr/bin/python3 /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.py >> /var/www/nebuleair_pro_4g/logs/loop.log 2>&1 +* * * * * flock -n /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.lock /usr/bin/python3 /var/www/nebuleair_pro_4g/loop/1_NPM/send_data.py >> /var/www/nebuleair_pro_4g/logs/loop.log 2>&1 0 0 */2 * * > /var/www/nebuleair_pro_4g/logs/loop.log diff --git a/html/launcher.php b/html/launcher.php index bf21f6c..f2ced74 100755 --- a/html/launcher.php +++ b/html/launcher.php @@ -145,11 +145,12 @@ if ($type == "sara_connectNetwork") { } -#SET THE URL for messaging +#SET THE URL for messaging (profile id 2) if ($type == "sara_setURL") { $port=$_GET['port']; $url=$_GET['url']; - $command = '/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setURL.py ' . $port . ' ' . $url; + $profile_id = 2; + $command = '/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setURL.py ' . $port . ' ' . $url . ' ' . $profile_id; $output = shell_exec($command); echo $output; } @@ -192,7 +193,8 @@ if ($type == "sara_sendMessage") { $port=$_GET['port']; $endpoint=$_GET['endpoint']; $endpoint = escapeshellcmd($endpoint); - $command = '/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_sendMessage.py ' . $port . ' ' . $endpoint; + $profile_id = 2; + $command = '/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_sendMessage.py ' . $port . ' ' . $endpoint. ' ' . $profile_id; $output = shell_exec($command); echo $output; } diff --git a/html/saraR4.html b/html/saraR4.html index 832e846..fd1940d 100755 --- a/html/saraR4.html +++ b/html/saraR4.html @@ -172,10 +172,9 @@ - +