From 05c54cf6d0b8e6f5b9e095c7b5647a2f11e7e646 Mon Sep 17 00:00:00 2001 From: PaulVua Date: Thu, 9 Jan 2025 17:52:45 +0100 Subject: [PATCH] update --- html/launcher.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/html/launcher.php b/html/launcher.php index 150e346..42db277 100755 --- a/html/launcher.php +++ b/html/launcher.php @@ -99,6 +99,32 @@ if ($type == "sara_connectNetwork") { $command = '/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_connectNetwork.py ' . $port . ' ' . $networkID . ' ' . $timeout; $output = shell_exec($command); echo $output; + #save to config.json + $configFile = '/var/www/nebuleair_pro_4g/config.json'; + // Read the JSON file + $jsonData = file_get_contents($configFile); + // Decode JSON data into an associative array + $config = json_decode($jsonData, true); + // Check if decoding was successful + if ($config === null) { + die("Error: Could not decode JSON file."); + } + // Update the value of SARA_R4_networkID + $config['SARA_R4_neworkID'] = $networkID; // Replace 42 with the desired value + // Encode the array back to JSON with pretty printing + $newJsonData = json_encode($config, JSON_PRETTY_PRINT); + // Check if encoding was successful + if ($newJsonData === false) { + die("Error: Could not encode JSON data."); + } + + // Write the updated JSON back to the file + if (file_put_contents($configFile, $newJsonData) === false) { + die("Error: Could not write to JSON file."); + } + + echo "SARA_R4_networkID updated successfully."; + } #SET THE URL for messaging