wifi hotspot improvements
This commit is contained in:
@@ -817,22 +817,50 @@ if ($type == "wifi_connect") {
|
||||
$SSID=$_GET['SSID'];
|
||||
$PASS=$_GET['pass'];
|
||||
|
||||
echo "will try to connect to </br>";
|
||||
echo "SSID: " . $SSID;
|
||||
echo "</br>";
|
||||
echo "Password: " . $PASS;
|
||||
echo "</br>";
|
||||
echo "</br>";
|
||||
// Get device name from database for instructions
|
||||
try {
|
||||
$db = new PDO("sqlite:$database_path");
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $db->prepare("SELECT value FROM config_table WHERE key = 'deviceName'");
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$deviceName = $result ? $result['value'] : 'NebuleAir';
|
||||
$db = null;
|
||||
} catch (PDOException $e) {
|
||||
$deviceName = 'NebuleAir';
|
||||
}
|
||||
|
||||
echo "You will be disconnected. If connection is successfull you can find the device on your local network.";
|
||||
|
||||
// Launch connection script in background
|
||||
$script_path = '/var/www/nebuleair_pro_4g/connexion.sh';
|
||||
$log_file = '/var/www/nebuleair_pro_4g/logs/app.log';
|
||||
shell_exec("$script_path $SSID $PASS >> $log_file 2>&1 &");
|
||||
|
||||
#$output = shell_exec('sudo nmcli connection down Hotspot');
|
||||
#$output2 = shell_exec('sudo nmcli device wifi connect "AirLab" password "123plouf"');
|
||||
|
||||
// Return JSON response with instructions
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'ssid' => $SSID,
|
||||
'deviceName' => $deviceName,
|
||||
'message' => 'Connection attempt started',
|
||||
'instructions' => [
|
||||
'fr' => [
|
||||
'title' => 'Connexion en cours...',
|
||||
'step1' => "Le capteur tente de se connecter au réseau « $SSID »",
|
||||
'step2' => "Vous allez être déconnecté du hotspot dans quelques secondes",
|
||||
'step3' => "Reconnectez-vous au WiFi « $SSID » sur votre appareil",
|
||||
'step4' => "Accédez au capteur via http://$deviceName.local ou cherchez son IP dans votre routeur",
|
||||
'warning' => "Si la connexion échoue, le capteur recréera automatiquement le hotspot"
|
||||
],
|
||||
'en' => [
|
||||
'title' => 'Connection in progress...',
|
||||
'step1' => "The sensor is attempting to connect to network « $SSID »",
|
||||
'step2' => "You will be disconnected from the hotspot in a few seconds",
|
||||
'step3' => "Reconnect your device to WiFi « $SSID »",
|
||||
'step4' => "Access the sensor via http://$deviceName.local or find its IP in your router",
|
||||
'warning' => "If connection fails, the sensor will automatically recreate the hotspot"
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user