diff --git a/html/launcher.php b/html/launcher.php
index f6eab25..0a778fb 100755
--- a/html/launcher.php
+++ b/html/launcher.php
@@ -631,36 +631,56 @@ if ($type == "sara_connectNetwork") {
$port=$_GET['port'];
$timeout=$_GET['timeout'];
$networkID=$_GET['networkID'];
+ $param="SARA_R4_neworkID";
//echo "updating SARA_R4_networkID in config file";
+
+ //OLD way to store data (JSON file)
+
// Convert `networkID` to an integer (or float if needed)
- $networkID = is_numeric($networkID) ? (strpos($networkID, '.') !== false ? (float)$networkID : (int)$networkID) : 0;
+ //$networkID = is_numeric($networkID) ? (strpos($networkID, '.') !== false ? (float)$networkID : (int)$networkID) : 0;
#save to config.json
- $configFile = '/var/www/nebuleair_pro_4g/config.json';
+ //$configFile = '/var/www/nebuleair_pro_4g/config.json';
// Read the JSON file
- $jsonData = file_get_contents($configFile);
+ //$jsonData = file_get_contents($configFile);
// Decode JSON data into an associative array
- $config = json_decode($jsonData, true);
+ //$config = json_decode($jsonData, true);
// Check if decoding was successful
- if ($config === null) {
- die("Error: Could not decode JSON file.");
- }
+ //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
+ //$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);
+ //$newJsonData = json_encode($config, JSON_PRETTY_PRINT);
// Check if encoding was successful
- if ($newJsonData === false) {
- die("Error: Could not encode JSON data.");
- }
+ //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.");
- }
+ //if (file_put_contents($configFile, $newJsonData) === false) {
+ // die("Error: Could not write to JSON file.");
+ //}
//echo "SARA_R4_networkID updated successfully.";
+ //NEW way to store data -> use SQLITE
+ try {
+ $db = new PDO("sqlite:$database_path");
+ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+ $updateStmt = $db->prepare("UPDATE config_table SET value = :value WHERE key = :param");
+ $updateStmt->bindParam(':value', $networkID);
+ $updateStmt->bindParam(':param', $param);
+ $updateStmt->execute();
+ echo "SARA_R4_networkID updated successfully.";
+
+ } catch (PDOException $e) {
+ // Return error as JSON
+ header('Content-Type: application/json');
+ echo json_encode(['error' => 'Database error: ' . $e->getMessage()]);
+ }
//echo "connecting to network... please wait...";
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_connectNetwork.py ' . $port . ' ' . $networkID . ' ' . $timeout;