Fix: overlay connexion WiFi affiche hostname.local au lieu de deviceName.local

Le mDNS utilise le hostname systeme (aircarto), pas le deviceName
de la DB (NebuleAir-pro034). Ajout de /html/ dans l'URL aussi.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
PaulVua
2026-03-17 19:58:49 +01:00
parent 2ff47dc877
commit 6a00ab85d9

View File

@@ -1109,7 +1109,7 @@ if ($type == "wifi_connect") {
$SSID=$_GET['SSID']; $SSID=$_GET['SSID'];
$PASS=$_GET['pass']; $PASS=$_GET['pass'];
// Get device name from database for instructions // Get device name and hostname for instructions
try { try {
$db = new PDO("sqlite:$database_path"); $db = new PDO("sqlite:$database_path");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -1121,6 +1121,7 @@ if ($type == "wifi_connect") {
} catch (PDOException $e) { } catch (PDOException $e) {
$deviceName = 'NebuleAir'; $deviceName = 'NebuleAir';
} }
$hostname = trim(shell_exec('hostname 2>/dev/null')) ?: 'aircarto';
// Launch connection script in background // Launch connection script in background
$script_path = '/var/www/nebuleair_pro_4g/connexion.sh'; $script_path = '/var/www/nebuleair_pro_4g/connexion.sh';
@@ -1133,6 +1134,7 @@ if ($type == "wifi_connect") {
'success' => true, 'success' => true,
'ssid' => $SSID, 'ssid' => $SSID,
'deviceName' => $deviceName, 'deviceName' => $deviceName,
'hostname' => $hostname,
'message' => 'Connection attempt started', 'message' => 'Connection attempt started',
'instructions' => [ 'instructions' => [
'fr' => [ 'fr' => [
@@ -1140,7 +1142,7 @@ if ($type == "wifi_connect") {
'step1' => "Le capteur tente de se connecter au réseau « $SSID »", 'step1' => "Le capteur tente de se connecter au réseau « $SSID »",
'step2' => "Vous allez être déconnecté du hotspot dans quelques secondes", 'step2' => "Vous allez être déconnecté du hotspot dans quelques secondes",
'step3' => "Reconnectez-vous au WiFi « $SSID » sur votre appareil", '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", 'step4' => "Accédez au capteur via http://$hostname.local/html/ ou cherchez son IP dans votre routeur",
'warning' => "Si la connexion échoue, le capteur recréera automatiquement le hotspot" 'warning' => "Si la connexion échoue, le capteur recréera automatiquement le hotspot"
], ],
'en' => [ 'en' => [
@@ -1148,7 +1150,7 @@ if ($type == "wifi_connect") {
'step1' => "The sensor is attempting to connect to network « $SSID »", 'step1' => "The sensor is attempting to connect to network « $SSID »",
'step2' => "You will be disconnected from the hotspot in a few seconds", 'step2' => "You will be disconnected from the hotspot in a few seconds",
'step3' => "Reconnect your device to WiFi « $SSID »", 'step3' => "Reconnect your device to WiFi « $SSID »",
'step4' => "Access the sensor via http://$deviceName.local or find its IP in your router", 'step4' => "Access the sensor via http://$hostname.local/html/ or find its IP in your router",
'warning' => "If connection fails, the sensor will automatically recreate the hotspot" 'warning' => "If connection fails, the sensor will automatically recreate the hotspot"
] ]
] ]