From d90fb14c903622325408965aa8fc3021ea7a088f Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 4 Mar 2025 13:23:26 +0100 Subject: [PATCH] update --- html/launcher.php | 14 +++++++++++--- loop/SARA_send_data_v2.py | 10 ++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/html/launcher.php b/html/launcher.php index 3e49ed4..bb60cbe 100755 --- a/html/launcher.php +++ b/html/launcher.php @@ -268,9 +268,10 @@ if ($type == "sara_connectNetwork") { $port=$_GET['port']; $timeout=$_GET['timeout']; $networkID=$_GET['networkID']; - $command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_connectNetwork.py ' . $port . ' ' . $networkID . ' ' . $timeout; - $output = shell_exec($command); - echo $output; + + echo "updating SARA_R4_networkID in config file"; + // Convert `networkID` to an integer (or float if needed) + $networkID = is_numeric($networkID) ? (strpos($networkID, '.') !== false ? (float)$networkID : (int)$networkID) : 0; #save to config.json $configFile = '/var/www/nebuleair_pro_4g/config.json'; // Read the JSON file @@ -297,6 +298,13 @@ if ($type == "sara_connectNetwork") { echo "SARA_R4_networkID updated successfully."; + + echo "connecting to network... please wait..."; + $command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_connectNetwork.py ' . $port . ' ' . $networkID . ' ' . $timeout; + $output = shell_exec($command); + echo $output; + + } #SET THE URL for messaging (profile id 2) diff --git a/loop/SARA_send_data_v2.py b/loop/SARA_send_data_v2.py index cd4c992..40a1f74 100755 --- a/loop/SARA_send_data_v2.py +++ b/loop/SARA_send_data_v2.py @@ -419,7 +419,8 @@ try: if signal_quality == 99: print('⚠️ATTENTION: Signal Quality indicates no signal (99)⚠️') print("TRY TO RECONNECT:") - command = f'AT+COPS=1,2,"{selected_networkID}"\r' + command = f'AT+COPS=1,2,{selected_networkID}\r' + #command = f'AT+COPS=0\r' ser_sara.write(command.encode('utf-8')) responseReconnect = read_complete_response(ser_sara, timeout=20, end_of_response_timeout=20) print('

') @@ -504,7 +505,8 @@ try: # and reset HTTP profile (AT+UHTTP=0) -> ne fonctionne pas.. # tester un reset avec CFUN 15 # 1.Reconnexion au réseau (AT+COPS) - command = f'AT+COPS=1,2,"{selected_networkID}"\r' + command = f'AT+COPS=1,2,{selected_networkID}\r' + #command = f'AT+COPS=0\r' ser_sara.write(command.encode('utf-8')) responseReconnect = read_complete_response(ser_sara) print("Response reconnect:") @@ -621,8 +623,8 @@ try: print('📞Try reconnect to network📞') #IMPORTANT! # Reconnexion au réseau (AT+COPS) - #command = f'AT+COPS=1,2,{selected_networkID}\r' - command = f'AT+COPS=0\r' + command = f'AT+COPS=1,2,{selected_networkID}\r' + #command = f'AT+COPS=0\r' ser_sara.write(command.encode('utf-8')) responseReconnect = read_complete_response(ser_sara, timeout=5, end_of_response_timeout=120, wait_for_lines=["OK", "+CME ERROR"], debug=True) print('

')